Skip to content

fix(bin): bound stale wakes for scouts parked on origin-held captain calls - #7983

Open
jrzimmerman wants to merge 6 commits into
kunchenguid:mainfrom
jrzimmerman:fm/fm-shipshape-fix
Open

jrzimmerman wants to merge 6 commits into
kunchenguid:mainfrom
jrzimmerman:fm/fm-shipshape-fix

Conversation

@jrzimmerman

@jrzimmerman jrzimmerman commented Oct 30, 2026 •

Copy link
Copy Markdown

Intent

lets continue with the firstmate issues and "Captain, shipshape." research investigation and fixes

Approved delivery: a PR to kunchenguid/firstmate from the jrzimmerman/firstmate fork, like the #7324 and #7325 fixes.

Context: firstmate's main session receives a repeated stale: <pane> wake every one to three minutes for a parked scout (plan-ytq-filters on pane default:w4:p1J, plan-autopopulate on default:w4:p1K) whose newest status line is an open needs-decision [key=board-review], and each wake forces a no-op Captain, shipshape. reply. Two finished investigations agree on the mechanism:

What Changed

  • Added a read-only fm-captain-hold.sh open-origin <origin-id> [--identity] predicate. It reports whether any open captain call is held on another task whose Captain hold origin: line names the origin, either as given or as its backend identity. The origin's own row is never counted. Exit codes are 0 yes, 1 no or no backlog file, 2 cannot tell. With --identity it prints the matching calls as <task-id>@<hold-set stamp>#<answer count>, sorted. The backlog resolution and call-identity code that open already had is now shared through open_backlog_resolve and open_call_identity.
  • task_captain_call_open in bin/fm-watch.sh now also asks open-origin, but only when the task's newest status line is an open needs-decision or blocked wait. Previously the bound only matched a call held on the task's own row. A scout parked on a call held for it on a separate task now gets the captain-call cadence for stale alarms, wedge escalations and open-decision reminders, so it no longer wakes the main session on every pane-hash change. A task still working beside such a call keeps its alarms. Both answers are combined into one identity (own=…;origin=…), so a new, released or re-held call on either side still alarms the first time it is seen.
  • Documented open-origin in docs/captain-hold-lifecycle.md (command table, exit codes, watcher use) and linked to it from the stale-pane bound in docs/architecture.md. Extended tests/fm-watch-open-decisions.test.sh and tests/fm-watch-triage-pause.test.sh to cover the origin-held case.

Risk Assessment

✅ Low: The change adds one read-only predicate, open-origin, and the watcher consults it only when the task's newest line is an open captain-relevant wait, as the recorded decisions require. Every failure path falls back to the alarms that fire today, the bound's identity now includes the origin-linked calls so a re-held call still alarms, and the new tests run the real watcher and tasks-axi for both the parked case and the working, other-origin and no-origin cases.

Testing

