Repository navigation
feat(#7499): route GitLab jobs by registered role identity - #7510
Conversation
Wire gitlabroles.Select into fullsend poll, fullsend run, and post-review so Poller, Analyst, Coder, and registered custom roles authenticate with their own credentials when the migration gate is migrating or enforced. Disabled and rollback keep the shared FULLSEND_FORGE_TOKEN path. Unregistered agents fail closed in role-aware modes. Analyst jobs do not receive PUSH_TOKEN. Coder cannot approve merge requests. Authentication failures never switch identities. Note: pre-commit could not fetch remote hook repos (HTTP 403). Local equivalents were run: gofmt, go vet, gitleaks, ADR lints, lychee, and whitespace/eof checks. Closes #7499
|
🤖 Finished Review · ✅ Success · Started 9:30 PM UTC · Completed 9:55 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $11.19 |
Site previewPreview: https://86b2ecfb-site.fullsend-ai.workers.dev Commit: |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Risk Assessment: moderate (2/5) DetailsRe-review anchoring holds: Tier 1 is unchanged (23 files/1567 lines, large blast radius, zero protected/security-sensitive paths, no CI/dependency changes, bot author, ~26% test ratio), Tier 2 shows heavy but stable churn on shared CLI/docs files typical of this busy area (fix/revert and coupling counts appear inflated by generic grep matching and monorepo-wide commits rather than targeted regression risk on the new gitlabroles routing code, which itself has no prior history), and Tier 3 remains a well-scoped, feature-flag-gated (opt-in, default-disabled) stage of the planned #7496 rollout with no risk labels and most acceptance criteria addressed, so the recomputed weighted composite confirms the prior moderate score of 2. Previous runRisk Assessment: moderate (2/5) DetailsRe-review anchoring holds: Tier 1 signals are unchanged in kind from the prior assessment (still 11-25-files/800-1999-lines bucket now at 23 files/1567 lines, zero protected/security-sensitive paths, no CI or dependency changes, bot author), Tier 2 shows the same hot-but-stable, multi-author, largely-non-reverted history typical of this heavily-churned docs/CLI area, and Tier 3 remains a well-scoped, migration-gated stage of the planned #7496 rollout with acceptance criteria mostly addressed and no risk-relevant labels, so the composite confirms the prior moderate score of 2. Previous run (2)Risk Assessment: moderate (2/5) DetailsTier 1 signals are unchanged in kind from the prior assessment (11-25 files, 800-1999 lines, zero protected/security-sensitive paths, no CI or dependency changes, bot author) with only incremental growth (+3 files, +257 lines) from further iteration on the same feature; Tier 2 shows the same moderately hot, multi-author, very-recent, non-reverted pattern as before; Tier 3 remains a well-scoped, gated (opt-in via migration state) stage of a planned multi-PR rollout with acceptance criteria mostly addressed, so the prior moderate score of 2 is preserved. Previous run (3)Risk Assessment: moderate (2/5) DetailsDespite a large raw diff (20 files, 1298 lines, new gitlabroles routing module), risk is pulled down by clean qualitative signals: bot author, zero protected/security-sensitive paths by the risk script's path heuristics, no CI or dependency changes, and a reasonable test ratio; git history shows moderately hot, multi-author files but very recent, stable code with no reverts; the linked issue is well-scoped with acceptance criteria mostly addressed. Composite score is moderate (~2.0) despite the security-relevant subject matter, which the code-review findings above surface separately. |
|
Looks good to me Previous runReviewFindingsMedium
Next steps:
Previous run (2)ReviewFindingsMedium
Low
Next steps:
Previous run (3)ReviewFindingsMedium
Low
Next steps:
|
|
🤖 Finished Fix · ✅ Success · Started 9:57 PM UTC · Completed 10:22 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $6.16 |
Fixes three GitLab role-routing security gaps flagged in review, a backward-compatibility regression, and updates stale docs: - checkGitLabApprovalCapability now verifies the token that will actually authenticate the approve call matches the selected role's own secret value (gitlabroles.ErrIdentityMismatch), instead of trusting a FULLSEND_GITLAB_ROLE/STAGE label alone. Also drops the redundant harnessRole lookup that read the same env var as agentName. - applyGitLabRoleSelection now blanks sibling role secrets (and the shared FULLSEND_FORGE_TOKEN) that aren't the selected credential, so a host-side pre/post-script inheriting the process environment can't read another role's raw token and authenticate as that identity. - childScriptEnv now pins GITLAB_TOKEN, FULLSEND_FORGE_TOKEN, and FULLSEND_GITLAB_* vars to the process environment so a harness runner_env/env.runner entry cannot override the dispatch-selected GitLab identity for a pre/post script. PUSH_TOKEN is deliberately left unpinned since the GitHub coder-remint path (#7231) relies on runner_env overriding a stale process-env PUSH_TOKEN, and GitLab never writes PUSH_TOKEN through that path. - fullsend run --forge gitlab falls back to its pre-PR no-op when the migration gate is disabled/rollback and only FULLSEND_FORGE_TOKEN is missing, so a directly-set GITLAB_TOKEN (the documented local-run workflow) keeps working instead of hard-failing. - Updated docs/architecture.md, docs/guides/user/running-agents-locally.md, and docs/problems/security-threat-model.md to describe the landed job-routing behavior instead of the pre-PR state. Addresses #7510
🔧 Fix agent — iteration 1 (bot-triggered)Addressed all 8 review findings: fixed the two auth-bypass gaps (approval capability checked against an unverified label instead of the authenticating token; GitLab role-routing env vars overridable via harness runner_env) and the privilege-escalation gap (sibling role secrets left in the process environment) with targeted checks and env clearing/pinning in internal/cli/gitlab_role.go and internal/cli/run.go; restored pre-PR no-op fallback behavior for fullsend run --forge gitlab when only the shared credential is unprovisioned in disabled/rollback mode; dropped a redundant env lookup; and updated three docs files to reflect that GitLab job routing has landed. Recorded one partial disagreement: PUSH_TOKEN is intentionally left out of the new pin list to avoid breaking the existing GitHub coder-remint mechanism (#7231), since GitLab never uses that override path anyway. Fixed (8):
Disagreed (1):
Tests: passed Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 10:24 PM UTC · Completed 10:45 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $10.06 |
|
🤖 Finished Fix · ✅ Success · Started 10:47 PM UTC · Completed 10:55 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $1.45 |
- running-agents-locally.md / cli/run.md: document that a directly-set GITLAB_TOKEN still works as a fallback when FULLSEND_FORGE_TOKEN is absent in unset/disabled/rollback mode (matches run.go's UsesSharedOnly + ErrSharedUnconfigured fallback); only migrating/enforced strictly require the per-role secret. - security-threat-model.md: qualify the "distinct per-role credentials" claim -- migrating mode can still fall back to the shared token for an unconfigured role, though approve_merge_request denial for Coder still holds because it resolves from role identity, not the backing secret. - gitlab-role-credentials.md: move the FailedSecret bullet off Select/SelectAgent (which never populate it) and describe it against Resolve/Request and the AuthFailed fail-closed pattern instead. Addresses #7510
🔧 Fix agent — iteration 2 (bot-triggered)Verified all three re-review findings (one medium, two low, all category incorrect-doc) against the current code in run.go, gitlabroles.go, and route.go, confirmed each was accurate, and corrected the four affected doc files with minimal, targeted wording changes. No code changes were needed or made. Fixed (4):
Tests: passedNext steps:
|
|
🤖 Finished Review · ✅ Success · Started 10:57 PM UTC · Completed 11:17 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $8.12 |
|
🤖 Finished Fix · ✅ Success · Started 11:19 PM UTC · Completed 11:24 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $0.70 |
The GitLab section of running-agents-locally.md said the shared-token fallback no longer applies once the gate is migrating or enforced. That is only true for enforced mode: in migrating mode, the resolver still falls back to FULLSEND_FORGE_TOKEN when a role's own secret is unconfigured, per the AllowsSharedFallback mode check which covers migrating only. Clarify that distinction, and note separately that the unmanaged fallback to a directly-set GITLAB_TOKEN no longer applies in either migrating or enforced mode. Addresses #7510
Superseded by updated review
|
🤖 Finished Retro · ✅ Success · Started 12:53 AM UTC · Completed 1:01 AM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $1.59 |
|
PR #7510 ("route GitLab jobs by registered role identity", stage 3 of the #7496 GitLab role-identity rollout) went through 4 review rounds over ~1h45m before human approval and merge. Round 1 (fullsend-ai/agents review agent) caught three real security gaps in the code agent's first commit — a capability check that trusted role labels instead of the actual authenticating token identity, sibling role secrets left un-blanked in the process environment after role selection (privilege-escalation risk via inherited env in pre/post-scripts), and role-routing env vars left unprotected against override by harness runner_env config — plus a backward-compatibility regression (local Proposals filed |
The checklist intro said the terminology rule (added in #7513) was part of "the review findings from PR #7510" and could be "reintroduced" by a routing-code change, which only makes sense for the four code invariants. Scope "They"/"any of them" to those four and attribute the terminology rule to #7513 separately. Addresses #7515
Capture the four review findings from PR fullsend-ai#7510 as a checklist in the existing GitLab role-credential contract so remaining rollout stages (fullsend-ai#7500 rotation, fullsend-ai#7501 shared-token retirement) hold the same invariants: check the authenticating token not a role label, blank sibling secrets after selection, pin routing env vars against runner_env override, and preserve disabled/rollback GITLAB_TOKEN fallback unless the change is marked breaking. Place the checklist in docs/contributing/gitlab-role-credentials.md rather than a new file, keeping this topic single-sourced. Point AGENTS.md's topic table at the checklist so later code-agent runs pick it up as repo-specific context. Note: pre-commit could not fetch remote hook repos (HTTP 403). Local equivalents were run: trailing-whitespace, eof, gitleaks, lint-docs-links, lychee, and lint-broken-symlinks. make lint is pre-commit run and could not complete for the same reason. Closes fullsend-ai#7511
Document the shared-token and local direct-GITLAB_TOKEN fallbacks with fixed terminology, list the four related documents, and require synchronized updates across them. Scope the checklist provenance to the four PR #7510 code invariants and attribute the terminology rule to #7513. Signed-off-by: Greg Allen <gallen@redhat.com>
Document the shared-token and local direct-GITLAB_TOKEN fallbacks with fixed terminology, list the four related documents, and require synchronized updates across them. Scope the checklist provenance to the four PR #7510 code invariants and attribute the terminology rule to #7513. Signed-off-by: Greg Allen <gallen@redhat.com> Signed-off-by: Codex <noreply@openai.com>
Summary
Route GitLab poll, agent, and post-review operations through the registered role-credential contract so Poller, Analyst, Coder, and administrator-registered custom roles authenticate with their own CI/CD variables when the migration gate is
migratingorenforced. Existing installations stay on the sharedFULLSEND_FORGE_TOKENwhile the gate is unset,disabled, orrollback.Related Issue
Stage 3 of the GitLab role-identity rollout (parent #7496). Depends on the contract from #7497 and provisioning from #7498.
Changes
gitlabroles.Select/SelectAgent/Requireas the dispatch-time entry points (ValidateAgentonly in role-aware modes).fullsend pollselects the Poller credential and fails closed on 401/403 without switching identities.fullsend run --forge gitlabexportsGITLAB_TOKENfrom the resolved role secret and setsPUSH_TOKENonly when the registration declareswrite_repository.fullsend post-reviewrefuses GitLabAPPROVEwhen the running identity lacksapprove_merge_request.Testing
go test -race ./internal/gitlabroles/— Select/SelectAgent mappings, custom own/reuse roles, missing-role, migration fallback, unregistered fail-closed, capability denial, auth-failed annotation, no secret leakage in diagnostics (98% package coverage; newroute.gofunctions at 100%).go test -race ./internal/cli/ -run GitLab|PollCmd|PostReview|Role— poller/agent credential application, Analyst PUSH_TOKEN clearing, Coder cannot approve, custom-role mapping, raw-token registry rejection, disabled-mode parity.go veton changed packages.pre-commit runcould not fetch hook repos.Checklist
!for breaking changes)Closes #7499
Post-script verification
agent/7499-gitlab-role-routing)b5a460eba36746483478f2c0683126d00443903b..HEAD)