Skip to content

bug(canary): B-02 has no pull awareness — fires critical on a healthy pull pilot, and Phase 5 does not retire it #2840

Closed

Description

@obasilakis

Summary

Canary B-02 ("no queued without slots-full") has no notion of pull mode. Its premise is that a queued row with free slots and a stale drain tick means the backend's drain pipeline has stalled — but on a pull-pilot agent the backend deliberately does not drain. A row sits queued until a worker claims it, and the drain tick is irrelevant to it.

So B-02 fires critical on a perfectly healthy pilot whenever the canary snapshot lands in the window between enqueue and claim while the drain tick happens to be ≥60s old.

Observed on eu2 / cornelius-oracle (the #1766 soak pilot), 2026-09-09:

signal_query: agent cornelius-oracle: queued=1, slots=0/3 (free=3), drain_tick_age=60s > 60s
observed_state: {"agent_name": "cornelius-oracle", "queued_count": 1, "slot_count": 0,
                 "max_parallel_tasks": 3, "effective_max_parallel_tasks": 3, "free_slots": 3,
                 "drain_tick_at": 1788934006.8633769, "drain_tick_age_seconds": 60,
                 "drain_tick_grace_seconds": 60,
                 "snapshot_time": "2026-09-09T06:07:29.866400Z"}

The queue was empty moments later and the pilot's M4 (lost/phantom) has been clean across every hourly sample. Nothing was wrong.

Cause

canary/invariants/b02_no_queued_without_slots_full.py allows exactly two legitimate reasons for a queued row, and both are push-shaped:

  1. slots are at the cap — irrelevant to a pilot, whose admission is the worker pool, not the ZSET;
  2. canary:drain_tick_at is fresh — irrelevant to a pilot, because CapacityManager.run_maintenance() will never drain that row. pull_owns_dispatch makes the pilot flag a true either/or (fix(pull): make the pilot flag a true either/or + soak measurement set (#1766) #1982): "the backend neither pushes them nor drains them."

Neither holds for a pilot, so any queued row observed at the wrong instant is a critical violation.

This is the same class as the two lease-awareness gaps already closed — E-05 (by #1766) and E-01 (by #1990) — plus S-01's leased-row exclusion. B-02 was missed in that sweep. Confirming the gap is general: grep -rl 'pull_pilot\|PULL_MODE_PILOT\|pull_owns_dispatch' src/backend/canary/ returns nothing. No invariant knows pull exists.

⚠️ The lease-exclusion pattern used for E-05/E-01/S-01 does not fix this one. lease_expires_at is stamped at claim; a row that is still queued has no lease. The offending row is pre-claim by construction, so excluding leased rows changes nothing here.

Why it matters beyond one false positive

  • It contaminates the Production soak-test of pull/work-stealing coordination (#1081) before default-on #1766 acceptance criterion. That issue requires "canary green throughout", and the one B-02 firing in the table lands on the soak pilot. Any window has to argue this away rather than report it clean.
  • Exposure grows with the pilot set. Two more pilots were added on eu2 on 2026-09-15 (oracle-6-science, oracle-7-ai-semi), both cron-driven, so there are now three agents whose queued rows can be caught mid-flight instead of one.
  • It is not retired by Phase 5. feat: pull / work-stealing coordination (push→pull dispatch) #1081's Phase 5 deletes canary S-01/S-02/S-03. B-02 is not on that list, so at default-ON — when every agent's rows pass through queued on the way to being claimed — B-02 as written becomes permanently and universally wrong, not occasionally wrong.

Frequency

Rare, because it needs the 5-minute canary snapshot to coincide with a sub-second enqueue→claim window and a ≥60s-stale drain tick. On eu2, exactly 1 firing in 38 days of canary_violations history (2026-08-04 → 2026-09-11) — against 30,060 E-06, 2,737 S-03, 244 R-01 and 23 S-01 in the same period. Low volume; wrong verdict; critical severity.

Suggested fix

Make B-02 pull-aware rather than skipping pilots outright — skipping would open a real coverage hole. If a pilot's workers all die, its rows sit queued forever with no lease, so E-01's grace-bounded lease check never sees them either (no lease to be overdue) and nothing fires at all. Today M4 is that scenario's only owner, and M4 is a manual soak query, not an invariant.

The shape that keeps the coverage: for an agent where pull_owns_dispatch is true, replace the drain-tick condition with a queue-age condition — a row queued longer than some multiple of the worker long-poll interval is the genuine violation, because a healthy pilot with a free worker claims within one poll. That catches "the workers stopped polling", which is the pull-mode equivalent of "the drain stalled", and it ignores the instantaneous enqueue→claim window that produces the false positive.

Acceptance criteria

  • B-02 does not fire on a pilot agent whose queued row is claimed within a normal poll interval
  • B-02 does fire when a pilot's workers stop claiming (rows age in queued with no lease) — verified, not assumed
  • Push-path behaviour unchanged
  • The Phase-5 disposition of B-02 is stated (it is currently absent from feat: pull / work-stealing coordination (push→pull dispatch) #1081's deletion list)
  • A test covers the pilot case, so the next invariant sweep does not miss it again

Notes

Activity

  1. added
    priority-p2
    type-bug
    theme-reliability
    on Sep 16, 2026
  2. obasilakis commented on Sep 16, 2026

    @obasilakis
    ContributorAuthor

    Operator decision, 2026-09-16 (@obasilakis): Open Question 7 resolves to the edge adapter — human-interactive chat goes on the durable queue, and the push coordination path is deleted rather than kept alongside. Full record on #1989; work created as #2842 and #2843.

    This changes the fix for this issue. Under one queue, every agent's rows pass through queued on the way to being claimed, so B-02 as written is not occasionally wrong — it is universally wrong. Making it pull-aware would be building a detector for a condition that is about to become the normal state.

    Revised disposition: retire B-02 alongside S-01/S-02/S-03 in Phase 5 rather than teach it about pull. The interim question is only whether it is worth a stop-gap carve-out for pilot agents in the meantime, given it has fired exactly once in 38 days on eu2 — I would say no, and instead treat its firings as expected noise on pilots until Phase 5 removes it.

    The coverage gap noted in the body still needs an owner either way: if a pilot's workers stop claiming, its rows sit queued with no lease, and nothing fires. That belongs to whatever replaces the slot/backlog invariants, not to B-02.

  3. added
    status-ready
    complexity-medium
    on Sep 17, 2026
  4. removed
    status-ready
    on Sep 25, 2026
  5. obasilakis commented on Sep 25, 2026

    @obasilakis
    ContributorAuthor

    /claim

  6. added
    status-in-progress
    on Sep 25, 2026
  7. github-actions commented on Sep 25, 2026

    @github-actions

    Claimed by @obasilakis. Label status-in-progress added.

    Next steps:

    1. Create branch: feature/2840-<short-slug>
    2. Implement the feature
    3. Open a PR with Fixes #2840
  8. obasilakis commented on Sep 28, 2026

    @obasilakis
    ContributorAuthor

    Operator decision (@obasilakis): B-02 is repurposed, not retired. This supersedes the 2026-09-16 comment above. B-02 now checks that work meant to be pulled is being pulled, and it survives Phase 5 as that check; its push arm is deleted with the slot ZSET. Implemented in #3048.

    • Pull arm: a pilot is judged by the pool size in its own container env and by 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.
    • Coverage gap from the body ("workers stop claiming, rows sit queued, nothing fires"): covered by that rule, and while the queue is empty by the new B-08 "Pull workers alive" (container not in pull mode, or idle workers silent for 300s). B-08 is a separate id so a pool broken for days cannot hold B-02 red and mute new push stalls.
    • Phase-5 disposition (AC 4): stated in docs/planning/PULL_MIGRATION_STATUS.md.
    • Filed: feat(pull): resize a pilot's worker pool live when its parallel limit changes #3039. The pool size is fixed at container create and does not follow a later cap change; this PR works around it by reading the container, and feat(pull): resize a pilot's worker pool live when its parallel limit changes #3039 fixes it properly.
  9. added
    status-in-dev
    and removed
    status-in-progress
    on Sep 29, 2026
  10. removed
    status-in-dev
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

complexity-mediumpriority-p2theme-reliabilitytype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions