Skip to content

feat(provider-review): expose exact repositories and branches - #5705

Closed
iscekic wants to merge 9 commits into
mobile-provider-parity-1d93-s5from
mobile-provider-parity-1d93-s6
Closed

feat(provider-review): expose exact repositories and branches#5705
iscekic wants to merge 9 commits into
mobile-provider-parity-1d93-s5from
mobile-provider-parity-1d93-s6

Conversation

@iscekic

@iscekic iscekic commented Aug 29, 2026

Copy link
Copy Markdown
Contributor
  • Cloud Agent can list branches and identify known default branches for GitHub, GitLab, and organization-owned Bitbucket repositories.
  • GitLab and organization-owned Bitbucket session requests can name the connection to use while keeping the selected branch.
  • If several GitLab connections exist, Cloud Agent requires a specific connection instead of choosing one.
  • Cloud Agent rejects branch requests when the selected connection or repository no longer matches.

Summary

launchRepositoryReferenceSchema separates repository identity from ownerIntegration authorization, so a repository name alone cannot authorize a branch request.
listRepositoryBranchesInputSchema accepts a bounded optional cursor; listRepositoryBranchesOutputSchema returns branch names, default markers, nullable defaultBranch, and nullable nextCursor.
instanceUrl requires https; references bind the provider, repository, owner, and integration, with workspace identifiers for Bitbucket.

Files
  • apps/web/src/routers/cloud-agent-next-schemas.ts — Source, modified (66 changed lines). Adds strict repository and branch schemas plus provider-matched optional prepare selectors.

listRepositoryBranches authorizes personal GitHub and GitLab access, plus organization access for all three providers; GitHub and GitLab reject cursors.
listGitHubRepositories and listGitLabRepositories add optional identity/default fields while keeping legacy outputs; GitLab accepts an optional integrationId.
Personal listBitbucketRepositories and Bitbucket branch requests return BAD_REQUEST; organization requests without producer identity return retryable SERVICE_UNAVAILABLE instead of resolving another integration.

Files
  • apps/web/src/routers/cloud-agent-next-router.ts — Source, modified (59 changed lines). Adds personal discovery fields and branch queries, rejects Bitbucket, and checks GitLab clone hosts.
  • apps/web/src/routers/organizations/organization-cloud-agent-next-router.ts — Source, modified (106 changed lines). Matches owners and Bitbucket producer references, preserves discovery identity, and checks GitLab clone hosts.
  • apps/web/src/routers/provider-repository-contract.test.ts — Test, added (772 changed lines). Covers legacy web, extension, bot, automation, and Worker payloads, branch results, and exact prepare forwarding.

basePrepareSessionNextSchema keeps old payloads valid and adds provider-matched gitlabIntegrationId, gitlabInstanceUrl, and bitbucketIntegrationId.
Both prepareSession routes retain provider pins and the exact upstreamBranch through PrepareSessionInput and CloudAgentPrepareSessionInput; personal Bitbucket preparation remains rejected.
getGitLabInstanceUrlForUser and getGitLabInstanceUrlForOrganization verify selected hosts; legacy fallbacks, including gitlab.com, remain until old callers and records disappear and the 30-day ledger window expires.

Files
  • apps/web/src/lib/cloud-agent-next/cloud-agent-client.ts — Source, modified (2 changed lines). Adds optional GitLab and Bitbucket integration selectors to the web client input.
  • packages/worker-utils/src/cloud-agent-next-client.ts — Source, modified (2 changed lines). Adds optional GitHub and GitLab integration selectors to the Worker client input.
  • packages/worker-utils/src/cloud-agent-next-client.test.ts — Test, modified (77 changed lines). Extends prepare serialization coverage for provider selectors, selected branches, and old payloads.

