Skip to content

feat(integrations): bound repository transport for harness reads - #5710

Open
iscekic wants to merge 1 commit into
shared-agent-harness-3bb0-s16from
shared-agent-harness-3bb0-s17
Open

feat(integrations): bound repository transport for harness reads#5710
iscekic wants to merge 1 commit into
shared-agent-harness-3bb0-s16from
shared-agent-harness-3bb0-s17

Conversation

@iscekic

@iscekic iscekic commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

No new behavior — existing repository lists do not use the new limits.


Summary

RepositoryReadOptions introduces opt-in bounded and caller signal; REPOSITORY_READ_LIMITS defines two pages, 50 repositories, one mebibyte (MiB) per response, and 30 seconds.
withRepositoryReadDeadline combines cancellation with one deadline; repositoryPageSchema, boundRepositoryResponse, and boundedRepositoryFetch check array limits before expansion and byte limits before parsing.
Only bounded: true activates these controls; omitted options preserve legacy behavior, and callers must not replace a complete shared cache with incomplete bounded results.

Files
  • apps/web/src/lib/integrations/core/repository-read-limits.ts — source, added; 102 changed lines. Checks successful JavaScript Object Notation (JSON) content types, declared and streamed bytes, and text encoding; cancels failed reads and refuses redirects.
  • apps/web/src/lib/integrations/core/repository-read-limits.test.ts — test, added; 77 changed lines. Covers exact-byte acceptance, oversized or invalid responses, stream cancellation, deadlines, and caller cancellation.

fetchGitLabProjects accepts RepositoryReadOptions and caps reads at two fetched pages and 50 active projects, counting archived-only pages and pagination jumps.
The 1 MiB response cap and one 30-second deadline cover public, self-hosted, and redirected requests.
Existing address checks, address binding, redirect limits, credential stripping, output fields, and omitted-option pagination remain unchanged; malformed bounded pages throw.

Files
  • apps/web/src/lib/integrations/platforms/gitlab/adapter.ts — source, modified; 158 changed lines. Propagates bounds through safe transports, narrows active-project inputs, retains deletion filtering, and selects results before mapping.
  • apps/web/src/lib/integrations/platforms/gitlab/adapter.test.ts — test, modified; 115 changed lines. Adds isolated mocks and coverage for archived-only pages, pagination jumps, response limits, safe redirects, and a shared deadline.

fetchGitHubRepositories accepts RepositoryReadOptions, limits reads to two pages and 50 unarchived repositories, and validates bounded pages before mapping results.
generateGitHubInstallationToken accepts an optional Octokit request, letting authentication and repository requests share the byte cap, deadline, and caller cancellation.
Standard/lite selection, token authentication, returned fields, and omitted-option pagination stay unchanged; bounded results do not guarantee a complete list.

Files
  • apps/web/src/lib/integrations/platforms/github/adapter.ts — source, modified; 90 changed lines. Passes the bounded transport through installation authentication, rejects malformed pages, and preserves archived filtering and the creation-time fallback.
  • apps/web/src/lib/integrations/platforms/github/adapter.repositories.test.ts — test, added; 130 changed lines. Uses installed Octokit with provider doubles to cover authentication, legacy pagination, malformed data, archived-only pages, provider errors, and authentication deadlines.

fetchBitbucketRepositoriesFromTokenService and fetchBitbucketWorkspaceAccessTokenRepositoriesFromTokenService accept RepositoryReadOptions, enforce the response-byte cap before parsing, and return at most 50 repositories in bounded mode.
BitbucketRepositoryListResult, authentication, and service pagination stay unchanged; validation still checks every item, including items beyond the returned limit.
Bounded network, body, and schema failures throw; non-success responses still return temporarily_unavailable, and omitted options retain legacy results and fallbacks.

Files
  • apps/web/src/lib/integrations/platforms/bitbucket/token-service-client.ts — source, modified; 85 changed lines. Applies shared bounds, deadlines, cancellation, and redirect rejection; forwards workspace access-token options and retains explicit provider states.
  • apps/web/src/lib/integrations/platforms/bitbucket/token-service-client.test.ts — test, modified; 124 changed lines. Covers both entry points, truncation, provider states, malformed trailing items, oversized bodies, network failures, stalled streams, and legacy fallbacks.

Tests: 4 files changed — repository-read-limits.test.ts and GitHub adapter.repositories.test.ts added; GitLab adapter.test.ts and Bitbucket token-service-client.test.ts modified.
Generated: 0 files changed.


