Skip to content

refactor(#8438): add CI_JOB_TOKEN child-pipeline agent dispatch route - #8482

Merged
ggallen merged 2 commits into
mainfrom
agent/8438-gitlab-protected-dispatch
Oct 16, 2026
Merged

ggallen merged 2 commits into
mainfrom
agent/8438-gitlab-protected-dispatch

Conversation

@fullsend-ai-coder

@fullsend-ai-coder fullsend-ai-coder Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

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_TOKEN through POST /projects/:id/trigger/pipeline; GitLab records it as source=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=pipeline pipeline, and the existing api (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 poll selects api or child-pipeline from the job-local FULLSEND_GITLAB_DISPATCH_ROUTE in both the cron and webhook drivers. An unknown route or a child route without CI_JOB_TOKEN fails closed; the child route also rejects a legacy variable-based dispatch contract.
  • Scaffold route selection picks child-pipeline only when the ledger is ready, a separate FULLSEND_GITLAB_DISPATCH_ACTIVATION record 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-routes probe.
  • Agent-job admission accepts source=pipeline only 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.
  • Backward-compatible activation record: activation lives in the separate FULLSEND_GITLAB_DISPATCH_ACTIVATION variable 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.
  • Docs cover the route, activation record, variable catalog, older-CLI behavior and rollback.
  • Tests cover gate activation and withdrawal, route selection and job-user mismatch, malformed ledgers, source admission, redirect refusal, CLI route parsing, workflow-rule drift, and agent-template scanning.

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:

  1. Migrating the managed webhook and polling schedules to the trigger-only account (install, reinstall, repair, rotation, interrupted cleanup, uninstall).
  2. Removing the obsolete per-user protected-branch merge-grant code and docs once dispatch no longer uses the Poller route.
  3. Install-level lifecycle tests for the above.
  4. The GitLab: activate protected-branch webhook and schedule dispatch #8438 disposable-project live acceptance test (a real issue event and a scheduled poll each reaching the agent job on protected 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

@fullsend-ai-review

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Ended 12:28 PM UTC

Commit: 73f4aa0 · View workflow run →

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 12:30 PM UTC · Completed 12:46 PM UTC

Commit: 73f4aa0 · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $4.64

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Site preview

Preview: https://92136527-site.fullsend-ai.workers.dev

Commit: e97ac4f06dc8976348f1b4c5ae08ecb2c5d2900f

@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Oct 16, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Large 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

Risk Assessment: moderate (2/5)

Details

Large 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)

Details

Large 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)

Details

Large 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)

Details

Large 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)

Details

Large 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)

Details

Moderate 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.

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review

Findings

Medium

  • [design-direction] docs/contributing/gitlab-role-credentials.md:929 — The PR ships only the dormant child-pipeline route and defers the remaining GitLab: activate protected-branch webhook and schedule dispatch #8438 acceptance work (migrating dispatch entry points to the trigger account, removing the per-user merge-grant code, lifecycle tests, live acceptance) to a follow-up. The latest commit message says the maintainer-scope question on deferring that work is left for maintainers. This push does not change the scope split, and the push does not resolve the question, so this finding stays open. Advisory only. A maintainer should confirm the split.

Earlier findings

  • f_9f5d26c83353884a — resolved_by_change: agentGlobalExecProblem is now gated on the agent job's own inherit setting (gitlab_trigger_jobs.go), with a regression test.
  • f_a418b6e661bc928d — resolved_by_change: pin-ci-job-identity.sh now requires ledger version == 1. The new route tests cover version 2 and a missing version, and both fall back to api.
  • f_3cf15dadac471534 — resolved_by_change: the doc comment in gitlab_trigger_dispatch_gate.go now names gitlabDispatchExtraWorkProblem.
  • f_2eae538acb5fe699 — resolved_by_change: the pin-ci-job-identity.sh header now lists FULLSEND_PINNED_JOB_USER_ID.
Previous run

Review

Findings

