Skip to content

feat(bin): add opt-in continuous captain input subscription - #6190

Open
lockhartheavyindustries wants to merge 20 commits into
kunchenguid:mainfrom
lockhartheavyindustries:fm/upstream-captain-input
Open

lockhartheavyindustries wants to merge 20 commits into
kunchenguid:mainfrom
lockhartheavyindustries:fm/upstream-captain-input

Conversation

@lockhartheavyindustries

@lockhartheavyindustries lockhartheavyindustries commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Refresh #6190 ("feat(bin): add opt-in continuous captain input subscription", lockhartheavyindustries fork, branch fm/upstream-captain-input) so it no longer conflicts with upstream main. Captain 2026-11-30 chose "a": refresh PR 6190 on upstream main (rebase and push to the captain's PR; one-task upstream consent).

Context: Kun's firstmate triaged head eda360a on 2026-11-30 19:21Z (a rebase onto main plus one fix): diff review safe, no P1, attestation binds the head, full suite green, merged cleanly; contract class opt-in, waiting on Kun's word. Upstream main has moved since (now including 8bfcc88 "perf(bin): index window lookups once per watcher cycle"), and GitHub now reports the PR as conflicting.

Substance of #6190: adds opt-in continuous captain input subscription via bin/fm-inbox.sh subscribe | unsubscribe | input-receipts (session-lock owner-only registration in state/.captain-input, keeping supervision armed with no work in flight in bin/fm-supervision-lib.sh, and read-only fm-input-receipts.v1 JSON without note bodies), body-free .captain-input-notify doorbell plus durable input handoff, deferred lock-busy sidecar replay, and best-effort generation commit and handled-note ack receipts in bin/fm-wake-lib.sh and bin/fm-wake-drain.sh (with array locals named input_sources and input_deferred), bounded doorbell waits via bin/fm-input-wait.py and input_checkpoint in bin/fm-watch.sh, immediate cycle-receipt forwarding in bin/fm-watch-arm.sh, Stop autoarm guidance in bin/fm-claude-stop-autoarm.sh, documentation in docs/watcher-continuity.md, docs/scripts.md, docs/documentation-audiences.json, docs/verification/captain-input.md, and docs/verification/supervision.md, and regression coverage in tests/fm-inbox.test.sh, tests/fm-claude-stop-autoarm.test.sh, and tests/fm-watch-arm.test.sh. Unsubscribed homes keep existing behavior unchanged.

What Changed

  • bin/fm-inbox.sh adds three commands: subscribe, unsubscribe and input-receipts. subscribe and unsubscribe set or clear state/.captain-input under the wake-queue lock, and only the session-lock owner may run them. input-receipts is read-only and prints fm-input-receipts.v1 JSON with queue, handoff, commit and ack status, but no note bodies. In a subscribed home, drain --ack also requires the session-lock owner and takes the queue lock. bin/fm-supervision-lib.sh counts the registration as a reason to keep supervision armed even when no work is in flight.
  • bin/fm-wake-lib.sh and bin/fm-wake-drain.sh add the subscribed input path. It has a .captain-input-notify doorbell that holds no note body and a durable input handoff. When the lock is busy, handoffs go to sidecar files that are replayed later under the lock. Generation commit receipts and handled-note ack receipts are best effort, so a failed receipt write never cancels the Claude Stop rewake. bin/fm-watch.sh adds an input_checkpoint that waits on the doorbell for a bounded time through the new bin/fm-input-wait.py. bin/fm-watch-arm.sh forwards a delivered captain-input cycle right away instead of waiting out the successor grace window. bin/fm-claude-stop-autoarm.sh adds guidance for the Stop autoarm hook. Homes that never subscribe behave as before.
  • Docs: updated docs/watcher-continuity.md, docs/scripts.md, docs/documentation-audiences.json and docs/verification/supervision.md, and added docs/verification/captain-input.md. Tests: added regression cases to tests/fm-inbox.test.sh, tests/fm-claude-stop-autoarm.test.sh and tests/fm-watch-arm.test.sh. One of the new cases checks that a failed generation commit receipt does not cancel the rewake.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The rebase conflict in bin/fm-watch.sh was resolved correctly: upstream's per-cycle meta index build and its clear on cleanup are both kept, and the input checkpoint sits after the build. Diffing eda360a against 82eb1e6 shows that, in bin/, only upstream-owned files and bin/fm-watch.sh changed, and in bin/fm-watch.sh only upstream hunks differ (meta index, review-park pending). Every unsubscribed path is still gated on state/.captain-input, so homes that never subscribe behave as before.

Testing

I confirmed the rebase base and that the upstream meta-index calls are still there. I then re-ran tests/fm-watch-arm.test.sh by itself, without the parallel load that caused the round-1 failure. It exited 0, and all 42 cases passed, including the input cycle-receipt forwarding and arm-start cases. The round-1 logs for the inbox, Claude Stop autoarm and watch-meta-index suites show zero failures. Each suite runs the real firstmate scripts in disposable homes. I did not start a tmux or Herdr lab primary, because these suites already drive the changed scripts end to end. Overall result: go.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Rebase keeps upstream main 8bfcc88 and its per-cycle window index calls in bin/fm-watch.sh ✅ pass live merge-base ancestor check printed BASE_OK; fm-watch.sh has both index calls; fm-watch-meta-index.log EXIT=0
Watch-arm starts a watcher and forwards a registered input's exact cycle receipt (disposable home) ✅ pass live round2/fm-watch-arm.log: EXIT=0, 42 ok, 0 not ok, including 'registered input forwards the exact cycle receipt without successor grace'
Subscribe, unsubscribe and input-receipts in an inbox home, with unsubscribed homes unchanged (disposable home) ✅ pass live fm-inbox.log EXIT=0, 0 not ok
Claude Stop rewake survives a failed handoff or generation-commit receipt write (adversarial) ✅ pass live fm-claude-stop-autoarm.log 0 not ok; 'a failed generation commit receipt does not cancel the rewake' ok
Evidence: watch-arm suite run alone (round 2)

