Skip to content

fix(bin): read orphaned green ci monitor and daemon-down failed record as not failed - #3846

Merged
kunchenguid merged 3 commits into
kunchenguid:mainfrom
RooseveltAdvisors:fm/fm-wrbz
Sep 6, 2026
Merged

kunchenguid merged 3 commits into
kunchenguid:mainfrom
RooseveltAdvisors:fm/fm-wrbz

Conversation

@RooseveltAdvisors

Copy link
Copy Markdown
Contributor

Intent

Captain (2026-09-06): "fix this gap asap. make your decision" on the beads failure-pattern gap. This item is one of the fleet failure patterns recorded 2026-09-05 (verbatim record follows).

Failure pattern: an orphaned CI monitor makes a correctly held PR read as a failed run

Evidence 2026-09-05, jr-voice home; verified in that home's status log, not only from the relay. Run 01M1PK18BGWABYYQJNNSA0S5P7, branch fm/jr-blog-rhythm-1, head 8022a41f, PR RooseveltAdvisors/jonroosevelt-site#203. Every substantive pipeline step COMPLETED - intent, rebase, review with one info finding, test, document, lint, push, pr. Only the ci step failed, after 76127890 ms (about 21 hours), with the error 'daemon shutting down'. GitHub, the actual authority on shippability, reported 2 of 2 checks passing and the PR green and mergeable.

The trap is structural, not bad luck. Under a draft-and-stage-only instruction the captain's hold is CORRECT and the merge will never come, so the ci step long-polls for a merge that cannot happen until the shared daemon restarts under it and marks the whole run failed. Every later reader then sees a failed run and infers a quality failure. That misreading is what produced a merge instruction against a PR that was deliberately being held - the failure mode is dangerous in both directions at once: it defames good work AND it prompted action on a held PR.

Contributing cause recorded honestly by the same seat: it exited the worker while the run was still in its merge-monitoring phase. That changed no artifact - the work was already pushed and the PR already green - but it is the mechanism that orphaned the monitor, and the agent should have been left parked.

Fix family: stand the ci monitor down once CI has been reported green, rather than polling to death for a merge signal. A monitor whose only remaining job is to observe a human decision must not be able to convert the absence of that decision into a failure verdict. Treat GitHub's own check state as the authority for shippability, never the pipeline run's aggregate.

Firstmate delivery is upstream: PRs go to https://github.com/kunchenguid/firstmate and are merged by the maintainer; the house main carries local commits, so branch from origin/main.

What Changed

  • bin/fm-crew-state.sh now reclassifies a terminal failed run as done (held-for-merge) when every substantive step completed, exactly one step (ci) failed, and the ci log's last marker reads checks green, surfacing the run's PR URL in the detail; a genuinely red check or a second failed step keeps the failed verdict.
  • In the coarse runs-ledger fallback (no steps table, no ci log), a terminal failed record now reads unknown ("unverified") instead of failed when an explicit daemon status probe proves the shared daemon down; with the daemon up the record still reads failed.
  • Added steps[] table parsing (nm_steps_rows) and new tests in tests/fm-crew-state.test.sh covering the orphaned-monitor reclassification (including the status-only shape), the genuine-red and second-failure disqualifiers, and the daemon-down coarse fallback; updated AGENTS.md and docs/architecture.md to document the new readings.

Risk Assessment

✅ Low: The fix-round commit implements precisely the captain-approved light remedy with positive-evidence guards, conservative failure directions, behavioral tests, and no new machinery, and no reachable defect was found in either commit.

Testing

Completed 1 recorded test check.

  • Outcome: ⚠️ 1 error across 1 run (2m1s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/fm-crew-state.sh:601 - The orphaned green-CI misreading remains reachable through the coarse runs-ledger fallback. When the shared daemon is down - exactly the incident context - fm_nm_run fail-opens to empty (bin/fm-nm-run-lib.sh:32), RUN_OUT is empty, and attribution falls to fm_nm_runs_status_for_worktree, whose coarse branch (line ~601, 'failed) RUN_STATE=failed; RUN_DETAIL="run failed"') has no steps table and no ci-log access, so nm_reclassify_failed_run_as_held_green is never attempted and the same correctly-held PR again reads as a failed run. The intent's criterion 'never [read] the pipeline run's aggregate' is violated on this sibling path. Remedy options (suppress the terminal-failed verdict toward unknown/blocked when the daemon socket is provably down despite a terminal record, or thread green evidence into the ledger path) add machinery beyond this change's stated reader fix, so the remedy - not just the defect - needs the author's decision.

🔧 Fix: Read daemon-down coarse failed ledger as unknown, not failed
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 error
  • 🚨 tests failed with exit code 1
  • bin/fm-test-run.sh --changed --exclude-family real-herdr-gated
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…iled

A no-mistakes run held for a captain merge decision keeps its ci step
polling until merged or closed; when the shared daemon restarts under
that poll, the run is recorded failed although every substantive step
completed and GitHub reports the PR green. A monitor whose only
remaining job is to observe a human decision must not convert the
absence of that decision into a failure verdict.

fm-crew-state.sh now reclassifies a terminal failed run as done
(held-for-merge), surfacing the run's PR URL, when the steps table
shows every step completed except exactly ci failed and the ci log's
last recognized marker reads checks green. A genuinely red check, an
unreadable ci log, or a second failed step keeps the failure.
@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge based on the reviewed state-classification paths and their negative controls.

The reclassification requires a complete terminal steps table, CI as the sole failed step, and a green CI marker; ambiguous coarse records remain unknown rather than becoming false failures.

Reviews (1): Last reviewed commit: "no-mistakes(document): docs: align AGENT..." | Re-trigger Greptile

@kunchenguid
kunchenguid merged commit a913539 into kunchenguid:main Sep 6, 2026
15 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @RooseveltAdvisors — really appreciate you taking the time on this.

Contract-class: restore — restores already-promised shippability reading. Main tip already overrides ci-monitor working→done once checks read green ("a green PR is never silently read as still-validating"); the orphaned-monitor terminal-failed shape broke that promise by converting captain-hold absence into a failure verdict. Reclassify predicates require positive evidence (steps table: every step completed except exactly ci failed + ci log last marker green); genuine red or second failed step stays failed. Coarse ledger daemon-down→unknown extends #3785 instrument-failure≠work-failure (not a new classification policy). Always-on reader honesty, not a new default path beyond prior promise.

Attestation: MATCH (head_sha 6715256 == HEAD). Security: clean (no workflows). CI: all green + NM SUCCESS + Greptile 5/5.

VISION: (1) OK — honest interface; stops false failure that defames held work (2) OK — GitHub checks remain shippability authority; captain hold not inferred as failure (3) OK — deterministic reclassify predicates in script (4) OK — daemon-down/monitor death ≠ work failure; restart honesty (5) OK (6) OK (7) OK — reader-only; conservative positive-evidence guards; no new machinery beyond the promised reading.