Medium

  • [privilege-escalation] internal/repos/gitlab_trigger_jobs.go:335 — The agent-template scan checks extends with the non-merge-aware findMappingValue, so an agent job using <<: *base where .base carries extends: .extra (a hidden template with after_script, services or hooks) passes the gate. GitLab would still run that after_script with protected credentials, even after run-agent-job.sh rejects the creator or HMAC. Exploiting it needs a commit to the protected default branch and the route is dormant until activation, so it is a defense-in-depth gap rather than a direct escalation. (id f_1ef8202c317c6561, reclassified from high)
    Remediation: Resolve extends with effectiveMappingValue and reject present or unevaluable values; apply the same to the other extends/only/except checks; add a regression test with a YAML-merged extends to a hidden template containing after_script, services or hooks.
  • [design-direction] docs/contributing/gitlab-role-credentials.md:929 — The maintainer instruction on GitLab: activate protected-branch webhook and schedule dispatch #8438 asks that all remaining acceptance criteria land in exactly one follow-up PR with no deferral. This PR ships only the dormant route and defers webhook/schedule migration, merge-grant removal, lifecycle tests and live acceptance to a later PR. Whether the split is acceptable is a maintainer decision, not a code defect.

Low

  • [logic-error] internal/repos/gitlab_trigger_jobs.go:503 — The shared checkInherited flag conflates dispatcher and agent inheritance, so an agent template with default:after_script and inherit: {default: false} on the agent job is still reported as inheriting it. This causes a false activation deferral. It fails closed.
  • [fail-open] internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh:448 — The trigger-account helper does not validate the ledger's own version, which the Go decoder requires. Creator matching, the dispatch HMAC and the ledger-bound activation record still apply, so this is a parity and hardening gap.
  • [doc-style] internal/repos/gitlab_trigger_dispatch_gate.go:45 — The doc comment cites gitlabTriggerExtraWorkProblem but the gate calls gitlabDispatchExtraWorkProblem (line 71).
  • [doc-style] internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh:21 — The Exports on success header omits FULLSEND_PINNED_JOB_USER_ID.

Earlier findings

  • f_a9ef7c9bdaffef10 — resolved_by_change: docs/contributing/config-source-inventory.md:137 now lists FULLSEND_GITLAB_DISPATCH_ACTIVATION.

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (2)

Review

Findings

High

  • [privilege-escalation] internal/repos/gitlab_trigger_jobs.go:56 — The source=pipeline check accepts the agent include by filename and never reads .gitlab/ci/fullsend-agent.yml. An extra job or include committed there passes the activation gate and runs in agent child pipelines with protected credentials, outside the creator/HMAC checks. Inherited-default checks are also derived only from the dispatcher's inherit setting, so inherit:default:false on the dispatcher skips them for the agent job.
    Remediation: Inspect the agent template when agentChild is set (allow only the intended agent job, validate extra includes and execution surfaces), evaluate inherited defaults for the agent separately, and add regression tests for both cases.

Medium

  • [logic-error] internal/repos/gitlab_trigger_jobs.go:56 — Same root cause as above, from the correctness side: the gate returns Ready although the agent template is unscanned, and the new tests only mutate the root configuration. See also: [privilege-escalation] finding at this location.
    Remediation: Scan fullsend-agent.yml when agentChild is enabled and add tests with an unrelated job and include inside it.
  • [misleading-label] docs/contributing/gitlab-role-credentials.md:930 — The PR is non-draft with the ready-for-review label, but its description says it is an in-progress implementation of GitLab: activate protected-branch webhook and schedule dispatch #8438 with required work still to land in this PR. The body is also stale (items 3 and 5 are implemented; it describes dispatch_active in the ledger while the code uses a separate FULLSEND_GITLAB_DISPATCH_ACTIVATION record).
    Remediation: Align the description with the diff and state whether this is a self-contained slice or still in progress.

Low

  • [pattern-inconsistency] internal/repos/gitlab_trigger_agent_child_work_test.go:146 — _ = forge.ErrNotFound is an unused statement kept only to justify the forge import.
    Remediation: Remove it and the import.
  • [api-shape] internal/repos/gitlab_trigger_jobs.go:347 — gitlabExtraWorkProblem hardcodes the "webhook fast-path deferred: " prefix, so CheckGitLabTriggerDispatchGate must strip it with strings.TrimPrefix.
    Remediation: Return bare problem text and add the prefix in gitlabTriggerExtraWorkProblem.
  • [doc-style] internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh:431 — The comment describes jq -s and a length check that the code (-nr with try fromjson catch null) does not use.
    Remediation: Rewrite the comment to match the current parsing.
  • [pattern-inconsistency] internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh:504 — _fs_job_user is not declared local while its siblings are; it is cleaned up with unset at line 531.
    Remediation: Declare it local and drop the unset.
  • [pattern-inconsistency] internal/forge/gitlab/poll_test.go:1067 — Two new httptest handlers never assert they were invoked, unlike sibling tests and the go-code.md guidance.
    Remediation: Add an invocation flag/counter and assert it.
  • [incomplete-doc] docs/contributing/config-source-inventory.md:137 — FULLSEND_GITLAB_DISPATCH_ACTIVATION is missing from the 'GitLab install machinery' list.
    Remediation: Add it to the list.

