Repository navigation
fix(canary): B-02 judges pull pilots by their own worker pool; B-08 checks the pool is alive (#2840) - #3048
Merged
Conversation
5 tasks
…08 checks the pool is alive (#2840) B-02 fired critical on a healthy pull pilot caught between enqueue and claim, because its only rule was the push drain's: free slots plus a stale drain tick. The backend never drains a pilot, so neither signal applies. B-02 now has one arm per dispatch mode. Push agents keep the drain rule. A pilot is judged by the pool size in its container's own env (the database cap drifts from it until a recreate, #3039) and by running rows whose lease has not expired. A row waiting over 120s while a worker is idle, or while the container runs no pull workers, is critical; a stopped pilot with aged work is major. B-08 (new) reports a running pilot whose pool cannot claim while its queue is empty: a container without pull mode, or idle workers that have not polled for 300s. The poll time is a new per-agent Redis timestamp written on every claim attempt. It is a separate id because alerts fire only on green->red, so a pool broken for days would otherwise hold B-02 red and mute new push stalls. The canary keeps only the two pull keys from the container env, which also carries credentials. The 24h stale-queue expiry now logs at warning. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ator acts (#2840) A stopped pilot with work waiting, and a container without pull mode, stay that way until someone starts or recreates the agent; cron keeps queueing behind them. Under B-02 either would hold it red for days and mute new push stalls, since alerts fire only on green->red. Both move to B-08. B-02's pull arm now reports only an idle worker ignoring aged work, which clears once the pool claims again. Also from review: a container whose env cannot be read is now labelled in sources_unavailable instead of skipped silently, the copied pool-clamp constants are parity-tested against the agent image, and comments that credited the poll timestamp to B-02 now name B-08. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
obasilakis
force-pushed
the
feature/2840-b02-pull-aware
branch
from
September 28, 2026 13:59
26a882c to
d7b1ff7
Compare
dolho
approved these changes
Sep 29, 2026
dolho
left a comment
Contributor
There was a problem hiding this comment.
/review — #3048
Approving: no critical findings, and the fix is proven by mutation.
Scope: clean. #2840 asked for a pull-aware B-02 that doesn't skip pilots. Moving the long-lived states into a new B-08 is a reasoned split, not drift.
Plan completion (#2840 AC): 4 done, 1 unverifiable (the eu2 soak)
- No fire when the claim lands inside the poll window:
test_freshly_queued_row_on_idle_pool_does_not_fire. - Fires when workers stop claiming:
test_aged_row_with_idle_worker_fires_critical, plus B-08workers_silent. - Push path unchanged:
test_push_agents_are_untouched_by_the_pilot_flag, and the existingTestInvariantB02passes. - Phase-5 disposition stated in
PULL_MIGRATION_STATUS.md.
Execution coverage
| Changed | Executed by | Live consumer | Verdict |
|---|---|---|---|
b02._check_pull, pull_pool_state, oldest_queued_age |
TestInvariantB02Pull (13) |
INVARIANTS["B-02"] → canary cycle |
✅ |
b08.check |
TestInvariantB08 (16) |
INVARIANTS["B-08"] |
✅ |
snapshot._pull_env_of / _is_pull_pilot / _collect_last_worker_poll |
TestInvariantB02PullEndToEnd (real collect_snapshot) |
collect_snapshot() |
✅ |
record_worker_poll |
test_every_claim_attempt_stamps_the_worker_poll |
routers/internal.py:163 via claim_next_task |
✅ |
test_pull_pool_defaults_mirror_the_agent_worker (read_text) |
— | vendored-constant parity with pull_worker.py |
🛡 guard |
Fix mutation: each mutation turned the listed number of tests red.
| Mutation | Tests red |
|---|---|
| Pilots routed back to the push arm | 14, including the eu2 case and the end-to-end env-secret test |
record_worker_poll call removed |
1 |
| Expired leases counted as busy | 1 (test_expired_lease_counts_as_idle) |
Unmodified: 413 pass and 3 skip (canary, 1081, 1880, 2337, 1560 suites).
Critical
None.
Informational
- [I1] The learning goes straight into
docs/memory/learnings.md(9/10), at:1032. It lands on the shared tail, which the file's header forbids ("so that two same-day PRs never conflict on this tail", #2945). Move it to a fragment underdocs/memory/learnings/2026-09-28-<slug>.md. - [I2] A synchronous Redis write on the async poll path (5/10).
pull_coordination_service.py:219hasrecord_worker_polldoing a blockingredis.setinsideasync def internal_next_task. The DB claim in the same handler was already synchronous, and it runs at most once every 15 s per idle worker, so the cost is negligible.
Clean
- SQL: no raw SQL. Reads reuse
_collect_executions. - Auth: no new endpoints.
/next-task's dual auth is unchanged. - Credentials:
_pull_env_ofkeeps only theTRINITY_PULL_MODE/TRINITY_MAX_PARALLEL_TASKSkeys, and the end-to-end test checks a credential-shaped env value is absent from the snapshot. - Enum completeness: B-08 is registered in
INVARIANTS, incanary_alerts(names, runbook, forensic, summary) and in the 2337 namespace test. 1880 parity passes. - Blindness labels:
pull_env[...]/pull_poll[...]avoid thedocker/redisprefixes, and a test pins it. - Enterprise-docs guard: no hits.
- Docs:
reliability.mdhas the B-02 and B-08 rows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
queued_not_claimed). That is B-02's only pull finding, because it clears once the pool claims again.runningrow whose lease has not expired.pilot_stopped), a running container not in pull mode (workers_missing), and idle workers that have not polled for 300s (workers_silent). The poll time is a newagent:pull_poll:{name}Redis timestamp stamped on every claim attempt. It is a separate id because canary alerts fire only on green→red, so a state that lasts days would otherwise hold B-02 red and mute new push stalls.Changes
src/backend/canary/invariants/b02_no_queued_without_slots_full.py: per-mode arms; sharedpull_pool_state/oldest_queued_agesrc/backend/canary/invariants/b08_pull_workers_alive.py: newsrc/backend/canary/snapshot.py:is_pull_pilot,last_worker_poll_at,pull_container_env(keeps only the two pull keys; the env carries credentials; an unreadable env is labelledpull_env[<agent>])src/backend/services/pull_coordination_service.py:record_worker_pollon every claim attempt (best-effort)src/backend/services/pull_pilot.py,agent_runtime_state.py: key constant; keyspace registered as exempt, with the reasonsrc/backend/services/canary_alerts.py: B-02/B-08 name, runbook, summary, forensicPULL_MIGRATION_STATUS.md, capacity feature flow, learnings entry, CSO diff reportTest Plan
pytest tests/unit/test_canary_invariants.py -k "B02 or B08": 42 pass, plus a parity test pinning the pool clamp to the agent image'spull_worker. Covers the eu2 2026-09-09 case, the idle/full/expired-lease pool, container pool vs database cap, no pull mode, stopped and unlisted containers, the Redis outage, and the timestamp formats.collect_snapshottests: pilot status fromPULL_MODE_PILOT_AGENTS, pool from the container env, and a credential-shaped env value absent from the snapshot. Mutation-checked: both deliberate breaks turn the tests red.test_1081_pull_endpoints.py: an empty claim stamps the poll; a Redis failure never blocks a claim.dev.tests/unit: the failures on this machine also fail ondev, and the count varies between runs. The branch adds none; the two errors seen only on the branch pass when their file runs alone.Fixes #2840
🤖 Generated with Claude Code