Repository navigation
feat(bin): opt-in continuous captain input demand on the shared wake owner - #6190
lockhartheavyindustries wants to merge 10 commits into
Conversation
… Slack desk example
|
…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
|
Speaking as Kun's firstmate: triage on HEAD contract-class: opt-in. Continuous captain input demand is gated on explicit 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 ( Waiting on: CI to finish. If green + mergeable → squash-merge candidate (opt-in). |
… 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
…nput # Conflicts: # bin/fm-watch-arm.sh # tests/fm-watch-arm.test.sh
…rtheavyindustries/firstmate into fm/upstream-captain-input
|
Speaking as Kun's firstmate: thanks @lockhartheavyindustries for bringing this up to date with main and re-raising it. The attestation now matches head I compared head What I checked: every new path is gated on CI: this is a fork contribution whose runs were waiting on approval. I reviewed the diff first: Contract-class: opt-in. An unconfigured home runs exactly as before. Continuous input demand starts only after an explicit owner VISION.md, rule by rule
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. |
Intent
Let an outside channel mark captain input as waiting, so an idle first mate wakes promptly to a new inbox note instead of on the next routine poll.
Today
bin/fm-inbox.sh noterecords a durable note and appends onecheckwake, but with no work in flight supervision may not be armed at all, and an armed idle watcher only sees the note on its next poll.That is fine for an occasional note, but it makes a chat-style front end to Firstmate feel unresponsive.
The motivating example is a Slack desk: a small listener, running outside Firstmate as a dedicated bot, receives the captain's messages from a private Slack channel, records each one with
fm-inbox.sh note --request-id <message id>(text, source thread, and local paths to downloaded attachments), and the first mate replies in the same Slack thread through that bot, posting new captain-facing asks top-level in the channel.Before this change such a listener had to run its own waiter and acknowledgement path next to the watcher, which competed with the shared wake owner.
What Changed
bin/fm-inbox.sh subscribe | unsubscribelets only the session-lock owner register or clear continuous input demand for the home, recorded asstate/.captain-input.bin/fm-inbox.sh input-receiptsprints a body-free, read-only JSON view of each registered note's queue sequence, committed Claude handoff generation, and post-handling acknowledgement.bin/fm-supervision-lib.shcounts the registration as needed supervision, so the watcher stays armed with no tasks in flight.bin/fm-wake-lib.shwrites a body-free doorbell after an inboxcheckwake commits, gives registered notes a banner with no user text, and records handoff and acknowledgement receipts under the existing queue lock, waiting briefly for that lock rather than dropping a Stop rewake when it is momentarily busy.bin/fm-watch.shchecks the doorbell between scan units and during otherwise blind idle sleeps, using the newbin/fm-input-wait.pybounded wait; in-progress bounded checks and backend-native event waits keep their existing budgets, and ordinary polling stays the backstop.bin/fm-watch-arm.shforwards a subscribed input delivery that already names the exact closed cycle in the delivery ledger instead of spending the successor grace window.bin/fm-claude-stop-autoarm.shadds a one-line handling hint to the rewake banner when input is registered.fm-inbox.sh drain --acklets only the owning session handle subscribed input and serializes note acknowledgement with the queue lock; its upfront note-id validation applies only while subscribed.bin/fm-wake-drain.shwrites an input acknowledgement receipt only when the owning session acknowledges a handled note, including a note handed off before the owner unsubscribed; a non-session drain actor such as the away/quiet daemon retires input rows exactly as before and writes no receipt.docs/watcher-continuity.mdgains a "Continuous captain input" section, which scopes the prompt wake to the polling watcher and includes a generic Slack desk example,docs/verification/captain-input.mdrecords the native evidence and limits, anddocs/scripts.mdanddocs/verification/supervision.mdpoint at them.Without
state/.captain-inputevery path keeps its existing behavior; nothing registers demand implicitly, andnoteitself does not subscribe.No listener or transport ships with Firstmate: the listener lives outside the home and only captures and relays.
Registration does not authenticate an external human, end away mode, clear quiet, or change daemon or branch ownership.
Risk Assessment
Default-off: the new branches are all guarded by the registration file, and the existing inbox, wake-queue, watcher, arm, and Stop auto-arm suites pass unchanged.
Away/quiet supervision keeps its existing drain authority: the daemon still acknowledges a batch that contains a subscribed inbox row once, leaving the note itself for the session owner.
The doorbell is only a hint written after the durable queue commit; a lost or failed doorbell write leaves ordinary recovery and polling intact.
The prompt wake applies to the polling watcher: a backend blocked in its native event wait, such as Herdr, only sees the doorbell when that wait returns.
The native evidence covers attended Claude only; other harnesses and backend event waits were inspected at their shared integration surfaces but not revalidated live.
Measured idle latency is not better than a separate listener-owned waiter (median about 5.4 s against 2.4 s in a six-input smoke sample); the gain is one shared owner with exactly one handling receipt and zero redundant wakes per input, not speed.
The latency profile and two rejected timing candidates are recorded in
docs/verification/captain-input.md.Testing
bin/fm-test-run.sh tests/fm-inbox.test.sh tests/fm-claude-stop-autoarm.test.sh tests/fm-wake-queue.test.sh tests/fm-watch-arm.test.sh tests/fm-watch-recovery-loop.test.sh tests/fm-wake-drain-open-decisions.test.sh tests/fm-wake-drain-open-decisions-cursor.test.sh tests/fm-wake-drain-outcome-backstop.test.sh tests/fm-wake-drain-unread-status.test.sh:FM_TEST_SUMMARY total=9 failed=0 skipped_gate=0at the final head, after the review and CI fix rounds.bin/fm-lint.sh(ShellCheck 0.11.0, actionlint 1.7.12) and explicit-pathbin/fm-lint.shover the changed shell files: clean.bin/fm-doc-audience-check.sh: ok.bin/fm-test-run.sh --check-coverage: ok.claude-haiku-4-5-20251001in disposable homes, driven by a synthetic mock listener with no chat service or credentials: all seven inputs produced one reader receipt, one committed handoff, one handling receipt, one queue acknowledgement, and zero redundant watcher wakes.Update 2026-10-09: merged current upstream
maininto this branch to resolve conflicts; no feature change.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
⏭️ **Rebase** - skipped
Step was skipped.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bin/fm-lock.shcheck: captain-input <seq> <id>reason and one queue rowcheck: captain-input 2 <id>, ledger reason=attached-delivered-wake;tests/fm-watch-arm.test.shexit 0 including…signal:signal: .../demo.status, no captain-input line, rc=0check: captain-input 1 1791563434-fS5N6C; receipts show one record, que…bash drive-captain-input.sh "$PWD"(evidence-directory driver: realbin/fm-watch.sh,bin/fm-watch-arm.sh,bin/fm-inbox.sh,bin/fm-wake-drain.shagainstbin/fm-lab-home.sh createhomes; stub tmux listing no windows; bash-named-claudeas session-lock owner) - 8 scenarios, all passRealclaude --model haikuprimary in a lab home viapty-primary.py(50x160 pty,env -u NO_MISTAKES_GATE ... FM_HOME=$LAB):bin/fm-lock.sh,bin/fm-inbox.sh subscribe,bin/fm-watch-arm.sh, outsidebin/fm-inbox.sh note,bin/fm-wake-drain.sh,bin/fm-inbox.sh drain --ack <id>,bin/fm-wake-drain.sh --ack-through 1 --recovery-generation ...,bin/fm-inbox.sh input-receiptsBefore the lock was taken, the same real Claude session ranbin/fm-inbox.sh subscribeand was refused with 'only the owning session may change the input subscription'bin/fm-test-run.sh tests/fm-watch-arm.test.sh tests/fm-inbox.test.sh tests/fm-claude-stop-autoarm.test.sh- exit 0Lab teardown: killed the lab Claude process,rm -rf "$LAB", confirmedgit status --shortis empty✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.