Skip to content

fix: let the Stop auto-arm recover an unowned home; alert on wedged away daemon - #4955

Open
marcospaterson wants to merge 3 commits into
kunchenguid:mainfrom
marcospaterson:fm/fm-4927-guard-deadlock
Open

marcospaterson wants to merge 3 commits into
kunchenguid:mainfrom
marcospaterson:fm/fm-4927-guard-deadlock

Conversation

@marcospaterson

Copy link
Copy Markdown

Fixes #4927. Addresses #4928 (scoped).

Change

  • 4927: the Stop auto-arm now claims an absent or malformed session lock through bin/fm-lock.sh, so a home with in-flight work and no live watcher recovers within one turn end. The guard grants the arm a bounded extra wait (FM_CLAUDE_AUTOARM_LOCK_CLAIM_WAIT_MS, default 2000) when the lock is unowned, because the claim precedes the generation claim. The guard is not made fail-open. Ownership order is documented in docs/turnend-guard.md.
  • 4928: the away daemon raises an out-of-band alert when a wedge exceeds its bound, and away entry verifies delivery once (docs/wedge-alarm.md).

Maintainer verification

  • New regression test test_hook_claude_mode_home_with_no_watcher_and_no_lock_self_heals_in_one_turn_end runs the real guard and real arm together on a home with no lock and no watcher; it fails on the pre-fix arm.
  • The first version of that test was flaky (about 1 in 3 runs, always under load) because fm-lock.sh alone takes ~0.4s against the 800ms wait; after the lock-claim allowance it passed 6/6 under 6 CPU-burner processes.
  • tests/fm-turnend-guard.test.sh and tests/fm-claude-stop-autoarm.test.sh pass; bin/fm-lint.sh (ShellCheck 0.11.0) and bin/fm-doc-audience-check.sh pass.
  • tests/fm-afk-launch.test.sh passes except the herdr e2e case, which cannot prepare a lab session on this machine (herdr unavailable).

@marcospaterson
marcospaterson force-pushed the fm/fm-4927-guard-deadlock branch from 9f403bd to 7a9dd59 Compare September 19, 2026 17:49
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: waiting-author (contract-class: new-default). Preferred over sibling #4943 for #4927.

Tip check (b6930db737c382533120d6005ac515478eb6f083): bin/fm-claude-stop-autoarm.sh still exits 0 on absent/malformed state/.lock (inert), while fm-turnend-guard.sh --claude blocks when no live watcher holds the home — so an unowned home cannot self-heal. Stop hooks remain same-group in .claude/settings.json. Not fixed on main. This HEAD claims the unowned lock through fm-lock.sh, adds FM_CLAUDE_AUTOARM_LOCK_CLAIM_WAIT_MS (default 2000) to the guard sync wait, and adds a regression that runs real guard+arm together.

Does it close #4927? Yes (invariant). Author body correctly rejects the issue's same-group-suppression guess (parallel Stop hooks) and names the real tip bug: arm inert on absent/malformed lock. The stated invariant — home with in-flight work and no live watcher recovers within one turn end — is what the new integrated test asserts. GitHub Fixes #4927 holds for that invariant. Does not fully close #4928 (entry-half only; mid-window wedge delivery already partially exists via inject_wedge_alarm; leave #4928 open).

Contract-class: new-default (mixed; new-default wins). The lock-claim + guard wait half is restore of the existing Stop auto-arm recovery path. Bundled away-entry wedge_alarm_verify is a new default-on gate: fm-afk-launch.sh start/start-native now refuses when no out-of-band channel delivers (Linux auto → empty channel fails until captain writes off or command:). Mixed restore + new default-on surface → new-default. Cannot auto-merge.

VISION.md (each rule)

  • One captain, one interface / peace of mind: aligns (self-heal restores looking-away; entry alarm check deepens honesty) — with tension: new away-start refusal is louder machinery on the unconfigured path.
  • Authority is explicit and never inferred: tension — entry verify assumes consent to a new refusal unless off/command: is set; not a quiet widen of agent autonomy, but it does change default away-start.
  • Scripts own the mechanics, agents own the judgment: aligns — lock claim and wait are script mechanics.
  • A restart is a non-event: aligns — watcher death recovers without operator ritual.
  • Delegation with a spine: aligns — in-flight tasks need live supervision.
  • The fleet outlives any vendor: aligns — Claude Stop adapter contract.
  • Scope: aligns — primary supervision / away daemon.

Checks: MERGEABLE / UNSTABLE. Attestation MISSING (no no-mistakes-pipeline-attestation:v1 for 7a9dd593eb23529931b27f171a8a94e6b2ba2e4f). First-time fork CI: workflow-approved (runs for HEAD). Need matching NM attestation + green CI before any Firstmate flag for the new-default merge gate.

Overlap: Prefer this over #4943 (same author; #4943 lacks the lock-claim wait that the regression needs under load). Open #4026 (CONFLICTING) takes a different approach (--ensure-watcher prime on refusal); keep it until one lands, then close leftovers. Sibling #4943 will be closed-overlap if this merges.

Security FYI: none material — reuses existing fm-lock.sh reclaim path; wedge verify sends a test alert through already-configured channels only.

No Firstmate escalation yet (attestation/CI not green). Author: please raise via no-mistakes so attestation matches HEAD, then CI can finish.

mremond added a commit to mremond/firstmate that referenced this pull request Sep 25, 2026
… work is spent

Refs kunchenguid#4018

Limits, stated as limits:
- It closes nothing. Every forge call is a read, including in the opt-in
  --sweep mode: no issue is closed, labelled, or commented on, and no backlog
  is read or written. It is the evidence half of the claim problem, not the
  loop closure the triage also leaves open.
- A fix that cites the issue number nowhere - no PR body, branch, or title,
  no commit message, and no --symbol the caller supplies - stays invisible to
  every check.

bin/fm-issue-claim.sh runs five read-only checks per issue and prints an
inspectable verdict (open, claimed, partially-covered, fixed-on-main, or
unknown): timeline cross-references, maintainer triage stamps (OWNER, MEMBER,
or COLLABORATOR only; the existing-pr target PR is read for its current
state), the complete open-PR corpus fetched by paginated REST and checked
against the search API total, the issue author's fork branches (resolved to
the PR each heads), and main history since the issue opened (commit messages
citing the issue, plus optional caller --symbol pickaxe searches). Issue
numbers match only as whole numbers, so 4018 never matches 40181, and a
foreign owner/repo#N is not a citation. A failed or rate-limited read, a
short or unverified corpus, or a history ref that cannot be searched yields
unknown or an explicit disclosure, never open. One corpus is shared across
every issue in a run and can be saved and reused across runs with its
completeness verdict and age.

--sweep is opt-in and report-only: one disposition line per issue
(close-candidate, leave-open, no-action, undetermined) with link candidates,
judged only from durable evidence and never from titles, branches, PR checks,
reviews, or mergeability. An issue with a live PR stamped existing-pr is
always leave-open, and merged evidence with incomplete coverage is
undetermined rather than a close candidate.

Live proof against kunchenguid/firstmate, 2026-09-23, history ref
origin/main@9296f9b9, open-PR corpus 1261/1261:
- kunchenguid#4927 claimed, reproduced: PR kunchenguid#4943 and PR kunchenguid#4955 (timeline, corpus, fork,
  and the maintainer existing-pr stamp on kunchenguid#4955), plus kunchenguid#4026 named by the
  earlier stamp and still open.
- kunchenguid#3370 fixed-on-main, reproduced: commit baede47 (kunchenguid#4656), found only by
  the history check with --symbol 3370:rerecord_device, issue still open.
- kunchenguid#4412 partially-covered, reproduced: PR kunchenguid#4775 merged (landed as 9bc051f)
  and PR kunchenguid#4832 open.
- kunchenguid#4466 open, reproduced, with every check complete.
- Reporter's cases in one --sweep: kunchenguid#3966 claimed by PR kunchenguid#3977 and kunchenguid#3942
  claimed by PR kunchenguid#3978 (leave-open); kunchenguid#3928 (PR kunchenguid#3946) and kunchenguid#3926 (PR kunchenguid#3944)
  show fixed-on-main and have since been closed on the forge (no-action).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Turn-end guard blocks the same-group Stop hook that restores the watcher, so missing supervision cannot self-heal

2 participants