feat(cloud-agent): preserve provider identity through checkout - #5700
Closed
iscekic wants to merge 10 commits into
Closed
feat(cloud-agent): preserve provider identity through checkout#5700iscekic wants to merge 10 commits into
iscekic wants to merge 10 commits into
Conversation
This was referenced Aug 29, 2026
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (20 files)
Reviewed by grok-4.6 · Input: 233.6K · Output: 14K · Cached: 628.9K Review guidance: REVIEW.md from base branch |
This was referenced Aug 29, 2026
This was referenced Aug 30, 2026
This was referenced Aug 30, 2026
Contributor
Author
|
Closing: the owner stopped this workflow section. The branch is retained. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ResolvedRepositoryIdentityandResolvedRepositoryIdentitySchemabindintegrationId,integrationOwner, andinstanceUrl;SessionRepositoryRequestandCurrentSessionMetadataSchemaaccept optionalresolvedIdentity.CloudAgentSession.updateResolvedRepositoryIdentitymerges identity into current metadata in a storage-only transaction, preserving concurrent updates and rejecting deletion or identity changes.Version 2 and legacy reads remain compatible, and later metadata writes cannot erase a resolved identity.
Files
services/cloud-agent-next/src/session/session-requests.ts— source, modified (26 changed lines); adds the identity types, optional GitLab integration pin, and normalization to explicitlegacy-unresolvedfor old requests and records.services/cloud-agent-next/src/persistence/session-metadata.ts— source, modified (79 changed lines); validates optional identity and GitLab pins. Guards the owner, provider, integration, repository location, instance, and Bitbucket identifiers while allowing branch and lifecycle updates. Retains legacy parsing and strips unknown identity fields.services/cloud-agent-next/src/persistence/CloudAgentSession.ts— source, modified (84 changed lines); shares the repository request contract and persists identity during registration. Checks GitLab pins and resolved identity during admission retries. Adds the transactional identity update, checks deletion markers, and returns current repository, workspace, and lifecycle state without overwriting unrelated metadata.services/cloud-agent-next/src/persistence/session-metadata.test.ts— test, modified (496 changed lines); updates metadata coverage, including concurrent updates, stale retries, and identity guards.GitTokenServiceaddsexpectedIntegrationOwnerfor GitHub andexpectedIntegrationIdfor GitLab; GitLab token and Bitbucket credential results requireintegrationId.RepositoryIdentityResolutionpreserves authentication for unpinned GitHub responses lacking both identity fields aslegacy-unresolved; all other successes requireresolved.service_compatibility_errorrejects missing proof or partial identities, andintegration_mismatchrejects conflicting identity; fallback requests retain both selectors.Files
services/cloud-agent-next/src/types.ts— source, modified (30 changed lines); re-exports the sharedOwnertype and extends token and capability contracts. Keeps GitHub response identity fields optional for older producers and adds the GitLabintegration_mismatchfailure.services/cloud-agent-next/src/services/git-token-service-client.ts— source, modified (143 changed lines); requires normalized identity in GitHub token, managed-auth, and capability results. Preserves both selectors through capability, managed-auth, and installation fallbacks. Carries GitLab and Bitbucket integration identifiers and classifies temporary GitLab failures. Documents fallback removal after old deployments, clients, and records disappear and the 30-day ledger window expires.services/cloud-agent-next/src/services/git-token-service-client.test.ts— test, modified (282 changed lines); updates credential compatibility coverage for legacy responses, selected integrations, and identity validation.PrepareSessionInputandRepositoryInputSchemaadd optionalgitlabIntegrationIdand reject cross-provider integration fields; ordinary Bitbucket prepares acceptbitbucketIntegrationIdwithout review-only context.Both
prepareSessionandstartpreserve the integration and branch, attach authorizedresolvedIdentity, and passcreatedOnPlatforminto authorization.Existing callers need no new required inputs; ledger-backed prepares defer authorization until operation admission, and code reviews still require complete review context.
Files
services/cloud-agent-next/src/router/schemas.ts— source, modified (26 changed lines); validates GitLab integration pins in flat and grouped inputs. Separates ordinary Bitbucket integration selection from automation-only review fields and rejects integration pins for other providers.services/cloud-agent-next/src/router/handlers/session-prepare.ts— source, modified (18 changed lines); carries the GitLab pin through the flat adapter. Stores preflight identity for ordinary prepares and delegates ledger-backed authorization to admission.services/cloud-agent-next/src/router/handlers/session-start.ts— source, modified (13 changed lines); exports the grouped adapter, forwards GitLab pins, and attaches preflight identity before registration.services/cloud-agent-next/src/router/schemas.test.ts— test, modified (103 changed lines); updates repository input validation coverage.services/cloud-agent-next/src/router/handlers/session-prepare.test.ts— test, modified (62 changed lines); updates prepare adapter and handler coverage.services/cloud-agent-next/src/session-prepare.test.ts— test, modified (63 changed lines); updates preparation integration coverage for the identity contract.assertRepositoryAccessBeforeSessionCreationreturnsResolvedRepositoryIdentityfor GitLab, Bitbucket, and pinned or resolved GitHub requests before session allocation.GitLab authorization includes
createdOnPlatformand the integration selector; temporary refresh, project-lookup, service, database, and transport failures returnSERVICE_UNAVAILABLE.Permanent failures return
BAD_REQUEST; unpinned GitHub requests retain lazy authorization, and Bitbucket still requires an organization.Files
services/cloud-agent-next/src/session/validate-repository-access.ts— source, modified (88 changed lines); adds GitLab preflight and returns authorized identity instead of only checking access. Uses stored integration selectors, retains the GitHub owner selector, and returns no managed credentials to registration.services/cloud-agent-next/src/session/validate-repository-access.test.ts— test, modified (170 changed lines); updates provider authorization coverage, including temporary GitLab failures and permanent rejections.createSessionWithLedgerrecordscreateIntentFingerprintbefore authorization and storesrepositoryIdentityseparately incanonical_result, so creation and clone retries reuse authorization.gitlabIntegrationIdjoins the existing provider pins and branch fingerprint; omitted additions preserve old fingerprint bytes, and changed same-key intent fails withsession_creation_failed.Legacy rows without fingerprints retain reconciliation; removing this fallback requires old clients and records to disappear and the 30-day window to expire.
Files
services/cloud-agent-next/src/session/session-registration.ts— source, modified (71 changed lines); includes GitLab pins in immutable creation intent. Records the fingerprint before authorization can fail, persists the resolved identity separately, and reauthorizes that identity during creation or clone recovery. Rejects a different resolution without changing the established retry contract.services/cloud-agent-next/src/session/session-prepare.test.ts— test, modified (241 changed lines); updates admission and retry coverage, including unchanged selection after temporary GitLab failures.SessionServicereloads stored identity before credential lookup and persists successful resolutions before exposing tokens or capabilities to workspace preparation.Raw-token and capability requests reuse
expectedIntegrationIdand GitHubexpectedIntegrationOwner; unproved GitHub identity returns retryableWORKSPACE_SETUP_FAILED.WrapperSessionReadyRequestkeepsupstreamBranch, initialstrictBranch, prepared-session resume, clone restoration, and the existing default branch behavior.Files
services/cloud-agent-next/src/session-service.ts— source, modified (130 changed lines); reads durable identity and calls the identity update before credential use. Applies the latest repository, workspace, and lifecycle state to the caller. Preserves GitLab instance subpaths, Bitbucket capability clone URLs, and the unpinned legacy GitHub fallback without weakening resolved requests.services/cloud-agent-next/src/session-service.test.ts— test, modified (385 changed lines); updates workspace credential and identity round-trip coverage.services/cloud-agent-next/wrapper/src/session-bootstrap.test.ts— test, modified (40 changed lines); extends strict branch regression coverage without changing the checkout engine.Tests: 9 modified files (1,842 changed lines):
persistence/session-metadata.test.ts,router/schemas.test.ts,router/handlers/session-prepare.test.ts,services/git-token-service-client.test.ts,session-prepare.test.ts,session-service.test.ts,session/session-prepare.test.ts,session/validate-repository-access.test.ts, andwrapper/src/session-bootstrap.test.ts.Generated: 0 files changed.
Visual Changes
Visual Changes: N/A
Verification
Reviewer Notes
mobile-provider-parity-1d93-s4...mobile-provider-parity-1d93-s5.Kilo-Org/cloud; worktree:/Users/igor/Projects/.worktrees/mobile-provider-parity-1d93.Human steps
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.
mobile-provider-parity-1d93-s1— feat(provider-review): add shared identity and stack checks #5663mobile-provider-parity-1d93-s2— feat(provider-review): define review contracts and vocabulary #5665mobile-provider-parity-1d93-s3— feat(provider-review): add safe provider SDK boundaries #5689mobile-provider-parity-1d93-s4— feat(git-token): authorize exact provider review resources #5692mobile-provider-parity-1d93-s5— feat(cloud-agent): preserve provider identity through checkout #5700 ← this PRmobile-provider-parity-1d93-s6— feat(provider-review): expose exact repositories and branches #5705mobile-provider-parity-1d93-s7— feat(mobile): preserve provider launch and recent identity #5711mobile-provider-parity-1d93-s8— feat(mobile): select exact provider repositories and branches #5729mobile-provider-parity-1d93-s9— feat(provider-review): add authorized GitLab review reads #5738mobile-provider-parity-1d93-s10— feat(provider-review): add authorized Bitbucket review reads #5745mobile-provider-parity-1d93-s11— feat(provider-review): add reconciled GitLab review actions #5748mobile-provider-parity-1d93-s12— feat(provider-review): add Bitbucket review actions and recovery #5756mobile-provider-parity-1d93-s13— feat(provider-review): expose the neutral review facade #5763 (tip)