Earlier findings

  • f_42d0317f0e196f4d — resolved_by_change: the ledger struct gitLabTriggerAccountState gains no field in this diff; dispatch activation moved to a separate protected FULLSEND_GITLAB_DISPATCH_ACTIVATION variable, so older decoders keep reading the ledger unchanged.

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (3)

Review

Findings

Low

  • [backward-incompatible] internal/repos/gitlab_trigger_account.go:212 — The ledger gains the dispatch_active field (omitempty) but the schema version stays at 1, and decodeGitLabTriggerAccountState uses DisallowUnknownFields. An older CLI therefore fails on a ledger that records an active dispatch (install, converge, uninstall). The PR now documents this downgrade limitation and rollback in docs/cli/repos.md and docs/contributing/gitlab-role-credentials.md, which mitigates it, so it remains low and advisory.
    Remediation: No code change is required if the documented no-downgrade policy is intended. Optionally bump the ledger version or have older CLIs tolerate the field, and point the unsupported-ledger error message at the rollback docs.

Earlier findings

  • f_8a2173ccd14deb8a — resolved_by_change: docs/cli/repos.md now describes dispatch_active activation, the clearing on every converge/rotate run, and the downgrade note, replacing the stale "no dispatch path uses the trigger token yet" text.
  • f_cbc6b885eb9fb051 — resolved_by_change: docs/guides/infrastructure/infrastructure-reference.md now documents FULLSEND_GITLAB_DISPATCH_ROUTE and the dispatch_active ledger field.
  • f_eb6059d786af78c1 — resolved_by_change: pin-ci-job-identity.sh now emits WARNING: instead of a GitHub-style ::warning:: command.

Re-review note: One or more prior blocking findings remain open and must still be addressed.

Blocking prior findings:

  • f_42d0317f0e196f4d: low backward-incompatible at internal/repos/gitlab_trigger_account.go:211 (original inline comment)

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (4)

Review

Findings

High

  • [stale-doc] docs/cli/repos.md:673 — The CLI reference for the GitLab trigger dispatch activation gate is stale after this PR. It says the recheck "only reads", that a deferral "changes nothing", and that "no dispatch path uses the trigger token yet". In the PR head, repos install calls repos.SetGitLabTriggerDispatchActive (internal/cli/repos_gitlab_trigger_account.go:74), which writes dispatch_active: true to the FULLSEND_GITLAB_TRIGGER_ACCOUNT ledger when the gate is ready, and fails the install if recording fails. That activates the source=pipeline agent route. The doc also omits that every converge or rotate run clears dispatch_active before rechecking.
    Remediation: Update docs/cli/repos.md lines ~671-688 to say that repos install records dispatch_active: true once the gate passes (and fails install if recording fails), which activates the child-pipeline dispatch route. Also say that each converge or rotate run clears dispatch_active before rechecking, and link to the downgrade/rollback note in gitlab-role-credentials.md.

Medium

  • [missing-doc] docs/guides/infrastructure/infrastructure-reference.md:351 — The new job-local variable FULLSEND_GITLAB_DISPATCH_ROUTE (child-pipeline or api, exported by pin-ci-job-identity.sh and read by fullsend poll in both the cron and webhook drivers) has no entry in the GitLab variable catalog, where FULLSEND_POLL_MODE is listed. The FULLSEND_GITLAB_TRIGGER_ACCOUNT entry at line 356 lists the ledger fields but omits the new dispatch_active field.
    Remediation: Add a FULLSEND_GITLAB_DISPATCH_ROUTE entry under the GitLab section, and add dispatch_active to the ledger field list on the FULLSEND_GITLAB_TRIGGER_ACCOUNT entry.

