Repository navigation
feat(dispatch)!: never cancel the agent run in flight on a work-item update - #7007
waynesun09 wants to merge 5 commits into
Conversation
PR Summary by QodoOptionally preserve in-flight agent stage runs
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
|
🤖 Review · ❌ Terminated · Started 2:21 PM UTC · Ended 3:03 PM UTC Commit: |
Code Review by Qodo
1.
|
Site previewPreview: https://96dbbe00-site.fullsend-ai.workers.dev Commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
🤖 Finished Review · ❌ Failure (validation failed after 2 iteration(s)) · Started 2:21 PM UTC · Completed 3:03 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $6.04 |
|
🤖 Review · Commit: |
e56312e to
9085c4d
Compare
|
🤖 Finished Review · ✅ Success · Started 3:30 PM UTC · Completed 3:52 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $5.53 |
|
Risk Assessment: elevated (3/5) DetailsModifying two protected CI workflow files alongside high churn and multi-author contention in internal/cli/run.go and reusable-dispatch.yml, coupled with a breaking concurrency change lacking a feature-flag or opt-out mechanism, sustains an elevated risk score of 3 under re-review anchoring. Previous runRisk Assessment: elevated (3/5) DetailsModifying two protected CI workflow files alongside high churn and multi-author contention in internal/cli/run.go and reusable-dispatch.yml, coupled with an unflagged breaking concurrency change lacking an opt-out mechanism, sustains an elevated risk score of 3 under re-review anchoring. Previous run (2)Risk Assessment: elevated (3/5) DetailsModifying two protected CI workflow files alongside high churn and multi-author contention in internal/cli/run.go and reusable-dispatch.yml, coupled with an unflagged breaking concurrency change lacking an opt-out mechanism, sustains an elevated risk score of 3 under re-review anchoring across the re-evaluated PR diff. Previous run (3)Risk Assessment: elevated (3/5) DetailsModifying two protected CI workflow files alongside high churn and multi-author contention in internal/cli/run.go and reusable-dispatch.yml, coupled with a breaking concurrency change lacking an opt-out feature flag, sustains an elevated risk score of 3 under re-review anchoring; only documentation files changed since the prior assessment. Previous run (4)Risk Assessment: elevated (3/5) DetailsModifying two protected CI workflow files alongside high churn and multi-author contention in internal/cli/run.go and reusable-dispatch.yml, coupled with a breaking concurrency change lacking an opt-out feature flag, sustains an elevated risk score of 3 under re-review anchoring. Previous run (5)Risk Assessment: elevated (3/5) DetailsTouching two protected CI workflows alongside high churn and multi-author contention in run.go and reusable-dispatch.yml, combined with a breaking concurrency change lacking an opt-out flag, sustains an elevated risk score of 3 under re-review anchoring. Previous run (6)Risk Assessment: elevated (3/5) DetailsElevated risk driven by breaking changes to protected CI dispatch workflows without an opt-out toggle, along with high git churn and multi-author contention on touched files, anchored to prior assessment (elevated, 3/5) and partially mitigated by dedicated unit test coverage. Previous run (7)Risk Assessment: elevated (3/5) DetailsElevated risk driven by breaking changes to protected CI dispatch workflows without a toggle flag, along with high git churn and multi-author contention on touched files, partially mitigated by focused issue scope alignment and dedicated unit tests. Previous run (8)Risk Assessment: elevated (3/5) DetailsRe-review anchoring preserves elevated (3) risk: Tier 1 confirms large blast radius with 2 protected CI workflow files, Tier 2 reflects high multi-author churn and regression history in core dispatch files, and Tier 3 represents an unflagged breaking behavior change addressing a subset of issue #6957. Previous run (9)Risk Assessment: elevated (3/5) DetailsRe-review anchoring holds at elevated (3): Tier 1 is unchanged from the prior round (large blast radius, PROTECTED_PATH_COUNT=2 confirmed as exactly the two .github/workflows/ files, no dependency changes, non-bot/non-first-time author); Tier 2 reconfirms run.go and reusable-dispatch.yml as extreme multi-author churn/fix hotspots; Tier 3 remains an unconditional, no-opt-out breaking behavior change against a deliberately partial (stacked-PR) match to linked issue #6957's full scope, so no signal moved strongly enough to shift the composite from the prior review round's score. Previous run (10)Risk Assessment: elevated (3/5) DetailsRe-review anchoring holds at elevated (3): Tier 1 is unchanged from the prior round (large blast radius, PROTECTED_PATH_COUNT=2 confirmed as exactly the two .github/workflows/ files, no dependency changes, non-bot/non-first-time author); Tier 2 reconfirms run.go and reusable-dispatch.yml as extreme multi-author churn/fix hotspots; Tier 3 remains an unconditional, no-opt-out breaking behavior change against a deliberately partial (stacked-PR) match to linked issue #6957's full scope, so no signal moved strongly enough to shift the composite from the prior review round's score. Previous run (11)Risk Assessment: elevated (3/5) DetailsRe-review anchoring holds at elevated (3): Tier 1 remains large-blast-radius with two protected .github/ paths, no dependency changes, and a non-bot/non-first-time author; Tier 2 git history reconfirms run.go and reusable-dispatch.yml as extreme multi-author churn/fix hotspots; Tier 3 still reflects an unconditional, no-opt-out breaking behavior change with no feature flag against a deliberately partial (stacked-PR) match to linked issue #6957's full scope, so no signal moved strongly enough to shift the composite from the prior review round's score. Previous run (12)Risk Assessment: elevated (3/5) DetailsRe-review anchoring holds at elevated (3): Tier 1 buckets are unchanged from the prior round (14 files, 628 lines, large blast radius, one protected CI-workflow path, non-bot/non-first-time author), Tier 2 git history reconfirms run.go and reusable-dispatch.yml as extreme multi-author churn/fix hotspots, and Tier 3 still reflects an unconditional, no-opt-out breaking behavior change with no feature flag against a deliberately partial (stacked-PR) match to linked issue #6957 scope, so no signal moved strongly enough to shift the composite from the prior score. Previous run (13)Risk Assessment: elevated (3/5) DetailsRe-review anchoring holds at elevated (3): Tier 1 buckets are unchanged from the prior round (14 files, 628 lines, large blast radius, one protected CI-workflow path, non-bot/non-first-time author), Tier 2 git-history analysis reconfirms run.go and reusable-dispatch.yml as extreme multi-author churn/fix hotspots, and Tier 3 confirms an unconditional, no-opt-out breaking behavior flip with no feature flag but a deliberately partial (stacked-PR) scope match to its linked issue -- together sustaining the composite at elevated with no new signal strong enough to move it. Previous run (14)Risk Assessment: elevated (3/5) DetailsRe-review anchoring holds at elevated (3): Tier 1 buckets are unchanged from the prior round (11-25 files, 300-799 lines, large blast radius, one protected CI-workflow path, non-bot/non-first-time author), git-history analysis reconfirms run.go and reusable-dispatch.yml as extreme multi-author churn/fix hotspots, and Tier 3 confirms an unconditional, no-opt-out breaking behavior flip with no feature flag — together sustaining the composite at elevated with no new signal strong enough to move it. Previous run (15)Risk Assessment: elevated (3/5) DetailsRe-review anchoring holds at elevated: Tier 1 buckets are unchanged from the prior round (11-25 files, 300-799 lines, large blast radius, one protected CI-workflow path, non-bot/non-first-time author) and the unconditional, no-opt-out cancel-in-progress flip across every repository keeps the composite at elevated; the one concrete delta since the prior round (internal/cli/github.go dropping out of the diff) reduces file/line count but the remaining files are still extreme multi-author churn/fix hotspots, so there is no basis to move off 3/elevated. Previous run (16)Risk Assessment: elevated (3/5) DetailsRe-review anchoring preserves the prior score of 3 (elevated): Tier 1 is unchanged (16 files, 628 lines, large blast radius, one protected/CI workflow path, non-bot non-first-time author), Tier 2 confirms run.go, github.go, and reusable-dispatch.yml remain extreme multi-author fix/churn hotspots, and the only delta since the prior round -- a new ADR (+85 lines) and a 6-line architecture.md addition -- is doc-only with no code change, so there is no basis to deviate from elevated. Previous run (17)Risk Assessment: elevated (3/5) DetailsRe-review anchoring preserves the prior score of 3 (elevated): Tier 1 is unchanged (one CI workflow file, one protected path, medium blast radius, non-bot non-first-time author), Tier 2 confirms run.go and reusable-dispatch.yml remain extreme multi-author churn hotspots, and Tier 3 shows a well-scoped, default-disabled subset of a larger linked issue; the only changes since the prior review are three doc-only additions, giving no reason to deviate from elevated. Previous run (18)Risk Assessment: elevated (3/5) DetailsRe-review anchoring preserves the prior score of 3 (elevated): Tier 1 signals are unchanged (one CI workflow file, one protected path, medium change size, moderate test ratio, no dependency changes); Tier 2 confirms run.go and reusable-dispatch.yml remain extreme, tightly-coupled, multi-author churn hotspots; Tier 3 shows the PR covers only a narrow, explicitly-scoped slice of a much broader linked issue. No signal delta warrants a change from the prior elevated assessment. Previous run (19)Risk Assessment: elevated (3/5) DetailsRe-review anchoring preserves the prior score of 3 (elevated): Tier 1 signals are unchanged (CI workflow modified, one protected path, moderate-large change size, decent test ratio), Tier 2 confirms run.go and reusable-dispatch.yml remain extreme churn hotspots under heavy multi-author contention, and Tier 3 retains a rollback-safety concern from the behavioral concurrency toggle — no articulable reason exists to deviate from the prior elevated assessment. Previous run (20)Risk Assessment: elevated (3/5) DetailsTier 1 signals are unchanged from the prior assessment (CI workflow modified, one protected path, moderate-large change size, decent test ratio); Tier 2 confirms run.go and reusable-dispatch.yml are extreme churn hotspots under heavy multi-author contention, and Tier 3 flags a rollback-safety concern from the behavioral concurrency toggle change -- all consistent with the prior score of 3 (elevated), which is preserved under re-review anchoring. Previous run (21)Risk Assessment: elevated (3/5) DetailsPR modifies critical workflow infrastructure (reusable-dispatch.yml) and core CLI logic (run.go) with CI workflow changes and one protected path file. Elevated by active development on run.go and the behavioral nature of the concurrency toggle change. |
ReviewFindingsMedium
Low
Next steps:
Previous runReviewFindingsMedium
Low
Previous run (2)ReviewFindingsMedium
Low
Next steps:
Previous run (3)ReviewFindingsMedium
Low
Next steps:
Previous run (4)ReviewFindingsMedium
Low
Next steps:
Previous run (5)ReviewFindingsMedium
Low
Next steps:
Previous run (6)ReviewFindingsMedium
Low
Next steps:
Previous run (7)ReviewFindingsMedium
Low
Previous run (8)ReviewFindingsMedium
Low
Previous run (9)ReviewFindingsMedium
Low
Previous run (10)ReviewFindingsMedium
Low
Next steps:
Previous run (11)ReviewFindingsMedium
Previous run (12)ReviewFindingsMedium
Low
Next steps:
Previous run (13)ReviewFindingsMedium
Low
Next steps:
Previous run (14)ReviewFindingsMedium
Low
Next steps:
Previous run (15)ReviewFindingsMedium
Low
Next steps:
Previous run (16)ReviewFindingsHigh
Medium
Low
Next steps:
Previous run (17)ReviewFindingsHigh
Medium
Low
Next steps:
|
9085c4d to
c6c05f8
Compare
|
🤖 Finished Review · ❌ Failure (validation failed after 2 iteration(s)) · Started 7:17 PM UTC · Completed 7:59 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high |
|
🤖 Finished Review · ✅ Success · Started 3:19 AM UTC · Completed 3:38 AM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $6.00 |
|
🤖 Finished Review · ✅ Success · Started 12:55 PM UTC · Completed 1:14 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $6.40 |
|
🤖 Finished Review · ✅ Success · Started 7:37 PM UTC · Completed 7:57 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $6.71 |
|
🤖 Finished Review · ✅ Success · Started 8:49 PM UTC · Completed 9:11 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $5.85 |
|
🤖 Finished Review · ✅ Success · Started 7:52 PM UTC · Completed 8:14 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $7.70 |
|
🤖 Finished Review · ✅ Success · Started 3:35 PM UTC · Completed 4:00 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $8.30 |
…update Every stage job in reusable-dispatch.yml ran in a concurrency group keyed on the work item with cancel-in-progress: true, so a second push, comment, label or title edit cancelled the run already working on the item and a fresh run started over: sandbox provisioning and bootstrap before the model read a line, then the whole item again from cold. On a review minutes from posting that is the entire spend lost, and a spaced burst of pushes produces a review of every intermediate state, each superseded before anyone reads it. ADR 0106 (serialize agent runs and coalesce subsequent events, Accepted) decided for preserve-and-coalesce and states that the reusable workflows must move to cancel-in-progress: false. This is that change on GitHub. All seven stage jobs, the matrix fan-out included, now carry the literal false, so the run in flight finishes and the last run to queue waits as the single pending run GitHub keeps per group. That is normally but not necessarily the newest event, since a stage job queues only after route completes; either way the pending run works from the item's current state, which is the agent's side of the bargain. The value is identical on every job on purpose: one role cancelling while another queues on the same item is harder to reason about than either behaviour alone. The workflow header records what the trade gives up: ADR 0063 counted per-stage cancellation as a layer against duplicate poll dispatch, and that layer is gone everywhere, leaving the poller's lock and agent idempotency. queue: max is not used because it is incompatible with cancel-in-progress and N pending full runs is the failure mode this exists to remove. The alignment test pinned six of the seven jobs and asserted a Go bool, which cannot tell a literal boolean from the quoted string that would silently turn the value into an expression. It now pins all seven with the YAML node's tag and value, and fails on any job in the workflow it was not told about, so an eighth stage job cannot ship with its concurrency unchecked. The per-repo shim's header comment, and its generated copy in this repository, described per-role cancel-in-progress groups; both now describe the preserved run, and the scaffold test pins the new wording. BREAKING CHANGE: Every repository stops cancelling the agent run in flight when a newer event arrives on the same work item, on the release that carries this. There is no opt-out. A run may now finish on input the work item has already moved past; the pending run that follows works from current state and corrects it. Repositories that relied on the newest event superseding an older run will see both run to completion instead. Assisted-by: Claude Signed-off-by: Wayne Sun <gsun@redhat.com>
Now that a newer event no longer cancels the run in flight, a run can outlive the state it was dispatched on, and the agent has to be able to tell whether the work item moved under it before it writes its result. The runner exports two run facts into the sandbox: FULLSEND_RUN_HEAD_SHA, the pull or merge request's head at run start and empty for an issue, and FULLSEND_RUN_STARTED_AT, RFC 3339 UTC. The head is empty rather than absent on an issue run so an agent can skip its re-check on an empty value, which it cannot do for a variable that is not there. The start is captured at the top of runAgent, before harness resolution, token minting and env expansion, each of which takes real time. It is still the runner's own clock rather than the workflow run's server-side created_at, and the gap runs one way: an agent re-checking against it sees a narrower window than the run spans, never a wider one. Both lines are emitted after .env.d is sourced and after the env.sandbox block, and both keys are added to reservedSandboxKeys. Position is what protects them: the reserved-key check drops an env.sandbox entry with either name but says nothing about .env.d, so a harness env file sourced above the line would otherwise overwrite them. The iteration-env source stays last because it re-reads a file rewritten before every iteration. That ordering is behaviour, so the script assembly moves out of bootstrapEnv into buildEnvScriptLines and a test pins the run facts after the .env.d line rather than at the end. The SHA is single-quoted with internal quotes escaped, the way every other exported value is, rather than trusting its shape. GITHUB_SHA is not a fallback for the head: on pull_request_target it is the base branch, and a base SHA presented as the head would report a head move on every run. Assisted-by: Claude Signed-off-by: Wayne Sun <gsun@redhat.com>
On GitLab the head was read from CI_MERGE_REQUEST_SOURCE_BRANCH_SHA alone. GitLab's predefined-variables reference says that variable is empty in merge request pipelines and present only in merged results pipelines, so on an ordinary merge request pipeline the run exported no head at all, the signal reserved for issue runs, and an agent could not notice the branch moving underneath it. CI_COMMIT_SHA fills the gap, but only when the pipeline carries the merge request's own variables: in a merged results pipeline it is the merge result commit rather than the source head, and on a branch pipeline it is the branch. The fallback is therefore gated on CI_MERGE_REQUEST_IID rather than on the pipeline source string, since only a pipeline with the merge request's variables has CI_COMMIT_SHA on the source branch, whatever its source says. In a merged results pipeline the first variable is populated, so the fallback is never reached there. fullsend's own GitLab agent job does not carry those variables. Since #7322 the cron poller raises every agent run as an API pipeline on the protected branch and passes the merge request's IID as STATUS_IID, and CI_COMMIT_SHA is the protected branch's commit. STATUS_IID is deliberately not accepted as "a merge request is known": pairing it with CI_COMMIT_SHA would tell the agent the head moved on every run, the same failure GITHUB_SHA is refused for on GitHub. On that path the head stays empty until the poller passes the source branch's SHA as a pipeline variable of its own, which is a follow-up and is recorded in the function comment and the run reference. Assisted-by: Claude Signed-off-by: Wayne Sun <gsun@redhat.com>
The run reference gains a Run baseline section: the two variables, what each holds, that the head is empty rather than absent on an issue run and today on GitLab's poller-raised pipeline, that the start is the runner's own clock and the gap it leaves runs one way, and why the export position after .env.d and env.sandbox is what protects the values. The custom-agent guide and bring-your-own-agent list the variables beside the budget ones and point at that section, and the CLI internals diagram shows where in the env script they land. The CI-workflows conventions record that every stage job in reusable-dispatch.yml carries cancel-in-progress: false, that the value must stay identical across jobs, and what the trade gives up against duplicate poll dispatch. The fix-agent page no longer says a /fs-fix comment cancels the run in flight: it waits as the single pending run and works from the PR's current state. The custom-agent workflow example switches to false and drops the sentence that promised the switch once ADR 0106 was implemented. Assisted-by: Claude Signed-off-by: Wayne Sun <gsun@redhat.com>
ADR 0106 decided preserve-and-coalesce and said the reusable workflows must move to cancel-in-progress: false. The change that does so carried its own ADR for a while; with 0106 Accepted on main that record was redundant, so none is added, and 0106 gets the one annotation the ADR rules allow: a short update note under the GitHub Actions paragraph of its Decision naming the pull request, the workflow setting and the two run facts, with a link to the run reference for the detail. ADR 0063's existing update note already says 0106 replaces automatic cancellation. It now also says that on GitHub the per-stage cancellation it counted as a second layer against duplicate poll dispatch is gone, and that the duplicate-poll case is where the trade is least favourable. The architecture overview's serialization bullet gains the GitHub shape: every stage job with cancel-in-progress: false, the last run to queue waiting as the single pending run, and the runner exporting the run facts, pointing at the run reference rather than at a second ADR. Assisted-by: Claude Signed-off-by: Wayne Sun <gsun@redhat.com>
|
🤖 Finished Review · ✅ Success · Started 6:45 PM UTC · Completed 7:06 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $6.38 |
Every stage job in
reusable-dispatch.ymlnow carriescancel-in-progress: false. A newer event on the same issue or pull request no longer cancels the agent already working on it; that run finishes, and the last run to queue waits as the single pending run GitHub keeps per concurrency group, then works from the item's current state. This is the GitHub implementation of ADR 0106, which is Accepted on main and states that the reusable workflows must move tofalse. No new ADR: the decision is already recorded, so 0106 receives an implementation note instead.Implements the design recorded in #6957 (closed as completed; this stack ships it).
Run facts. So an agent can tell whether the item moved under it before it writes its result, the runner exports
FULLSEND_RUN_HEAD_SHA(the head at run start, empty for an issue) andFULLSEND_RUN_STARTED_AT(RFC 3339 UTC) into the sandbox, after.env.dandenv.sandboxso a harness cannot shadow them. The start is the runner's own clock, and the gap it leaves runs one way: a re-check sees a narrower window than the run spans, never a wider one. On GitLab the head falls back toCI_COMMIT_SHAon an ordinary merge request pipeline, gated onCI_MERGE_REQUEST_IID; on the poller-raised pipeline fullsend actually runs it stays empty until the poller passes the source SHA itself. Seefullsend run§ Run baseline indocs/cli/run.mdon this branch.BREAKING CHANGE: a repository stops cancelling the run in flight as soon as its shim follows a fullsend ref that carries this (the fullsend repository itself on merge, consumers at their next pin bump or scaffold sync), with no opt-out once it does. A run may finish on input the item has moved past and the pending run corrects it; repositories that relied on the newest event superseding an older run will see both run to completion. The pending run is the last to queue, which is normally but not necessarily the newest event, since a stage job queues only after route completes.
What it gives up. ADR 0063 counted per-stage cancellation as a second layer against duplicate poll dispatch. That layer is gone everywhere, leaving the poller's lock and agent idempotency; the duplicate-poll case is where the trade is least favourable, because two duplicate dispatches are the same work rather than a newer state superseding an older one.
Edits to Accepted ADRs on main: ADR 0106 gains an update note under the GitHub Actions paragraph of its Decision naming this PR, the setting and the two run facts. ADR 0063's existing update note gains two sentences on the GitHub trade. Neither Context, Decision nor Consequences is rewritten.
Known, not fixed here: the
harness-runconcurrency group keys on the bare item number rather than the canonical subject identity ADR 0106 requires, so two sources' items with one number share a slot; pre-existing, tracked in #7475.Stacked above this PR: the steering ADRs, which deliver a work-item update into the running agent. None is a prerequisite; when nothing steers, the pending run simply does the work.
Testing
runfacts_test.gocovers both exports, UTC normalisation, quote escaping, the empty head on an issue run, every GitLab pipeline shape, thatGITHUB_SHAis never a fallback, that both keys are reserved, and that the export sits after the.env.dline.make lintand gitlint pass over the range.Checklist
Refs #6957