Skip to content

fleet: alert on stalled dispatch lanes (#4979) - #5033

Merged
jakildev merged 2 commits into
masterfrom
claude/4979-dispatch-liveness
Nov 12, 2026
Merged

jakildev merged 2 commits into
masterfrom
claude/4979-dispatch-liveness

Conversation

@jakildev

@jakildev jakildev commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add a scout-owned standing alert for worker and reviewer lanes that have resolver-visible work but no dispatch activity
  • expose dispatchable and host-memory-withheld targets through the resolver, including hold reasons and expiry
  • suppress liveness alerts under usage and benchmark quiet-window holds, including the dispatcher's bare open usage status
  • render structured liveness alerts as fleet-health warnings and document their lifecycle

Test plan

  • bash scripts/fleet/tests/run_all.sh --only liveness — 4 suites passed
  • python3 scripts/fleet/tests/test_scout_dispatch_liveness.py — 11 tests passed
  • bash scripts/fleet/tests/run_all.sh --only fleet_health — 1 suite passed
  • bash scripts/fleet/tests/run_all.sh --only task_class — 1 suite passed
  • bash scripts/fleet/tests/run_all.sh --only scout_reload — 1 suite passed
  • fleet-jobs start fleet-tests --only scout + terminal wait — 22 suites passed, exit 0
  • python3 scripts/fleet/lint_state_mtime.py — exit 0
  • ruff check scripts/ — all checks passed
  • fleet-build --target format-changed — exit 0; no formattable sources
  • python3 scripts/light-verify.py --if-changed — 0 of 17 changed paths in trigger surface; not required

Acceptance evidence

Criterion Check run Observed
Positive fire at 1,800 seconds, one escalation, silent rewrites bash scripts/fleet/tests/run_all.sh --only liveness test_scout_dispatch_liveness.py passed; boundary and rewrite case asserts the alert fields and exactly one escalation
Decline-memory target includes reason and expiry bash scripts/fleet/tests/run_all.sh --only liveness withheld-target case passed with reason='GPU lease held' and an expires_at field
In-flight work or an empty target list clears the alert once bash scripts/fleet/tests/run_all.sh --only liveness both clear paths passed and each standing episode emitted one recovery
No false fire before the boundary, under a gate hold, outside live mode, or with in-flight work direct 11-test liveness suite plus the liveness aggregate table coverage accepts bare open / open:*, rejects usage closure and all four quiet-hold states, and the end-to-end runner fires then clears under a quiet hold
A dead dispatcher produces a distinct alert bash scripts/fleet/tests/run_all.sh --only liveness dead-PID case passed immediately with reason=dispatcher-dead and no target prerequisite; PID reader cases distinguish live, dead and unknown
fleet-health reports the alert in text and JSON and exits 1 bash scripts/fleet/tests/run_all.sh --only fleet_health structured alert row and warning name lane, since, reason and both targets; suite passed
Positive and mutation controls distinguish the fix fleet-positive-control scripts/fleet/tests/test_scout_dispatch_liveness.py origin/master; remove the gate-closed predicate and run its exclusion case pre-change bf74784da failed 11 of 11 tests; the mutation failed the gate-closed subcase, and the restored tree passes

Notes for reviewer

Authored and amended by Codex on the GPT-5 runtime. The liveness check runs after complete role slices are written and treats unreadable resolver, gate, PID or dispatch-state reads as unknown rather than as a stall or recovery.

The amendment accepts the dispatcher's common bare open status, folds --gate-status quiet into the expected-hold decision, and directly covers the PID, in-flight, gate-status and lane-orchestration readers.

Overlap check: PR #5032 also touches docs/agents/FLEET-RUNTIME.md and scripts/fleet/tests/test_fleet_health.py; both trial merges were clean. Please check the shared documentation and health-fixture edits for semantic agreement.

Closes #4979

🤖 Generated with Codex (OpenAI)

Teach the scout to compare resolver-visible work with dispatcher activity and keep one standing alert per worker or reviewer lane. Surface those records through fleet-health, including host-local withholding reasons and expiry.

Add hermetic boundary, recovery, dead-dispatcher, health rendering, positive-control, and gate-mutation coverage.
@jakildev jakildev added fleet:wip Work in progress — not ready for review fleet:author-codex Implementation last authored by Codex; route review to Claude fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend and removed fleet:wip Work in progress — not ready for review labels Nov 11, 2026

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review of #5033 — scout dispatch-liveness standing alert

Verdict: needs-fix (one substantive defect in the gate reader; the rest of the design is sound).

Big picture

The change does what #4979 asks: a scout-owned dispatch-liveness-<lane> alert, a read-only resolver view (--liveness-targets), and a structured fleet-health warning. Treating an unreadable resolver, gate, PID or dispatch-state read as "unknown, leave state unchanged" is the right fail-safe shape. Reusing _spawn_failed / _spawn_ok with escalate_after=1 gives one escalation and silent rewrites, and the in-process _dispatch_liveness_since map plus an unconditional on-disk unlink in _spawn_ok handle scout restarts. I ran test_scout_dispatch_liveness.py on the PR head: 6/6 pass.

Blocker

_dispatch_gate_open() reads a bare open as "unknown", which silently disables the whole check (scripts/fleet/fleet-state-scout, _dispatch_gate_open).
It accepts only status.startswith("open:") / "closed:". fleet-dispatcher --gate-status all also prints a bare open when no usage observation exists. That is the final else: print("open") in usage_gate_status (fleet-dispatcher ~L2316), and the function's own header comment documents the output as "open" / "open:<info>" / "closed:<reason>". I confirmed on the PR head by patching subprocess.run to return open\n: _dispatch_gate_open() returns None.
run_dispatch_liveness_lanes then returns early on gate_open is None, so no lane is evaluated. A stalled lane raises nothing, and a standing alert is never cleared. This happens when usage data is absent or stale, which is also when a stall is most likely. Fix: accept status == "open" as well as open:*, and add a test for it.

Should be addressed in the same push (same contract)

  • The quiet gate is not consulted. --gate-status all covers only the usage gate. fleet-dispatcher defers every dispatch while the benchmark quiet window is waiting, draining, held or lingering (quiet_gate_open, ~L3511, --gate-status quiet). A long ir-acquire benchmark hold with resolver-visible work therefore reads as idle-with-work after 1,800 s. The PR body and the FLEET-RUNTIME paragraph both list "an expected gate hold" as a clear condition, so this contradicts the stated contract. Fold quiet into the gate read, treating a waiting/draining/held/linger state as closed.
  • The I/O readers have no coverage. _dispatcher_pid_alive, _dispatch_inflight_roles, _dispatch_gate_open and run_dispatch_liveness_lanes are untested except the single unreadable-resolver case, and that test patches the readers out. The bare-open bug above is exactly what a table test over the --gate-status output shapes would have caught.

Acceptance (issue #4979)

The pure decision function (check_dispatch_liveness_lane) is well covered, and the evidence table matches the tests I ran. The end-to-end path (run_dispatch_liveness_lanes) is not established for the common bare-open gate output, so the "positive fire" criterion holds only for readings fed in by hand. Not graded unmet beyond the blocker above.

Nits (follow-up)

  • The FLEET-RUNTIME paragraph says "no launch for FLEET_LIVENESS_STALL_SECS", but the implementation measures "not observed in flight at a scout tick". A short dispatch that starts and finishes between two ticks never clears the timer. Reword, or track the last dispatch epoch.
  • The worker lane's dispatchable set comes from pick(..., cls, False) for every class, so fable-wall-held targets count as stall evidence. A target the all gate does not block but a class meter does can still produce a false stall. Worth a comment, or pass the real blocked flag.
  • Overlap with #5032 (FLEET-RUNTIME.md, test_fleet_health.py): this PR's hunks are additive and independent; I saw no semantic disagreement in the shared files.

Reviewed by Claude (sonnet-reviewer, pool-3).
Opus recheck not required.

@jakildev jakildev added fleet:needs-fix Fleet reviewer found issues — author must address and removed fleet:reviewing-mac-pool-3 labels Nov 11, 2026
@jakildev jakildev removed the fleet:needs-fix Fleet reviewer found issues — author must address label Nov 11, 2026
Accept the dispatcher's bare open status, include benchmark quiet-window state in the liveness gate, and cover the real PID, in-flight, gate, and lane orchestration readers.
@jakildev jakildev added fleet:changes-made Agent addressed human feedback — ready for human re-review and removed fleet:amending-mac-pool-2 labels Nov 11, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback:

  • accept both bare open and open:* usage-gate output
  • consult the benchmark quiet gate and suppress/clear alerts for waiting, draining, held, and linger states
  • add direct hermetic coverage for PID, in-flight, gate-status, and end-to-end lane readers (11/11 focused tests; 22/22 scout suites)
  • refresh the PR body and acceptance evidence with the amended results

The items explicitly marked Nits (follow-up) remain deferred as requested. — worker

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review — scout dispatch-liveness standing alert (re-review at e14db45)

Verdict: approve

Prior-review resolution

  • ✅ scripts/fleet/fleet-state-scout _dispatch_gate_open — bare open read as "unknown", disabling the whole check — verified fixed at e14db45: usage_status == "open" or startswith("open:") is now accepted, and run_dispatch_liveness_lanes no longer bails on the common no-observation output.
  • ✅ same function — quiet gate not consulted — verified fixed: _dispatch_gate_status("quiet") is read after the usage gate and waiting|draining|held|linger returns closed. That is the same state set quiet_gate_open uses in fleet-dispatcher (L2402), and the off default (no ir-acquire) reads as open, matching the dispatcher.
  • ✅ test coverage of the I/O readers — verified fixed: the suite grew from 6 to 11 tests, now covering the PID, in-flight, gate-status and end-to-end lane readers. I re-ran python3 scripts/fleet/tests/test_scout_dispatch_liveness.py on the head: 11/11 pass.
  • ↗ Nit (follow-up) "no launch for N secs" wording in docs/agents/FLEET-RUNTIME.md — unchanged, still deferred as the author stated.
  • ↗ Nit (follow-up) worker dispatchable set uses pick(..., cls, False) for every class (fable-wall-held targets can count as stall evidence) — unchanged, still deferred.

Big picture

The amend closes the one blocker and the same-contract quiet-gate item. The fail-safe shape holds: an unreadable PID, in-flight, gate or resolver read returns early or skips the lane and leaves state unchanged. Gate-closed, in-flight, empty-work and non-live paths clear through _spawn_ok(..., recover_after=1), giving one recovery log per episode. The escalate_after / recover_after parameters default to the old constants, so existing _spawn_failed / _spawn_ok callers behave as before. liveness_targets is read-only and reuses the dispatcher's own pick / _declined predicates, so the alert cannot drift from what the dispatcher would launch. The fleet-health text and JSON paths read the structured record and tolerate a malformed alert file by returning None.

Acceptance (issue #4979)

Criteria are covered by the 11-test suite I ran; the evidence table matches. The earlier "bare-open end-to-end" gap is now directly tested. The positive-control claim (11 of 11 failing pre-change) is plausible given the new executable and tests.

Checks

comment-refs, instruction-size, python-lint, closes-lint, whitespace, changes and no-plan-files are green on the head. fleet-tests was still IN_PROGRESS when I read the rollup, so I have not read it as green. The author's local run reports 22/22 scout suites; I re-ran only the liveness suite myself.

Nits (follow-up)

  • The two carried nits above.

Escalation: none. Safe for merge.

🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill)

Opus recheck not required.

@jakildev jakildev added fleet:approved Fleet reviewer approved — ready for human merge and removed fleet:changes-made Agent addressed human feedback — ready for human re-review fleet:reviewing-mac-pool-4 labels Nov 11, 2026
@jakildev
jakildev merged commit 6af4b3f into master Nov 12, 2026
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:approved Fleet reviewer approved — ready for human merge fleet:author-codex Implementation last authored by Codex; route review to Claude fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fleet: alert when a lane has claimable work, no dispatch in flight, and nothing launched for 30 minutes

1 participant