Low

  • [pattern-inconsistency] internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh:487 — The script prints a warning with GitHub Actions workflow-command syntax (::warning::...). It is the only occurrence in the GitLab CI scripts directory. GitLab does not interpret it, and the other scripts use echo "WARNING: <message>" >&2.
    Remediation: Change the line to echo "WARNING: Pipeline creator is the trigger account but the running job is not; keeping the api route" >&2.
  • [backward-incompatible] internal/repos/gitlab_trigger_account.go:211 — The ledger gains an omitempty dispatch_active field while gitLabTriggerAccountStateVersion stays 1 and the decoder uses DisallowUnknownFields(). A pre-change CLI reading an activated ledger fails closed with a generic decode error, not the "use a compatible CLI" message. This is a documented trade-off, so the existing documentation suffices unless you prefer a version bump.
    Remediation: Optional: bump the state version so older CLIs get the clearer error.

Labels: PR adds GitLab install/ledger activation behavior and updates documentation alongside the existing dispatch/CI areas.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (5)

Review

Findings

Medium

  • [logic-error] internal/repos/gitlab_trigger_account.go:453 — Dispatch activation is withdrawn only inside convergeGitLabTriggerAccountLocked and RotateGitLabTriggerAccount. The early containment path install runs first (ContainGitLabTriggerAccount) never clears DispatchActive. If a later install stage fails (preflight, scaffold convergence, Poller inventory, lease), the ledger stays ready with dispatch_active=true even though an activation prerequisite may have changed. The new tests cover converge, rotate and deferral, not failures before the lifecycle runs. Mitigating: published-sink containment already revokes the trigger token when the pipeline-variable override role weakens, and creator, job-user, protected-ref and HMAC checks still apply.
    Remediation: Clear DispatchActive under the project lease in ContainGitLabTriggerAccount before any install stage can fail, keeping the later gate-controlled re-activation. Add a regression test that starts with an active ledger, fails an install stage before the lifecycle, and asserts dispatch_active is false.

  • [breaking-schema] internal/repos/gitlab_trigger_account.go:206 — The FULLSEND_GITLAB_TRIGGER_ACCOUNT ledger gains dispatch_active but gitLabTriggerAccountStateVersion stays at 1, and the decoder uses DisallowUnknownFields(). An older CLI reading an activated ledger fails with an unknown-field decode error instead of the "use a compatible CLI" message, blocking install, rotate and uninstall/cleanup after a rollback or in a mixed-version fleet. The docs cover upgrade ordering but not downgrade.
    Remediation: Bump the ledger schema version, or make the decoder tolerate the field. At minimum, document the downgrade limitation and a rollback procedure.

Low

  • [fail-open] internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh:431 — The ledger parser does not fail closed on a parse error after a valid object: jq prints the account ID for a leading valid object, and || true keeps it. {"phase":"ready","dispatch_active":true,"account_id":77} {broken returns 77, so route selection and the agent activation check accept a ledger the Go installer rejects. Low because the ledger is a protected variable written only by the installer, and creator, job-user, protected-branch and HMAC checks still apply.
    Remediation: Publish parser output only after the whole input parses as exactly one JSON object. Add negative admission tests for trailing content and multiple documents.

  • [edge-case] internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh:431 — Same parser: trailing garbage or two concatenated objects still yield an account ID, while the Go decoder rejects both. The malformed-ledger tests only cover invalid input before any valid object.
    Remediation: Accept exactly one JSON document (e.g. jq -s 'if length == 1 then .[0] else error end | ...') and print output only on jq success. Add trailing-garbage and multi-document cases to the route-selection and agent-admission tests.

  • [pattern-inconsistency] internal/cli/poll_test.go:23 — clearPollEnv does not clear FULLSEND_GITLAB_DISPATCH_ROUTE or CI_JOB_TOKEN, which poll/webhook execution now reads via gitlabChildDispatchJobToken(os.Getenv), so CLI tests can become nondeterministic on a runner that sets them.
    Remediation: Add forge.VarGitLabDispatchRoute and "CI_JOB_TOKEN" to the cleared variables.

  • [pattern-inconsistency] internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh:245 — FULLSEND_PINNED_JOB_USER_ID is missing from the unset lists on every later fail-closed return in fullsend_pin_ci_job_identity (unlike the sibling FULLSEND_PINNED_* variables); the script is sourced, so an aborted pin can leave it set in the caller's shell.
    Remediation: Add it to the unset statements on the fail-closed returns.

  • [intent-alignment] internal/repos/gitlab_trigger_account.go:212 — The PR body no longer matches the second commit: it omits the dispatch_active gating, the GET /job user-ID check and redirect suppression, and still says "Keep this PR as a draft" although the API reports is_draft: false.
    Remediation: Update the PR description accordingly.


Labels: PR changes GitLab agent dispatch, CI templates and scripts in Go.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (6)

Review

Findings

High

  • [fail-open] internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh:463 — The child-pipeline route is selected solely when the FULLSEND_GITLAB_TRIGGER_ACCOUNT ledger is ready and the pinned pipeline creator equals its account_id. run-agent-job.sh then admits source=pipeline on the same ledger check plus HMAC. Nothing on this path enforces CheckGitLabTriggerDispatchGate; it is only invoked as an informational report in the CLI. The lifecycle enforces no_one_allowed before publishing the token, but nothing outside the read-only gate checks that CI job-token repository push is disabled or that schedule-variable migration is done. A ready ledger with a published trigger token can therefore coexist with a deferred gate, and a pipeline started with that token will dispatch and admit agent pipelines as the trigger account. This contradicts GitLab: activate protected-branch webhook and schedule dispatch #8438's criterion that no trigger dispatch or agent-credential admission occurs before the gate passes. Exploitation needs the masked, protected trigger-account token (insider-level), and the agent still requires a valid dispatch HMAC.
    Remediation: Gate route selection and source=pipeline admission on a gate-passed signal recorded only by install after the gate returns Ready (for example a protected activation flag in the ledger that the lifecycle clears on any deferral), or withhold/contain the published token whenever the full gate (including job-token push disabled) does not pass. Add negative tests showing a ready ledger alone cannot select child-pipeline or admit a source=pipeline agent job.

Medium

  • [logic-error] internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh:461 — Route selection checks the upstream pipeline's creator, but CI_JOB_TOKEN authenticates as the user associated with the running job. When someone retries a trigger-account-created poll/dispatcher job, the pipeline keeps the trigger account as creator while the job token belongs to the retrier. The helper still selects child-pipeline, the downstream pipeline is created as the retrier, and run-agent-job.sh rejects it, so the dispatch is lost. Tests always equate pipeline creator with job-token identity.
    Remediation: Validate the running job's user ID from the authenticated GET /job response against the ready trigger account before selecting child-pipeline, or fail explicitly. Add a regression test where pipeline.user.id is the trigger account but job.user.id differs.

  • [secret-exposure] internal/forge/gitlab/ci.go:1194 — The trigger request carries CI_JOB_TOKEN in a replayable body (bytes.NewReader) and goes through the redirect-following client. Its CheckRedirect strips PRIVATE-TOKEN but does not reject the redirect, so on 307/308 Go replays the body, forwarding the job token, ref and signed inputs cross-origin or over cleartext.
    Remediation: Disable redirects for this request (shallow-copied client with CheckRedirect returning http.ErrUseLastResponse) and treat redirect responses as errors. Add cross-origin and HTTPS-to-HTTP 307/308 tests.

  • [stale-doc] docs/guides/getting-started/operations.md:128 — The manual uninstall step lists the fullsend workflow rules to remove without the new source=pipeline rule, which convergence now writes into every install. Line 130 also describes the written workflow block without the protected-default-branch pipeline/trigger rules.
    Remediation: Add pipeline to the list at line 128 and update line 130.

Low

  • [stale-doc] docs/cli/README.md:28 — The fullsend poll row omits the new CI_JOB_TOKEN child-pipeline route (FULLSEND_GITLAB_DISPATCH_ROUTE). Remediation: mention both routes.
  • [stale-doc] docs/contributing/workflow-contracts.md:3 — "Either way the pipelines run as API-triggered pipelines" becomes inaccurate once the trigger account dispatches via source=pipeline. Remediation: state both source=api and source=pipeline.
  • [stale-doc] docs/ADRs/0125-gitlab-hybrid-webhook-poller-dispatch.md:379 — ADR says the agent job admits only api; it now admits api pipeline. Remediation: add a top-level > **Update (#8438):** note per docs/contributing/adrs.md.
  • [stale-doc] docs/contributing/sandbox-topology.md:20 — Says stage input is set by API-triggered pipelines; child pipelines can now carry it. Remediation: acknowledge source=pipeline.
  • [version-skew] internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/run-poll-job.sh:87 — A newer scaffold with an older CLI ignores FULLSEND_GITLAB_DISPATCH_ROUTE, dispatches via the Poller PAT, and the agent job rejects it late. Fails closed; route inactive today. Remediation: before activation, fail the poll job when the CLI predates support or require a minimum CLI version.
  • [version-skew] internal/repos/gitlabci.go:135 — The source=pipeline root workflow rule reaches existing installs only after convergence; ordering relative to the new scaffold route is undocumented. Fails closed. Remediation: note in upgrade/activation docs that root workflow:rules must converge first.

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-coder

fullsend-ai-coder Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 12:48 PM UTC · Completed 1:04 PM UTC

Commit: 73f4aa0 · View workflow run →

Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.36

fullsend-ai-coder Bot added a commit that referenced this pull request Oct 16, 2026
- 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>
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 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):

  1. fail-open: child-pipeline route selected and source=pipeline admitted on a ready ledger alone, without the activation gate (internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh): Added a dispatch_active field to the trigger-account ledger. Install records it only after CheckGitLabTriggerDispatchGate returns Ready (SetGitLabTriggerDispatchActive), and every converge or rotate run clears it first, including deferred runs. The shared ledger helper now requires it, so both route selection and source=pipeline admission need it. Added negative scaffold tests (ready ledger without activation, withdrawn, non-boolean) and lifecycle tests.
  2. logic-error: route selection compared the pipeline creator, not the job-token identity, so a retried job lost the dispatch (internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh): The pin now records the running job's user ID from the authenticated GET /job response. child-pipeline is selected only when both the pipeline creator and the job user equal the trigger account; otherwise the api route is kept with a warning. Added regression tests for a retrier and a job record without a user.
  3. secret-exposure: job-token trigger request followed 307/308 redirects and replayed its body (internal/forge/gitlab/ci.go): TriggerPipelineWithJobToken now sends through a shallow-copied client whose CheckRedirect returns ErrUseLastResponse. The redirect response is rejected by the status check and never followed. Added 307 and 308 tests that assert the target is not contacted and the token is not in the error.
  4. stale-doc: manual uninstall step omits the source=pipeline workflow rule (docs/guides/getting-started/operations.md): Added pipeline to the rule list and updated the written-workflow-block description to name the schedule/api/trigger/pipeline rules.
  5. stale-doc: fullsend poll CLI row omits the child-pipeline route (docs/cli/README.md): Described both the api and child-pipeline routes and the fail-closed cases.
  6. stale-doc: workflow contracts say pipelines always run as API-triggered (docs/contributing/workflow-contracts.md): Stated both source=api and source=pipeline.
  7. stale-doc: ADR 0125 says the agent job admits only api (docs/ADRs/0125-gitlab-hybrid-webhook-poller-dispatch.md): Added a top-level Update (GitLab: activate protected-branch webhook and schedule dispatch #8438) note next to the existing update notes.
  8. stale-doc: sandbox topology says stage input is set only by API-triggered pipelines (docs/contributing/sandbox-topology.md): Acknowledged source=pipeline child pipelines.
  9. version-skew: root workflow:rules for source=pipeline reach existing installs only after convergence; ordering undocumented (docs/contributing/gitlab-role-credentials.md): Added an Upgrade ordering note: converge the root workflow rules before activation. Also documented the dispatch_active activation and the job-user check in the role-credentials and configuring-gitlab docs.

Disagreed (1):

  1. version-skew: a newer scaffold with an older CLI ignores FULLSEND_GITLAB_DISPATCH_ROUTE; fail the poll job or require a minimum CLI version: The route is inactive until activation is recorded, and the skew case already fails closed because the agent job rejects the Poller-created pipeline. The reviewer scoped this to before activation. A CLI capability check needs a version or feature-discovery contract that does not exist yet, so it belongs with the activation change. The risk is documented in the upgrade-ordering note instead.

Tests: passed

CI inspections (6):

  1. test (passing, success): Passed on the previous head.
  2. build (passing, success): Passed on the previous head.
  3. codecov/patch (passing, success): Patch coverage gate passed on the previous head.
  4. commit-lint (passing, success): Passed on the previous head.
  5. DCO (passing, success): Passed on the previous head.
  6. run (passing, skipped): Skipped; not applicable.

Conflict update: skipped; strategy none; forge MERGEABLE; target main

Decision points
  • How to gate the child-pipeline route on the activation gate (alternatives: Add a dispatch_active flag to the existing trigger-account ledger, Add a separate protected CI/CD variable, Withhold the published token when the gate fails; rationale: The ledger is already the protected variable both scripts read, and every lifecycle write already goes through it. A flag there adds no new variable to clean up on uninstall, and clearing it is one step at the start of each converge or rotate run.)

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 1:06 PM UTC · Completed 1:30 PM UTC

Commit: 0671b1c · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $5.62

fullsend-ai-review[bot]

This comment was marked as outdated.

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review fullsend-ai-review Bot added component/dispatch Workflow dispatch and triggers component/ci CI pipelines and checks go Pull requests that update go code labels Oct 16, 2026
@fullsend-ai-coder

fullsend-ai-coder Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 1:32 PM UTC · Completed 1:43 PM UTC

Commit: 0671b1c · View workflow run →

Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.58

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 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):

  1. Dispatch activation is not withdrawn by early containment (logic-error, medium) (internal/repos/gitlab_trigger_account.go): ContainGitLabTriggerAccount now withdraws dispatch_active first, under the project lease, before any install stage can fail. Added a regression test that starts with an active ledger and asserts containment clears it.
  2. Ledger gains dispatch_active without a schema bump; older CLIs fail to decode it (breaking-schema, medium) (internal/repos/gitlab_trigger_account.go): Took the reviewer's minimum remedy: documented the downgrade limitation and the rollback procedure (uninstall with the newer CLI first) in the GitLab role-credentials contributor doc and the configuring-gitlab guide. The schema version is unchanged: a bump would make existing v1 ledgers unreadable to the new CLI and would need a dual-version decoder, which is wider than this PR.
  3. Scaffold ledger parser accepts a valid object followed by trailing garbage (fail-open, low) (internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh): The parser now slurps the input and accepts exactly one JSON object, so partial parses print nothing. Added trailing-garbage cases to the route-selection test and to the agent-admission test.
  4. Parser accepts two concatenated ledger objects (edge-case, low) (internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh): Same single-document check rejects multiple documents. Added multi-document cases to both test suites.
  5. clearPollEnv does not clear FULLSEND_GITLAB_DISPATCH_ROUTE or CI_JOB_TOKEN (pattern-inconsistency, low) (internal/cli/poll_test.go): Added both variables to the cleared set.
  6. FULLSEND_PINNED_JOB_USER_ID missing from unset lists on fail-closed returns (pattern-inconsistency, low) (internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh): Added it to the unset statement on every later fail-closed return in fullsend_pin_ci_job_identity.

Disagreed (1):

  1. PR description no longer matches the second commit (intent-alignment, low): This needs a PR body edit, which the fix agent cannot make (it has no way to edit PR metadata). No code change is warranted. A human or the PR author should update the description to cover dispatch_active gating, the GET /job user-ID check and redirect suppression, and drop the stale draft sentence.

Tests: passed

CI inspections (5):

  1. CI / test (passing, success): Passed on the previous head.
  2. CI / commit-lint (passing, success): Passed on the previous head.
  3. codecov/patch (passing, success): Passed on the previous head; new changes add tests for the changed lines.
  4. E2E Tests / behaviour (passing, success): Passed on the previous head.
  5. DCO (passing, success): Passed on the previous head.

Conflict update: skipped; strategy none; forge MERGEABLE; target main

Decision points
  • How to address the ledger schema compatibility finding (alternatives: Bump gitLabTriggerAccountStateVersion, Make the decoder tolerate the field, Document the downgrade limitation and rollback; rationale: A version bump or tolerant decoder cannot help already-shipped older CLIs and would need a dual-version decoder; the reviewer allowed documentation as the minimum, which keeps the change small.)

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

fullsend-ai-coder Bot added a commit that referenced this pull request Oct 16, 2026
- 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>
fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-coder

fullsend-ai-coder Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 7:14 PM UTC · Completed 7:26 PM UTC

Commit: 3281a27 · View workflow run →

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>
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 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):

  1. [privilege-escalation] extends is checked with a non-merge-aware lookup, so an extends inherited through a YAML merge key passes the agent-template gate (internal/repos/gitlab_trigger_jobs.go): Resolve extends, only and except merge-aware via a new jobHasUnevaluableAdmission helper and the existing effectiveMappingValue, rejecting present or unevaluable values in the job-scan, exec-surface and dispatcher-template checks. Added a regression test with extends inherited through a merge key to a hidden template carrying after_script.
  2. [logic-error] shared checkInherited flag conflates dispatcher and agent inheritance, giving a false activation deferral when the agent job sets inherit default false (internal/repos/gitlab_trigger_jobs.go): The agent template's global-default scan now depends only on the agent job's own inherit setting. Other files keep the existing conservative behavior. Added a test where the agent job disables default inheritance and the template has a default after_script.
  3. [fail-open] trigger-account helper does not validate the ledger version that the Go decoder requires (internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh): The jq condition now requires version 1 on the ledger. Added route-selection test cases for an unsupported and a missing ledger version.
  4. [doc-style] doc comment cites gitlabTriggerExtraWorkProblem but the gate calls gitlabDispatchExtraWorkProblem (internal/repos/gitlab_trigger_dispatch_gate.go): Corrected the function name in the doc comment.
  5. [doc-style] Exports on success header omits FULLSEND_PINNED_JOB_USER_ID (internal/scaffold/fullsend-repo-gitlab/.gitlab/ci/scripts/pin-ci-job-identity.sh): Added the variable to the exports list in the header comment.