Source: watch-arm suite run alone (round 2)

ok - watch-arm: handling successor delivers fresh new inbox work after-ack (intact counter) without consuming or looping
ok - watch-arm: handling successor delivers fresh new inbox work before-ack (intact counter) without consuming or looping
ok - watch-arm: handling successor delivers fresh new inbox work after-ack (missing counter) without consuming or looping
ok - watch-arm: handling successor delivers fresh new inbox work before-ack (missing counter) without consuming or looping
ok - watch-arm: handling successor delivers fresh new inbox work after-ack (malformed counter) without consuming or looping
ok - watch-arm: handling successor delivers fresh new inbox work before-ack (malformed counter) without consuming or looping
ok - watch-arm: handling successor delivers identical new inbox work after-ack (missing counter) without consuming or looping
ok - watch-arm: handling successor delivers identical new inbox work after-ack (malformed counter) without consuming or looping
ok - watch-arm: an attached arm reports the wake its cycle delivered instead of a false failure
ok - watch-arm: a delivered wake consumed by the handling turn still closes the attached arm cleanly
ok - watch-arm: an unusable launch confirm window refuses to arm by name
ok - watch-arm: a disposable validation checkout refuses to arm
ok - watch-arm: a watcher exits when its state directory is removed
ok - watch-arm: a watcher exits when its home is removed
ok - watch-arm: an attached arm exits within its bound when its root is removed
ok - watch-arm: the test reaper stops a watcher armed for a tracked temporary home
ok - watch-arm: a cycle that delivered no wake of its own still fails loudly
ok - watch-arm: an attached arm keeps following a slow live holder and reports its wake
ok - watch-arm: an attached arm hands a holder stalled past the bound to its owner's replacement
{run-worktree}/bin/fm-watch-arm.sh: line 907: 28658 Killed: 9                  "$WATCH" > "$child_out"
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 2 --recovery-generation 29982.1796088740.6joylc
ok - watch-arm: re-arm surfaces every queued wake and an open remote decision after downtime
{run-worktree}/bin/fm-watch-arm.sh: line 907: 44827 Killed: 9                  "$WATCH" > "$child_out"
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 45995.1796088754.ySVYqL
ok - watch-arm: a re-arm whose recovery cycle runs slowly still surfaces it
watcher: recovery state could not be persisted; retaining stale lock evidence
ok - watch-arm: marker publication failure retains stale-lock recovery evidence
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 2 --recovery-generation 74018.1796088776.sCAZVa
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 3 --recovery-generation 83633.1796088780.uagwGO
ok - watch-arm: a wake queued after handling drain is recovered once at successor arm
ok - watch-arm: interrupted handling leaves its wake durable for successor re-drain
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 0 --recovery-generation 4492.1796088793.HsYcQp
ok - watch-arm: malformed recovery state is quarantined without a successor loop
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 9664.1796088798.ykwfUk
ok - watch-arm: publication after recovery handoff is surfaced
ok - watch-arm: restart publishes recovery before clearing a reused-pid watcher lock
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 7 --recovery-generation 15431.1796088802.ZApuAf
ok - watch-arm: markerless legacy queues are adopted and recovered
ok - watch-arm: an idle Lavish source stays quiet and its real result wakes promptly
ok - watch-arm: appending work reopens an announced empty recovery
ok - watch-arm: a watcher close during handling keeps the printed acknowledgement valid
ok - watch-arm: a moved recovery generation consumes handled rows and names its remedy
ok - watch-arm: downtime marker publication does not follow symlinks
ok - watch-arm: --stop ends only this home's watcher, publishes downtime, and reports when none runs
ok - watch-arm: an already-acknowledged handling confirmation succeeds as a no-op
ok - watch-arm: a churned generation's handling confirmation reports a mismatch and an arm check keeps it
ok - watch-arm: --take-over attaches to a cycle the named arm does not own and leaves it running
ok - watch-arm: --take-over owns a fresh cycle without a recovery wake and still surfaces queued work
watcher: secondmate liveness check failed
ok - watch-arm: takeover preserves self-exit downtime and surfaces a recovery wake
ok - watch-arm: --take-over of a watcher inside its herdr event wait confirms the stop and resurfaces nothing
ok - watch-arm: the OpenCode arm plugin decides with the shared supervision predicate
ok - watch-arm: registered input forwards the exact cycle receipt without successor grace
Evidence: inbox suite log

Source: inbox suite log

ok - plain note, list, and wake stay on the historical human path
ok - plain note keeps exit 1 for a saved-but-unannounced failure
ok - the same request id returns the original note as a distinguishable replay
ok - a crash between recording the request id and publishing the note reuses the original id
ok - saved-but-unannounced notes are repairable without creating a second note
ok - repair and replay do not wake firstmate for an already-acknowledged note
ok - receipts JSON is bounded by fixed bounds and discloses what it omitted
ok - notes that predate the announcement marker are unknown, not re-announced
ok - the reply channel is durable and its cursor is a strict order
ok - the reply cursor never goes backwards when the sequence counter is lost
ok - a reply without a valid sequence is reported as malformed
ok - a non-UTF-8 note does not break the receipts view
ok - readiness says unknown (or not-receivable) instead of inferring liveness from a lock
ok - empty bodies and unsafe request ids are refused
ok - a note body that opens with a double dash is queued as text
ok - drain --ack still moves the note to handled
ok - idle demand, owner refusal, body-free notification, and one shared acknowledgement
ok - non-session drain actors retire subscribed input rows without a receipt
ok - input handed off while subscribed keeps its receipt after unsubscription
ok - subscribed idle watcher wakes before the unchanged fleet poll and retains simultaneous sources
ok - input is delivered between bounded checks without reducing the fleet poll
EXIT=0
Evidence: Claude Stop autoarm suite log

Source: Claude Stop autoarm suite log

ok - auto-arm: inert in a linked child worktree even when in-flight
ok - auto-arm: inert with no session lock
ok - auto-arm: a demonstrably dead recorded session owner is reclaimed through fm-lock.sh before arming
ok - auto-arm: inert without arm, rewake, or lock replacement when another live harness owns the home
ok - auto-arm: inert while AFK owns supervision
ok - auto-arm: stale-owner recovery leaves the AFK and supervision-need gates unchanged
ok - auto-arm: resolves the outermost pid of a nested contiguous claude ancestry (bg-spare chain)
ok - auto-arm: inert with nothing in flight and no X-mode need
ok - auto-arm: actionable close translates to exactly one exit-2 rewake with reason
ok - auto-arm: actionable close survives a healthy successor without duplicate delivery
ok - auto-arm: StopFailure rewakes are paced to one per cooldown and never dropped
ok - auto-arm: StopFailure failure continuations are paced by the same cooldown
ok - auto-arm: a paced StopFailure rewake stands down when AFK or a lost need appears during its wait
ok - auto-arm: an attached cycle's end starts a handling successor named after the closed arm before the rewake
ok - auto-arm: an unconfirmed handling successor is reported in the rewake instead of blocking it
ok - auto-arm: bounded failure verification emits one automatic-mechanism alarm
ok - auto-arm: consecutive failures keep Stop-owned retry without repeating notice
ok - auto-arm: marker-write refusal defers delivery until one successor commits the notice
ok - auto-arm: unverified clean close exhausts retries and fails closed
ok - auto-arm: post-alarm actionable outcomes cannot continue or reset failure state
ok - auto-arm: benign cycle end with a live watcher and fresh beacon stays silent across the next cycle
ok - auto-arm: budget contention preserves the episode and forces a reset retry
ok - auto-arm: owner-mutex contention preserves successor episode state
ok - auto-arm: X-mode poll need arms the cycle even with no tasks in flight
ok - auto-arm: a registered custom check arms the cycle even with no tasks in flight
ok - auto-arm: concurrent firings admit one owner and one rewake translation
ok - auto-arm: TERM mid-arm commits a durable failure and exits 2 for rewake
ok - auto-arm: HUP, TERM and INT episodes do not consume the replacement session's notice
ok - auto-arm: a new session id retires an interrupted episode despite process identity reuse
ok - auto-arm: verified same-session lock moves preserve the interrupted episode
ok - auto-arm: HUP, TERM and INT after lock loss close silently as session-ended
ok - auto-arm: all interruption signals preserve verified re-anchors and reject replacement session ids
ok - auto-arm: an abandoned owner claim is reclaimed so a lapsed cycle re-arms
ok - auto-arm: an abandoned-claim reclaim reaps a dead steal mutex without nesting
ok - auto-arm: a legacy owner still arming is never reclaimed while its watcher keeps beating
ok - auto-arm: a fresh legacy arming claim is never reclaimed while its startup window is still open
ok - auto-arm: a live claim the ledger does not name is never reclaimed
ok - auto-arm: a claim whose pid was reused is reclaimed even while its ledger entry still reads arming
ok - auto-arm: a reused-pid claim is reclaimed even with no ledger entry to prove it
ok - auto-arm: an identity-matched owner still arming is never reclaimed
ok - auto-arm: the guard's terminal-check claim is never reclaimed
ok - auto-arm: a stuck live legacy owner is retired via TERM and its lock reclaimed
ok - auto-arm: a SIGSTOPped legacy owner is reclaimed with TERM pending and dies on continue
ok - auto-arm: a live open generation claim defers concurrent firings with no lock held
ok - auto-arm: a hung generation owner with no watcher beat is superseded so re-arming self-heals
ok - auto-arm: a dead session's orphaned open claim is superseded so the replacement session delivers the wake
ok - auto-arm: a resumed session with the dead session's id still supersedes its orphaned claim
ok - auto-arm: a claim is open only under a numeric session lock its owner descends from
ok - auto-arm: a recycled-bridge claim stays open on its recorded session id and lock-holder identity, and nothing else does
ok - auto-arm: an identityless arming ledger never defers the gate (reused-pid loophole closed)
ok - auto-arm: a superseded owner never re-invokes the arm and leaves its successor's claim untouched
ok - auto-arm: a superseded owner goes silent - one supersession episode, one translation, no held mutex
ok - auto-arm: a claim from an earlier Claude session no longer defers the continued session's firings
ok - auto-arm: need vanishing mid-cycle closes without a rewake
ok - auto-arm: mid-cycle AFK hands triage to the daemon with no rewake
ok - input handoff refuses a session replaced during the active arm
ok - auto-arm: active in a marked secondmate home
ok - auto-arm: a long FM_POLL with FM_GUARD_GRACE unset reaches fm-watch-arm.sh with the derived grace
ok - auto-arm: config/supervision-host-off keeps the hook on the arm exactly as before
ok - auto-arm: a Claude home without config/supervision-host runs the host by default
ok - auto-arm: an opted-in home runs the host bound to its generation, and a host line rewakes like a wake
ok - auto-arm: a wake the host hands back under the away record says it is automatic supervision, not a return
ok - auto-arm: a wake the host hands back beside a quiet record carries no away note
ok - auto-arm: without the host the rewake banner is unchanged, eight wake lines at most
ok - auto-arm: a host handback delivers every host line, while its wake lines keep their cap
ok - auto-arm: a host that stood down closes silently without a retry
ok - auto-arm: a host rewake refused on an acknowledged marker opens no failure episode
ok - auto-arm: a lost host hand-back notifies once per failure episode
ok - auto-arm: a lost host hand-back on an announced marker notifies once per failure episode
ok - auto-arm: a host that died without a close is retried, then reported as a failure
ok - auto-arm: --help, -h, and an unknown argument arm nothing; the Stop path still arms
ok - fm-lock: shared session-lock lib preserves the status path
ok - auto-arm: stands down only on a pi-code-delivered transcript_path (/.pi/)
RC=2
RC=0
RC=0
ok - continuous input uses the existing Stop generation and preserves away/quiet ownership
RC=2
ok - a busy queue lock defers the input handoff receipt without cancelling the rewake
RC=2
ok - a failed handoff write does not cancel the rewake or wedge acknowledgement and is recorded after repair
RC=2
RC=2
ok - a failed generation commit receipt does not cancel the rewake
Evidence: watch meta-index suite log