Verification

The handoff reports no manual or live-provider verification for this level.

Runtime verification remains pending at the stack tip. This level adds opt-in transports without activating harness consumers.

Visual Changes

Visual Changes: N/A

Reviewer Notes

  • Scope: level 17 only, between shared-agent-harness-3bb0-s16 and shared-agent-harness-3bb0-s17; this change adds no authorized procedure or harness consumer.
  • Repository: Kilo-Org/cloud; worktree: /Users/igor/Projects/.worktrees/shared-agent-harness-3bb0.
  • The reviewer reports 4 passing checks: Jest (77 tests), oxlint, oxfmt, and git diff --check.
  • The transport tests use provider doubles, not live providers.

Human steps

  • No human steps before merge or after merge. This change needs no new environment value, secret, migration, or manual activation.

Stacked PRs — merge bottom to top. Each level shows only its own diff.

Runtime verification (E2E, user advocacy, simplify) runs on the tip PR over every level.
Every level keeps its own checks, its own bot review, and its own threads; each one is answered on its own PR.
Each level is its own deliverable: it builds and passes its own checks alone.
A finding on a level is repaired on that level, then carried upward with stack.sh forward.

  1. shared-agent-harness-3bb0chore(agent-harness): register workspaces and enforce CI boundaries #5632
  2. shared-agent-harness-3bb0-s2feat(agent-harness): define portable domain and snapshots #5637
  3. shared-agent-harness-3bb0-s3feat(agent-harness): define commands tools and permission policy #5639
  4. shared-agent-harness-3bb0-s4feat(agent-harness): share client state and cursor recovery #5643
  5. shared-agent-harness-3bb0-s5feat(agent-harness): persist command intents and execution receipts #5647
  6. shared-agent-harness-3bb0-s6feat(db): add harness ingress grants and retirement fences #5655
  7. shared-agent-harness-3bb0-s7feat(agent-harness): deliver legacy history and project durable text #5659
  8. shared-agent-harness-3bb0-s8feat(agent-harness): authorize durable grants and registered clients #5662
  9. shared-agent-harness-3bb0-s9feat(agent-harness): fence retirement and retry payload cleanup #5667
  10. shared-agent-harness-3bb0-s10feat(agent-harness): persist authoritative state in SQLite #5675
  11. shared-agent-harness-3bb0-s11feat(agent-harness): admit durable runs and revisioned commands #5678
  12. shared-agent-harness-3bb0-s12feat(agent-harness): recover queued runs and stream checkpointed steps #5688
  13. shared-agent-harness-3bb0-s13feat(agent-harness): resolve interactions and dispatch tools sequentially #5693
  14. shared-agent-harness-3bb0-s14feat(agent-harness): fence designated client tool execution #5697
  15. shared-agent-harness-3bb0-s15feat(agent-harness): synchronize durable snapshots and legacy history #5701
  16. shared-agent-harness-3bb0-s16feat(agent-harness): reuse authorized invitations with durable replay #5704
  17. shared-agent-harness-3bb0-s17feat(integrations): bound repository transport for harness reads #5710 ← this PR
  18. shared-agent-harness-3bb0-s18feat(integrations): expose bounded authorized repository reads #5714
  19. shared-agent-harness-3bb0-s19feat(agent-harness): expose named authorized resource reads #5718
  20. shared-agent-harness-3bb0-s20feat(sessions): bound history transport for harness reads #5724
  21. shared-agent-harness-3bb0-s21feat(agent-harness): read scoped Cloud Agent context and progress #5726 (tip)

@kilo-code-bot

kilo-code-bot Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Opt-in bounded repository transport (GitHub, GitLab, Bitbucket) preserves legacy unbounded callers; abort, size, pagination, and schema limits look correct.

Files Reviewed (8 files)
  • apps/web/src/lib/integrations/core/repository-read-limits.ts
  • apps/web/src/lib/integrations/core/repository-read-limits.test.ts
  • apps/web/src/lib/integrations/platforms/github/adapter.ts
  • apps/web/src/lib/integrations/platforms/github/adapter.repositories.test.ts
  • apps/web/src/lib/integrations/platforms/gitlab/adapter.ts
  • apps/web/src/lib/integrations/platforms/gitlab/adapter.test.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/token-service-client.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/token-service-client.test.ts

Reviewed by grok-4.6 · Input: 194.5K · Output: 22K · Cached: 236.7K

Review guidance: REVIEW.md from base branch shared-agent-harness-3bb0-s16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant