Repository navigation
refactor(#8438): add CI_JOB_TOKEN child-pipeline agent dispatch route - #8482
Conversation
|
🤖 Review · Commit: |
|
🤖 Finished Review · ✅ Success · Started 12:30 PM UTC · Completed 12:46 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $4.64 |
Site previewPreview: https://92136527-site.fullsend-ai.workers.dev Commit: |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
Risk Assessment: moderate (2/5) DetailsLarge diff and historical churn across GitLab dispatch files are mitigated by bot authorship, 34% test file ratio, absence of protected path edits, and dormant opt-in ledger gating. Previous runRisk Assessment: moderate (2/5) DetailsLarge diff and historical churn across GitLab dispatch files are mitigated by bot authorship, 34% test file ratio, absence of protected path edits, and dormant opt-in ledger gating. Previous run (2)Risk Assessment: moderate (2/5) DetailsLarge diff and historical churn across GitLab dispatch files are mitigated by bot authorship, 35% test file ratio, absence of protected path edits, and opt-in ledger gating. Previous run (3)Risk Assessment: moderate (2/5) DetailsLarge diff and historical churn across GitLab poller files are mitigated by bot authorship, 33% test file ratio, absence of protected path edits, and default-disabled ledger gating. Previous run (4)Risk Assessment: moderate (2/5) DetailsLarge diff and historical churn across GitLab poller files are mitigated by bot authorship, 35% test coverage, absence of protected path edits, and default-disabled ledger gating. Previous run (5)Risk Assessment: moderate (2/5) DetailsLarge diff and historical churn across GitLab poller files are mitigated by bot authorship, 35% test coverage, absence of protected path edits, and default-disabled ledger gating. Previous run (6)Risk Assessment: moderate (2/5) DetailsModerate risk assigned because elevated git history churn and a large 28-file diff are mitigated by zero protected paths, no workflow or dependency changes, and an opt-in environment variable that keeps the new dispatch route inactive by default. |
ReviewFindingsMedium
Earlier findings
Previous runReviewFindingsMedium
Low
Earlier findings
Next steps:
Previous run (2)ReviewFindingsHigh
Medium
Low
Earlier findings
Next steps:
Previous run (3)ReviewFindingsLow
Earlier findings
Blocking prior findings:
Next steps:
Previous run (4)ReviewFindingsHigh
Medium
Low
Labels: PR adds GitLab install/ledger activation behavior and updates documentation alongside the existing dispatch/CI areas. Next steps:
Previous run (5)ReviewFindingsMedium
Low
Labels: PR changes GitLab agent dispatch, CI templates and scripts in Go. Next steps:
Previous run (6)ReviewFindingsHigh
Medium
Low
Next steps:
|
|
🤖 Finished Fix · ✅ Success · Started 12:48 PM UTC · Completed 1:04 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.36 |
- Gate the CI_JOB_TOKEN child-pipeline route on a recorded activation: the trigger-account ledger gains dispatch_active, set by install only after CheckGitLabTriggerDispatchGate returns Ready and cleared by every converge/rotate run. Route selection and source=pipeline admission now require it; a ready ledger alone no longer activates the route. - Select child-pipeline only when the running job's user (GET /job), not just the pipeline creator, is the trigger account, so a retried job falls back to the api route. - Do not follow redirects on the job-token trigger request, so a 307/308 cannot replay the body (job token, ref, signed inputs) elsewhere. - Update stale docs (uninstall workflow rules, CLI poll row, workflow contracts, ADR 0125 note, sandbox topology) and document upgrade ordering for root workflow rules and CLI version. Disagreement: no fail-the-poll-job CLI version check in run-poll-job.sh; the route is inactive until activation, fails closed, and the ordering is documented instead. Note: pre-commit could not fetch hook repositories (TLS failure in the sandbox). Ran gofmt, go vet, git diff --check, EOF newline checks and scan-secrets directly; shellcheck is not installed. TestStartFetchService_* and TestPostScriptEnv_NoSchema* in internal/cli fail identically without this change. Addresses #8482 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
🔧 Fix agent — iteration 1 (bot-triggered)Addressed all 10 findings: 9 fixed, 1 reasoned disagreement (CLI version check in run-poll-job.sh, deferred to activation). The High fail-open is fixed with a ledger activation flag recorded only after the full gate passes and cleared on every lifecycle run. The retried-job and redirect-replay issues are fixed with tests. The stale docs are updated. Scaffold, repos, forge/gitlab and poll tests pass. internal/cli has six failures (TestStartFetchService_* and TestPostScriptEnv_NoSchema*) that also fail without this change. pre-commit could not run because of a TLS failure in the sandbox, so gofmt, go vet, whitespace and EOF checks and scan-secrets were run directly. shellcheck is not installed. Fixed (9):
Disagreed (1):
Tests: passed CI inspections (6):
Conflict update: skipped; strategy Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 1:06 PM UTC · Completed 1:30 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $5.62 |
|
🤖 Finished Fix · ✅ Success · Started 1:32 PM UTC · Completed 1:43 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.58 |
🔧 Fix agent — iteration 2 (bot-triggered)Addressed six of seven findings with code, test or doc changes: containment now withdraws dispatch_active, the scaffold ledger parser accepts exactly one JSON document, the missing unset and test-env clears were added, and the downgrade limitation is documented. The PR-description finding is recorded as a disagreement because the agent cannot edit the PR body. Go tests for internal/repos and internal/scaffold pass, and so do the targeted internal/cli poll tests. The remaining internal/cli failures are the fetch-service tests, which cannot bind a socket in this sandbox. Pre-commit and golangci-lint could not run here (the sandbox network blocks hook installation; golangci-lint is not installed), so CI should confirm lint. Fixed (6):
Disagreed (1):
Tests: passed CI inspections (5):
Conflict update: skipped; strategy Decision points
Next steps:
|
- Withdraw dispatch_active in ContainGitLabTriggerAccount so an install that fails before the lifecycle cannot leave an activation recorded. - Make the scaffold ledger parser accept exactly one JSON document, with negative tests for trailing content and concatenated documents. - Unset FULLSEND_PINNED_JOB_USER_ID on every fail-closed return of the pin. - Clear FULLSEND_GITLAB_DISPATCH_ROUTE and CI_JOB_TOKEN in clearPollEnv. - Document the dispatch_active downgrade limitation and rollback procedure. Not changed: the ledger schema version stays at 1 (documented instead), and the PR description update is left to a human. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
🤖 Finished Fix · ✅ Success · Started 7:14 PM UTC · Completed 7:26 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.68 |
Resolve extends/only/except merge-aware in the trigger-job scans so an extends inherited through a YAML merge key cannot hide a hidden template's after_script, services or hooks. Scope the agent template's inherited-default check to the agent job's own inherit setting. Require the ledger version in pin-ci-job-identity.sh to match the Go decoder, and fix two doc comments. Not addressed: the maintainer-scope question on deferring follow-up work and the PR description wording are left for the maintainers/author. pre-commit could not fetch hook repos (TLS); gofmt and go vet were run directly, shellcheck was unavailable. internal/cli has pre-existing failures unrelated to this change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
🔧 Fix agent — iteration 1 (bot-triggered)Addressed all six findings in the latest review: four code or script fixes with regression tests, two comment fixes, and one disagreement on the maintainer scope question. Targeted tests in internal/repos and internal/scaffold pass. internal/cli tests fail identically on the unmodified branch. pre-commit could not fetch hook repos, so gofmt and go vet were run directly and shellcheck was unavailable. Fixed (5):
Disagreed (1):
Tests: passed CI inspections (4):
Conflict update: skipped; strategy Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 7:28 PM UTC · Completed 7:38 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $3.14 |
Superseded by updated review
Managed polling schedules (fullsend slash poll, fullsend event poll) were always owned by the installer, so scheduled pipelines ran as the installer and dispatched through the Poller api route; the CI_JOB_TOKEN child-pipeline route from #8482 stayed dormant for them. Add internal/repos/gitlab_trigger_schedules.go: - ConvergeGitLabTriggerSchedules runs only on a ready, published ledger whose FULLSEND_GITLAB_DISPATCH_ACTIVATION record is bound to the current generation. It recreates the managed schedules as the trigger account using a short-lived bootstrap PAT minted while the account stays at Developer (reusing the ledger's pat_pending/pat_id obligation, so the ledger gains no field and containBootstrap handles interruptions). Replacements keep the spec cron, the recorded branch, no variables and the original active state. Installer-owned originals are deleted only after GitLab reports every replacement as account-owned. Drifted (ref, cron, variables) and duplicate account schedules are replaced or removed. - ReleaseGitLabTriggerSchedules hands account-owned managed schedules back to the installer (copy first, then delete) for the current and retired generations. - The hand-back also runs before the account is raised to Maintainer and when rotation or repair retires an account; uninstall deletes the account's managed schedules without a copy. checkForeignResources now accepts account-owned schedules whose description is a managed one and still fails closed on any other. GitLabTriggerBootstrapAPI gains CreatePipelineSchedule and UpdatePipelineSchedule. The CLI applies the ownership decision after the activation gate: move when the activation is recorded, otherwise hand back (also on deferral and lifecycle failure). The managed webhook and the Poller merge grant are unchanged. Live acceptance against a disposable GitLab project has not been run and remains the pre-merge gate described in the issue. Note: pre-commit could not fetch remote hook repositories in the sandbox (TLS failure); gofmt, go vet, lint-docs-links, lychee and whitespace/EOF checks were run directly and passed, and scan-secrets passed. internal/cli fetch-service and FULLSEND_OUTPUT_SCHEMA tests fail in this sandbox with and without this change (environmental). Closes #8508 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Managed polling schedules (fullsend slash poll, fullsend event poll) were always owned by the installer, so scheduled pipelines ran as the installer and dispatched through the Poller api route; the CI_JOB_TOKEN child-pipeline route from #8482 stayed dormant for them. Add internal/repos/gitlab_trigger_schedules.go: - ConvergeGitLabTriggerSchedules runs only on a ready, published ledger whose FULLSEND_GITLAB_DISPATCH_ACTIVATION record is bound to the current generation. It recreates the managed schedules as the trigger account using a short-lived bootstrap PAT minted while the account stays at Developer (reusing the ledger's pat_pending/pat_id obligation, so the ledger gains no field and containBootstrap handles interruptions). Replacements keep the spec cron, the recorded branch, no variables and the original active state. Installer-owned originals are deleted only after GitLab reports every replacement as account-owned. Drifted (ref, cron, variables) and duplicate account schedules are replaced or removed. - ReleaseGitLabTriggerSchedules hands account-owned managed schedules back to the installer (copy first, then delete) for the current and retired generations. The copy runs on the recorded branch, never on a drifted ref, and a copy that is incomplete is replaced. - The hand-back also runs before the account is raised to Maintainer and when rotation or repair retires an account; uninstall deletes the account's managed schedules without a copy. checkForeignResources now accepts account-owned schedules whose description is a managed one and still fails closed on any other. GitLabTriggerBootstrapAPI gains CreatePipelineSchedule and UpdatePipelineSchedule. The CLI applies the ownership decision after the activation gate: move when the activation is recorded, otherwise hand back (also on deferral and lifecycle failure). Interrupted moves are recoverable. Schedules are deleted oldest last and, on hand-back, installer-owned stale schedules before the account's, so a retry still finds them. The intended active state comes from one rule shared by both directions: the oldest schedule with the description is the record, and a disabled installer-owned hand-back copy newer than the account's schedule keeps polling disabled even after the record that asked for it is deleted, so an interrupted cleanup or hand-back never re-enables polling without --reactivate-schedules. The managed webhook and the Poller merge grant are unchanged. Live acceptance against a disposable GitLab project has not been run and remains the pre-merge gate described in the issue. Note: pre-commit could not fetch remote hook repositories in the sandbox (TLS failure); gofmt, go vet, git diff --check and the repos, gitlablifecycle and cli trigger tests were run directly and passed, and scan-secrets passed. Closes #8508 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Managed polling schedules (fullsend slash poll, fullsend event poll) were always owned by the installer, so scheduled pipelines ran as the installer and dispatched through the Poller api route; the CI_JOB_TOKEN child-pipeline route from #8482 stayed dormant for them. Add internal/repos/gitlab_trigger_schedules.go: - ConvergeGitLabTriggerSchedules runs only on a ready, published ledger whose FULLSEND_GITLAB_DISPATCH_ACTIVATION record is bound to the current generation. It recreates the managed schedules as the trigger account using a short-lived bootstrap PAT minted while the account stays at Developer (reusing the ledger's pat_pending/pat_id obligation, so the ledger gains no field and containBootstrap handles interruptions). Replacements keep the spec cron, the recorded branch, no variables and the original active state. Installer-owned originals are deleted only after GitLab reports every replacement as account-owned. Drifted (ref, cron, variables) and duplicate account schedules are replaced or removed. - ReleaseGitLabTriggerSchedules hands account-owned managed schedules back to the installer (copy first, then delete) for the current and retired generations. The copy runs on the recorded branch, never on a drifted ref, exactly one complete copy is kept, and an incomplete copy is replaced. - The hand-back also runs before the account is raised to Maintainer and when rotation or repair retires an account; uninstall deletes the account's managed schedules without a copy. - RepairGitLabTriggerSchedules hands account-owned schedules that carry pipeline variables back to the installer for every ownership-verified generation, without gating on ready, published or activation state, so the override-role preflight can proceed. The CLI runs it after early containment, repository-selection validation and the configuration preflights, and before repos.Converge reaches the pipeline-variable migration preflight, so a failed install leaves live schedules untouched. A failed activation write also hands every account-owned managed schedule back. A schedule that must stay disabled is created disabled: the create request carries active=false (new forge.Client method CreatePipelineScheduleWithActive; the GitLab client omits the attribute for active schedules, so existing requests are unchanged). The trigger account's bootstrap client and the installer hand-back both use it, so a disabled replacement is never active, even briefly or after an interrupted run, and the separate disable request and its compensating delete are gone. GitLabTriggerBootstrapAPI therefore takes an active argument on CreatePipelineSchedule and no longer needs UpdatePipelineSchedule. checkForeignResources now accepts account-owned schedules whose description is a managed one and still fails closed on any other. Interrupted moves are recoverable. Schedules are deleted oldest last and, on hand-back, installer-owned stale schedules before the account's, so a retry still finds them. The intended active state comes from one rule shared by both directions: the oldest schedule with the description is the record, and a disabled installer-owned hand-back copy newer than the account's schedule keeps polling disabled even after the record that asked for it is deleted. The rule stays as a safeguard if a GitLab ignores the create request's active attribute; tests simulate that case. Docs describe the polling schedule ownership, the uninstall deletion of account-owned schedules, and the dispatch activation status. The managed webhook and the Poller merge grant are unchanged. Live acceptance against a disposable GitLab project has not been run and remains the pre-merge gate described in the issue; the GitLab create endpoint's optional active attribute is likewise unverified against a live instance. Note: pre-commit could not fetch remote hook repositories in the sandbox (TLS failure); gofmt, go vet, git diff --check and the repos, forge, gitlablifecycle and cli tests were run directly and passed, and scan-secrets passed. Unrelated internal/cli tests (fetch service, post-script env) fail in this sandbox with and without this change. Closes #8508 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Add GIT_TEMPLATE_DIR and GOROOT to the pre-authorization variable denylist, unset them in install-fullsend-cli.sh, and run the source-pinned git init/checkout with an empty template and a null hooks path. Add gate regression entries for project, inherited, and committed overrides. - Have the dispatch gate report inherited CI/CD variable scopes it could not read, print them from repos install, and document that an inherited override of an execution-controlling variable runs before creator/HMAC verification. - Clarify the minimum CLI versions: the route probe only gates polling (#8482 onward); installer operations after a transfer need #8508. Not done: deferring ownership transfer when an inherited scope is unreadable (opt-in design change, shared with the webhook path). Pre-commit could not fetch hook repos (TLS); gofmt, go vet, git diff --check and bash -n were run directly. shellcheck is not installed. Six unrelated internal/cli tests fail identically on the base branch (sandbox environment). Addresses #8519 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Summary
This PR adds the GitLab CI_JOB_TOKEN child-pipeline agent dispatch route and its activation gate — one self-contained slice of #8438. A poll or webhook-dispatcher job running as the trigger-only service account can start an agent pipeline with its own
CI_JOB_TOKENthroughPOST /projects/:id/trigger/pipeline; GitLab records it assource=pipeline. The request uses typed inputs and the existing dispatch HMAC, sends no Poller PAT, and refuses redirects so a 307/308 cannot replay the job token.This route is dormant. No dispatch entry point is on the trigger account yet, so nothing fullsend owns creates a
source=pipelinepipeline, and the existingapi(Poller) route and the per-user protected-branch merge grant are untouched. This change ships only the inert machinery; it changes no runtime behavior and is safe to merge on its own.What's included
fullsend pollselectsapiorchild-pipelinefrom the job-localFULLSEND_GITLAB_DISPATCH_ROUTEin both the cron and webhook drivers. An unknown route or a child route withoutCI_JOB_TOKENfails closed; the child route also rejects a legacy variable-based dispatch contract.child-pipelineonly when the ledger is ready, a separateFULLSEND_GITLAB_DISPATCH_ACTIVATIONrecord matches the ledger generation, and both the pinned pipeline creator and the running job user equal the trigger account. A CLI that predates the route refuses before dispatch via a--print-dispatch-routesprobe.source=pipelineonly for the protected default branch, the active trigger account as creator, valid typed inputs, and a valid dispatch HMAC. The activation gate scans the committed CI files for unrelated work in trigger and agent child pipelines — including the agent template itself: only the one agent job is allowed there, and an extra job, include, predefined-variable override, job-level execution surface, or inherited global defers activation.FULLSEND_GITLAB_DISPATCH_ACTIVATIONvariable bound to the ledger nonce and resource IDs; the ledger keeps its earlier field set so an older strict decoder still reads it. Every converge, rotate, containment or uninstall run withdraws the record first.Not in this PR — the activation follow-up
Activating the route — i.e. moving a dispatch entry point onto the trigger account — is deliberately a separate PR, because it is an atomic, credential-critical change that requires live GitLab verification. It covers:
main), which requires maintainer-run verification.Splitting here keeps this PR a reviewable, non-breaking, mergeable slice and isolates the credential-model change into a focused, independently-verifiable follow-up.
Related to #8438.
🤖 Generated with Claude Code