docs/spec/implementation/requirements/the-script-12.md
Requirements
Section titled “Requirements”The Script — requirements, continued (part 12 of 13; 60–69: The CLI surface: scripts/node-health.sh…)
Section titled “The Script — requirements, continued (part 12 of 13; 60–69: The CLI surface: scripts/node-health.sh…)”-
The CLI surface:
scripts/node-health.sh.[--live|--ready|--health| --metrics] [--json] [--config FILE] [--state-dir DIR] [--peers-dir DIR](the last three test-only overrides, on the same conventionscripts/pickup-metrics.shalready carries). Exactly one compact JSON object on stdout per call, always —--jsonis accepted but changes nothing, since there is no other rendering to select. Exit code matches the verdict:--live/--readyexit0when the verdict is good,1otherwise;--healthexits0(ok),1(fail) or2(unknown) — a third code, distinct from both, since “the endpoint could not tell” is not the same fact as “the endpoint tells you it is broken”;--metricsalways exits0, since it reports data, never a verdict. No argument prints--health.60a. Read-only throughout. Touches no lock, writes no event, publishes nothing, and triggers no state-sync push, gather, dashboard publish or
claudeinvocation: every verdict computes on demand from what cron already wrote. Exactly two forge reads exist across the whole CLI, each confined to the one mode that reports it: 58a’s own cached/rate_limitread, which--readyneeds for the GitHub budget, and — wherestate_repois configured at all — the singlefleet/mix.jsoncontents read--metricsmakes throughproviders_apply_mixfor its ownmixfield (60e, requirement 2.3e). That second read is uncached across processes, unlike 58a’s:fleet_flag_fetch‘s own memo is keyed by pid, so one CLI invocation is one read, and a collector polling/metrics(60d) spends one contents call per scrape — the cost #2495 weighs against routing it through 58a’s TTL cache instead.test/node-health-cli.test.shasserts the rest of this directly — a fixturestate_dir/workspace_rootare byte-identical, file for file, before and after every mode runs, excepting only the one cache file 58a’s own header documents. That fixture configures nostate_repo, so the assertion holds over a CLI whose mix read short-circuits before it fetches (fleet_flag_fetch_status’ own empty-slug no-op); where one is configured,--metricsalso writes the family’s ownstate_dir/fleet-cache/mix.json(or its.errsibling on a failed read), the same cache every other fleet-flag reader shares.60b. The three verdicts genuinely diverge, from one CLI, in one process.
test/node-health-cli.test.shbuilds a fixture that is live (a fresh marker), not ready (the node switch set) and unhealthy (astuckupdater verdict and a stale publication) all at once, and asserts all three answers from the same three calls — the acceptance criterion this whole item exists to satisfy, proven end to end through the CLI rather than only throughlib/node-health.sh’s own pure functions (test/node-health.test.sh).60c. The container-runtime healthcheck runs the identical CLI.
deploy/docker/compose.yaml’sschedulerservice carries ahealthcheck:runningscripts/node-health.sh --liveinside the container — the same command a Kubernetesexecprobe would run, so the two can never disagree about what “live” means. Deliberately the liveness verdict alone, never readiness or health: a sidecar answering for a wedged scheduler beside it would be the identical self-certification the 2026-08-08 incident exposed, arriving by a new route.docker compose configrenders it cleanly.60d. The HTTP surface is a second front over the identical computation, never a second answer.
scripts/node-health-server.pyanswers/livez,/readyz,/healthz,/metricsby shelling out to the samescripts/node-health.shthe container healthcheck runs in-container —200when the underlying call exits0,503otherwise (/metrics: always200, since it reports data, not a verdict), the CLI’s own JSON body either way; any other path answers404— including a path that merely resembles one of the four (a trailing slash, a query string), which is matched literally rather than normalised. Holds no cache and no state of its own — a request whilestate_diris unreadable still returns valid JSON, readingunknownrather than hanging or stack-tracing, because the underlying CLI itself never crashes on that input (lib/node-health.sh’s own contract). Served by thenode-healthcompose service, which is in that one profile and no other, so it is off unless a node opts in — bound0.0.0.0inside the container, published to the host’s own loopback alone (127.0.0.1:${NODE_HEALTH_PORT:-8788}:${NODE_HEALTH_PORT:-8788}), the identical loopback-only patternscripts/serve-dashboard.sh’s own header documents fordashboard-local. This service is never what makes the scheduler’s own liveness honest (60c already is, in-process); it exists solely for a reader — a collector, an orchestrator’s own URL-level probe — that can only speak HTTP. It also carries the scheduler’s ownHTTPS_PROXY/HTTP_PROXYvariables (both spellings) and sits ondefaultandegressboth, alongside its loopback publishing — neveregressalone, since that network isinternal: trueand a published port into it is not the reachable mapping this paragraph already requires — so the one forge read 58a describes leaves through the same D24 egress path the scheduler uses (issue #1587).60e.
--metrics’ field list is the node metrics shapedocs/reference/metering-schema.mddocuments under its own stability policy. Node identity (node,role,ts,version), all three other verdicts and their components in full (live,ready,health), cycle counters over this node’s own retainedlog.jsonl(cycles.log_selections,cycles.log_attempts_failed— this node’s own log only, deliberately never the fleet union, so nothing here double-counts against whatever else unions each peer), and per- container resource actuals-against-budget where issue #606’s collector has produced them (host-facts/<node>.json’s ownbudgetsection,containers,nullwhen absent — reported where it exists, never fabricated: issue #606 itself, not this item, produces those figures), and the credit mix’s effective lanes per provider (mix, requirement 2.3e —mix_fleet_status_json’s own object verbatim, the identical oneagent-cycle.sh --statusrenders from, so the two surfaces cannot disagree about what is open right now, requirement 34a). Explicitly not Prometheus/OpenMetrics, not OTLP, and no adapter to either — the wire-format question issue #614 owns, deliberately parked by this item’s own scope.test/node-health-cli.test.shasserts every top-level field’s presence against this documented shape.60f. New config keys, documented and rendered.
node_health_live_stale_after_minutes(57) andnode_health_forge_check_cache_seconds(58a) — both flat top-level keys,config.schema.json’s existing convention, never nested: this feature is fleet-wide likenode_stale_after_minutesandupdater_stuck_after_minutesbeside it, not per-repository likerepos[].preview. Neither the HTTP bind address nor its port is aconfig.jsonkey —NODE_HEALTH_PORTis a compose/.envvariable on the identical conventionDASHBOARD_PORTalready carries for the dashboard’s ownlocalprofile, since a listening port is a deployment topology choice, not pipeline behaviour.scripts/render-config-table.sh --checkpasses against both new keys. -
A missed CI trigger is detected and retried at the push itself, not only hours later at a Reviewer handoff (issue #2560).
lib/review-gate.sh’s own backstops —_review_gate_missing_required_ contexts(issue #1543) and_review_gate_repair_duplicate_runs(issue #1978) — both run only at the Reviewer’sreadyhandoff, and neither has a run id to act on when a pull request’s head carries zero check runs at all: agent-ops#2506 sat roughly seven hours in that state, looking exactly like “CI still queued”, while its head actually failedscripts/spec.sh check— the same branch having already needed one manual nudge (6c379e10a9, “chore(ci): nudge a missed synchronize event for the previous push”).lib/ci-trigger.sh’sci_trigger_ensurecloses this immediately after the Implementer stage’s own push instead (lib/coordinator-phase.sh, right after the pull request it raised or confirmed is labelled and gated, ahead of the Reviewer stage): it pollsgh pr checks <n> -R <slug> --json name,bucket— unfiltered, “did anything run at all” rather than--required’s narrower subset — up toCI_TRIGGER_POLL_ATTEMPTSxCI_TRIGGER_POLL_INTERVALseconds (default 10 x 30s = 5 minutes, the conservative end of a threshold the issue left open), and where that whole window closes on a confirmed-empty list — never on an unreadable one, which staysunknownand is never treated as “confirmed empty” — pushes one empty commit (chore(ci): nudge a missed CI trigger for <sha>) onto the pull request’s own branch, naming the head commit it nudged. Nevergh run rerun/workflow_dispatch: there is no run id to rerun when the count is genuinely zero, andworkflow_dispatchis not a trigger every relevant workflow declares.69a. At most one retrigger per head commit, and advisory throughout. A nudge that itself produces zero check runs is left for the #1543/#1978 backstops at the next Reviewer handoff to find, rather than looped on here. The nudge never runs against a pull request currently queued in a merge group (
lib/merge-queue.sh’smerge_queue_probe, D17) — a push would evict it with no further signal — nor when either the check-runs read or the queue probe itself could not be confirmed: an unreadableghcall readsunknown, never “confirmed empty” or “not queued”, the same fail-closed conventionreview_gate_required_checksandmerge_queue_probealready apply to their own unreadable reads. Telling those two apart is a stderr test, not a stdout one: a head with no check runs at all does not makegh pr checks --jsonprint[], it makes it fail — nothing on stdout,no checks reported on the '<branch>' branchon stderr — the identical shape a 502 or a rate limit arrives in, so the diagnosis is the only thing that separates the state this requirement exists to detect from a read that could not be made. This is the same two-shapes-one-reason testreview_gate_required_checksalready applies to its own--requiredread. None of this blocks the handoff —ci_trigger_ensure’sunknown/queued/nudge-failedoutcomes only log a warning,nudgedlogs its ownci-trigger-nudgedevent, and the Reviewer stage runs regardless.69b. Never computed in the Implementer’s own clone. The nudge commit is authored in a disposable repository fetched fresh from the forge by branch name alone and discarded afterward — the same shape
lib/rebase-only.sh’srebase_only_forge_capturealready uses, and for the identical reason (requirement 45e): that clone is the Implementer’s to rewrite, so a commit authored there would run the stage’s own.git/config— hooks, filters, an fsmonitor — as the Script. The fetch confirms the branch’s current tip still matches the head commit the poll window observed before committing anything, refusing rather than overwriting a peer’s or a human’s own push landing in the gap between the poll and this call. Unit-tested against a stubbedgh(test/ci-trigger.test.sh), with the real nudge push itself stubbed as a recorder — the same technique test/rebase-only-wiring.test.sh already uses forrebase_only_forge_capture/rebase_only_forge_check— since a real push needs a real forge. Must passshellcheck.