GitHubRepositoriesResult adds integration/account identity, LaunchRepositoryReference, and default branches to cached and refreshed personal and organization discovery.
listGitHubRepositoryBranches checks the owner, healthy integration, repository identifier, and case-insensitive name; fetchGitHubBranches also checks the live repository identifier.
fetchGitHubRepositories retains provider defaults; old caches return an unknown default, and legacy name-only branch calls remain valid.

Files
  • apps/web/src/lib/cloud-agent/github-integration-helpers.ts — Source, modified (107 changed lines). Attaches the producing owner and integration on every discovery path; validates exact branch references.
  • apps/web/src/lib/integrations/platforms/github/adapter.ts — Source, modified (13 changed lines). Preserves default branches and rejects a changed live repository identifier before listing branches.
  • apps/web/src/lib/cloud-agent/github-integration-helpers.test.ts — Test, modified (192 changed lines). Extends discovery identity, ownership, default-branch, and branch-result coverage.
  • apps/web/src/lib/integrations/platforms/github/adapter.test.ts — Test, added (164 changed lines). Covers provider defaults and live identifier checks, including legacy name-only calls.

GitLabRepositoriesResult now returns normalized instance identity, LaunchRepositoryReference, and default branches through shared personal and organization discovery.
getGitLabIntegration accepts an optional integrationId, enforces exact ownership, and returns CONFLICT instead of choosing among multiple integrations.
listGitLabRepositoryBranches and listGitLabBranches verify an active integration, instance, project identifier, and full path before identifier-based lookup; legacy path-only calls remain valid.

Files
  • apps/web/src/lib/cloud-agent/gitlab-integration-helpers.ts — Source, modified (310 changed lines). Unifies discovery and identity mapping, validates clone-host selectors, and removes unused credential metadata fields.
  • apps/web/src/lib/integrations/gitlab-service.ts — Source, modified (116 changed lines). Adds exact integration and branch selection; carries producer snapshots through refresh and personal access token reconnects.
  • apps/web/src/lib/cloud-agent/gitlab-integration-helpers.test.ts — Test, modified (378 changed lines). Covers exact selectors, instance changes, old cache rows, legacy fallback, and branch authorization.

updateRepositoriesForIntegration accepts an optional expectedIntegration snapshot and updates only when updated_at and metadata still match.
GitLab discovery, refresh, and connectWithPAT pass their producing snapshot; reconnecting to another instance clears repositories and repositories_synced_at inside the transaction.
This protects reconnects that reuse an integration identifier, while legacy two-argument writers keep their previous behavior.

Files
  • apps/web/src/lib/integrations/db/platform-integrations.ts — Source, modified (23 changed lines). Adds timestamp and metadata conditions, including null metadata, without changing callers that omit the snapshot.
  • apps/web/src/lib/integrations/db/platform-integrations.test.ts — Test, modified (265 changed lines). Extends regression coverage for snapshot guards and reconnects that reuse an integration identifier.

BitbucketRepositorySchema keeps identity fields optional for old responses, but rejects inconsistent provider, host, workspace, repository, default branch, or integration values.
The Bitbucket cache producers use withBitbucketRepositoryIdentity to retain their actual integration and owner; unknown defaults remain null.
listBitbucketRepositories retains expectedIntegrationId when retrying a cache write, so a replacement connection cannot silently satisfy a pinned request.

Files
  • apps/web/src/lib/integrations/platforms/bitbucket/token-service-client.ts — Source, modified (53 changed lines). Extends strict wire validation and constructs exact owner/integration references without guessing a default branch.
  • apps/web/src/lib/integrations/platforms/bitbucket/repository-cache.ts — Source, modified (14 changed lines). Adds cached/fresh identities and preserves the selector during stale-write retries.
  • apps/web/src/lib/integrations/platforms/bitbucket/workspace-access-token-repository-cache.ts — Source, modified (31 changed lines). Adds producing identities to cached, refreshed, status, and readiness results.
  • apps/web/src/lib/integrations/platforms/bitbucket/token-service-client.test.ts — Test, modified (137 changed lines). Covers legacy responses, identity additions, and inconsistent references.
  • apps/web/src/lib/integrations/platforms/bitbucket/repository-cache.test.ts — Test, modified (6 changed lines). Updates repository projection expectations for the added identity fields.
  • apps/web/src/lib/integrations/platforms/bitbucket/workspace-access-token-repository-cache.test.ts — Test, modified (14 changed lines). Updates cache projection expectations for the added identity fields.

listBitbucketRepositoryBranches sends the authenticated actor and exact organization, integration, workspace, and repository identity through the existing interactive broker.
The branches operation returns up to 50 names per page and uses the selected repository's default with a broker-validated nextCursor.
Access, identity, and cursor errors map to FORBIDDEN, NOT_FOUND, and BAD_REQUEST; response mismatch returns PRECONDITION_FAILED, and other failures return SERVICE_UNAVAILABLE.

Files
  • apps/web/src/lib/integrations/platforms/bitbucket/oauth-integration.ts — Source, modified (144 changed lines). Adds scoped branch pagination, response identity checks, and typed errors; attaches exact identity to the connection status cache.
  • apps/web/src/lib/integrations/platforms/bitbucket/oauth-integration.test.ts — Test, added (487 changed lines). Covers scoped branch dispatch, trusted defaults, pagination, provider failures, and connection status projections.

Tests: 10 files changed (3 added, 7 modified; 2,492 changed lines): github-integration-helpers.test.ts, gitlab-integration-helpers.test.ts, platform-integrations.test.ts, oauth-integration.test.ts, repository-cache.test.ts, token-service-client.test.ts, workspace-access-token-repository-cache.test.ts, adapter.test.ts, provider-repository-contract.test.ts, and cloud-agent-next-client.test.ts.
Generated: 0 files changed.


Visual Changes

Visual Changes: N/A

Verification

  • No manual tests ran for this level; runtime verification remains pending for the cumulative stack.
  • This level does not establish live checkout, provider-write, or continuous integration (CI) results.

Reviewer Notes

Human steps

  • before merge: Deploy the preceding token service and Cloud Agent changes before relying on pinned provider launches.
  • before merge: Require actual standard CI execution, including all three changed database suites.
  • after merge: No additional human steps. This level adds no required environment values, secrets, migrations, or manual cache clearing.

The bot owns remaining verification.

Check evidence

  • The handoff reports 106 passing producer tests, 103 passing public/Bitbucket web tests, and 23 passing Worker-utils tests.
  • The focused reports also record passing file-only lint, formatting, and whitespace checks.
  • The three changed database suites remain unverified locally because prepared no-setup inputs are missing.

Scope

  • Level 6 only: mobile-provider-parity-1d93-s5...mobile-provider-parity-1d93-s6.
  • Repository: Kilo-Org/cloud; worktree: /Users/igor/Projects/.worktrees/mobile-provider-parity-1d93.
  • Diff size: 24 files, 3,240 insertions, and 298 deletions.

Notes

Runtime verification is pending for the cumulative stack; this level adds no visual surface.

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. mobile-provider-parity-1d93-s1feat(provider-review): add shared identity and stack checks #5663
  2. mobile-provider-parity-1d93-s2feat(provider-review): define review contracts and vocabulary #5665
  3. mobile-provider-parity-1d93-s3feat(provider-review): add safe provider SDK boundaries #5689
  4. mobile-provider-parity-1d93-s4feat(git-token): authorize exact provider review resources #5692
  5. mobile-provider-parity-1d93-s5feat(cloud-agent): preserve provider identity through checkout #5700
  6. mobile-provider-parity-1d93-s6feat(provider-review): expose exact repositories and branches #5705 ← this PR
  7. mobile-provider-parity-1d93-s7feat(mobile): preserve provider launch and recent identity #5711
  8. mobile-provider-parity-1d93-s8feat(mobile): select exact provider repositories and branches #5729
  9. mobile-provider-parity-1d93-s9feat(provider-review): add authorized GitLab review reads #5738
  10. mobile-provider-parity-1d93-s10feat(provider-review): add authorized Bitbucket review reads #5745
  11. mobile-provider-parity-1d93-s11feat(provider-review): add reconciled GitLab review actions #5748
  12. mobile-provider-parity-1d93-s12feat(provider-review): add Bitbucket review actions and recovery #5756
  13. mobile-provider-parity-1d93-s13feat(provider-review): expose the neutral review facade #5763 (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

Files Reviewed (24 files)
  • apps/web/src/lib/cloud-agent-next/cloud-agent-client.ts
  • apps/web/src/lib/cloud-agent/github-integration-helpers.test.ts
  • apps/web/src/lib/cloud-agent/github-integration-helpers.ts
  • apps/web/src/lib/cloud-agent/gitlab-integration-helpers.test.ts
  • apps/web/src/lib/cloud-agent/gitlab-integration-helpers.ts
  • apps/web/src/lib/integrations/db/platform-integrations.test.ts
  • apps/web/src/lib/integrations/db/platform-integrations.ts
  • apps/web/src/lib/integrations/gitlab-service.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/oauth-integration.test.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/oauth-integration.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/repository-cache.test.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/repository-cache.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/token-service-client.test.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/token-service-client.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/workspace-access-token-repository-cache.test.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/workspace-access-token-repository-cache.ts
  • apps/web/src/lib/integrations/platforms/github/adapter.test.ts
  • apps/web/src/lib/integrations/platforms/github/adapter.ts
  • apps/web/src/routers/cloud-agent-next-router.ts
  • apps/web/src/routers/cloud-agent-next-schemas.ts
  • apps/web/src/routers/organizations/organization-cloud-agent-next-router.ts
  • apps/web/src/routers/provider-repository-contract.test.ts
  • packages/worker-utils/src/cloud-agent-next-client.test.ts
  • packages/worker-utils/src/cloud-agent-next-client.ts
Previous Review Summary (commit ea934a7)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit ea934a7)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (24 files)
  • apps/web/src/lib/cloud-agent-next/cloud-agent-client.ts
  • apps/web/src/lib/cloud-agent/github-integration-helpers.test.ts
  • apps/web/src/lib/cloud-agent/github-integration-helpers.ts
  • apps/web/src/lib/cloud-agent/gitlab-integration-helpers.test.ts
  • apps/web/src/lib/cloud-agent/gitlab-integration-helpers.ts
  • apps/web/src/lib/integrations/db/platform-integrations.test.ts
  • apps/web/src/lib/integrations/db/platform-integrations.ts
  • apps/web/src/lib/integrations/gitlab-service.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/oauth-integration.test.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/oauth-integration.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/repository-cache.test.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/repository-cache.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/token-service-client.test.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/token-service-client.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/workspace-access-token-repository-cache.test.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/workspace-access-token-repository-cache.ts
  • apps/web/src/lib/integrations/platforms/github/adapter.test.ts
  • apps/web/src/lib/integrations/platforms/github/adapter.ts
  • apps/web/src/routers/cloud-agent-next-router.ts
  • apps/web/src/routers/cloud-agent-next-schemas.ts
  • apps/web/src/routers/organizations/organization-cloud-agent-next-router.ts
  • apps/web/src/routers/provider-repository-contract.test.ts
  • packages/worker-utils/src/cloud-agent-next-client.test.ts
  • packages/worker-utils/src/cloud-agent-next-client.ts

Reviewed by grok-4.6 · Input: 80.4K · Output: 10.8K · Cached: 623.1K

Review guidance: REVIEW.md from base branch mobile-provider-parity-1d93-s5

@iscekic

iscekic commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Closing: the owner stopped this workflow section. The branch is retained.

@iscekic iscekic closed this Aug 31, 2026
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