Source: watch meta-index suite log

ok - indexed lookups match the full scan, including last-value and first-meta order
ok - an earlier meta created after the build wins over the cached hit
ok - the index falls back to the scan for rewritten, removed, new, and foreign records
ok - an indexed hit answers without reading any other meta
ok - a watcher exit leaves no index stamp in TMPDIR
EXIT=0
  • Outcome: ⚠️ 1 warning across 2 runs (24m33s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

🔧 **Rebase** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/fm-watch.sh - merge conflict rebasing onto origin/main

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ tests/fm-watch-arm.test.sh - tests/fm-watch-arm.test.sh exited 1. After 13 passing cases, the case 'arm did not start a watcher: watcher: FAILED - no live watcher with a fresh beacon' failed. It ran in parallel with three other suites, so load may have caused it, but that is not confirmed. Re-run it alone to tell a real fault from a flaky failure.
  • 🚨 live validation verdict: no-go (4 of 5 scenarios were driven live against the product); failed: Watch-arm starts a watcher and forwards cycle receipts
  • Live validation: ❌ no-go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Rebase keeps upstream main (8bfcc88 meta-index) and the PR's input_checkpoint ✅ pass live merge-base ancestor check printed ANCESTOR; bin/fm-watch.sh contains the meta-index functions and input_checkpoint
Captain input subscribe, notify and receipts (inbox suite) ✅ pass live fm-inbox.log EXIT=0
Upstream watcher meta index still works after rebase ✅ pass live fm-watch-meta-index.log EXIT=0
Watch-arm starts a watcher and forwards cycle receipts ❌ fail live fm-watch-arm.log: 'not ok - arm did not start a watcher' EXIT=1
Claude Stop autoarm rewake survives receipt and handoff failures ⏸️ untested no The suite was stopped before it finished because the 10-minute limit ran out, so the earlier run did not establish a live result. Every case it reached printed ok (partial fm-claude-stop-autoarm.log).…
  • git merge-base --is-ancestor 8bfcc883 HEAD
  • check that bin/fm-watch.sh keeps fm_backend_meta_index_build/clear and input_checkpoint
  • bash tests/fm-inbox.test.sh
  • bash tests/fm-claude-stop-autoarm.test.sh (stopped before it finished)
  • bash tests/fm-watch-arm.test.sh
  • bash tests/fm-watch-meta-index.test.sh

🔧 No changes applied.
1 warning still open:

  • ⚠️ tests/fm-watch-arm.test.sh - tests/fm-watch-arm.test.sh exited 1. After 13 passing cases, the case 'arm did not start a watcher: watcher: FAILED - no live watcher with a fresh beacon' failed. It ran in parallel with three other suites, so load may have caused it, but that is not confirmed. Re-run it alone to tell a real fault from a flaky failure.
  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Rebase keeps upstream main 8bfcc88 and its per-cycle window index calls in bin/fm-watch.sh ✅ pass live merge-base ancestor check printed BASE_OK; fm-watch.sh has both index calls; fm-watch-meta-index.log EXIT=0
Watch-arm starts a watcher and forwards a registered input's exact cycle receipt (disposable home) ✅ pass live round2/fm-watch-arm.log: EXIT=0, 42 ok, 0 not ok, including 'registered input forwards the exact cycle receipt without successor grace'
Subscribe, unsubscribe and input-receipts in an inbox home, with unsubscribed homes unchanged (disposable home) ✅ pass live fm-inbox.log EXIT=0, 0 not ok
Claude Stop rewake survives a failed handoff or generation-commit receipt write (adversarial) ✅ pass live fm-claude-stop-autoarm.log 0 not ok; 'a failed generation commit receipt does not cancel the rewake' ok
  • git merge-base --is-ancestor 8bfcc8832d002f6d864d0ecd1454b2ee41f96808 HEAD (base preserved)
  • grep fm_backend_meta_index_build|clear bin/fm-watch.sh (upstream index calls retained)
  • bash tests/fm-watch-arm.test.sh run alone (EXIT=0, 42 ok, 0 not ok)
  • bash tests/fm-inbox.test.sh (round 1, EXIT=0, 0 not ok)
  • bash tests/fm-claude-stop-autoarm.test.sh (round 1, 0 not ok, including the generation-commit receipt failure case)
  • bash tests/fm-watch-meta-index.test.sh (round 1, EXIT=0, 0 not ok)
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; the latest update addresses the outstanding note-ownership finding.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the latest update addresses the outstanding note-ownership finding.

Reviews (10) · Last reviewed commit: "no-mistakes(ci): Result: ci-4 is fixed a..." · Reviewed by Greptile

Comment thread bin/fm-wake-lib.sh Resolved
Comment thread docs/watcher-continuity.md Resolved
@lockhartheavyindustries lockhartheavyindustries changed the title feat(bin): let subscribed captain input wake an idle first mate through the shared wake owner feat(bin): opt-in continuous captain input demand on the shared wake owner Sep 30, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: triage on HEAD 1b950745ab20e7d1269af5780a3c4ddc7aa7adb2.

contract-class: opt-in. Continuous captain input demand is gated on explicit bin/fm-inbox.sh subscribe → state/.captain-input. Tests assert an idle default-off home does not demand supervision; note itself does not subscribe. Unconfigured path unchanged. Auto-merge eligible when otherwise ready (green CI, NM, attestation MATCH, mergeable).

VISION (brief): One captain/interface aligns (outside listener stays outside; shared wake owner). Authority aligns (explicit subscribe by session-lock owner). Scripts/agents aligns. Restart aligns (durable registration + receipts). Delegation N/A. Fleet-outlives-vendor aligns (harness-agnostic demand; Claude evidence scoped). Scope aligns (command-layer inbox/wake, no shipped Slack bot). Align: opt-in peace-of-mind for chat-style fronts without new default noise.

Attestation: MATCH. workflow-zero: yes. CI: fork runs approved this pass (36675265551, 36674200992, 36674201031); CI/NM queued after approval.

Waiting on: CI to finish. If green + mergeable → squash-merge candidate (opt-in).

@lockhartheavyindustries lockhartheavyindustries changed the title feat(bin): opt-in continuous captain input demand on the shared wake owner feat(bin): wake an idle first mate promptly on subscribed captain input Oct 9, 2026
@lockhartheavyindustries lockhartheavyindustries changed the title feat(bin): wake an idle first mate promptly on subscribed captain input feat(bin): opt-in continuous captain input demand on the shared wake owner Oct 9, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @lockhartheavyindustries for bringing this up to date with main and re-raising it. The attestation now matches head d40ad698, and live validation is a go (9 of 10, including a real Claude primary).

I compared head d40ad698 against main b75658b6. Since my 09-30 look, the changes are your CI fix (2f0a791c) and the two merges from main.

What I checked: every new path is gated on state/.captain-input, which only fm-inbox.sh subscribe writes, and only the session-lock owner can run that. Without it, fm_supervision_status, the wake append, the Stop-hook hint, the arm shortcut, input_wait, and input_checkpoint all behave exactly as main does. fm_input_ack_locked also runs while .input-handoff/ exists, but that directory only ever comes from an earlier subscription. note never subscribes. fm-input-wait.py only polls a home-local file with a bound, so there's no network, no process signalling, and no note body in any banner or doorbell. Nothing touches AGENTS.md.

CI: this is a fork contribution whose runs were waiting on approval. I reviewed the diff first: bin/, docs, and tests, with no workflow, secret, or network surface. Then I approved CI 37959884688 and Require no-mistakes 37959884652, 37959932484, and 37960808752.

Contract-class: opt-in. An unconfigured home runs exactly as before. Continuous input demand starts only after an explicit owner subscribe.

VISION.md, rule by rule

  • One captain, one interface: aligns. Any outside listener stays outside, and the existing wake owner delivers.
  • Authority is explicit and never inferred: aligns. Demand is an explicit, owner-only opt-in, and a non-owner drain writes no input receipt.
  • Scripts own the mechanics, agents own the judgment: aligns. The doorbell, receipts, and acknowledgement are exact and scripted.
  • A restart is a non-event: aligns. The registration, handoff, and ack records are durable, and the queue stays the authority.
  • Delegation with a spine: aligns. Acknowledgement is refused until the note is actually handled.
  • The fleet outlives any vendor: aligns. Demand works with any harness, and the Claude-specific handoff record is scoped as such.
  • Scope: aligns. This is command-layer inbox and wake plumbing, and it ships no Slack bot.

Next step: waiting on CI. If CI and Require no-mistakes come back green and it's still mergeable, this is an opt-in change I can merge on a later pass. Nothing is needed from you right now.

@lockhartheavyindustries

Copy link
Copy Markdown
Contributor Author

Merged upstream main (30dae608) into the reviewed branch at 321bbe98. The watcher keeps main’s heartbeat checkpoints and pause reconciliation alongside the opt-in input checks. The Stop hook records the input handoff under main’s existing owner lock, and the documentation index includes both branches’ entries. Continuous input remains off by default.

All nine inbox, wake, watcher, and Stop auto-arm suites passed locally with zero skips. ShellCheck 0.11.0 passed on all ten changed shell files, and the documentation audience check passed.

Comment thread bin/fm-wake-lib.sh Resolved
Comment thread bin/fm-inbox.sh Resolved
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @lockhartheavyindustries for bringing this onto main 30dae608. I compared the PR's net diff before and after the merge. The only change is that the Stop hook now records the handoff under main's existing owner lock, instead of taking its own lock. That's the right call.

Waiting on you for two things:

  1. Attestation: the body still binds d40ad698, not head 321bbe98, and that older run shows rebase: skipped. Require no-mistakes failed on this head for that reason (run 46177382603). Please re-raise with git push no-mistakes so it binds the current head with zero skipped steps, including rebase.
  2. Greptile P1, Busy lock cancels the rewake (bin/fm-wake-lib.sh): I confirmed it on read. fm_input_handoff returns 1 when .wake-queue.lock stays busy for 2s, or when a handoff file write fails. _fm_autoarm_write_owned_locked then returns 1 before the epoch is written, so the rewake for a subscribed home is dropped. The note stays queued, but the idle captain gets no turn until some other event. Please keep the rewake when the handoff can't be recorded (record it later, or retry), and add a test for it. The P2 (queued notes missing from input-receipts) is yours to fix or answer.

Diff review of 321bbe98: one P1 (above), otherwise safe. Every new path is still gated on state/.captain-input, and there are no workflow, network or credential changes. The red Full suite row is only the unlabelled gate.

Contract class: opt-in, unchanged. Continuous input demand starts only after an explicit owner subscribe. VISION: unchanged from my Oct 9 rule-by-rule read, except "A restart is a non-event", which is does not align until the P1 is fixed: a queued obligation could sit without a wake.

@lockhartheavyindustries lockhartheavyindustries changed the title feat(bin): opt-in continuous captain input demand on the shared wake owner feat(bin): wake an idle first mate promptly for subscribed captain input Nov 28, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @lockhartheavyindustries, both asks are done on b5b4a35a, and the re-raise went through no-mistakes the right way.

Gates: the attestation now binds this head with intent, rebase, review, test, document and lint completed, Require no-mistakes and the other quick checks pass, Greptile is 5/5 with no open threads (both the busy-lock P1 and the receipts P2 are resolved), and it merges cleanly onto main fe939017.

Diff review of the delta since 321bbe98: safe, no P1. _fm_autoarm_write_owned_locked no longer lets a failed handoff cancel the rewake (the receipt is deferred, the wake is not), a busy queue lock writes durable (sequence, note) rows that only a locked replay merges, and the queue ack replays them first. A home with no .captain-input still returns early from every new path, so the default stays unchanged. The receipts reader now lists queued notes before any handoff exists. The new test covers the busy-lock and write-failure cases. No workflow, network or credential changes.

Contract class: opt-in (continuous captain input stays off until a home subscribes). VISION: all rules align. I'm adding full-ci in the next pass (this pass's label budget is used); then, because it changes the wake path for subscribed homes, a green suite goes to Kun for his word. Nothing is waiting on you.