Disagreed (1):

  1. [design-direction] PR ships only the dormant route and defers remaining acceptance criteria, contrary to the one-follow-up-PR instruction on the issue: The reviewer states this is a maintainer decision rather than a code defect, and no code change is prescribed. Splitting scope is not something the fix agent should decide; it is left for the maintainers.

Tests: passed

CI inspections (4):

  1. test (passing, success): Project test job passed on the reviewed head.
  2. commit-lint (passing, success): Commit lint passed.
  3. codecov/patch (passing, success): Patch coverage gate passed.
  4. E2E Tests (playback, behaviour) (passing, success): E2E jobs passed.

Conflict update: skipped; strategy none; forge MERGEABLE; target main

Decision points
  • Whether to change the inherited-default scope for non-agent files (alternatives: Scope every file's check per job, Scope only the agent template's check; rationale: The finding concerns only the agent template; the other files keep the existing conservative check so no protection is loosened beyond what the reviewer described.)

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 7:28 PM UTC · Completed 7:38 PM UTC

Commit: e97ac4f · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $3.14

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the review comment for full details.

@fullsend-ai-review fullsend-ai-review Bot added the requires-manual-review Review requires human judgment label Oct 16, 2026
@ggallen
ggallen added this pull request to the merge queue Oct 16, 2026
Merged via the queue into main with commit b9fe1fe Oct 16, 2026
102 checks passed
@ggallen
ggallen deleted the agent/8438-gitlab-protected-dispatch branch October 16, 2026 20:22
fullsend-ai-coder Bot added a commit that referenced this pull request Oct 17, 2026
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>
fullsend-ai-coder Bot added a commit that referenced this pull request Oct 17, 2026
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>
fullsend-ai-coder Bot added a commit that referenced this pull request Oct 17, 2026
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>
fullsend-ai-coder Bot added a commit that referenced this pull request Oct 17, 2026
- 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>

This branch was successfully deployed

1 active and 1 inactive deployments
site-preview — e97ac4f0 Deployed Oct 16, 2026 by github-actions[bot]
dev — e97ac4f0 Deployed Oct 16, 2026 by fullsend-ai-coder[bot] via behaviour #16891
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/ci CI pipelines and checks component/dispatch Workflow dispatch and triggers component/docs User-facing documentation component/install CLI install and app setup go Pull requests that update go code ready-for-review Triggers review agent dispatch requires-manual-review Review requires human judgment risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant