Repository navigation
fix(#72): document the runner broker; keep cancels across restarts - #140
fullsend-ai-coder[bot] wants to merge 2 commits into
Conversation
Document the broker behaviour added by #29 in docs/guides/runner-broker-protocol.md: the JobCancellation message and its (1 << 40) + job_id id range, re-sending it until the runner deletes it, the TaskAgentJobNotFoundException 404, a cancelled job keeping conclusion=cancelled, self-delete versus REST delete of a busy runner, and the in-memory broker state. ADR-0005 records that the broker runs in one process and keeps that state in memory. The broker's in-memory hold was lost on a restart, which dropped two cancellations: a runner handed a job before the restart was freed by an Online poll once the job was cancelled, and a job deleted with its repository left nothing to cancel. _restore_hold rebuilds a busy runner's hold on its next poll, from its newest in-progress or cancelled job, else from a deleted job its lastMessageId names. Tests: - test_runner_broker_restart.py resets broker state between hand-out and cancellation (4 of 5 failed before the fix). - test_runner_protocol_upstream_contract.py parses broker messages into data contracts recorded from actions/runner v2.338.2, the CI stack's pinned version, and fails if that pin moves. pre-commit could not fetch its hook repos (HTTP 403); its pre-commit-hooks, ruff and gitleaks checks were run directly and passed. tests/actions/test_runner_shutdown.py has one failure that also occurs on main in this sandbox. Closes #72 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🤖 Finished Review · ✅ Success · Started 10:59 PM UTC · Completed 11:06 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.53 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
🤖 Finished Fix · ✅ Success · Started 11:08 PM UTC · Completed 11:19 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.52 |
An older cancelled job kept its runner_id and cancelled conclusion, so _restore_hold restored it and never consulted lastMessageId, masking a newer job deleted with its repository. Prefer the job named by lastMessageId when it no longer exists and the database candidate is not in progress. Adds a regression test with a prior cancelled job. Note: pre-commit could not fetch hook repos (network 403) and ruff is not installed; whitespace and syntax were checked manually. Two unrelated tests (test_composite_env, test_runner_shutdown) fail with and without this change in the sandbox. Addresses #140 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
🔧 Fix agent — iteration 1 (bot-triggered)Fixed the single review finding: _restore_hold no longer lets an older cancelled job mask a newer deleted job that the runner's lastMessageId names. Added a regression test. The runner broker restart tests pass (6/6). In the full tests/actions run, two unrelated tests fail with and without this change in the sandbox (composite env and runner shutdown). The pre-commit hooks could not run because remote hook fetching is blocked and ruff is unavailable; I checked whitespace and syntax manually. Fixed (1):
Tests: passed CI inspections (4):
Conflict update: skipped; strategy Finding threads:
Next steps:
Updated by fullsend fix agent |
|
🤖 Finished Review · ✅ Success · Started 11:22 PM UTC · Completed 11:28 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.71 |
|
Risk Assessment: moderate (2/5) DetailsModerate risk driven by high churn and recent regression history in the broker API without a feature flag, mitigated by bot authorship, zero protected or security-sensitive paths, and comprehensive documentation and test coverage matching linked issue #72. |
ReviewOutcome: approve (head Re-review of the commit since the prior review (
|
Superseded by updated review
Summary
This PR writes down the runner broker behaviour that #29 added. It also checks the broker's messages against a pinned upstream runner and fixes the two cancellations a restart loses. Those fixes come from the broker state living in process memory.
Docs
docs/guides/runner-broker-protocol.md, linked from the Actions runners guide. It covers:JobCancellationmessage, its(1 << 40) + job_idid range, and re-sending it on every poll until the runner deletes it;404/TaskAgentJobNotFoundExceptionanswer to a report of a job the runner no longer holds;conclusion=cancelledwhen its runner reports the end;422while the runner is busy;_holding,_poll_generation,_acknowledged,_cancellation_acknowledged, the runner locks) and the single-process requirement.PLAN.mdindex entries.Fix: cancellations lost after a restart
Two cases, both reproduced by the new tests before the fix (4 of 5 failed):
Onlinepoll marked it idle, because a cancelled job is no longerin_progress. The cancellation was never sent._restore_holdinsrc/app/api/actions_distributed_task.pyruns on each poll pass, under the runner lock, before the poll settles the runner. For a runner the database records as busy but that has no hold in memory, it rebuilds the hold from one of two sources:lastMessageIdnames (a cancellation id is mapped back to its job id), if that job no longer exists.From there the existing logic keeps the runner busy and sends the cancellation, as it does without a restart.
Upstream contract test
tests/fixtures/upstream_runner_contracts.jsonrecords theTaskAgentMessage,JobCancelMessageandWrappedExceptiondata contracts, theTaskAgentJobNotFoundExceptiontype key, andDeleteMessageAsync'slongmessage id. They were copied from theactions/runnersources atv2.338.2, the CI stack's checksum-pinned version.tests/actions/test_runner_protocol_upstream_contract.pyparses the broker's job message, cancellation message and404body into those contracts the way Newtonsoft reads them: case-insensitive member names, unknown keys ignored, CLR typesInt64/Guid/TimeSpan.scripts/ci-stack.shor the emulator action's default runner version moves away from the fixture's, so a pin bump forces a re-check.Testing
tests/actions/test_runner_broker_restart.py: 5 new tests, each resetting broker state between hand-out and cancellation. 4 failed before the fix; all pass after it.tests/actions/test_runner_protocol_upstream_contract.py: 5 new tests pass.tests/actions/test_runner_*.py,tests/actions/test_job_claim_race.py, and the runner delete/status tests.ruff checkand the pre-commit-hooks checks pass on the changed files. They were run directly becausepre-commitcould not fetch its hook repositories in the sandbox (HTTP 403).Notes
🤖 Generated with Claude Code
Closes #72
Post-script verification
agent/72-runner-broker-protocol-doc)fdad287855ddb6f1e85a045e407b1f09948ade1c..HEAD)