You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(bin): stop repeating unknown-wake escalations that were already delivered - #5599
Fixes#4758.
Implement ready-for-pr issue #4758: fail-safe unknown-wake escalations repeat for already-handled events with no acknowledgement.
A wake reason the away daemon cannot classify escalates as unknown wake. That fail-safe is correct. The escalation has no acknowledgement path, so it repeats for an event already handled. Examples include unknown wake lines for decisions already closed and for an inactive terminal outcome already presented. An unknown wake that was handled should not re-present under the same event identity. A genuinely new unknown wake should still fire.
What Changed
bin/fm-supervise-daemon.sh: once an escalation digest reaches the supervisor, each unknown wake: line in it is written to state/.subsuper-unknown-acked. After that, escalate_add drops any line that matches an acknowledged line exactly. A new unknown wake, or one that is still only buffered or failed to deliver, still escalates. If the acknowledgement write fails, the daemon logs it and still clears the delivered buffer, so the only cost is that the wake may escalate again.
The ack file only lasts for one away session. fm-afk-start.sh and fm-afk-return.sh clear it with the other delivery artifacts. fm-afk-launch.sh backs it up and restores it alongside them.
The afk SKILL.md now describes the acknowledgement rules and lists the ack file among the session-scoped artifacts. The daemon, launch, and return tests are updated to cover the new behavior.
✅ Low: The change is small and self-contained: it adds an exact-line acknowledgement file that is written only after a successful inject, cleared together with the other away-session artifacts, and included in launch backup and restore. The previous rounds' fixes check out. The in-buffer dedupe is gone, and a failed acknowledgement write now logs and clears the delivered digest. Both behaviors are covered by tests that run handle_wake and escalate_flush.
Testing
I ran the real away daemon, started through bin/fm-afk-start.sh, against an isolated private tmux server with a scripted supervisor pane, across three away sessions. All six live scenarios passed: a handled unknown wake was delivered once per session and not again; a new unknown wake and ordinary escalations were still delivered; starting a new session made the same wake deliverable again; and a failed acknowledgement write did not cause a second delivery. I did not drive the return catch-up (fm-afk-return.sh clearing the acknowledgement file) live, so it is marked untested. The scripted fm-afk-return test covers it and passed. The first harness attempt showed repeated deliveries, but that was my setup, not the product: I had used inactive-outcome: queue keys that the wake drain refuses to acknowledge without a matching reconcile record, so it replayed those rows every cycle. With neutral keys the run was clean. The targeted fm-daemon tests also passed. This change has no visual UI surface, so the evidence is the verbatim pane submissions and daemon log lines.
Live validation: ✅ go - 6 of 7 scenarios driven live against the product
Scenario
Result
Live
Evidence
An unknown wake while the captain is away (an inactive terminal outcome row) reaches the supervisor pane once and is recorded as acknowledged
✅ pass
live
unknown-wake-live-results.txt S1; supervisor-pane-submissions.txt line 1; ack file holds the exact 'unknown wake: ...' line
The same unknown-wake text arrives again in the same away session under a new queue key: it is not delivered again, and its queue row is still drained
✅ pass
live
unknown-wake-live-results.txt S2; daemon-log-excerpt.txt shows the second classification at 02:37:21 with no second pane submission
A different unknown wake (a closed-decision line) is still delivered after another wake was acknowledged
✅ pass
live
unknown-wake-live-results.txt S3; supervisor-pane-submissions.txt line 2
An ordinary escalation (a done: status) is still delivered each time and never written to the acknowledgement file
A new away session started through fm-afk-start.sh clears the acknowledgements, so a wake handled in the previous session is delivered again
✅ pass
live
unknown-wake-live-results.txt S5; supervisor-pane-submissions.txt line 5
Adversarial: the acknowledgement file cannot be written (it is replaced by a directory). The digest is delivered exactly once, the buffer is cleared, and the failure is logged
✅ pass
live
unknown-wake-live-results.txt S6; daemon-log-excerpt.txt shows 'unknown-wake acknowledgement write failed'; supervisor-pane-submissions.txt line 6 appears once
The return catch-up (fm-afk-return.sh clear_delivery_artifacts) removes the acknowledgement file
⏸️ untested
no
The earlier payload did not show a live result for this scenario. Driving the return gate live needs a full captain return turn, which I did not run. The only coverage is the scripted test `bash tests…
=== Session 1: fresh away session via bin/fm-afk-start.sh
submitted lines after first unknown wake:
| FIRSTMATE_OP: v1 away-supervisor: Supervisor escalate (1 event(s)): unknown wake: inactive terminal outcome awaiting captain presentation: child=c1 state=done pr=https://example.test/pull/1 (pre-read; re-arm not needed — watcher daemon-managed)
PASS: S1 first unknown wake escalates once to supervisor pane
PASS: S1 delivered unknown wake is recorded in state/.subsuper-unknown-acked
ack file:
> unknown wake: inactive terminal outcome awaiting captain presentation: child=c1 state=done pr=https://example.test/pull/1
PASS: S2 same unknown-wake identity re-presented is NOT escalated again
PASS: S2 re-presented wake row was drained/acked (not stuck in queue)
PASS: S3 genuinely new unknown wake still escalates
PASS: S4 ordinary (non-unknown) escalation still delivered and never written to ack file
submitted lines at end of session 1:
=== Session 2: new away session via bin/fm-afk-start.sh (fresh entry clears acknowledgements)
PASS: S5 fresh away-session entry cleared the acknowledgement file
PASS: S5 same identity handled in a PRIOR session fires again in the new session
=== Session 3: acknowledgement write fails after delivery
PASS: S6 digest delivered exactly once despite ack-write failure (no re-injection)
PASS: S6 escalation buffer cleared after delivery
PASS: S6 daemon logged the acknowledgement-write failure
=== Final supervisor-pane submissions (verbatim)
=== Daemon log excerpt
=== RESULTS
PASS S1 first unknown wake escalates once to supervisor pane
PASS S1 delivered unknown wake is recorded in state/.subsuper-unknown-acked
PASS S2 same unknown-wake identity re-presented is NOT escalated again
PASS S2 re-presented wake row was drained/acked (not stuck in queue)
PASS S3 genuinely new unknown wake still escalates
PASS S4 ordinary (non-unknown) escalation still delivered and never written to ack file
PASS S5 fresh away-session entry cleared the acknowledgement file
PASS S5 same identity handled in a PRIOR session fires again in the new session
PASS S6 digest delivered exactly once despite ack-write failure (no re-injection)
PASS S6 escalation buffer cleared after delivery
PASS S6 daemon logged the acknowledgement-write failure
KEPT_WORKDIR=/tmp/fm-unk-ack.LKNyzV
⚠️bin/fm-supervise-daemon.sh:498 - The unknown-wake acknowledgement file state/.subsuper-unknown-acked is append-only and nothing ever clears or prunes it. fm_afk_clear_stale_artifacts (bin/fm-afk-start.sh:64), the fm-afk-launch.sh artifact lists (488-494, 618, 675) and clear_delivery_artifacts (bin/fm-afk-return.sh:256) all delete the escalation buffer but leave this file. The only identity is the exact distilled text. Concrete case: fm-inactive-reco
Intent
Fixes #4758.
Implement ready-for-pr issue #4758: fail-safe unknown-wake escalations repeat for already-handled events with no acknowledgement.
A wake reason the away daemon cannot classify escalates as unknown wake. That fail-safe is correct. The escalation has no acknowledgement path, so it repeats for an event already handled. Examples include unknown wake lines for decisions already closed and for an inactive terminal outcome already presented. An unknown wake that was handled should not re-present under the same event identity. A genuinely new unknown wake should still fire.
What Changed
bin/fm-supervise-daemon.sh: once an escalation digest reaches the supervisor, eachunknown wake:line in it is written tostate/.subsuper-unknown-acked. After that,escalate_adddrops any line that matches an acknowledged line exactly. A new unknown wake, or one that is still only buffered or failed to deliver, still escalates. If the acknowledgement write fails, the daemon logs it and still clears the delivered buffer, so the only cost is that the wake may escalate again.fm-afk-start.shandfm-afk-return.shclear it with the other delivery artifacts.fm-afk-launch.shbacks it up and restores it alongside them.SKILL.mdnow describes the acknowledgement rules and lists the ack file among the session-scoped artifacts. The daemon, launch, and return tests are updated to cover the new behavior.Fixes #4758.
Risk Assessment
✅ Low: The change is small and self-contained: it adds an exact-line acknowledgement file that is written only after a successful inject, cleared together with the other away-session artifacts, and included in launch backup and restore. The previous rounds' fixes check out. The in-buffer dedupe is gone, and a failed acknowledgement write now logs and clears the delivered digest. Both behaviors are covered by tests that run handle_wake and escalate_flush.
Testing
I ran the real away daemon, started through bin/fm-afk-start.sh, against an isolated private tmux server with a scripted supervisor pane, across three away sessions. All six live scenarios passed: a handled unknown wake was delivered once per session and not again; a new unknown wake and ordinary escalations were still delivered; starting a new session made the same wake deliverable again; and a failed acknowledgement write did not cause a second delivery. I did not drive the return catch-up (fm-afk-return.sh clearing the acknowledgement file) live, so it is marked untested. The scripted fm-afk-return test covers it and passed. The first harness attempt showed repeated deliveries, but that was my setup, not the product: I had used
inactive-outcome:queue keys that the wake drain refuses to acknowledge without a matching reconcile record, so it replayed those rows every cycle. With neutral keys the run was clean. The targeted fm-daemon tests also passed. This change has no visual UI surface, so the evidence is the verbatim pane submissions and daemon log lines.Evidence: Live scenario results
Source: Live scenario results
Evidence: Supervisor pane submissions (verbatim)
Source: Supervisor pane submissions (verbatim)
Evidence: Daemon log excerpt
Source: Daemon log excerpt
Evidence: Live driver script
Source: Live driver script
Evidence: Live transcript
Source: Live transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 3 issues found → auto-fixed (3) ✅
bin/fm-supervise-daemon.sh:498- The unknown-wake acknowledgement file state/.subsuper-unknown-acked is append-only and nothing ever clears or prunes it. fm_afk_clear_stale_artifacts (bin/fm-afk-start.sh:64), the fm-afk-launch.sh artifact lists (488-494, 618, 675) and clear_delivery_artifacts (bin/fm-afk-return.sh:256) all delete the escalation buffer but leave this file. The only identity is the exact distilled text. Concrete case: fm-inactive-reco