Repository navigation
fix: harden away-mode escalation delivery - #54
Conversation
… submit
Root-causes afk-invx-i5, where away-mode supervised 9.5h and surfaced nothing.
- Composer detection now strips the harness's box borders before deciding, so an
idle bordered claude composer ("│ > … │") reads as empty, not pending input.
The old check only matched a bare prompt, so every idle claude pane looked like
pending input and the daemon deferred 100% of escalations.
- Add a max-defer escape: anything buffered past FM_MAX_DEFER_SECS (default 300)
forces one delivery (bypassing the composer guard on an idle pane); if even
that cannot confirm a submit, a rate-limited wedge alarm fires (ERROR log +
state/.subsuper-inject-wedged marker + status-line flash). The daemon can no
longer silently wedge forever.
- Submit is now verified against the same border-aware detector, fixing the
parallel false "Enter swallowed" ACK. fm-send.sh shares the one primitive
(bin/fm-tmux-lib.sh) and exits non-zero on a positively-confirmed swallow, so
a steer that does not land is no longer silent.
Tests: bordered idle composer reads not-pending; bordered text still pending;
submit-ACK confirms on a bordered-empty composer and reports pending on a
persistent swallow; max-defer forces+alarms on a stuck pane, recovers on an idle
one, and stays quiet below threshold; fm-send exits non-zero on a swallow.
Ports the intent of upstream e4fbed5 (kunchenguid#54, afk-invx-i5) onto the herdr-backed sub-supervisor — adapted to herdr pane-text reading, no tmux, no fm-tmux-lib.sh. Root cause (afk-invx-i5): away-mode supervised 9.5h and surfaced nothing because composer detection matched only a BARE prompt, so an idle *bordered* Claude composer ("│ > … │") read as pending input and the daemon deferred 100% of escalations forever. Three fixes: - Border-aware composer detection. New shared primitive bin/fm-herdr-lib.sh (sourced by both the daemon and fm-send.sh, herdr-only) strips Claude's box borders ("│ ┃ ║ |") before deciding empty-vs-pending, and handles both the bare ❯/> prompt and the bordered "│ > … │" form. An idle composer reads NOT pending; FM_COMPOSER_IDLE_RE still overrides empty matching after stripping. pane_input_pending now delegates to this primitive; the bare-prompt path is generalized, not regressed. - Max-defer escape. A digest buffered past FM_MAX_DEFER_SECS (default 300, 0 disables) forces one normal flush; if a submit still cannot be confirmed, a loud RATE-LIMITED wedge alarm fires — an ERROR log line, a durable state/.subsuper-inject-wedged marker, and a `herdr notification show` status flash on the supervisor client. A guard false-positive becomes a visible stall, never an unbounded silent no-op. - Verified submit, shared primitive. inject_msg verifies the submit landed with the same border-aware detector (turn-started OR confirmed-empty composer) and preserves the buffer on an unknown/unconfirmed pane (strict). fm-send.sh shares the same primitive and EXITS NON-ZERO on a positively-confirmed swallow (Enter swallowed, text still in composer), so a steer that does not land is no longer silent. Docs: .agents/skills/afk/SKILL.md (border-aware note, max-defer escape + wedge marker, surface it on the "while you were out" catch-up) and AGENTS.md §8 synced. Tests: tests/fm-supervise-daemon.test.sh gains bordered-composer detection, verified submit-ACK on a bordered composer, and the max-defer escape (quiet below threshold, alarms on a stuck pane, recovers on idle); new tests/fm-send.test.sh covers the non-zero exit on a confirmed swallow. shellcheck clean; all 6 suites green.
Port upstream batch 2: away-mode reliability (kunchenguid#54) + Claude ghost text (kunchenguid#59)
|
Reviewer: Claude Sonnet 5.5 (claude-sonnet-5-5) Rules read: RanEverything else is "read". I did not rerun the CI suites, and I called no outside service (no Neon, Cloudflare, GitHub Actions).
Findings
Judgments the brief asked for(1) Declared departures (L7). 1 lock order: accepted, see finding 5(c). 2 operator invitation SELECT with a company: needed, because PostgreSQL reads the row through SELECT before a filtered DELETE (checked in the policy text); fine. 3 UPDATE to lock rows: correct about PostgreSQL, but the verb is wider than the need; finding 2. 4 first person through (2) The two provisional A decisions. I agree with A for both.
(3) A: the typed context. (4) Every policy against the matrix. Read each of the 31 policies in the three policy migrations against the card's table: every cell matches, plus the two declared additions (operator invitation SELECT with a company; invitation scope SELECT on members). (5) The nine proofs. B1 (6) H: staged activation. Phase 1 alone is safe in the sense the card needs: RLS is on and (7) Deleting a client and J. The server flow is the card's: one (8) The card's size. 4002 words, covered by finding 1 (with the roadmap). Verdictrequest changes: finding 1 (the step's own documents break the docs ceilings, so Visual QA (T23), what I ran and sawI wrote a scratch Playwright test on the repository's own harness ( Screenshots (all taken, 1366x800, 390x844 and 320x640, light and dark, full page), each named Measured in the page: Console: no CSP message and no page error. The browser logged four |
…id#54) * Build gateway v2 core protocols * no-mistakes(review): Harden gateway v2 serving loop, connections, and recovery * no-mistakes(review): Gate gateway v2 channel readiness on database and liveness * no-mistakes(document): Document gateway v2 adapter contract, refresh stale gateway docs * no-mistakes(document): Declare dedicated gateway-v2 capability in fork surface
|
Puesta al día con |
Verification (HCP speculative plan-only runs, nothing applied)Both runs uploaded this branch (19ce65c) as a speculative, plan-only configuration version. Logs:
RiskMerging to develop and applying the dev workspace performs state-only moves ( |
…and talk impossible to miss (kunchenguid#54) * feat(bin): show the whole queue on the Factory pane and make answers and talk impossible to miss The pane said only "N in line" per factory, so a long queue was invisible. A line under the count line now counts every job nobody has started, by what will start it: starts on its own, in line, on hold, and waiting on the owner with dated deferrals counted apart. Each factory carries its own counts, and what is held or still waits on other work is read as the backlog's adapter reads it, so a blocker that was finished and archived holds nothing up. Closed work no longer reads as finished: only a merged change, a landing or a report reads landed or finished; work closed without one reads closed. In NEEDS YOU only the highlighted call opens as a card; the rest stay one line with their factory and how long they have waited. An answer, keep, or talk now opens one outlined box that floats over a dimmed pane, under the row it is about. A confirmation takes only enter, esc or another option key, so a stray key cannot drop it, and the pane says in plain words whether the note was sent, not sent, or cancelled. An answered call says so on its card until it is acted on. t listens at once where the desk voice is set up: the words appear in the box while they are spoken, the note goes when the speaker stops or presses enter, and the first typed key switches to typing. Without a microphone recorder or the speech key the box is typed and says so. * fix(bin): bound what a spoken note costs, drop a cancelled one for good, and name held calls by what they wait on Review findings on the Factory pane's new talk box and queue. A note cancelled while it was being written down could still be written down and uploaded once the writing under way returned, and left its recording on disk. A dropped note now stops the writing under way, starts no other, and leaves no file, on esc, on a typed key and on quit. Showing the words while speaking re-sent the whole recording every second, so a long note cost the speech service far more than its length. Only the newest eight seconds are written down now, at most every two seconds, a failed writing waits before it is tried again, and the note that is sent is one writing down of the whole recording when the speaker finishes. The per-call sent history is cut down to one marker: an answered call reads "answered HH:MM, waiting for Starship" and marks the option picked, also after a restart, until the call is settled. Pickup and reply tracking and the extra rows on the card are gone. A decision held for the owner that other open work still blocks is counted as waiting on other work, in the queue line and on its factory's page. Only an aged hold is called an older call; any other is one more that waits on the owner. * no-mistakes(review): Drop confirm-time option swap and fix queue wrap example * no-mistakes(test): Pace stand-in mic by clock and squeeze borders locale-safely * no-mistakes(document): Correct Factory pane notice duration and retry wording
Intent
Fix the away-mode (/afk) sub-supervisor failure root-caused in data/afk-invx-i5/report.md, where the daemon (bin/fm-supervise-daemon.sh) supervised for 9.5 hours overnight and surfaced nothing: two crewmate pipelines parked at their gates and no escalation ever reached firstmate.
Three fixes, all flowing from one underlying bug — the composer-empty detector only recognized a BARE prompt glyph, but claude (the firstmate harness) draws its input box with box-drawing borders ('│ > … │'), so every idle claude pane was misread as 'pending input' and the daemon deferred 100% of escalations.
(1) RC1a — border-aware composer detection. New shared primitive lib bin/fm-tmux-lib.sh strips the harness's composer box borders (literal-string substitution, bash-3.2 / locale safe) before deciding empty-vs-pending. Deliberate choice: structural border-strip rather than enumerating per-harness regexes, keeping FM_BUSY_REGEX/FM_COMPOSER_IDLE_RE override hooks. The daemon's pane_is_busy/pane_input_pending become thin delegations so existing call sites and unit tests stay stable.
(2) RC1b — max-defer escape so the daemon can never silently wedge. If anything stays buffered past FM_MAX_DEFER_SECS (default 300), housekeeping forces one delivery that bypasses the composer guard on an idle pane (the busy-guard still holds); if even the forced submit can't be confirmed, a rate-limited wedge alarm fires (ERROR log + durable state/.subsuper-inject-wedged marker + tmux status-line flash). The force is throttled to once per max-defer window via the marker so a wedged composer isn't retyped every tick. Accepted tradeoff: a force could merge with a human half-typed line, but only after 300s of failure and only while afk (captain away) — far better than the 9.5h silent no-op.
(3) RC2 — verified submit, shared between the daemon and bin/fm-send.sh via fm_tmux_submit_core. Types once, retries Enter only (never retypes), and confirms via the same border-aware detector, fixing the parallel false 'Enter swallowed' ACK. Deliberate split: the daemon is STRICT (clears its buffer only on a confirmed-empty composer; an unreadable pane is NOT treated as delivered), while fm-send is LENIENT (exits non-zero only on a positively-confirmed swallow; an unreadable pane is assumed sent) so the change can't regress the many existing fm-send steers. fm-send now exits non-zero when a steer's Enter is positively swallowed so firstmate learns it did not land.
Also added 8 regression tests in tests/fm-wake-queue.test.sh (the bug existed because the prior pane_input_pending tests only covered bare prompts, never a bordered composer) and updated docs (.agents/skills/afk/SKILL.md, AGENTS.md §8). Scope: this was a scout investigation promoted to ship; no behavior change beyond these fixes.
What Changed
fm-send.shreport confirmed swallowed submits.Risk Assessment
✅ Low: Captain, the change is well-scoped to AFK tmux submission/composer detection with focused regression coverage and no material review findings found.
Testing
Inspected the changed afk and tmux submit paths, ran the focused regression shell suite and private-socket afk E2E test, then captured a preserved private-tmux transcript showing the end-user behavior: pending input is not merged with daemon text, the digest is delivered after the pane goes idle, and a swallowed Enter still produces one clean sentinel-prefixed escalation.
Evidence: private tmux afk evidence transcript
scenario_a_before_enter_digest_count=0 scenario_a_human_lines=1 scenario_a_injection_lines=1 scenario_b_digest_count=1 scenario_b_user_lines=0 scenario_b_digest_hex_prefix=1f manual private-tmux afk evidence passedEvidence: afk inject private-socket E2E output
ok - Scenario A: partial input defers injection; digest arrives clean after idle ok - Scenario B: swallowed Enter produces exactly one clean digest all e2e injection tests passedEvidence: wake queue and afk regression output
Targeted regression transcript with 57 ok lines, including bordered composer idle detection, bordered submit ACK, max-defer alarm and recovery, and fm-send nonzero exits on confirmed swallow.Evidence: manual submitted-line log
Raw submitted-line log from the preserved private tmux evidence run. The digest hex starts with 1f, proving the sentinel-prefixed daemon injection reached the pane as an injection.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed (5) ✅
bin/fm-tmux-lib.sh:57- The shared composer detector no longer honors the previously documentedFM_COMPOSER_IDLE_REoverride. It now only accepts the hard-coded prompt glyphs here, then the busy regex, so any installation that used the override for a custom empty prompt will classify an idle composer as pending until max-defer forces delivery, andfm-send.shcan falsely report a swallowed Enter. ReapplyFM_COMPOSER_IDLE_REafter border stripping before falling back to the built-in prompt list.bin/fm-supervise-daemon.sh:429- A successful normal flush does not clear a prior.subsuper-inject-wedgedmarker. If a forced inject fails while the supervisor pane is busy, the marker is written; when the pane later becomes idle, the regular batch flush can deliver and clear the buffer through this path, but the stale marker remains for catch-up reporting and also throttles later max-defer force attempts. Clear the wedge marker on any confirmed successful inject, not only on successful forced injects.🔧 Fix: Fix AFK idle override and wedge cleanup
2 warnings still open:
bin/fm-supervise-daemon.sh:501- The max-defer escape can raise a false wedge while afk is inactive. Buffered escalations are expected to sit quietly whenstate/.afkis absent, but this block still forces a flush afterFM_MAX_DEFER_SECS;inject_msgthen fails the presence gate andinject_wedge_alarmwrites.subsuper-inject-wedged/flashes tmux for a normal off-afk buffer. Gate the max-defer force/alarm onafk_active "$state"or treat afk-inactive as an ordinary defer.bin/fm-send.sh:58-fm-send.shcan now report success when the initialtmux send-keys -lfails.fm_tmux_submit_coremaps that positive transport failure tounknown, andfm-send.shtreats anything exceptpendingas success, so a pane disappearing between resolve and send silently drops a steer that used to fail underset -e. Return a distinct failure for the initial send error, or makefm-send.shfail on that case while staying lenient for post-submit readback unknowns.🔧 Fix: Harden AFK defer and send failure handling
1 warning still open:
AGENTS.md:568- The new wedge marker is created so failed forced injections are not silent, but the primary afk return contract still only tells firstmate to summarize.subsuper-escalations. If the forced inject could not reach the pane, this marker may be the only durable signal after the status-line flash is gone, so addstate/.subsuper-inject-wedgedto the return/recovery catch-up instructions.🔧 Fix: Document AFK wedge catch-up
1 warning still open:
bin/fm-supervise-daemon.sh:611- Forced max-defer delivery can retype the same escalation into a composer that already contains the previous failed injection. A normal flush that typed the digest but got a swallowed Enter leaves that text in the composer and preserves the buffer; once max-defer fires, this bypasses the pending-input guard and calls the submit primitive, which types the digest again before pressing Enter. Try Enter-only first when the pending composer already holds an unsent daemon digest, or avoid bypassing the guard for that case.🔧 Fix: Captain, prevent forced AFK digest retyping
1 error still open:
bin/fm-supervise-daemon.sh:632- Forced max-defer now treats any pending composer as if it already contains the daemon digest. If the pending text is a human draft, an unsupported prompt false-positive, or any other non-daemon content, this branch sends Enter only; when the composer clears, escalate_flush clears.subsuper-escalationseven though the escalation digest was never typed. Only use the Enter-only path after confirming the pending composer contains this daemon digest, otherwise preserve the buffer and alarm/defer.🔧 Fix: Remove unsafe AFK force delivery
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
git diff --stat 2a2fe0566e63b883ec53dc3e34dc14306689f989..925188c2b0a15401ac248fab40fcaa6c9a2744d5and changed-file inspection for the tmux/afk paths.bash tests/fm-wake-queue.test.sh > /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KVTS9SETQG83GGNV0GWP7VSR/fm-wake-queue.out 2>&1bash tests/fm-afk-inject-e2e.test.sh > /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KVTS9SETQG83GGNV0GWP7VSR/fm-afk-inject-e2e.out 2>&1Manual private-tmux daemon scenario via inlinebash -s, captured to/var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KVTS9SETQG83GGNV0GWP7VSR/afk-private-tmux-transcript.out: pending human input deferred injection, idle pane received a clean daemon digest, and a swallowed Enter retried into exactly one sentinel-prefixed injection.git status --shortafter testing to confirm no working-tree artifacts were left.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.