I ran the real fm-watch.sh and fm-captain-hold.sh against disposable homes using the real tasks-axi, in two ways: through the focused open-decision suite and the stale-churn suite, and by hand from the CLI. A parked needs-decision scout whose call is held on an origin-linked task surfaces once and then absorbs pane churn. A working scout, a call held for another origin, and a call with no origin all keep alarming on each new hash. A released and re-held call alarms again on first sight. An invalid origin slug or an unreadable backend gives exit 2 ("cannot tell"), never "no call". The new origin-linked test fails against the base commit's scripts, which confirms it reproduces the reported bug. I did not drive a Claude primary or a Herdr lab: this change only touches watcher and captain-hold CLI logic, which the real scripts exercise directly. Everything passed.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Parked scout (newest line needs-decision [key=board-review], call held on a separate --origin task): the real fm-watch.sh surfaces one stale wake, absorbs pane-hash churn after that, and re-surfaces o… ✅ pass live triage-pause-targeted.txt: test_open_captain_call_bounds_stale_churn, origin-decision case
Working scout beside an open origin-linked call: the wedge ladder and stale alarms still fire on every new hash, and the overdue reminder is not hidden ✅ pass live triage-pause-targeted.txt (origin-worker-line); open-decisions.txt test_origin_linked_captain_call
Adversarial: a call held for another origin, or with no origin, does not bound the scout's stale wakes ✅ pass live triage-pause-targeted.txt (elsewhere-decision, unrelated-decision); open-origin-cli-transcript.txt (open-origin plan-autopopulate exits 1)
Answering and releasing the origin-linked call, then re-holding it, is a new identity whose first sight alarms ✅ pass live triage-pause-targeted.txt; open-origin-cli-transcript.txt (identity changes from @...#0 to @...#1)
open-origin CLI contract: exit 1 when no call is held, exit 0 with an id@stamp#count identity when one is, exit 2 on an invalid slug or an unreadable backend ✅ pass live open-origin-cli-transcript.txt
Regression: the parked-scout bound fails on the base commit ✅ pass live open-decisions-on-base-commit.txt
Evidence: open-origin CLI transcript (hold --origin, open vs open-origin, release, re-hold identity, adversarial)

Source: open-origin CLI transcript (hold --origin, open vs open-origin, release, re-hold identity, adversarial)

# no calls held yet
$ fm-captain-hold.sh open-origin plan-ytq-filters --identity
[exit 1]
# hold the scout's call on a separate task with --origin (captain-hold-lifecycle shape)
$ fm-captain-hold.sh hold ytq-filters-design --title filters design call --reason awaiting captain board-review --origin plan-ytq-filters
ytq-filters-design
[exit 0]
# the scout's OWN row is not held (this is why the old bound never matched)
$ fm-captain-hold.sh open plan-ytq-filters
[exit 1]
$ fm-captain-hold.sh open-origin plan-ytq-filters --identity
ytq-filters-design@2026-11-15T06:28:06Z#0
[exit 0]
# a different origin is not matched
$ fm-captain-hold.sh open-origin plan-autopopulate
[exit 1]
# answer + release closes the call
$ fm-captain-hold.sh answer ytq-filters-design --decision-file /var/folders/rm/y8k0bw_x3qs_66fwtm0rbmn40000gn/T//fm-oo.hvAb/dec.txt --release
released: ytq-filters-design
[exit 0]
$ fm-captain-hold.sh open-origin plan-ytq-filters --identity
[exit 1]
# re-hold gives a new identity
$ fm-captain-hold.sh hold ytq-filters-design --reason awaiting captain on revised board
ytq-filters-design
[exit 0]
$ fm-captain-hold.sh open-origin plan-ytq-filters --identity
ytq-filters-design@2026-11-15T06:28:12Z#1
[exit 0]
# adversarial: bad origin slug
$ fm-captain-hold.sh open-origin bad id/../x
fm-captain-hold: origin id must be a non-empty privacy-safe slug: bad id/../x
[exit 2]
# adversarial: corrupt backlog root (cannot tell must not read as no call)
$ fm-captain-hold.sh open-origin plan-ytq-filters
fm-captain-hold: could not resolve the backend identity of plan-ytq-filters
[exit 2]
Evidence: Stale-churn watcher scenarios (targeted triage-pause tests)

Source: Stale-churn watcher scenarios (targeted triage-pause tests)

1..4
ok - work under an open captain call, on its own row or held for it as origin, surfaces once, absorbs pane churn, then re-surfaces when the window elapses
ok - a stale window with no open captain call keeps alarming on every new hash
ok - a released-then-re-held task is a distinct captain call whose first sight still alarms
ok - a captain-held secondmate re-surfaces on the bounded normal-mode cadence
FM_TEST_COMPLETE
bash $T/t.sh  63.04s user 75.14s system 56% cpu 4:05.80 total
Evidence: Open-decision reminder / wedge evidence suite on the change

Source: Open-decision reminder / wedge evidence suite on the change

1..17
ok - absent flag emits nothing and does not fold status
ok - oldest key surfaces once, and independent per-key backoff doubles up to its cap
ok - keys 1 and 01 receive separate reminders and retain independent bounded backoff
ok - tasks 1 and 01 receive separate reminders and retain independent bounded backoff
ok - resolution stops reminders immediately and a later episode starts fresh
ok - an origin-linked captain call bounds a parked scout and leaves a working one its alarms
ok - paused waits, verified transfers, and backlog captain holds are exempt
ok - captain-hold- keys are exempt by prefix while unrelated and prose-only keys still remind
ok - a structured [until=] date re-arms a relayed hold; prose never does and a malformed one re-arms at once
ok - an unchanged republish keeps its backoff while a changed verb or note restarts it
ok - a resolution and same-text reopen between ticks starts a fresh episode across a restart
ok - a republish keeps its opened time and takes the newest deferral date
ok - only explicitly keyed records with valid source timestamps are aged
ok - quiet polls reuse the timed fold and only new status bytes are folded
watcher: invalid open-decision reminder settings
watcher: open-decision backoff cap is below threshold
ok - invalid settings refuse the tick without queueing reminders
ok - task retirement removes the timed cursor and ends reminders
ok - the actual watcher wakes and exits on an overdue key without any recorded pane
FM_TEST_COMPLETE
bash tests/fm-watch-open-decisions.test.sh  10.12s user 11.16s system 82% cpu 25.899 total
Evidence: Same suite against base commit scripts: fails on the parked-scout case (reproduces the bug)

Source: Same suite against base commit scripts: fails on the parked-scout case (reproduces the bug)

not ok - a scout parked on its decision was not bounded by its origin-linked call

1..17
ok - absent flag emits nothing and does not fold status
ok - oldest key surfaces once, and independent per-key backoff doubles up to its cap
ok - keys 1 and 01 receive separate reminders and retain independent bounded backoff
ok - tasks 1 and 01 receive separate reminders and retain independent bounded backoff
ok - resolution stops reminders immediately and a later episode starts fresh
not ok - a scout parked on its decision was not bounded by its origin-linked call

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Parked scout (newest line needs-decision [key=board-review], call held on a separate --origin task): the real fm-watch.sh surfaces one stale wake, absorbs pane-hash churn after that, and re-surfaces o… ✅ pass live triage-pause-targeted.txt: test_open_captain_call_bounds_stale_churn, origin-decision case
Working scout beside an open origin-linked call: the wedge ladder and stale alarms still fire on every new hash, and the overdue reminder is not hidden ✅ pass live triage-pause-targeted.txt (origin-worker-line); open-decisions.txt test_origin_linked_captain_call
Adversarial: a call held for another origin, or with no origin, does not bound the scout's stale wakes ✅ pass live triage-pause-targeted.txt (elsewhere-decision, unrelated-decision); open-origin-cli-transcript.txt (open-origin plan-autopopulate exits 1)
Answering and releasing the origin-linked call, then re-holding it, is a new identity whose first sight alarms ✅ pass live triage-pause-targeted.txt; open-origin-cli-transcript.txt (identity changes from @...#0 to @...#1)
open-origin CLI contract: exit 1 when no call is held, exit 0 with an id@stamp#count identity when one is, exit 2 on an invalid slug or an unreadable backend ✅ pass live open-origin-cli-transcript.txt
Regression: the parked-scout bound fails on the base commit ✅ pass live open-decisions-on-base-commit.txt
  • bash tests/fm-watch-open-decisions.test.sh (all 17 tests, including test_origin_linked_captain_call)
  • Filtered copy of tests/fm-watch-triage-pause.test.sh running test_open_captain_call_bounds_stale_churn, test_stale_churn_without_a_captain_call_still_alarms, test_reheld_captain_call_starts_its_own_resurface_window, test_secondmate_captain_held_resurfaces_in_normal_mode
  • Manual CLI drive of fm-captain-hold.sh hold --origin / open / open-origin --identity / answer --release / re-hold against a disposable markdown backlog with real tasks-axi
  • Adversarial: open-origin with an invalid slug, and with a corrupt .tasks.toml backend
  • Regression: new tests/fm-watch-open-decisions.test.sh run against base commit 427056c4 scripts (git archive into a temp dir)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…an origin-linked task

A parked scout's captain call is held on a separate task recorded with
'Captain hold origin: <scout>', so the watcher's captain-call stale bound,
which only read the scout's own row, never matched and every pane tick
re-alarmed. Add a read-only 'fm-captain-hold.sh open-origin' lookup and have
the watcher fold its lifecycle identity beside the task's own hold.

Refs kunchenguid#6069
@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were established.

Reviews (1) · Last reviewed commit: "no-mistakes(lint): Rewrite origin match ..." · Reviewed by Greptile

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @jrzimmerman. The write-up is careful, and the base vs. fix lab runs with both controls make the mechanism easy to follow.

I read the full diff at head cd992acb against main 7647d6ba. It touches bin/ (fm-captain-hold.sh, fm-watch.sh), docs and tests only. There are no workflow, network or credential changes, so I approved the first-time fork CI runs.

The quick checks (coverage guard, repo invariants, no-mistakes) have since passed. The red "Full suite" check is just the gate for outside PRs. It needs a maintainer label, and that part is on us. Nothing is needed from you. After the full suite passes, this goes to the captain for the merge-or-leave call.

@jrzimmerman jrzimmerman changed the title fix(bin): bound stale alarms for scouts parked on a captain call held on another task fix(bin): bound stale wakes for scouts parked on origin-held captain calls Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants