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): reopen a pending-reply escalation after its resolve - #6654
Contribute the fix for #6635, which the maintainer labelled ready-for-pr (contract class: restore): a second same-kind pending-reply escalation appends no status line after an operator close, so the second loss stays closed and invisible. The issue's expected behaviour: after the operator closes an escalation, a later escalation of the same kind appends a new blocked [key=pending-reply-<corr>] line, and that line opens the decision again.
The maintainer's triage: the status stream is an append-only keyed decision log where an open decision is one not yet resolved; a fresh escalation after a resolve should open it again. The dedupe is there for idempotent retries, not to suppress a new episode. It asks for regression coverage for escalate, operator resolve, second escalate.
What Changed
status_event_recorded in bin/fm-classify-lib.sh now treats a keyed needs-decision or blocked line as one episode of a decision: a later resolve line for the same key ends the episode, so the next identical line reads as new and is appended. A resolve for another key, or one the reserved-key rule rejects, does not end the episode, and every other kind of line (notes, done, unkeyed lines) stays recorded for the life of the file.
As a result, a second same-kind pending-reply escalation after an operator close appends a new blocked [key=pending-reply-<corr>] line and the decision opens again, while a retry of a still-open decision appends nothing. The header comment in bin/fm-pending-reply-lib.sh describes this behaviour.
Regression tests cover the sequence escalate, retry, operator resolve, second escalate, retry in tests/fm-pending-reply.test.sh, plus the episode rules in tests/fm-classify-decision-key.test.sh and tests/fm-classify-corr-token.test.sh.
Risk Assessment
✅ Low: The change is a bounded edit to one shared retry check that satisfies the intent (retry of an open decision appends nothing, a same-key resolve the fold accepts makes the next identical opener append and reopen), and tracing every caller (pending-reply escalate, parent-channel append, continuity blocker, document note, captain-hold, inactive-outcome, merge-outcome) found no caller that replays a keyed opener after its resolve in a way that would wrongly reopen a decision.
Testing
I ran the three test files the change touches, and all passed, including the new regression test for escalate, operator resolve, second escalate. That regression test stubs tmux, so it is not a live result and its scenario is marked untested below. I then drove the product live in a disposable lab home (made by bin/fm-lab-home.sh create) from a pane on the private fm-lab tmux socket, with the real clock and a grace period of 0. The driver used the watcher tick fm_pending_reply_tick to escalate, the real bin/fm-send.sh mate --resolve-key as the operator close, and status_open_decisions to read the open decisions. On the target commit every step passed: first loss, retry, two adversarial resolves, operator close, second loss reopening the decision, retry of the reopened decision, and a second close followed by a third loss. On the base commit the same driver failed at the second loss exactly as issue 6635 describes. There is no UI surface, so the evidence is the two CLI transcripts and the driver script. I killed the lab tmux server and removed both lab directories; the worktree is clean.
Live validation: ✅ go - 5 of 6 scenarios driven live against the product
Scenario
Result
Live
Evidence
Operator closes a pending-reply escalation, then the same kind of loss happens again: the status log gains a second blocked [key=pending-reply-<corr>] line and the decision is open again
✅ pass
live
live-target-22b5f0e9.log steps 5 and 6: blocked lines went 1 -> 2 and status_open_decisions listed the key again. live-base-e5b9dddc.log step 6 shows the bug on the base commit: blocked lines stayed…
A retry of an escalation whose decision is still open appends no duplicate line (first episode and reopened episode)
✅ pass
live
live-target-22b5f0e9.log steps 2 and 7: blocked lines stayed 1, then stayed 2, with the decision open both times.
Adversarial: a resolved line for a different key does not end the episode, so the next retry still appends nothing
✅ pass
live
live-target-22b5f0e9.log step 3: after resolved [key=scope], blocked lines stayed 1 and the decision stayed open.
Adversarial: a forged resolved [key=pending-reply-<corr>]: answered: ... line, which the reserved-key rule rejects, neither closes the decision nor allows a duplicate blocked line
✅ pass
live
live-target-22b5f0e9.log step 4: blocked lines stayed 1 and the decision stayed open.
The cycle repeats: a second operator close closes the reopened decision, and a third loss appends a third blocked line and opens it again
✅ pass
live
live-target-22b5f0e9.log step 8: fm-send exit=0, decision closed, then blocked lines=3 and the decision open. On the base commit the second close exited 1 because no decision was open.
Regression test for escalate, operator resolve, second escalate, as the maintainer asked
⏸️ untested
no
The prior payload did not establish a live result for this scenario. It recorded only a run of bash tests/fm-pending-reply.test.sh, which stubs tmux, so it is a unit test and not a drive of the real…
Evidence: Live transcript on the target commit 22b5f0e (all expectations ok)
== source root: ~/.no-mistakes/worktrees/5284051b2355/01M46PNNZHXH7JCN2WESN7SMF9 @ 22b5f0e9
== 1. create an undelivered pending reply, attempt delivery, run the watcher tick
corr=2479caba13ba501e
-- status log (/tmp/fm-lab.4sWpo7/state/mate.status):
| blocked [key=pending-reply-2479caba13ba501e] [at=1791226744]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
-- blocked lines for the key: 1
-- status_open_decisions: [pending-reply-2479caba13ba501e blocked pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport]
-- record phase: escalated
RESULT ok - first loss appends one blocked line and opens the decision (blocked lines=1, decision open=yes)
== 2. retry while the decision is still open (idempotent retry)
-- status log (/tmp/fm-lab.4sWpo7/state/mate.status):
| blocked [key=pending-reply-2479caba13ba501e] [at=1791226744]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
-- blocked lines for the key: 1
-- status_open_decisions: [pending-reply-2479caba13ba501e blocked pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport]
-- record phase: escalated
RESULT ok - a retry of an open decision appends nothing (blocked lines=1, decision open=yes)
== 3. adversarial: a resolved line for ANOTHER key must not end this episode
-- status log (/tmp/fm-lab.4sWpo7/state/mate.status):
| blocked [key=pending-reply-2479caba13ba501e] [at=1791226744]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
| needs-decision [key=scope]: narrow or wide?
| resolved [key=scope]: answered: narrow
-- blocked lines for the key: 1
-- status_open_decisions: [pending-reply-2479caba13ba501e blocked pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport]
-- record phase: escalated
RESULT ok - a resolve for another key does not reopen the dedupe (blocked lines=1, decision open=yes)
== 4. adversarial: a forged resolved line the reserved-key rule rejects must not end this episode
-- status log (/tmp/fm-lab.4sWpo7/state/mate.status):
| blocked [key=pending-reply-2479caba13ba501e] [at=1791226744]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
| needs-decision [key=scope]: narrow or wide?
| resolved [key=scope]: answered: narrow
| resolved [key=pending-reply-2479caba13ba501e]: answered: looks fine
-- blocked lines for the key: 1
-- status_open_decisions: [pending-reply-2479caba13ba501e blocked pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport]
-- record phase: escalated
RESULT ok - a rejected resolve neither closes nor allows a duplicate (blocked lines=1, decision open=yes)
== 5. operator close: bin/fm-send.sh mate --resolve-key pending-reply-2479caba13ba501e
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.4sWpo7
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● WATCHER DOWN - SUPERVISION IS OFF
● 1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
● Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
● This is a supervision warning only; the requested message WILL still be sent.
● watcher supervision needs Stop-owned automatic recovery; inspect the hook registration and startup status before ending the turn.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
fm-send: doorbell not typed because the agent in primary:fm-mate has exited; the steer is durably recorded at /tmp/fm-lab.4sWpo7/state/mate.inbox/001.msg for recovery (stuck-crewmate-recovery), and the watcher will not re-ring a dead pane
fm-send exit=0
-- status log (/tmp/fm-lab.4sWpo7/state/mate.status):
| blocked [key=pending-reply-2479caba13ba501e] [at=1791226744]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
| needs-decision [key=scope]: narrow or wide?
| resolved [key=scope]: answered: narrow
| resolved [key=pending-reply-2479caba13ba501e]: answered: looks fine
| resolved [key=pending-reply-2479caba13ba501e] [at=1791226750]: pending-reply-resolved: task=mate pending-reply-id=2479caba13ba501e via=operator-resolve-key dismiss the unknown-delivery hold
-- blocked lines for the key: 1
-- status_open_decisions: []
-- record phase: escalated
RESULT ok - the operator close closes the decision (blocked lines=1, decision open=no)
== 6. second same-kind loss after the operator close
-- status log (/tmp/fm-lab.4sWpo7/state/mate.status):
| blocked [key=pending-reply-2479caba13ba501e] [at=1791226744]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
| needs-decision [key=scope]: narrow or wide?
| resolved [key=scope]: answered: narrow
| resolved [key=pending-reply-2479caba13ba501e]: answered: looks fine
| resolved [key=pending-reply-2479caba13ba501e] [at=1791226750]: pending-reply-resolved: task=mate pending-reply-id=2479caba13ba501e via=operator-resolve-key dismiss the unknown-delivery hold
| blocked [key=pending-reply-2479caba13ba501e] [at=1791226752]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
-- blocked lines for the key: 2
-- status_open_decisions: [pending-reply-2479caba13ba501e blocked pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport]
-- record phase: escalated
RESULT ok - a new escalation after the close appends and reopens the decision (blocked lines=2, decision open=yes)
== 7. retry of the reopened decision
-- status log (/tmp/fm-lab.4sWpo7/state/mate.status):
| blocked [key=pending-reply-2479caba13ba501e] [at=1791226744]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
| needs-decision [key=scope]: narrow or wide?
| resolved [key=scope]: answered: narrow
| resolved [key=pending-reply-2479caba13ba501e]: answered: looks fine
| resolved [key=pending-reply-2479caba13ba501e] [at=1791226750]: pending-reply-resolved: task=mate pending-reply-id=2479caba13ba501e via=operator-resolve-key dismiss the unknown-delivery hold
| blocked [key=pending-reply-2479caba13ba501e] [at=1791226752]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
| blocked [key=pending-reply-f6d60ee318743760] [at=1791226757]: pending-reply-missed: task=mate pending-reply-id=f6d60ee318743760 request=dismiss the unknown-delivery hold
-- blocked lines for the key: 2
-- status_open_decisions: [pending-reply-2479caba13ba501e blocked pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport;pending-reply-f6d60ee318743760 blocked pending-reply-missed: task=mate pending-reply-id=f6d60ee318743760 request=dismiss the unknown-delivery hold]
-- record phase: escalated
RESULT ok - a retry of the reopened decision appends nothing (blocked lines=2, decision open=yes)
== 8. second operator close, then a third loss
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.4sWpo7
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
fm-send: doorbell not typed because the agent in primary:fm-mate has exited; the steer is durably recorded at /tmp/fm-lab.4sWpo7/state/mate.inbox/003.msg for recovery (stuck-crewmate-recovery), and the watcher will not re-ring a dead pane
fm-send exit=0
RESULT ok - the second operator close closes the decision (blocked lines=2, decision open=no)
-- status log (/tmp/fm-lab.4sWpo7/state/mate.status):
| blocked [key=pending-reply-2479caba13ba501e] [at=1791226744]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
| needs-decision [key=scope]: narrow or wide?
| resolved [key=scope]: answered: narrow
| resolved [key=pending-reply-2479caba13ba501e]: answered: looks fine
| resolved [key=pending-reply-2479caba13ba501e] [at=1791226750]: pending-reply-resolved: task=mate pending-reply-id=2479caba13ba501e via=operator-resolve-key dismiss the unknown-delivery hold
| blocked [key=pending-reply-2479caba13ba501e] [at=1791226752]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
| blocked [key=pending-reply-f6d60ee318743760] [at=1791226757]: pending-reply-missed: task=mate pending-reply-id=f6d60ee318743760 request=dismiss the unknown-delivery hold
| resolved [key=pending-reply-2479caba13ba501e] [at=1791226758]: pending-reply-resolved: task=mate pending-reply-id=2479caba13ba501e via=operator-resolve-key dismiss again
| blocked [key=pending-reply-2479caba13ba501e] [at=1791226760]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
-- blocked lines for the key: 3
-- status_open_decisions: [pending-reply-f6d60ee318743760 blocked pending-reply-missed: task=mate pending-reply-id=f6d60ee318743760 request=dismiss the unknown-delivery hold;pending-reply-2479caba13ba501e blocked pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport]
-- record phase: escalated
RESULT ok - a third episode appends and reopens again (blocked lines=3, decision open=yes)
== SUMMARY: 0 failed expectation(s)
DRIVER-DONE fails=0
Evidence: Live transcript on the base commit e5b9ddd (reproduces issue 6635)
== source root: /tmp/fm-lab-base.5VK3Hs/src @ e5b9dddc
== 1. create an undelivered pending reply, attempt delivery, run the watcher tick
corr=5d6651d5e125bfbc
-- status log (/tmp/fm-lab-base.5VK3Hs/home/state/mate.status):
| blocked [key=pending-reply-5d6651d5e125bfbc] [at=1791226776]: pending-reply-delivery-unknown: task=mate pending-reply-id=5d6651d5e125bfbc request=wake after lost transport
-- blocked lines for the key: 1
-- status_open_decisions: [pending-reply-5d6651d5e125bfbc blocked pending-reply-delivery-unknown: task=mate pending-reply-id=5d6651d5e125bfbc request=wake after lost transport]
-- record phase: escalated
RESULT ok - first loss appends one blocked line and opens the decision (blocked lines=1, decision open=yes)
== 2. retry while the decision is still open (idempotent retry)
-- status log (/tmp/fm-lab-base.5VK3Hs/home/state/mate.status):
| blocked [key=pending-reply-5d6651d5e125bfbc] [at=1791226776]: pending-reply-delivery-unknown: task=mate pending-reply-id=5d6651d5e125bfbc request=wake after lost transport
-- blocked lines for the key: 1
-- status_open_decisions: [pending-reply-5d6651d5e125bfbc blocked pending-reply-delivery-unknown: task=mate pending-reply-id=5d6651d5e125bfbc request=wake after lost transport]
-- record phase: escalated
RESULT ok - a retry of an open decision appends nothing (blocked lines=1, decision open=yes)
== 3. adversarial: a resolved line for ANOTHER key must not end this episode
-- status log (/tmp/fm-lab-base.5VK3Hs/home/state/mate.status):
| blocked [key=pending-reply-5d6651d5e125bfbc] [at=1791226776]: pending-reply-delivery-unknown: task=mate pending-reply-id=5d6651d5e125bfbc request=wake after lost transport
| needs-decision [key=scope]: narrow or wide?
| resolved [key=scope]: answered: narrow
-- blocked lines for the key: 1
-- status_open_decisions: [pending-reply-5d6651d5e125bfbc blocked pending-reply-delivery-unknown: task=mate pending-reply-id=5d6651d5e125bfbc request=wake after lost transport]
-- record phase: escalated
RESULT ok - a resolve for another key does not reopen the dedupe (blocked lines=1, decision open=yes)
== 4. adversarial: a forged resolved line the reserved-key rule rejects must not end this episode
-- status log (/tmp/fm-lab-base.5VK3Hs/home/state/mate.status):
| blocked [key=pending-reply-5d6651d5e125bfbc] [at=1791226776]: pending-reply-delivery-unknown: task=mate pending-reply-id=5d6651d5e125bfbc request=wake after lost transport
| needs-decision [key=scope]: narrow or wide?
| resolved [key=scope]: answered: narrow
| resolved [key=pending-reply-5d6651d5e125bfbc]: answered: looks fine
-- blocked lines for the key: 1
-- status_open_decisions: [pending-reply-5d6651d5e125bfbc blocked pending-reply-delivery-unknown: task=mate pending-reply-id=5d6651d5e125bfbc request=wake after lost transport]
-- record phase: escalated
RESULT ok - a rejected resolve neither closes nor allows a duplicate (blocked lines=1, decision open=yes)
== 5. operator close: bin/fm-send.sh mate --resolve-key pending-reply-5d6651d5e125bfbc
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab-base.5VK3Hs/home
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● WATCHER DOWN - SUPERVISION IS OFF
● 1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
● Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
● This is a supervision warning only; the requested message WILL still be sent.
● watcher supervision needs Stop-owned automatic recovery; inspect the hook registration and startup status before ending the turn.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
fm-send: doorbell not typed because the agent in primary:fm-mate has exited; the steer is durably recorded at /tmp/fm-lab-base.5VK3Hs/home/state/mate.inbox/001.msg for recovery (stuck-crewmate-recovery), and the watcher will not re-ring a dead pane
fm-send exit=0
-- status log (/tmp/fm-lab-base.5VK3Hs/home/state/mate.status):
| blocked [key=pending-reply-5d6651d5e125bfbc] [at=1791226776]: pending-reply-delivery-unknown: task=mate pending-reply-id=5d6651d5e125bfbc request=wake after lost transport
| needs-decision [key=scope]: narrow or wide?
| resolved [key=scope]: answered: narrow
| resolved [key=pending-reply-5d6651d5e125bfbc]: answered: looks fine
| resolved [key=pending-reply-5d6651d5e125bfbc] [at=1791226782]: pending-reply-resolved: task=mate pending-reply-id=5d6651d5e125bfbc via=operator-resolve-key dismiss the unknown-delivery hold
-- blocked lines for the key: 1
-- status_open_decisions: []
-- record phase: escalated
RESULT ok - the operator close closes the decision (blocked lines=1, decision open=no)
== 6. second same-kind loss after the operator close
-- status log (/tmp/fm-lab-base.5VK3Hs/home/state/mate.status):
| blocked [key=pending-reply-5d6651d5e125bfbc] [at=1791226776]: pending-reply-delivery-unknown: task=mate pending-reply-id=5d6651d5e125bfbc request=wake after lost transport
| needs-decision [key=scope]: narrow or wide?
| resolved [key=scope]: answered: narrow
| resolved [key=pending-reply-5d6651d5e125bfbc]: answered: looks fine
| resolved [key=pending-reply-5d6651d5e125bfbc] [at=1791226782]: pending-reply-resolved: task=mate pending-reply-id=5d6651d5e125bfbc via=operator-resolve-key dismiss the unknown-delivery hold
-- blocked lines for the key: 1
-- status_open_decisions: []
-- record phase: escalated
RESULT FAIL - a new escalation after the close appends and reopens the decision (blocked lines=1 want 2, decision open=no want yes)
== 7. retry of the reopened decision
-- status log (/tmp/fm-lab-base.5VK3Hs/home/state/mate.status):
| blocked [key=pending-reply-5d6651d5e125bfbc] [at=1791226776]: pending-reply-delivery-unknown: task=mate pending-reply-id=5d6651d5e125bfbc request=wake after lost transport
| needs-decision [key=scope]: narrow or wide?
| resolved [key=scope]: answered: narrow
| resolved [key=pending-reply-5d6651d5e125bfbc]: answered: looks fine
| resolved [key=pending-reply-5d6651d5e125bfbc] [at=1791226782]: pending-reply-resolved: task=mate pending-reply-id=5d6651d5e125bfbc via=operator-resolve-key dismiss the unknown-delivery hold
| blocked [key=pending-reply-0b99755e55bd81af] [at=1791226788]: pending-reply-missed: task=mate pending-reply-id=0b99755e55bd81af request=dismiss the unknown-delivery hold
-- blocked lines for the key: 1
-- status_open_decisions: [pending-reply-0b99755e55bd81af blocked pending-reply-missed: task=mate pending-reply-id=0b99755e55bd81af request=dismiss the unknown-delivery hold]
-- record phase: escalated
RESULT FAIL - a retry of the reopened decision appends nothing (blocked lines=1 want 2, decision open=no want yes)
== 8. second operator close, then a third loss
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab-base.5VK3Hs/home
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
error: --resolve-key 'pending-reply-5d6651d5e125bfbc': no open decision or blocker with that key in /tmp/fm-lab-base.5VK3Hs/home/state/mate.status, and no captain-held task 'pending-reply-5d6651d5e125bfbc' or 'mate-decision-pending-reply-5d6651d5e125bfbc' still open (already closed or mistyped). Re-check the OPEN DECISIONS listing, then resend without that key or with the right one; nothing was sent.
fm-send exit=1
RESULT FAIL - the second operator close closes the decision (blocked lines=1 want 2, decision open=no want no)
-- status log (/tmp/fm-lab-base.5VK3Hs/home/state/mate.status):
| blocked [key=pending-reply-5d6651d5e125bfbc] [at=1791226776]: pending-reply-delivery-unknown: task=mate pending-reply-id=5d6651d5e125bfbc request=wake after lost transport
| needs-decision [key=scope]: narrow or wide?
| resolved [key=scope]: answered: narrow
| resolved [key=pending-reply-5d6651d5e125bfbc]: answered: looks fine
| resolved [key=pending-reply-5d6651d5e125bfbc] [at=1791226782]: pending-reply-resolved: task=mate pending-reply-id=5d6651d5e125bfbc via=operator-resolve-key dismiss the unknown-delivery hold
| blocked [key=pending-reply-0b99755e55bd81af] [at=1791226788]: pending-reply-missed: task=mate pending-reply-id=0b99755e55bd81af request=dismiss the unknown-delivery hold
-- blocked lines for the key: 1
-- status_open_decisions: [pending-reply-0b99755e55bd81af blocked pending-reply-missed: task=mate pending-reply-id=0b99755e55bd81af request=dismiss the unknown-delivery hold]
-- record phase: escalated
RESULT FAIL - a third episode appends and reopens again (blocked lines=1 want 3, decision open=no want yes)
== SUMMARY: 4 failed expectation(s)
DRIVER-DONE fails=4
#!/usr/bin/env bash
# Live driver for issue 6635: escalate, operator close, second escalate.
# Usage: drive-reescalation.sh <source-root> <lab-home>
# Runs the real scripts of <source-root> against the disposable <lab-home>.
# The clock is the real clock; only the grace period is configured to 0.
set -u
ROOT=$1; HOME_DIR=$2
STATE="$HOME_DIR/state"
export FM_HOME="$HOME_DIR" FM_PENDING_REPLY_GRACE_SECS=0 FM_SEND_SETTLE=0
. "$ROOT/bin/fm-classify-lib.sh"
. "$ROOT/bin/fm-pending-reply-lib.sh"
STATUS="$STATE/mate.status"
fails=0
say() { printf '\n== %s\n' "$*"; }
show() {
printf -- '-- status log (%s):\n' "$STATUS"; sed 's/^/ | /' "$STATUS"
printf -- '-- blocked lines for the key: %s\n' "$(grep -cF "blocked [key=pending-reply-$corr]" "$STATUS")"
printf -- '-- status_open_decisions: [%s]\n' "$(status_open_decisions "$STATUS" | tr '\t' ' ' | tr '\n' ';')"
printf -- '-- record phase: %s\n' "$(fm_pending_reply_get "$(fm_pending_reply_path "$STATE" "$corr")" phase)"
}
expect() { # <label> <want-blocked-count> <want-open: yes|no>
local n open got
n=$(grep -cF "blocked [key=pending-reply-$corr]" "$STATUS")
open=$(status_open_decisions "$STATUS" | cut -f1 | grep -cxF "pending-reply-$corr")
[ "$open" = 1 ] && got=yes || got=no
if [ "$n" = "$2" ] && [ "$got" = "$3" ]; then
printf 'RESULT ok - %s (blocked lines=%s, decision open=%s)\n' "$1" "$n" "$got"
else
printf 'RESULT FAIL - %s (blocked lines=%s want %s, decision open=%s want %s)\n' "$1" "$n" "$2" "$got" "$3"
fails=$((fails + 1))
fi
}
lose_again() { # the correlation-reusing resend path, then the watcher tick
fm_pending_reply_reset_known_undelivered "$STATE" "$corr" || echo "reset refused rc=$?"
fm_pending_reply_prepare_delivery "$STATE" "$corr" || echo "prepare refused rc=$?"
sleep 1
fm_pending_reply_tick "$STATE"
}
say "source root: $ROOT @ $(git -C "$ROOT" rev-parse --short HEAD 2>/dev/null || cat "$ROOT/.rev")"
say "1. create an undelivered pending reply, attempt delivery, run the watcher tick"
corr=$(fm_pending_reply_create "$HOME_DIR" "$STATE" mate "wake after lost transport")
echo "corr=$corr"
fm_pending_reply_prepare_delivery "$STATE" "$corr"
sleep 1
fm_pending_reply_tick "$STATE"
show; expect "first loss appends one blocked line and opens the decision" 1 yes
say "2. retry while the decision is still open (idempotent retry)"
lose_again
show; expect "a retry of an open decision appends nothing" 1 yes
say "3. adversarial: a resolved line for ANOTHER key must not end this episode"
printf 'needs-decision [key=scope]: narrow or wide?\nresolved [key=scope]: answered: narrow\n' >> "$STATUS"
lose_again
show; expect "a resolve for another key does not reopen the dedupe" 1 yes
say "4. adversarial: a forged resolved line the reserved-key rule rejects must not end this episode"
printf 'resolved [key=pending-reply-%s]: answered: looks fine\n' "$corr" >> "$STATUS"
lose_again
show; expect "a rejected resolve neither closes nor allows a duplicate" 1 yes
say "5. operator close: bin/fm-send.sh mate --resolve-key pending-reply-$corr"
"$ROOT/bin/fm-send.sh" mate --resolve-key "pending-reply-$corr" "dismiss the unknown-delivery hold"
echo "fm-send exit=$?"
show; expect "the operator close closes the decision" 1 no
say "6. second same-kind loss after the operator close"
lose_again
show; expect "a new escalation after the close appends and reopens the decision" 2 yes
say "7. retry of the reopened decision"
lose_again
show; expect "a retry of the reopened decision appends nothing" 2 yes
say "8. second operator close, then a third loss"
"$ROOT/bin/fm-send.sh" mate --resolve-key "pending-reply-$corr" "dismiss again"
echo "fm-send exit=$?"
expect "the second operator close closes the decision" 2 no
lose_again
show; expect "a third episode appends and reopens again" 3 yes
say "SUMMARY: $fails failed expectation(s)"
echo "DRIVER-DONE fails=$fails"
Evidence: Target commit: status log after the operator close and the second loss
blocked [key=pending-reply-2479caba13ba501e] [at=1791226744]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
resolved [key=pending-reply-2479caba13ba501e] [at=1791226750]: pending-reply-resolved: task=mate pending-reply-id=2479caba13ba501e via=operator-resolve-key dismiss the unknown-delivery hold
blocked [key=pending-reply-2479caba13ba501e] [at=1791226752]: pending-reply-delivery-unknown: task=mate pending-reply-id=2479caba13ba501e request=wake after lost transport
-- blocked lines for the key: 2
-- status_open_decisions: [pending-reply-2479caba13ba501e blocked pending-reply-delivery-unknown: ...]
RESULT ok - a new escalation after the close appends and reopens the decision (blocked lines=2, decision open=yes)
Evidence: Base commit: same step, the bug
blocked [key=pending-reply-5d6651d5e125bfbc] [at=1791226776]: pending-reply-delivery-unknown: ...
resolved [key=pending-reply-5d6651d5e125bfbc] [at=1791226782]: pending-reply-resolved: ... via=operator-resolve-key dismiss the unknown-delivery hold
-- blocked lines for the key: 1
-- status_open_decisions: []
-- record phase: escalated
RESULT FAIL - a new escalation after the close appends and reopens the decision (blocked lines=1 want 2, decision open=no want yes)
ℹ️ bin/fm-classify-lib.sh:581 - status_event_recorded ends an episode only on the resolve verb, while the fold (_fm_decision_fold_line, bin/fm-classify-lib.sh:889) also closes a key on a captain-held [key=K] line and on a ship or scout done/failed line. This does not affect the issue's key: a pending-reply key is reserved, and the transfer note tracked by ... written at bin/fm-captain-hold.sh:1803 fails _fm_decision_key_transition_allowed, so the fold never closes a pending-reply decision that way, and pending-reply escalations land on a secondmate status where done does not clear decisions. The gap is reachable only for an unreserved key that uses this dedupe: blocked [key=remote-reply-continuity-<id>] (bin/fm-procevent-remote-reply.sh:547), then a captain-held transfer closes it, then a later break with the same reason appends nothing. That sequence behaved the same before this change, so it is not a regression, and extending the rule to the held verb goes beyond the stated intent. Noted so the asymmetry with the comment's phrase when the fold would close on it is a known choice.
✅ **Test** - passed
✅ No issues found.
Live validation: ✅ go - 5 of 6 scenarios driven live against the product
Scenario
Result
Live
Evidence
Operator closes a pending-reply escalation, then the same kind of loss happens again: the status log gains a second blocked [key=pending-reply-<corr>] line and the decision is open again
✅ pass
live
live-target-22b5f0e9.log steps 5 and 6: blocked lines went 1 -> 2 and status_open_decisions listed the key again. live-base-e5b9dddc.log step 6 shows the bug on the base commit: blocked lines stayed…
A retry of an escalation whose decision is still open appends no duplicate line (first episode and reopened episode)
✅ pass
live
live-target-22b5f0e9.log steps 2 and 7: blocked lines stayed 1, then stayed 2, with the decision open both times.
Adversarial: a resolved line for a different key does not end the episode, so the next retry still appends nothing
✅ pass
live
live-target-22b5f0e9.log step 3: after resolved [key=scope], blocked lines stayed 1 and the decision stayed open.
Adversarial: a forged resolved [key=pending-reply-<corr>]: answered: ... line, which the reserved-key rule rejects, neither closes the decision nor allows a duplicate blocked line
✅ pass
live
live-target-22b5f0e9.log step 4: blocked lines stayed 1 and the decision stayed open.
The cycle repeats: a second operator close closes the reopened decision, and a third loss appends a third blocked line and opens it again
✅ pass
live
live-target-22b5f0e9.log step 8: fm-send exit=0, decision closed, then blocked lines=3 and the decision open. On the base commit the second close exited 1 because no decision was open.
Regression test for escalate, operator resolve, second escalate, as the maintainer asked
⏸️ untested
no
The prior payload did not establish a live result for this scenario. It recorded only a run of bash tests/fm-pending-reply.test.sh, which stubs tmux, so it is a unit test and not a drive of the real…
bash tests/fm-pending-reply.test.sh - passed, including test_same_kind_escalation_reopens_after_operator_close (stubbed tmux, not live)
Live on target 22b5f0e9: bash drive-reescalation.sh <worktree> <lab-home> inside a pane of tmux -L fm-lab with FM_HOME=<lab-home> - 0 failed expectations
Live on base e5b9dddc (git archive extracted into a temp lab directory): same driver - 4 failed expectations starting at the second loss, which reproduces issue 6635
Operator close through the real bin/fm-send.sh mate --resolve-key pending-reply-<corr> "dismiss the unknown-delivery hold" - exit 0 and a resolved ... via=operator-resolve-key line in the status log
Teardown: tmux -L fm-lab kill-server, bin/fm-lab-home.sh teardown, rm -rf of both lab directories; git status --short printed nothing
A retry of an open decision still appends nothing. A later same-kind escalation after a resolved line for that key appends again, so the next loss is visible.
Intent
Fixes #6635.
Contribute the fix for #6635, which the maintainer labelled ready-for-pr (contract class: restore): a second same-kind pending-reply escalation appends no status line after an operator close, so the second loss stays closed and invisible. The issue's expected behaviour: after the operator closes an escalation, a later escalation of the same kind appends a new
blocked [key=pending-reply-<corr>]line, and that line opens the decision again.The maintainer's triage: the status stream is an append-only keyed decision log where an open decision is one not yet resolved; a fresh escalation after a resolve should open it again. The dedupe is there for idempotent retries, not to suppress a new episode. It asks for regression coverage for escalate, operator resolve, second escalate.
What Changed
status_event_recordedinbin/fm-classify-lib.shnow treats a keyedneeds-decisionorblockedline as one episode of a decision: a later resolve line for the same key ends the episode, so the next identical line reads as new and is appended. A resolve for another key, or one the reserved-key rule rejects, does not end the episode, and every other kind of line (notes,done, unkeyed lines) stays recorded for the life of the file.blocked [key=pending-reply-<corr>]line and the decision opens again, while a retry of a still-open decision appends nothing. The header comment inbin/fm-pending-reply-lib.shdescribes this behaviour.tests/fm-pending-reply.test.sh, plus the episode rules intests/fm-classify-decision-key.test.shandtests/fm-classify-corr-token.test.sh.Risk Assessment
✅ Low: The change is a bounded edit to one shared retry check that satisfies the intent (retry of an open decision appends nothing, a same-key resolve the fold accepts makes the next identical opener append and reopen), and tracing every caller (pending-reply escalate, parent-channel append, continuity blocker, document note, captain-hold, inactive-outcome, merge-outcome) found no caller that replays a keyed opener after its resolve in a way that would wrongly reopen a decision.
Testing
I ran the three test files the change touches, and all passed, including the new regression test for escalate, operator resolve, second escalate. That regression test stubs tmux, so it is not a live result and its scenario is marked untested below. I then drove the product live in a disposable lab home (made by
bin/fm-lab-home.sh create) from a pane on the privatefm-labtmux socket, with the real clock and a grace period of 0. The driver used the watcher tickfm_pending_reply_tickto escalate, the realbin/fm-send.sh mate --resolve-keyas the operator close, andstatus_open_decisionsto read the open decisions. On the target commit every step passed: first loss, retry, two adversarial resolves, operator close, second loss reopening the decision, retry of the reopened decision, and a second close followed by a third loss. On the base commit the same driver failed at the second loss exactly as issue 6635 describes. There is no UI surface, so the evidence is the two CLI transcripts and the driver script. I killed the lab tmux server and removed both lab directories; the worktree is clean.blocked [key=pending-reply-<corr>]line and the decision is open againstatus_open_decisionslisted the key again. live-base-e5b9dddc.log step 6 shows the bug on the base commit: blocked lines stayed…resolvedline for a different key does not end the episode, so the next retry still appends nothingresolved [key=scope], blocked lines stayed 1 and the decision stayed open.resolved [key=pending-reply-<corr>]: answered: ...line, which the reserved-key rule rejects, neither closes the decision nor allows a duplicate blocked linefm-send exit=0, decision closed, then blocked lines=3 and the decision open. On the base commit the second close exited 1 because no decision was open.bash tests/fm-pending-reply.test.sh, which stubs tmux, so it is a unit test and not a drive of the real…Evidence: Live transcript on the target commit 22b5f0e (all expectations ok)
Source: Live transcript on the target commit 22b5f0e9 (all expectations ok)
Evidence: Live transcript on the base commit e5b9ddd (reproduces issue 6635)
Source: Live transcript on the base commit e5b9dddc (reproduces issue 6635)
Evidence: Driver script used for both runs
Source: Driver script used for both runs
Evidence: Target commit: status log after the operator close and the second loss
Evidence: Base commit: same step, the bug
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-classify-lib.sh:581- status_event_recorded ends an episode only on the resolve verb, while the fold (_fm_decision_fold_line, bin/fm-classify-lib.sh:889) also closes a key on acaptain-held [key=K]line and on a ship or scoutdone/failedline. This does not affect the issue's key: a pending-reply key is reserved, and the transfer notetracked by ...written at bin/fm-captain-hold.sh:1803 fails _fm_decision_key_transition_allowed, so the fold never closes a pending-reply decision that way, and pending-reply escalations land on a secondmate status wheredonedoes not clear decisions. The gap is reachable only for an unreserved key that uses this dedupe:blocked [key=remote-reply-continuity-<id>](bin/fm-procevent-remote-reply.sh:547), then a captain-held transfer closes it, then a later break with the same reason appends nothing. That sequence behaved the same before this change, so it is not a regression, and extending the rule to the held verb goes beyond the stated intent. Noted so the asymmetry with the comment's phrasewhen the fold would close on itis a known choice.✅ **Test** - passed
✅ No issues found.
blocked [key=pending-reply-<corr>]line and the decision is open againstatus_open_decisionslisted the key again. live-base-e5b9dddc.log step 6 shows the bug on the base commit: blocked lines stayed…resolvedline for a different key does not end the episode, so the next retry still appends nothingresolved [key=scope], blocked lines stayed 1 and the decision stayed open.resolved [key=pending-reply-<corr>]: answered: ...line, which the reserved-key rule rejects, neither closes the decision nor allows a duplicate blocked linefm-send exit=0, decision closed, then blocked lines=3 and the decision open. On the base commit the second close exited 1 because no decision was open.bash tests/fm-pending-reply.test.sh, which stubs tmux, so it is a unit test and not a drive of the real…bash tests/fm-pending-reply.test.sh- passed, includingtest_same_kind_escalation_reopens_after_operator_close(stubbed tmux, not live)bash tests/fm-classify-decision-key.test.sh- passedbash tests/fm-classify-corr-token.test.sh- passedLive on target 22b5f0e9:bash drive-reescalation.sh <worktree> <lab-home>inside a pane oftmux -L fm-labwithFM_HOME=<lab-home>- 0 failed expectationsLive on base e5b9dddc (git archiveextracted into a temp lab directory): same driver - 4 failed expectations starting at the second loss, which reproduces issue 6635Operator close through the realbin/fm-send.sh mate --resolve-key pending-reply-<corr> "dismiss the unknown-delivery hold"- exit 0 and aresolved ... via=operator-resolve-keyline in the status logTeardown:tmux -L fm-lab kill-server,bin/fm-lab-home.sh teardown,rm -rfof both lab directories;git status --shortprinted nothing✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.