Repository navigation
Conversation
…napshot Give operators a deterministic command that reports mechanically provable Firstmate failures without a second fleet parser, network by default, or any repair side effects. Co-authored-by: Cursor <[email protected]>
…alth Report a high-confidence dead Codex session from the resume banner or a bare-shell pane, and a stale worker done: signal with no later steering, without enabling scheduling or repair. Co-authored-by: Cursor <[email protected]>
bb2900d to
5ff5f66
Compare
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (3): Last reviewed commit: "no-mistakes: apply CI fixes" | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bb2900d683
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| | select(.kind == "ship") | ||
| | select((.pr.url // null) != null) | ||
| | select(.pr.source == "meta") | ||
| | select($prs.available == true) |
There was a problem hiding this comment.
Scope PR listener corruption to the affected task
Captain, when any unrelated task has a malformed or unreadable PR-listener artifact, $prs.available becomes false globally, so this selector skips every ship and suppresses a provable result-listener-missing finding for otherwise authoritative tasks. Preserve validity per task, as the inbox activity path already does, so corruption for task B does not hide task A's missing poll.
Useful? React with 👍 / 👎.
| fm_procevent_claim_state_locked "$id" | ||
| status=$? | ||
| case "$status" in | ||
| 0) owner=live ;; | ||
| 1) owner=missing ;; |
There was a problem hiding this comment.
Treat dangling process-event claims as inconclusive
When a registered source's machine-wide claim is a dangling symlink, fm_procevent_claim_state_locked returns status 1 because -e is false, and this mapping reports a high-confidence missing listener. The claim evidence is malformed rather than proof that no owner exists, so detect the symlink and return an uncertain/invalid owner instead.
Useful? React with 👍 / 👎.
| raw=$(last_nonempty_line "$log" || true) | ||
| verb=$(status_line_verb "$raw") | ||
| note=$(status_line_note "$raw") | ||
| case "$verb" in | ||
| done|blocked|failed) handoff_required=1 ;; |
There was a problem hiding this comment.
Preserve unavailable status-log evidence
When a task's status path is dangling or unreadable, last_nonempty_line fails into an empty string and this classification quietly leaves handoff_required=false; the snapshot remains valid and a live worker can therefore be reported healthy even though the evidence needed to detect a missed handoff was unavailable. Distinguish an absent log from an invalid or unreadable one and propagate the latter as inconclusive.
Useful? React with 👍 / 👎.
|
Speaking as Kun's firstmate: Reviewed HEAD Class: opt-in. Adds a clearly named, read-only Does not close ready-for-pr #3124 from body+code. Author body never claims Closes/Fixes #3124. #3124 is durable health binding for a quiet live no-mistakes fixer (task-bound notification / distinguish quiet-live vs dead). This PR is an on-demand fleet operational health checker over the structured snapshot. Related class, different defect; #3124 stays open. VISION (per rule, inspected evidence):
What is not cleared:
Fork CI approved after this review: CI run This is waiting on the author, not the captain: push a matching Merge-eligible: NO. |
Intent
Create the first proven phase of a deterministic, read-only fleet health checker, using the existing structured fleet snapshot as its canonical input rather than adding a parallel parser or another control plane. The intended public interface is a clearly named bin/ command with a concise human view and stable JSON suitable for later automation. Its job is to identify mechanically provable Firstmate operational failures, not product blockers and not semantic judgments about whether a quiet worker is thinking well.
Required behavior:
Verification:
Scheduling is deliberately not activated in this phase.
Investigate the smallest supported follow-up integration and record a concise recommendation in the PR or delivery evidence: compare the existing watcher's slow-check path, session-start checks, process-event sources, and an OS scheduler. Prefer a durable Firstmate notification path that survives an absent chat over direct Herdr composer injection. Explain whether cron adds any value, how a changed finding would enter Firstmate's durable queue, how unchanged fingerprints would be suppressed, and how recovery works when Firstmate is not currently alive. Do not add cron entries, direct Herdr typing, background daemons, scheduled pings, or automatic repairs yet.
What Changed
Risk Assessment
✅ Low: The latest fail-closed lock handling correctly prevents branch-outcome commands from proceeding after state-boundary rejection, and the broader health-check change has no additional material source defect substantiated in this review.
Testing
Focused health, branch, snapshot, inactive-reconcile, and pending-reply tests passed; real-home human and JSON checks reported healthy, while the supporting wake suite reproducibly encountered an unrelated pre-existing oversized-fixture
grepresource failure after its relevant new cases passed.Evidence: Real-home human health report
Source: Real-home human health report
Evidence: Real-home stable JSON report
Source: Real-home stable JSON report
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 4 issues found → auto-fixed (11) ✅
bin/fm-fleet-health.sh:198- The checker accepts any output whose only validated property is the schema string. A schema-tagged snapshot missingtasks,main_inventory, or collection fields then passes the check and jq's optional traversals can produce zero findings, yieldinghealthyinstead of incomplete/inconclusive. Validate the required snapshot shape and types before evaluation.bin/fm-fleet-health.sh:473- Required criterion: detect a terminal-ishdone:or contract-defined step-complete line with no later status append or steering message. The changed selector only accepts.paths.status_log.last_event.state == "done", so any supported step-complete status verb is silently ignored even after the stale threshold. Extend the canonical status classification to include the fleet's step-complete contract.bin/fm-fleet-health.sh:496- A task withcurrent_state.state == "unknown"due unavailable endpoint evidence, metadata containing a PR, and no valid listener passesterminal_state(...) | notand emits a high-confidenceresult-listener-missingfinding. Unknown does not prove the worker is in flight, so this must remain inconclusive until a known nonterminal state is established.bin/fm-task-inbox-lib.sh:490-fm_task_inbox_latest_activity_jsonchecks only the inbox directory and then globshandled/*.msgwithout validating thathandledexists, is searchable, or contains valid records. A later message moved into an unreadable/malformed handled directory is missed and can produce a false high-confidencemissed-handoff, while a corrupt regular handled record can suppress the finding without any inconclusive signal. Validate nested handled evidence and expose invalid/unreadable results.🔧 Fix: Harden fleet health evidence and handoff detection
5 errors still open:
bin/fm-fleet-snapshot.sh:602- Required criterion: “Default to no network calls.” Health setsFM_SNAPSHOT_REMOTE_PROBES=0, buttask_json_linesstill callscrew_state_jsonfor every task before the remote-probe gate. A task withremote_hosttherefore reachesfm-crew-state.shand can perform SSH during an ordinary health check. Gate remote current-state collection at the snapshot boundary and return explicit unavailable evidence when disabled.bin/fm-wake-lib.sh:138- Required criterion: “Treat unavailable evidence as inconclusive, never healthy or definitely broken.” A malformed or empty watcher-lock PID makesfm_watcher_lock_evidence_unreadablereturn false, so a fresh beacon can be classified asno-watcherand emitted as high-confidencesupervision-unhealthy. Malformed lock evidence must remain inconclusive.bin/fm-procevent-lib.sh:111- Required criterion: “Treat unavailable evidence as inconclusive, never healthy.” A danglingstate/proceventregistry symlink satisfies the absent-registry check and is returned as an available empty inventory. Health can then report no listener problems andhealthydespite unavailable registration evidence. Preserve invalid/unavailable status for dangling registry roots.bin/fm-fleet-snapshot.sh:986- Required criterion: “Treat unavailable evidence as inconclusive, never healthy.” A danglingdata/secondmates.mdsymlink is treated as an absent registry and converted into an available empty registry. With no task rows, the checker can reporthealthywhile canonical secondmate evidence is unavailable. Distinguish genuinely absent registries from dangling or invalid paths.bin/fm-fleet-health.sh:149- The accepted snapshot-validation fix remains incomplete:snapshot_shape_validchecks only a subset of the documented v1 top-level contract, so a schema-tagged snapshot can omit fields such asbacklog,roots, orsecondmate_landedand still be evaluated as healthy. Validate the complete required top-level shape and types before producing findings.🔧 Fix: Harden snapshot boundaries and malformed evidence handling
2 errors still open:
bin/fm-fleet-health.sh:160- Required criterion: “Validate the required snapshot shape and types before evaluation so a schema-tagged but incomplete snapshot cannot report healthy.”nullable()treats omitted jq fields as null, so a task missingendpoint.existspasses validation. A working/alive task with otherwise valid evidence then produces no finding and can report healthy. Require required nullable keys to be present, and validate state enums.bin/fm-pr-lib.sh:637- Required criterion: “Treat unavailable evidence as inconclusive, never healthy or definitely broken.” The canonical PR inventory silently drops every malformed or unreadable.check.shand retirement marker while returningavailable:true; health then interprets the absent row at lines 603-607 as a high-confidence missing listener. A present invalid listener artifact can therefore produceresult-listener-missinginstead of an inconclusive result. Expose invalid/unreadable inventory evidence and only assert missing when the current PR identity and inventory are authoritative.🔧 Fix: Centralize fail-closed evidence classification
5 errors still open:
bin/fm-fleet-health.sh:170- The snapshot validator only checks that endpoint.agent_state, agent_alive, and probe are strings, not that they are valid enum values. A schema-tagged task with agent_state="" can pass validation; agent_state() then returns the empty string, produces no endpoint finding, and the checker may report healthy. This contradicts the required fail-closed rule and the requirement to validate state enums.bin/fm-wake-lib.sh:140- A live watcher PID with missing or empty fm-home, watcher-path, or pid-identity metadata falls through this helper as readable: fm_watcher_lock_matches_pid fails, fm_pid_identity succeeds, and the function returns nonzero. The caller then emits high-confidence supervision-unhealthy instead of inconclusive, even though lock ownership evidence is incomplete.bin/fm-pending-reply-lib.sh:203- The pending-reply validator claims full schema validation but only requires parent_home and parent_status to be nonempty. Values such as parent_home=x and parent_status=not-a-path are accepted as available records, allowing malformed owner evidence to avoid an inconclusive finding. Validate their documented absolute-path contract and the remaining field types.bin/fm-task-inbox-lib.sh:115- The inbox timestamp check uses '?' wildcards, so a value such as at=xxxx-xx-xxTxx:xx:xxZ is accepted as valid. The record is then aged from filesystem mtime and can produce a high-confidence aged-message finding despite malformed evidence. Use digit-constrained validation or classify the record as inconclusive.bin/fm-classify-lib.sh:53- The required criterion says: “Implement these two findings through ONE shared classification helper that every evidence-reading boundary calls.” fm_evidence_classify is added in fm-classify-lib.sh, but the inbox, pending-reply, and process-event readers independently encode available/invalid/unreadable outcomes instead of calling it. Route those canonical boundaries through the shared classifier so malformed or unavailable evidence has one enforced classification policy.🔧 Fix: Centralize fail-closed evidence classification
1 error still open:
bin/fm-fleet-health.sh:623- Required criterion: “Treat unavailable evidence as inconclusive, never healthy or definitely broken.” A readablestate/<id>.metacontainingpr=not-a-urlis copied into the snapshot aspr.source:"meta"; the validator checks only that the URL is a string. With that task stillworkingand no listener record, this predicate emits a high-confidenceresult-listener-missingfinding instead of classifying the invalid PR identity as inconclusive. Validate the current PR identity through the canonicalfm_pr_url_parseboundary and surface invalid metadata before applying the missing-listener check.🔧 Fix: Validate malformed current PR metadata before listener checks
4 issues (3 errors, 1 warning) still open:
bin/fm-pending-reply-lib.sh:183-fm_pending_reply_record_validrequiresescalation_closed_epoch, butfm_pending_reply_createnever writes that key. Every freshly created normal record is therefore rejected as invalid, causing health to lose all pending-reply records and miss broken or overdue delivery findings.bin/fm-wake-lib.sh:322-fm_path_ageconverts beacon stat failures to999999, and this verdict only marks evidence unavailable when the beacon is fresh. An unreadable or dangling.last-watcher-beattherefore remainsavailable:truewithok:false, producing high-confidencesupervision-unhealthyinstead of an inconclusive result.bin/fm-fleet-health.sh:121- InvalidFM_FLEET_HEALTH_HANDOFF_STALE_SECSexits 2 inside the timed worker, but the outer wrapper replaces the missing JSON withstatus:"incomplete"and exits 3. Invalid configuration is thus indistinguishable from checker failure rather than retaining usage-error semantics.bin/fm-classify-lib.sh:159- The required criterion limits detection to “a step-complete line whose contract expects firstmate to send the next instruction,” but this new classifier treats everystep-complete:line ashandoff_required; the existing ship-task brief defines no such status or task-level contract. A stalestep-complete:line from a task that proceeds autonomously can therefore produce a false high-confidencemissed-handofffinding. Define and consume the authoritative contract before asserting this finding.🔧 Fix: Fixed pending replies, supervision, and handoff evidence
2 errors still open:
bin/fm-fleet-snapshot.sh:362- Required behavior says to inspect Codex-harness panes for the exact resume banner. This branch skips capture whenever the canonical agent state isunverifiedorunreadable; for a supported backend such as zellij, a present pane containing the banner therefore producesresume_banner:nulland nodead-codex-sessionfinding. Capture when the local endpoint exists, treating only failed capture as inconclusive.bin/fm-pending-reply-lib.sh:208- The validator accepts inconsistent recovery records.fm_pending_reply_finish_recoverywritesrecovery_delivery_outcome=confirmedbefore advancingphasetorecovery_sent; a crash between those writes leavesphase=recovery_sendingwith outcomeconfirmed. The reader returnsrecovery_verdict=confirmed, while health flags only failed/unknown/orphaned or overdue phases, so this open record can yield no finding and a healthy report. Validate phase/outcome lifecycle invariants and classify inconsistent records as inconclusive.🔧 Fix: Capture Codex exits and reject inconsistent recovery records
1 error still open:
bin/fm-fleet-health.sh:614- Required criterion: detect “a step-complete line whose contract expects firstmate to send the next instruction.” This selector now accepts onlylast_event.state == "done", and the accompanying regression test explicitly declaresstep-complete:unsupported. That contradicts both the authoritative intent and the earlier instruction to establish the ship-task scaffold’s explicit step-complete contract; a stale contracted step-complete signal remains reachable without anymissed-handofffinding. Restore a canonical contract-derived status classification and consume it here rather than treating every step-complete line as actionable.🔧 Fix: Restore canonical contracted handoff detection
1 error still open:
bin/fm-fleet-snapshot.sh:319- Required criteria say the checker is “not [for] product blockers” and must “keep product decisions … out.”status_is_terminal_verbincludes everyneeds-decisionandblockedline, so this marks both ashandoff_required; after 30 minutes without an inbox append, an ordinaryneeds-decision: choose option Aorblocked: waiting on credentialsbecomes a high-confidencemissed-handoff. Restrict this flag to scaffold states that specifically represent completed work awaiting the next instruction, rather than all captain-relevant stop states.🔧 Fix: Exclude captain decisions from missed handoffs
1 error still open:
bin/fm-fleet-health.sh:623- Missed-handoff detection is globally disabled by corruption in any unrelated inbox.fm_task_inbox_latest_activity_jsonsets one fleet-wideavailable:false/invalid count, and this branch converts every stale contracted handoff into inconclusive. For example, task A has a staledone:status and no later steering, while task B has one malformed handled message; task A's mechanically provable missed handoff is suppressed. Preserve validity per task in the canonical inbox activity result and consult task A's evidence here, while separately reporting task B's corruption.🔧 Fix: Scope inbox corruption to affected handoffs
1 error still open:
bin/fm-branch-outcome.sh:155-lock_storeexplicitly rejects a symlinked or uncreatable state directory, but every caller ignores its nonzero return. For example,appendwith$STATEsymlinked returns fromlock_storebefore acquiring$LOCK, then appends through the symlink and callsfm_lock_releasedespite owning no lock. This defeats the new boundary check and permits unlocked writes, potentially outside the intended home. Make every call fail closed, e.g.lock_store || exit 1.🔧 Fix: Fail closed when branch outcome locking fails
✅ Re-checked - no issues remain.
tests/fm-wake-queue.test.sh:583- The wake-queue suite reproducibly reachesgrep: out of memorywhen comparing its pre-existing oversized single-line fixture. The health-check changes did not modify this case, and the newly added wake initialization regressions passed before it.tests/fm-fleet-health.test.shbin/fm-fleet-health.shagainst the real worktree homebin/fm-fleet-health.sh --jsonagainst the real worktree homebash tests/fm-branch-supervision.test.shbash tests/fm-fleet-snapshot-view.test.shbash tests/fm-inactive-reconcile.test.shbash tests/fm-pending-reply.test.shbash tests/fm-wake-queue.test.sh(two attempts; relevant new cases passed, later pre-existing oversized fixture hitgrep: out of memory)git status --shortto verify testing left no worktree artifacts✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix: Remove unused health test locals
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.