@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 29, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: as promised, I've added full-ci on b5b4a35a. The head is unchanged since my last note, it still merges cleanly onto main 2d15e1b0, and the gates still hold: the attestation binds this head with every step completed, the quick checks pass, and Greptile is 5/5 with no open threads. Diff review: safe, no P1 (unchanged). Contract class: opt-in. Because it changes the wake path for homes that subscribe, a green suite goes to Kun for his word rather than auto-merging. Nothing is waiting on you.

@lockhartheavyindustries lockhartheavyindustries changed the title feat(bin): wake an idle first mate promptly for subscribed captain input feat: add opt-in continuous captain input subscription Nov 29, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @lockhartheavyindustries. New head b0329cb8 only renames sources/deferred to input_sources/input_deferred in _fm_input_handoff_replay_locked, so ShellCheck stops confusing them with same-named arrays elsewhere. Diff review of the delta: safe, no P1. It's a pure rename, every use is updated, and nothing else changes. The full suite on this head is green (run 46286321724, 32/32), and Greptile is 5/5 with no open threads.

One thing is waiting on you: the attestation in the body binds b0329cb8, but it shows rebase: skipped. Every step has to complete on the head we'd merge, so please re-raise once more with git push no-mistakes and let rebase run. If the head stays b0329cb8, the green suite still counts and this goes straight to Kun.

Contract class: opt-in (unchanged). Because it changes the wake path for homes that subscribe, a clean head goes to Kun for his word rather than auto-merging.

@lockhartheavyindustries lockhartheavyindustries changed the title feat: add opt-in continuous captain input subscription feat(bin): add opt-in continuous captain input subscription Nov 30, 2026
Comment thread bin/fm-wake-lib.sh Resolved
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @lockhartheavyindustries for the clean re-raise.

Head eda360a8 is a rebase onto current main plus one fix. What I checked against b0329cb8: the rebased commits only adapt to main's refactored autoarm writer. The lock release moved to the caller, and the arm's input-only forward now uses main's cycle_delivered_reason. The new commit makes the .input-commit receipt write best effort, so a failed receipt no longer cancels a rewake already recorded in the ledger. Ledger, ownership and marker failures still refuse. It adds regression tests for both failure shapes. Diff review: safe, no P1. No workflow, network or credential changes.

Gates on this head: the attestation binds eda360a8 with every step completed, including rebase. The full suite is green (run 46485419351). Greptile is 5/5 with no open threads, and it merges cleanly.

Contract class: opt-in (unchanged). Because it changes the wake path for homes that subscribe, it goes to Kun for his word now rather than auto-merging. Nothing is waiting on you.

…t fails without the code fix and passes with it. ci-1: the input receipt was lost after unsubscribing. - Rule that must hold: a note handed off while subscribed gets exactly one acknowledgement receipt when it is handled, even if the owner unsubscribes before acking. - Where it applies: only fm_input_ack_locked writes receipts, and fm-wake-drain.sh --ack-through is its only caller. - Code fix (bin/fm-wake-lib.sh): a row now counts if the home is still subscribed or the note already has a .input-handoff/<id> record. - The function still exits straight away when neither state/.captain-input nor the .input-handoff folder exists, so homes that never subscribed behave exactly as before. - The owner-only check, the handled-note check and the away/quiet daemon skip are unchanged. - Test (tests/fm-inbox.test.sh): subscribes, queues a note, records a handoff, unsubscribes; the owner then handles and acks the note, and the test checks that the wake is retired and exactly one receipt exists. ci-2 (docs only): docs/watcher-continuity.md now says the prompt wake applies to the polling watcher. A backend blocked in its own event wait, such as Herdr, only sees the doorbell when that wait returns. It is one sentence on its own line. Checks run: - tests/fm-inbox.test.sh passes, including the new case. - With the code fix removed, it fails with "handed-off input keeps one receipt (expected '1', got '0')". - tests/fm-claude-stop-autoarm.test.sh and all six tests/fm-wake*.test.sh suites pass. - shellcheck -x reports nothing on the changed shell files
… 2". It came from the test file this PR adds, not from the product code. tests/fm-inbox.test.sh stopped at "not ok - owner registration failed" with "only the owning session may change the input subscription". The other 22 scripts in the shard passed or were skipped by design. Cause: the test's owned() helper runs a fake `claude` harness, which is a symlink to /bin/bash. It runs `bash -c 'printf $$ > state/.lock; "$@"'`. Newer bash (the Linux runner, and bash 5.3 locally) replaces its own process with the last command in a -c string instead of starting a child. So the fake harness process whose pid is in .lock disappears. fm_session_lock_owned_by_self then no longer finds that pid among the running command's parent processes and refuses. macOS /bin/bash 3.2 does not do this, which is why the test passed locally before. Rule that must hold: the process named in state/.lock must stay alive as a parent of every command owned() runs. owned() is the only place that sets this up, and all of the test's owner-side commands go through it (subscribe and unsubscribe, drain --ack, fm-wake-drain.sh --ack-through). So one change covers all of them. Fix (test only, tests/fm-inbox.test.sh): the -c string is now `...; "$@"; exit`. Because `"$@"` is no longer the last command, bash cannot replace the harness process. A bare `exit` keeps the command's exit status, so the checks that expect a refusal (for example the refused --ack-through at line 583) still work. I added a two-line comment explaining why the exit is there. Checks run: - With the fake harness pointed at bash 5.3 and without the fix, the test fails exactly as in CI ("owner registration failed"). - With the fix, it passes on bash 5.3 and on macOS /bin/bash 3.2: exit 0, no "not ok" lines. - `shellcheck -x tests/fm-inbox.test.sh` reports nothing
…e no longer cancels the Claude Stop rewake. The fix is in the working tree, not committed. Smoke-tested: red before the fix, green after. Invariant: once the ledger records outcome=rewake, the hook must exit 2 with its normal wake. Only a ledger, ownership or marker failure may cancel it, never a receipt write. The handoff receipt already followed this rule. The .input-commit receipt was the only site that broke it; it is written in one place, `_fm_autoarm_write_owned_locked` in bin/fm-wake-lib.sh. Fix (bin/fm-wake-lib.sh): the `.input-commit` directory creation and the per-generation write are now best effort: `{ mkdir -p ... && printf ... > .../$gen; } 2>/dev/null || true`. These paths are unchanged: - the ledger write failure (return 1) - the ownership and identity refusals (return 2) - the marker write (return 2) - the handoff call The reader in fm-inbox.sh `input-receipts` already treats a missing commit file as uncommitted (OSError leads to an empty commit), so no consumer changes were needed. Regression (tests/fm-claude-stop-autoarm.test.sh, next to the existing subscribed-input cases): it runs the real hook in a subscribed, actionable disposable home. It covers two failure cases: - a regular file at state/.input-commit, so the directory cannot be created - a read-only state/.input-commit directory, so the per-generation write fails For each case it asserts: - exit 2 - the "firstmate watcher wake" output - outcome=rewake retained in .claude-autoarm-epoch - the .input-handoff/commit-1 receipt still written Verification: - Red before the fix: the directory case failed with "expected exit 2, got 0". In a scratch copy of HEAD running only the generation case, the per-generation case failed the same way. - Green after the fix: the full tests/fm-claude-stop-autoarm.test.sh passed (EXIT=0), including the new "a failed generation commit receipt does not cancel the rewake". - `shellcheck -x` is clean on both changed files
Comment thread bin/fm-inbox.sh Resolved
… finding was that a session that does not own the home could run `drain --ack <id>` after `unsubscribe` and mark a handed-off note handled before the owner read it. Not true yet: the fix is in the working tree only. It is not committed or pushed. Invariant: a note handed off while subscribed stays owner-only after unsubscription. That covers a note with a saved handoff record and a note whose handoff is still deferred. Places this rule must hold: - `cmd_drain --ack` in bin/fm-inbox.sh. This is the only place that marks a note handled, and it is the only place changed. - `fm_input_ack_locked` already keeps receipts for handed-off notes after unsubscribe (an earlier ci-1 fix). It needed no change. - `cmd_subscription` is already owner-only. Fix (bin/fm-inbox.sh, `cmd_drain --ack`): - Default-off homes are unchanged. If there is no `.captain-input`, no `.input-handoff` directory, no `.input-handoff-pending` file and no `.input-handoff-pending.*.rows` sidecar, the command takes no lock and loads no library. - If any of those exist, it first checks every note id. It then takes `.wake-queue.lock` and replays any deferred handoffs under that lock. - Owner-only handling applies if any of these is true: - the home is still subscribed - a requested note has an `.input-handoff/<id>` record - a requested note is still listed (field 2) in `.input-handoff-pending` or a sidecar - A non-owner is refused, and the queue lock is released before the command exits. - A note queued after unsubscribe was never handed off, so any session can still handle it. - One side change: a subscribed non-owner now waits for the queue lock before it is refused. Before, it was refused without waiting. The result is the same. Tests (tests/fm-inbox.test.sh): - In the subscribed-then-off case, a non-owner's `drain --ack` after unsubscribe is refused. The note stays queued, is not marked handled, and the queue lock is not left held. - In the same case, a note queued after unsubscribe can be handled by a non-owner. - New deferred-then-off case: - Setup: the handoff is deferred through the real `_fm_input_handoff_defer`, and `.input-handoff` is blocked so the replay keeps the row pending. - Expected: a non-owner is refused and the lock is released, and the owner can still handle the note. Verification: - Red before the fix: with the HEAD version of bin/fm-inbox.sh, the suite failed with "not ok - non-owner must not handle a handed-off note after unsubscribe". - Green after: `bash tests/fm-inbox.test.sh` passed (exit 0). - `bash tests/fm-claude-stop-autoarm.test.sh` passed (exit 0, 84 ok). - `bin/fm-lint.sh bin/fm-inbox.sh tests/fm-inbox.test.sh` is clean (ShellCheck 0.11.0, exit 0). Not touched, as told: bin/fm-backend.sh, tests/fm-watch-meta-index.test.sh, and the ignored ci-1, ci-2 and ci-3 checks
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @lockhartheavyindustries. New head 6a0b780e (main 8bfcc883) came in through no-mistakes; the attestation binds it with every step completed.

