Repository navigation
feat(#7500): rotate GitLab role credentials with recovery - #7514
Conversation
|
🤖 Finished Review · ✅ Success · Started 1:56 AM UTC · Completed 2:16 AM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $8.30 |
|
Risk Assessment: moderate (2/5) DetailsRe-anchored to the prior score of 2 (moderate): Tier 1 metadata is unchanged in kind (same 20 files, 0 protected/security-sensitive paths, no CI/dependency changes, established bot author, test ratio still in the 0.10-0.29 band) and lines_changed (3627) stays in the same >=2000 bucket as the prior round; Tier 2 shows the same concentrated 30d churn and low code age on shared docs/CLI/forge files, with the rotation/test files still new/untracked in base history; this rounds delta is a small, targeted bug fix (~13 production lines, ~90 test lines) to an already-scored file, giving no specific reason to depart from the anchored composite score of 2. Previous runRisk Assessment: moderate (2/5) DetailsAnchored to the prior score of 2 (moderate): Tier 1 metadata is unchanged in kind (same 20 files, 0 protected/security-sensitive paths, no CI/dependency changes, established bot author, test ratio still in the 0.10-0.29 band), and line growth from ~3489 to 3533 stays within the same >=2000 bucket. Tier 2 shows the same pattern as before - concentrated 30d churn and fix/revert history on shared docs/CLI/forge files this PR only lightly touches, offset by very low code age and author contention; the four new dedicated rotation/lifecycle files remain untracked and excluded from scoring. Tier 3 remains unchanged with issue scope essentially matched, no unresolved discussion, a security label but no breaking-change/needs-discussion flags, and rotation gated behind new opt-in CLI flags. No Tier 2/3 signal provides a specific reason to depart from the anchored composite score of 2. Previous run (2)Risk Assessment: moderate (2/5) DetailsRe-anchored to the prior score of 2 (moderate): Tier 1 metadata is unchanged in kind (same 20 files, 0 protected/security-sensitive paths, no CI/dependency changes, established bot author with 5+ prior review rounds), and the growth from 3187 to 3489 lines stays within the same large/>=2000 bucket; Tier 2 shows the same pattern as before - concentrated 30d churn and fix/revert history on shared docs/CLI/forge files this PR only lightly touches, with the four new dedicated rotation/lifecycle files still untracked and excluded from scoring; Tier 3 remains unchanged with issue scope matched, no unresolved discussion, and only a moderate risk label. No Tier 2/3 signal provides a specific reason to depart from the anchored composite score of 2. Previous run (3)Risk Assessment: moderate (2/5) DetailsRe-anchored to the prior score of 2 (moderate): Tier 1 metadata is unchanged in kind (same 20 files, 0 protected/security-sensitive paths, no CI/dependency changes, established bot author) and the growth from 2921 to 3187 lines stays within the same large bucket; Tier 2 confirms the same pattern as the prior run: concentrated churn/fix history on shared docs/CLI/forge files this PR only lightly touches, with the four new dedicated rotation/lifecycle files still untracked and excluded from scoring; Tier 3 remains unchanged with full acceptance-criteria coverage, no unresolved discussion, and a moderate risk label. The single intervening commit touched only files already covered by the prior review's risk profile, so no Tier 2/3 delta justifies departing from the anchored score of 2. Previous run (4)Risk Assessment: moderate (2/5) DetailsRe-review anchored to the prior score of 2 (moderate): Tier 1 metadata is unchanged in kind (same 20 files, 0 protected/security-sensitive paths, no CI/dependency changes, established bot author) and line growth from 2673 to 2921 stays within the same >=2000 large bucket (Tier 1 avg ~1.75); Tier 2 independently confirms concentrated churn/fix/coupling history on the shared docs/CLI/forge files this PR only lightly touches (avg ~3.0) while the four new dedicated rotation/lifecycle files are untracked and excluded from history scoring; Tier 3 shows full acceptance-criteria coverage, no unresolved discussion, and a built-in rollback design with only a moderate risk label (avg ~1.8). The weighted composite (0.50x1.75 + 0.30x3.0 + 0.20x1.8 = 2.14) rounds to 2, matching the prior anchor with no Tier 2/3 delta large enough to justify a different score. Previous run (5)Risk Assessment: moderate (2/5) DetailsRe-review anchored to the prior score of 2 (moderate): Tier 1 metadata is unchanged in kind (same 20 files, 0 protected/security-sensitive paths, no CI/dependency changes, established bot author) and the line growth from 2673 to 2844 stays within the same >=2000 large bucket; Tier 2 still shows concentrated churn/fix history on shared docs/infra/CLI files this PR only lightly touches while the new dedicated rotation files remain untracked/new; Tier 3 still shows full acceptance-criteria coverage with an explicit rollback design and no risk-elevating labels. No specific, articulable Tier 2/3 delta justifies moving off the prior anchor score. Previous run (6)Risk Assessment: moderate (2/5) DetailsRe-review anchored to the prior score of 2 (moderate): Tier 1 metadata is unchanged in kind (same 20 files, 0 protected paths, 0 security-sensitive/dependency matches, no CI changes, established bot author) and the diff-size growth from 2408 to 2673 lines does not cross a scoring bucket boundary (both fall in the >=2000 large band). Tier 2 continues to show elevated churn/fix-history concentration on shared files this PR only lightly touches, while the newly added dedicated rotation files have no git history and are excluded from churn analysis. Tier 3 signals show the PR fully addresses #7500's five acceptance criteria with an explicit rollback/grace-period design. No specific, articulable Tier 2/3 delta justifies moving off the prior anchor score. Previous run (7)Risk Assessment: moderate (2/5) DetailsTier 1 metadata signals are unchanged in kind from the prior review (still no protected paths, no security-sensitive or dependency-file matches, no CI changes, non-first-time bot author, large diff of 2408 lines across the same 20 files), and Tier 2 shows the same pattern as before -- elevated churn/fix history only on shared files this PR barely touches while the new dedicated credential-rotation files have no history -- so the score is anchored to the prior moderate score of 2. This review still found unresolved high-severity credential-stranding gaps in the rotation recovery path, but risk scoring reflects blast radius and change characteristics, not code-review outcome. Previous run (8)Risk Assessment: moderate (2/5) DetailsDespite touching security-sensitive GitLab credential-rotation code with a large diff (2219 lines across 20 files), the PR has no protected-path or CI/dependency changes, a non-first-time bot author, reasonable test coverage, and moderate git-history churn/fix signals on shared files it barely touches plus a well-scoped, criteria-matched linked issue with built-in rollback support, yielding a moderate overall score of 2. |
ReviewThis round re-verified the prior medium FindingsLow
Previous runReviewThis round re-verified the prior high-severity FindingsMedium
Next steps:
Previous run (2)ReviewThe four prior docs-currency findings and the prior correctness finding (unproven-orphan proof gap on the already-present-secret provisioning path) are resolved and verified against the current code. This round's re-review of the security and intent-coherence dimensions (re-qualified because FindingsHigh
Medium
Next steps:
Next steps:
Previous run (3)ReviewThree of the four medium findings from the prior review are resolved and verified against the current code: the lock-claim overwrite race ( FindingsMedium
Low
Next steps:
Previous run (4)ReviewFindingsMedium
Next steps:
Previous run (5)ReviewFindingsMedium
Next steps:
Previous run (6)ReviewFindingsHigh
Medium
Low
Next steps:
Previous run (7)ReviewFindingsHigh
Medium
Low
Next steps:
Previous run (8)ReviewFindingsHigh
Medium
Low
Next steps:
|
7a918a5 to
6ec003d
Compare
|
Implemented and pushed as Review follow-up:
Verification: |
|
🤖 Review · ❌ Terminated · Started 2:52 AM UTC · Ended 3:15 AM UTC Commit: |
Site previewPreview: https://f07539f8-site.fullsend-ai.workers.dev Commit: |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
🤖 Finished Review · ✅ Success · Started 2:52 AM UTC · Completed 3:15 AM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $7.55 |
|
🤖 Finished Fix · ✅ Success · Started 3:17 AM UTC · Completed 3:42 AM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $5.04 |
Fix GitLab role rotation findings from review: - Do not trust a fresh-looking or "not due" live PAT as proof rotation completed when the inventory is ambiguous (multiple active same-named tokens, or an incomplete distributing/failed phase); require the rotation state to prove this process distributed the live token before skipping. Fixes two related crash-recovery gaps: partial distribution unreachable on the default auto-rotate path, and an orphan token minted before the first state write masquerading as a completed rotation. - Stop recording every active same-named PAT as outgoing when enrolling an administrator-provided replacement, since its own token ID is unknown and grace cleanup could revoke the just-enrolled replacement itself. - Persist rotation-state writes against a freshly re-read document (via a new mergeRoleState helper) instead of the snapshot loaded before the lock claim, so a concurrent process rotating a sibling role is not silently reverted. - Fix double-counting of Summary.Drifted when a repo already had unrelated drift and also gains a GitLab-role lifecycle drift. - Rename removeListedID to deactivateListedToken to match its actual behavior, and document EnrichGitLabRoleStatus's boolean return value. Addresses #7514
🔧 Fix agent — iteration 1 (bot-triggered)Fixed all three High findings (two related auto-rotate skip-logic gaps that let an ambiguous token inventory mask an incomplete or crashed distribution, and rotateProvided's risk of self-revoking an administrator-enrolled replacement), the Medium race condition where a lock-claim re-read was discarded instead of replacing the working state (extended to a reload-and-merge pattern at every subsequent write site), and all three Low findings (Summary.Drifted double-counting, a misleading function name, and an incomplete doc comment). Added five new regression tests, each verified to fail against the pre-fix code and pass after the fix. All existing tests in internal/repos, internal/cli, internal/gitlabroles, and internal/forge/gitlab pass (including -race for repos/gitlabroles/forge-gitlab); go vet and gofmt are clean. pre-commit itself could not run (sandbox network policy blocks fetching hook repositories), so the configured hooks relevant to the changed Go files were run directly: gofmt -w (no changes needed), go vet ./... (clean), plus manual checks for trailing whitespace, missing final newline, merge-conflict markers, and private keys (all clean) — matching the generic pre-commit-hooks and local go-fmt/go-vet hooks in .pre-commit-config.yaml for these file types. Fixed (7):
Tests: passed Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 3:44 AM UTC · Completed 4:05 AM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $6.08 |
|
🤖 Finished Fix · ✅ Success · Started 4:07 AM UTC · Completed 4:27 AM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $3.75 |
Fix GitLab role rotation findings from re-review: - Require rotation-state proof (IncomingID matches the live PAT and DistributedAt is set) before treating any live token as already rotated or not due, including the single-active-PAT case. Previously a lone active same-named PAT was trusted without proof whenever no overlap or stale distributing/failed phase was present, so a crash right after CreateProjectAccessToken succeeded (before any rotation-state write landed) could leave an orphaned token that auto-rotation would trust indefinitely. - Record rotation-state distribution proof during initial provisioning (provisionOwnRoles) too, so a healthy just-provisioned PAT is not immediately treated as unproven and re-minted by the next rotation run. - Claim the rotation lock via mergeRoleState (re-read immediately before writing) instead of writeRotationState of the state snapshot loaded earlier in the call, closing the window where a sibling role's concurrent update landing between that load and the lock claim was silently reverted. Later mergeRoleState writes in the same rotation now abort if a different, still-valid holder has since reclaimed the lock. - Add missing Rotated/created-count assertions to the non-Force partial-distribution recovery test so a regression that no-ops without appending Skipped would be caught. Addresses #7514
🔧 Fix agent — iteration 2 (bot-triggered)Addressed all three findings from the re-review: unconditional distribution proof for the alreadyFresh/not-due skip (plus provisioning now writes that proof), lock claim via mergeRoleState with an ownership check on later writes, and the missing regression assertions. All internal/repos, internal/gitlabroles, and internal/forge/gitlab tests pass with -race; go vet is clean repo-wide. pre-commit could not fetch hook repos (HTTP 403, same as the PR's prior run); ran gofmt, go vet ./..., trailing-whitespace/EOF/merge-conflict checks, and scan-secrets directly instead. Fixed (3):
Tests: passed Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 11:33 AM UTC · Completed 11:57 AM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $9.11 |
|
🤖 Finished Fix · ✅ Success · Started 11:59 AM UTC · Completed 12:14 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $2.05 |
…lacements currentListed (the "current PAT" selector distributionProven compares IncomingID against) picked whichever same-named token GitLab listed first when two active PATs shared a calendar-day expiry, since exp.After never fires on a tie. A same-day force-rotate or recovery mint could therefore leave a healthy, already-distributed replacement unrecognized as current, causing the next non-Force rotate to treat it as unproven and mint again. Separately, the unparseable-expiry branch could steal "current" from a valid dated winner because it compared only token IDs without checking whether a dated winner had already been found. Mirror currentToken's guard against unparseable expiries displacing a dated winner, and add a higher-token-ID tie-break for equal expiries so a same-day replacement is recognized as current regardless of list order. Add direct unit tests for both branches of currentListed and an integration-level regression test seeding two same-day PATs (older ID listed first, incoming_id set to the newer ID) asserting the next non-Force rotate skips rather than minting. Note: pre-commit run could not fetch its hook repositories (sandbox network policy). Ran the applicable local file-type hooks directly instead: gofmt (clean) and go vet ./... (clean). Full go test ./... passes for internal/repos and internal/gitlabroles; three pre-existing failures elsewhere (internal/cli TestPostScriptEnv_* and internal/fetch TestPortRestriction/DefaultRejectsNonStandard) are unrelated to this change (sandbox network/DNS restrictions and unrelated schema-env logic) and were not touched by this commit. Addresses #7514
🔧 Fix agent — iteration 1 (bot-triggered)Fixed the reviewer's currentListed logic-error finding: the selector now mirrors currentToken's unparseable-expiry guard and adds a higher-token-ID tie-break for equal (same-day) expiries, so a same-day replacement is recognized as the current PAT instead of whichever token GitLab lists first. Added unit and integration regression tests per the reviewer's remediation and verified currentListed reaches 100% function coverage. Fixed (1):
Tests: passed Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 12:16 PM UTC · Completed 12:30 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $3.79 |
Superseded by updated review
|
🤖 Finished Retro · ✅ Success · Started 1:38 PM UTC · Completed 1:46 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $2.15 |
|
PR #7514 (GitLab role credential rotation, #7500) took 9 automated review rounds and 7 fix rounds — hitting the bot fix-iteration cap of 5 at fix #6 and escalating to human ggallen — before merging ~12.5h after triage-ready. The review agent repeatedly caught genuine high/medium-severity concurrency and security bugs in the PAT rotation state machine (orphan-token stranding on crash, revoking a live in-use token during recovery, self-revocation of a just-enrolled replacement, cross-process rotation-lock races, a fail-open state loader, and a final tie-break edge case), and a human reviewer (ggallen) verified each fix inline before approving and merging — a healthy, substantive review process on both sides, not a rubber stamp. The root-cause driver of the high rework rate was on the code-generation side: the code agent's skill set contains no guidance on safe credential/secret rotation patterns (revoke-after-verify ordering, idempotent/crash-resumable state machines, avoiding self-revocation, concurrent-lock correctness) — confirmed absent from agents/code.md and skills/code-implementation/SKILL.md in fullsend-ai/agents@57df504a4e48. I'm filing one new proposal for that gap. I checked for duplicates on four other angles surfaced by this PR and found the ground already well covered, so I'm recording them here as evidence rather than new issues: (1) fix-iteration-cap persistence/escalation behavior — this run is a concrete data point matching agents#1293 (bot cap hit, human intervened, 2 more rounds ran under the higher human cap of 10, consistent with the counter not resetting) and generally agents#1297/#1348/#1340/#636/#1294/#1201/fullsend#5547/#7389; no new issue needed. (2) Inline review comment 422s — two out-of-diff pagination findings fell back to a top-level comment successfully in this run, which is useful counter-evidence against fullsend#7346's claim that the fallback path itself fails 100% of the time; matches the well-tracked agents#193/#430/#699/#760/fullsend#6039/#7346 cluster. (3) Risk score staying flat at 'moderate (2/5)' across all 9 rounds despite repeated critical findings is consistent with the risk-assessment sub-agent's documented design (blast-radius/churn/metadata only, explicitly not review-outcome-driven per skills/pr-risk-assessment/SKILL.md) — this is a real data point supporting agents#1349's concern that the risk score discards churn/fix-revert signal, worth attaching there rather than a new issue. (4) No autonomy-readiness gap found: the human's 13 inline comments confirmed bot-identified fixes rather than catching anything new, so the review agent already matches human performance on this class of change; no repo-level autonomy change is indicated beyond what's already in flight. Proposals filed
|
Summary
Implement role-aware rotation, recovery, and rollback for GitLab Poller, Analyst, Coder, and custom own-credential roles so expiring or revoked project access tokens can be replaced without stranding a role or silently falling back to the shared bot PAT.
Related Issue
#7500 (sub-issue of #7496; depends on the merged contract in #7497 / #7506 and provisioning in #7498 / #7508).
Changes
gitlabroles.DiagnoseLifecycleto classify each registered role as ok, expiring, expired, revoked, unverified, overlapping, or unconfigured from project-access-token inventory (names, IDs, and dates only).repos.RotateGitLabRoleCredentials: create-then-distribute a replacement PAT, keep the previous PAT valid for in-flight jobs for 24 hours, serialize concurrent attempts, and roll back a failed distribution by revoking only the unused replacement.repos install(auto-rotate due roles when the gate ismigrating/enforced) with--rotate-gitlab-rolesand--rotate-gitlab-role.FULLSEND_GITLAB_ROLE_ROTATION. Uninstall removes it. The sharedFULLSEND_FORGE_TOKENis never rotated or selected as a fallback.repos statusand document the lifecycle in the GitLab role-credential contract and CLI/operator guides.Testing
go test -race ./internal/gitlabroles/ ./internal/repos/ ./internal/forge/gitlab/covering normal rotation per built-in role, custom-role rotation, reuse-follows-target, concurrent serialized/idempotent rotation, failed create, failed distribution/rollback, in-flight overlap, grace cleanup, recovery of a partial distribution, disabled-mode skip, dry-run, enrolled replacement, and expiry/revocation status drift.go veton changed packages. Direct execution of pre-commit equivalents afterpre-commit runfailed to fetch hook repos (HTTP 403): gofmt, docs-link scope, lychee, scan-secrets.Checklist
feat, issue-number scope)Closes #7500
Post-script verification
agent/7500-gitlab-role-credential-rotation)465f437ad067eab2b58991080a2b7c4342ac5d91..HEAD)