Repository navigation
fix: end away mode on inbox notes in daemon and Pi supervision - #50
Merged
Merged
Conversation
Keep captain inbox notes on main while away, retain their durable rows, and hand them back through the existing daemon delivery and Pi watcher paths. Recheck Pi eligibility before granting rows so notes arriving after accept also return to main. Preserve quiet mode and ordinary away routing. Validation: daemon and Pi watcher suites, focused branch inbox/archive/row rechecks, all 34 supervision-host cases, branch-state suite, SDK 1.1.0/1.2.0 typechecks, pinned lint, documentation audience and coverage checks passed. The canonical Pi branch suite passes the new inbox case, then fails in the existing synthetic broken-branch fallback fixture. Firstmate reproduced the identical failure on unchanged main 5d6b207 and directed this task to record it as a pre-existing baseline failure without fixing that fixture.
peterOC26
force-pushed
the
fm/fm-afk-return-daemon-pi-f1
branch
from
November 9, 2026 15:02
b701bde to
fe6d42e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Captain wants his Jobs page or inbox notes to end away mode reliably. The earlier round (fm-afk-return-on-jobs-page-note-r1, review finding pi-daemon-not-covered) makes such a note end away mode only on homes running the supervision host; the away daemon and the Pi supervision branch still keep the note with the away actor. Firstmate decided 2026-11-05 under the captain's away words that this is a separate follow-up.
What Changed
Risk Assessment
✅ Low: The away daemon and the Pi branch now hand captain inbox notes back to main without consuming them, and only away mode (not quiet) adds the return line. Tracing the code confirms all three earlier fixes: the daemon no longer restarts the watcher while a note waits for main, the return line is placed first so the size limit cannot cut it, and the hand-back keeps its retry and alarm state instead of reloading the library. afkPostureRecordPresent is still presence-only, as the user asked. The new tests run the real code paths rather than checking source text.
Testing
Live Codex/Pi returns, large-backlog recovery, quiet guards, routing boundaries, and focused fixtures passed after correcting Codex setup. Product transcripts, state, receipts, and rendered Pi HTML were captured; the exact Pi acceptance race remains fixture-only. Disposable labs and wrappers were removed.
Evidence: Rendered Pi away-return and quiet-mode session
Source: Rendered Pi away-return and quiet-mode session
Evidence: Codex large-backlog return transcript
Source: Codex large-backlog return transcript
Evidence: Verified live state and reply observations
Source: Verified live state and reply observations
Evidence: Real routing CLI boundary results
Source: Real routing CLI boundary results
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 3 issues found → auto-fixed ✅
bin/fm-supervise-daemon.sh:1961- Whenhand_back_captain_inboxstands aside,handle_durable_wakesreturns 0 without draining or acking. The main loop then restarts the watcher straight away (start_watcher, line ~2246). The new watcher starts with the queue non-empty and un-acked. At startupfm_recovery_marker_reopen_announcedturnsannounced:*back into pending downtime,fm_recovery_marker_arm_checkreturnsrecover, andresurface_after_downtimeemitscheck: rearm-resurfaceon the first cycle (bin/fm-watch.sh:3760-3770, 3867-3889). So every daemon iteration (about 1s plus watcher startup) spawns a watcher. Each one runs procevent reconcile and the secondmate ticks, exits, and logswake: check: rearm-resurface. While delivery is still deferred, each iteration also callsescalate_flush, not only on housekeeping ticks as the header comment says. Concrete case: the captain leaves a draft in main's composer, goes away, and sends a Jobs note. The busy guard defers injection for as long as the draft stays, and the daemon churns watcher restarts for that whole time. After a confirmed delivery the same loop continues until main's model turn drains and acks the queue. Housekeeping (line 1358) is skipped for the same period, so retries cannot rely on its tick cadence while this loop runs. Smallest fix: once the hand-back stands aside, do not restart the watcher while a queuedinbox:check row remains and the away posture holds. Leave retries to housekeeping ticks, for example by gatingstart_watcherin the main loop on the same predicate, or by sleeping the housekeeping tick after a stand-aside.bin/fm-supervise-daemon.sh:1939- The away-return line is appended to the end ofstate/.subsuper-escalationswithescalate_add.escalate_digest_body(lines 870-893) fills its 8192-byte budget from the oldest item and replaces items that don't fit with+K more event(s). Concrete case: injection is deferred for a while (busy or occupied composer, or pending wedge), so four or more ~2KB escalations are buffered. The confirmed digest then contains noaway-daemon: the captain sent a note and away mode should endtext, only a pointer to the full-text file. Main's return rule (.agents/skills/afk/SKILL.md, "How to exit: the return") keys on that line, so main may handle the wake as ordinary away supervision, and the daemon has already marked the note surfaced. Fix: put the hand-back message first in the delivered digest, for example by prepending it to the buffer rather than appending, or delivering it ahead of the batch, so the bound can never cut it.bin/fm-supervise-daemon.sh:1925-hand_back_captain_inboxre-sources the wholefm-wake-lib.sh(over 3,000 lines, plus its nested libs and aunamesubprocess) on every call. It is called on every housekeeping tick and every durable-wake close while a note is queued. In productionfm_super_mainhas already sourced it with the sameSTATE, so the re-source only serves sourced test callers. It also resets lib globals such asFM_RECOVERY_MARKER_*,_FM_LOCK_SELF_START*andFM_WATCHER_*. Simpler: rely on the parent's sourcing and bind onlyFM_WAKE_QUEUE/FM_WAKE_QUEUE_LOCK/STATElocally, or source once in the test harness.🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Test** - 2 issues found → auto-fixed ✅
bin/fm-supervise-daemon.sh:1948- Reproduced twice with real Codex 0.167.0 on private tmux: queue a captain note behind five roughly 2 KB escalations, then clear an occupied composer. The daemon logs successful hand-back, clears the escalation buffer, and stops retrying, but Codex retains the digest as unsubmitted pasted content. The note remains unanswered and away mode remains active. The second reproduction followed successful initialization and a completed short-note return. The shared transport is unchanged, but the new hand-back depends on its false-positive confirmation. Prevent retiring delivery until submission is proven, or deliver the return through a short envelope independent of the large digest.bash tests/.phase-fm-daemon.test.sh: selected captain-note hand-back, retry-state, frozen-generation, and watcher-parking cases.NODE_OPTIONS=--experimental-strip-types bash tests/.phase-fm-pi-watch-extension.test.sh: selected away-routing matrix, including the quiet-note fixture.NODE_OPTIONS=--experimental-strip-types bash tests/.phase-fm-pi-branch-extension.test.sh: selected late-note and eligible-row scope cases.Real Pi in a marked disposable lab on private tmux at 120×40; entered away mode, published throughbin/fm-inbox.sh note --json, verified reply and acknowledged queue, and exported native session HTML.bin/fm-branch-dispatch.mjs offer --afkagainst a real published inbox note.Real Codex with inherited shell environment and lab write access; ranbin/fm-session-start.sh, started the actual away daemon, and verified a completed short-note return.Seeded five pending events through productionescalate_add; exercised occupied-composer deferral and reproduced large-digest false delivery twice.Captured terminal transcripts, daemon logs, receipts, and persisted state; removed disposable labs and temporary test drivers; confirmed a clean worktree.🔧 Fix applied.
✅ Re-checked - no issues remain.
bash tests/.live-fm-daemon.test.sh: four captain-note selectors covering guarded delivery, retry state, frozen generations, and watcher parking; temporary wrapper removed.bash tests/.live-fm-pi-watch-extension.test.sh:test_pi_away_record_collapses_eligibility_and_keeps_vetoes_on_main; temporary wrapper removed.bash tests/.live-fm-pi-branch-extension.test.sh:test_captain_note_arriving_after_offer_returns_to_main; temporary wrapper removed.Real Codex and Pi primaries on separate private tmux sockets with 120×40 grids; drovefm-afk-contract.sh,fm-afk-launch.sh, andfm-inbox.shthrough away, composer-deferral, repeat-return, and quiet scenarios.node bin/fm-branch-dispatch.mjs offer --afkagainst queues produced by the real wake library and inbox CLI.Captured terminal transcripts, persisted states, inbox receipts, and Pi/exportHTML; checked full backlog preservation and stopped and removed all disposable labs.Corrected initial Codex environment filtering and private-socket sandbox restrictions through invocation-local options; global configuration remained unchanged.✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.