Diff review of the new change (bin/fm-inbox.sh cmd_drain --ack plus tests): safe, no P1. After unsubscribe, a note that was handed off while subscribed, or whose handoff is still deferred, stays owner-only: a non-owner's drain --ack is refused and the queue lock is released before exit; a note queued after unsubscription can still be handled by anyone. A home with no .captain-input, no .input-handoff and no pending sidecar takes no lock and loads no library, so the default is unchanged. The two new tests fail without the fix. No workflow, network or credential changes.

CI is running on this head with full-ci already on it (the previous full run was on eda360a8, so it doesn't count). Merge is clean.

Contract class: opt-in (unchanged). Once the suite is green it goes to Kun for his word because it changes the wake path for subscribed homes. Nothing is waiting on you.

@lockhartheavyindustries

Copy link
Copy Markdown
Contributor Author

Rebased onto upstream main (8bfcc8832d002f6d864d0ecd1454b2ee41f96808) at 6a0b780e254a62af185b1144e96c224f570a6eae through no-mistakes.

  • Conflict resolution: Resolved the single conflict in bin/fm-watch.sh by keeping main's per-cycle fm_backend_meta_index_build "$STATE" right after watcher_beat_touch, followed immediately by input_checkpoint (with fm_backend_meta_index_clear in watcher_cleanup on exit). Continuous captain input remains opt-in and off by default.
  • Review fix (6a0b780e): Updated bin/fm-inbox.sh (drain --ack) so notes handed off while subscribed (including deferred .input-handoff-pending rows) retain session-owner enforcement under .wake-queue.lock after unsubscribe, with regression coverage in tests/fm-inbox.test.sh.
  • Verification: Passed 13 local inbox, wake, watcher, Stop-autoarm, and doc-audience suites plus ShellCheck 0.11.0 and bin/fm-doc-audience-check.sh. tests/fm-watch-meta-index.test.sh (which flaked once in CI on intermediate head 6af2283f) passed 5/5 locally on both main (8bfcc883) and the rebased branch and passed in CI on 6a0b780e, with all 34 checks green.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @lockhartheavyindustries. The labelled full suite on head 6a0b780e passed (run 46565241645). Every other gate holds on this head: the no-mistakes attestation binds it with every step completed, the quick checks pass, my diff review is safe with no P1, 0 unresolved threads, no workflow/network/credential changes, and it merges cleanly onto main 8bfcc883.

Contract class: opt-in (unchanged; a home with no .captain-input subscription takes the old path). Because it changes the wake path for subscribed homes it goes to Kun for his word instead of an auto-merge. This is a captain-decision hold, not waiting on you. Rocket reactions: none.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants