Skip to content

fix(bin): exclude a remote mate's own parent channel from self-home status scans - #5263

Merged
kunchenguid merged 6 commits into
kunchenguid:mainfrom
kesslerio:fm/fm-parent-channel-scan-fix
Oct 1, 2026
Merged

kunchenguid merged 6 commits into
kunchenguid:mainfrom
kesslerio:fm/fm-parent-channel-scan-fix

Conversation

@kesslerio

@kesslerio kesslerio commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Exclude a remote mate's own parent channel when scanning that mate's home.

What Changed

  • Adds a home-shape-aware exclusion helper — fm_parent_channel_outbound_status() in bin/fm-parent-channel-lib.sh plus status_scan_parent_channel_exclude() in bin/fm-classify-lib.sh — that resolves a home's outbound parent-channel status path only for a remote mate (the same remote route verdict used by wrong-home detection); a main home, a local mate, or an unusable identity/binding resolves nothing, so nothing is excluded.
  • Every self-home status scan now skips exactly that resolved path (compared by path, never by file name): the watcher's scan_signals and heartbeat_scan_finds_actionable, the away-mode daemon's housekeeping catch-all heartbeat scan, and the fleet-wide folds scan_open_decisions, scan_open_decisions_incremental, status_presentation_snapshot, and scan_unread_surface_lines. A remote mate's state/parent-replies.status — already mirrored into the parent home by the reply adapter — no longer produces spurious signal wakes or a phantom parent-replies open decision, while a parent-replies.status in any other home shape still folds and wakes as an ordinary task log.
  • Adds tests/fm-parent-channel-scan-exclusion.test.sh (registered in bin/fm-test-run.sh, documented in docs/secondmate-parent-channel.md) covering real remote, main-home, and local-mate fixtures across all scans plus the real fm-wake-drain.sh end to end, and fixes a torn shared-clock race in the tests/fm-contributions.test.sh fake forge wrapper by publishing clock bumps through an atomic mktemp + mv instead of truncating in place.

Risk Assessment

✅ Low: The change is a narrowly scoped, home-shape-aware exclusion owned by one helper, applied at every wake- and fold-producing scan of a home's state dir, with fail-open defaults, main-home/local-mate negative cases, and end-to-end drain coverage; the only notes are informational and the bundled fixture fix touches no production code.

Testing

Per the recorded decision I did not build a lab, watcher, daemon, or new driver: the assigned scenario set was exercised by running tests/fm-parent-channel-scan-exclusion.test.sh from the repository root, which executes the real product modules (bin/fm-classify-lib.sh folds, bin/fm-watch.sh scan_signals and heartbeat backstop, bin/fm-supervise-daemon.sh housekeeping catch-all, bin/fm-parent-channel-lib.sh route resolution) and the real bin/fm-wake-drain.sh binary against disposable remote-mate, main-home, and local-mate fixtures. It passed on the first run and again after every probe, so no code was changed. Two scenarios count as live: the real drain binary executed as a subprocess over a hand-seeded remote mate home (fix active: genuine task only, manifest holds only real-task), and the adversarial probe that ran the actual watcher scan, daemon housekeeping, and drain as subprocesses with the fix suppressed, reproducing the leak the change targets. The other scenarios were driven by sourcing the real modules and calling their functions against fixtures — production code paths, but no running watcher or daemon process — so under the live-validation contract they are recorded as untested, not passed. To show the assertions are not decorative, the four changed bin files were reverted to the base commit (test then fails immediately: the exclusion helper does not exist). The process-level gap is a long-running watcher/away-mode daemon over a remote mate home across a full poll interval: the directive for this step ruled out standing one up, and two earlier rounds attempted exactly that and were cut off by the 1h invocation budget before producing a result.

  • Live validation: ⚠️ inconclusive - 2 of 9 scenarios driven live against the product
Scenario Result Live Evidence
An operator drains a remote mate home: the presentation shows the home's genuine task and never its own outbound parent channel ✅ pass live drain-remote-mate-home-fixed.out — real bin/fm-wake-drain.sh executed as a subprocess against a disposable remote mate home (.fm-secondmate-home + .fm-secondmate-parent route=remote); output lis…
The watcher's signal scan over a remote mate home emits no wake for the home's own parent channel and still emits wakes for the home's genuine task logs ⏸️ untested no Not driven against a live watcher process. The repo test sourced the real bin/fm-watch.sh and called scan_signals in-process over a fixture home, asserting the channel is skipped and the task logs sti…
A remote mate home goes away and its heartbeat fail-safe backstop stays quiet on the home's own channel while a genuinely blocked task still surfaces ⏸️ untested no Not driven against a live watcher process. The test invoked the watcher's own heartbeat_scan_finds_actionable directly — first with a channel-only actionable line, then with a blocked [key=wedge] li…
The away-mode daemon's catch-all scan over a remote mate home writes no channel escalation and records no phantom parent-replies task, while a blocked genuine task still escalates ⏸️ untested no Not driven against a live daemon process. The test sourced the real bin/fm-supervise-daemon.sh and ran its housekeeping as a single pass over a fixture home, asserting the escalation buffer and the pe…
Fleet-wide status folds for a remote mate home (whole-file, cursor-backed incremental, presentation snapshot, unread surface) omit the home's own parent channel and keep the genuine task's decision, n… ⏸️ untested no Not driven against a live product process. The real fm-classify-lib.sh fold entry points were executed over a seeded remote mate state dir and their returned lines asserted (whole-file, cursor-backed…
Adversarial: a file merely named parent-replies.status in a main home or in a local mate home is still folded, woken, and escalated as an ordinary task log ⏸️ untested no Not driven against a live product process. The home-shape boundary was exercised through the real modules and the daemon's catch-all pass inside the test harness — exclusion is keyed on the remote rou…
Adversarial: a remote mate home left behind by an older, unfixed watcher (channel already folded and tracked as a task) does not resurface the phantom through the fixed drain ⏸️ untested no Not driven live by me this run. The test seeded stale state (.parent-replies.open-decisions-cursor plus a parent-replies row in .status-presentation-cursor) in a fixture home and ran the real dr…
Adversarial regression proof: with the exclusion removed, the phantom channel returns through every consumer of a remote mate home ✅ pass live probe-exclusion-is-load-bearing.log — with status_scan_parent_channel_exclude reduced to return 0, scan_signals enumerated the channel, the daemon's housekeeping wrote a `parent-replies.status: ..…
A live long-running watcher/away-mode daemon over a real remote mate home stays quiet about the home's own parent channel across a full poll interval ⏸️ untested no Never driven live. The recorded decision for this step instructs: 'Do not create a lab, a watcher, a daemon, or a new driver. From the repository root run only: bash tests/fm-parent-channel-scan-exclu…
Evidence: Targeted test run at target commit (14 ok, exit 0)

Source: Targeted test run at target commit (14 ok, exit 0)

ok - only a remote mate home resolves its own parent channel for exclusion ok - fm_parent_channel_outbound_status resolves only the remote route ok - a remote mate's folds omit its channel and keep a genuine task ok - the cursor-backed incremental fold omits a remote mate's channel ok - the channel's resolution and note lines stay off the remote unread surface ok - a parent-replies.status in a main home still folds ok - a parent-replies.status in a local mate still folds ok - scan_signals skips a remote mate's channel and still reports its tasks ok - the heartbeat backstop skips a remote mate's channel and keeps its tasks ok - scan_signals keeps parent-replies.status outside remote mate homes ok - the daemon's catch-all scan skips a remote mate's channel and keeps its tasks ok - the daemon's catch-all scan keeps parent-replies.status outside remote mate homes ok - the real drain presents no channel content from a remote mate home ok - stale channel records from an older watcher are dropped, not presented

ok - only a remote mate home resolves its own parent channel for exclusion
ok - fm_parent_channel_outbound_status resolves only the remote route
ok - a remote mate's folds omit its channel and keep a genuine task
ok - the cursor-backed incremental fold omits a remote mate's channel
ok - the channel's resolution and note lines stay off the remote unread surface
ok - a parent-replies.status in a main home still folds
ok - a parent-replies.status in a local mate still folds
ok - scan_signals skips a remote mate's channel and still reports its tasks
ok - the heartbeat backstop skips a remote mate's channel and keeps its tasks
ok - scan_signals keeps parent-replies.status outside remote mate homes
ok - the daemon's catch-all scan skips a remote mate's channel and keeps its tasks
ok - the daemon's catch-all scan keeps parent-replies.status outside remote mate homes
ok - the real drain presents no channel content from a remote mate home
ok - stale channel records from an older watcher are dropped, not presented
Evidence: Real fm-wake-drain.sh output for a remote mate home (fix active): genuine task only, no parent-replies rows

Source: Real fm-wake-drain.sh output for a remote mate home (fix active): genuine task only, no parent-replies rows

UNREAD STATUS (new since last drain, not re-printed after this presentation): real-task note: benchmark results are in OPEN DECISIONS (still open, folded from the durable status logs - not just the latest line): real-task [key=api-shape] needs-decision: pick REST or RPC OPEN DECISIONS: close one by answering it: bin/fm-send.sh <task> --resolve-key <key> '<answer>' (persisted manifest .status-presentation-cursor: 'real-task\tstrong:...\t80\t0' — the only tracked row; parent-replies.status exists in that state dir and is not tracked or presented)

UNREAD STATUS (new since last drain, not re-printed after this presentation):
real-task note: benchmark results are in
OPEN DECISIONS (still open, folded from the durable status logs - not just the latest line):
real-task [key=api-shape] needs-decision: pick REST or RPC
OPEN DECISIONS: close one by answering it: bin/fm-send.sh <task> --resolve-key <key> '<answer>'
Evidence: Adversarial probe: with the exclusion helper neutered, the phantom returns via watcher, daemon catch-all, and drain

Source: Adversarial probe: with the exclusion helper neutered, the phantom returns via watcher, daemon catch-all, and drain

### watcher scan_signals over a remote mate home enumerated: .../watch/home/state/parent-replies.status => LEAK: channel enumerated ### away-mode daemon catch-all scan over a remote mate home escalation buffer: parent-replies.status: needs-decision [key=captain-hold-pr-7-1]: captain hold pr-7: merge the green PR? (catch-all scan) phantom seen-file: v2 r1:strong:... ### real fm-wake-drain.sh over a remote mate home drain says: 2:parent-replies note: the release branch is cut drain says: 4:parent-replies [key=captain-hold-pr-7-1] needs-decision: captain hold pr-7: merge the green PR? => LEAK: channel content presented ### fixed tree (helper active) for comparison channel lines in drain output: 0

1072:status_scan_parent_channel_exclude() {  # <state>
1073-  return 0
1074-  local state=$1 exclude
--- helper neutered (exclude resolves to nothing, as before the fix) ---

\### watcher scan_signals over a remote mate home
  enumerated: /var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T//fm-probe.z0vzKE/watch/home/state/parent-replies.status
  => LEAK: channel enumerated

\### away-mode daemon catch-all scan over a remote mate home
  escalation buffer: parent-replies.status: needs-decision [key=captain-hold-pr-7-1]: captain hold pr-7: merge the green PR? (catch-all scan)
  phantom seen-file: v2	r1:313832007374726f6e673a31363737373233313a3139343330343437363a313739303834373732392e30343731373736393300526567756c61722046696c653a313030363434002d007265616461626c65007265616461626c65	182@strong:16777231:194304476:1790847729.047177693

\### real fm-wake-drain.sh over a remote mate home
  drain says: 2:parent-replies note: the release branch is cut
  drain says: 4:parent-replies [key=captain-hold-pr-7-1] needs-decision: captain hold pr-7: merge the green PR?
  => LEAK: channel content presented

\### fixed tree (helper active) for comparison
  channel lines in drain output: 0
Evidence: Same test with the four changed bin files reverted to base commit (proves the test exercises the new code)

Source: Same test with the four changed bin files reverted to base commit (proves the test exercises the new code)

_: line 3: status_scan_parent_channel_exclude: command not found not ok - the remote mate's channel must resolve for exclusion, got rc=127

_: line 3: status_scan_parent_channel_exclude: command not found
not ok - the remote mate's channel must resolve for exclusion, got rc=127
- Outcome: ⚠️ 1 warning across 3 runs (2h9m45s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 3 infos
  • ℹ️ bin/fm-classify-lib.sh:1072 - Completeness check of the exclusion against every other enumeration of a home's state/*.status in a remote mate home. The wake- and fold-producing enumerations are all covered (bin/fm-classify-lib.sh:1091, :1386, :1405, :2021; bin/fm-watch.sh:1997 signal scan and :2266 heartbeat; bin/fm-supervise-daemon.sh:1350 catch-all), and the remaining ones produce neither a wake nor a phantom open decision, so the authorized failure is not reachable through them: bin/fm-fleet-ledger.sh:117 grown_logs (opt-in config/fleet-ledger only; records the channel's lines as task=parent-replies ledger rows), bin/fm-session-start.sh:927 (lists parent-replies.status under 'Orphan status logs' in the digest), bin/fm-captain-hold.sh:1823 diverged (still reads the channel's resolved line, so the RECORD DIVERGENCE section keeps working). All three are pre-existing and outside the stated intent. Related, also not required here: bin/fm-pending-reply-lib.sh:1362-1366 keeps a parallel basename-based copy of the same rule, which could now be routed through fm_parent_channel_outbound_status; its result is identical for the $sm_home/state layout, so it is a deduplication opportunity, not a defect. No action requested.
  • ℹ️ bin/fm-classify-lib.sh:1405 - Traced tradeoff, not a defect: while the channel is excluded, its per-task positions stop advancing, and status_acknowledge_presented_snapshot (bin/fm-classify-lib.sh:1816-1843) rebuilds state/.status-presentation-cursor from the snapshot, so the channel row is dropped (the new test pins this). state/parent-replies.status is append-only and never truncated (docs/remote-secondmates.md 'Source log continuity'), so if a live home ever stopped resolving route=remote, the next scan would re-fold the channel's whole history from offset 0 and print_unread_status_section (bin/fm-wake-drain.sh:426-450) prints unread lines with no byte cap. I checked whether that lapse is reachable by any intended caller and it is not: both writers publish .fm-secondmate-parent and .fm-secondmate-home atomically via tmp+mv at seed/provision time (bin/fm-home-seed.sh:973-979, bin/fm-remote-home-provision.sh:272-277) and no code path removes or re-routes a marker in place (teardown removes whole mate home dirs, bin/fm-teardown.sh:2591, :2597). Noting it so a future re-route/unesbind feature knows to retire the task via status_retire_presentation_task rather than let the backlog flood.
  • ℹ️ tests/fm-contributions.test.sh:614 - The branch also carries a fix unrelated to the stated intent: the fake forge wrapper's shared-clock bump now publishes via mktemp+mv instead of truncate-in-place. Verified as safe and fixture-only — base..target touches no production contributions code, bin/fm-contributions.sh:205/:381 keep reading date +%s unchanged, and the fake date at :637 always sees one complete value after the rename. One residual limitation worth knowing: the read-modify-write inside clock_bump is still non-atomic across processes, so two concurrent bumps can lose an increment; each fault pattern bumps a distinct endpoint (reserve/issues/9, exhaust/issues/8/comments, fail-late/pulls/8/reviews) and the assertions only need the budget to expire, so no assertion depends on both increments landing. Left in because it unblocks this run's CI shard; removal would restore the flake, so no action requested.
⚠️ **Test** - 1 warning
  • ⚠️ The Test agent did not finish within its invocation budget. Reported: agent run tests timed out after 1h0m0s: agent last produced output 5s ago (714 observed); agent reported: pi exited: exit status 143. This is a budget or provider-slowness cut, not a code failure. Re-running the same request costs another full budget, so no further attempt is made automatically. If this repository's targeted tests or evidence gathering routinely approach the default 30m0s, raise test_agent_timeout in global config. Respond with fix to spend another budget: a repair turn runs only for selected findings other than this budget cut, then validation re-runs. Or abort and retry after raising the budget.

🔧 No changes applied.
1 warning still open:

  • ⚠️ The Test agent did not finish within its invocation budget. Reported: agent run tests timed out after 1h0m0s: agent last produced output 20m25s ago (432 observed); agent reported: pi exited: exit status 143. This is a budget or provider-slowness cut, not a code failure. Re-running the same request costs another full budget, so no further attempt is made automatically. If this repository's targeted tests or evidence gathering routinely approach the default 30m0s, raise test_agent_timeout in global config. Respond with fix to spend another budget: a repair turn runs only for selected findings other than this budget cut, then validation re-runs. Or abort and retry after raising the budget.

🔧 No changes applied.
1 warning still open:

  • ⚠️ live validation verdict: inconclusive (2 of 9 scenarios were driven live against the product); untested: The watcher's signal scan over a remote mate home emits no wake for the home's own parent channel and still emits wakes for the home's genuine task logs, A remote mate home goes away and its heartbeat fail-safe backstop stays quiet on the home's own channel while a genuinely blocked task still surfaces, The away-mode daemon's catch-all scan over a remote mate home writes no channel escalation and records no phantom parent-replies task, while a blocked genuine task still escalates, Fleet-wide status folds for a remote mate home (whole-file, cursor-backed incremental, presentation snapshot, unread surface) omit the home's own parent channel and keep the genuine task's decision, note, and snapshot entry, Adversarial: a file merely named parent-replies.status in a main home or in a local mate home is still folded, woken, and escalated as an ordinary task log, Adversarial: a remote mate home left behind by an older, unfixed watcher (channel already folded and tracked as a task) does not resurface the phantom through the fixed drain, A live long-running watcher/away-mode daemon over a real remote mate home stays quiet about the home's own parent channel across a full poll interval
  • Live validation: ⚠️ inconclusive - 2 of 9 scenarios driven live against the product
Scenario Result Live Evidence
An operator drains a remote mate home: the presentation shows the home's genuine task and never its own outbound parent channel ✅ pass live drain-remote-mate-home-fixed.out — real bin/fm-wake-drain.sh executed as a subprocess against a disposable remote mate home (.fm-secondmate-home + .fm-secondmate-parent route=remote); output lis…
The watcher's signal scan over a remote mate home emits no wake for the home's own parent channel and still emits wakes for the home's genuine task logs ⏸️ untested no Not driven against a live watcher process. The repo test sourced the real bin/fm-watch.sh and called scan_signals in-process over a fixture home, asserting the channel is skipped and the task logs sti…
A remote mate home goes away and its heartbeat fail-safe backstop stays quiet on the home's own channel while a genuinely blocked task still surfaces ⏸️ untested no Not driven against a live watcher process. The test invoked the watcher's own heartbeat_scan_finds_actionable directly — first with a channel-only actionable line, then with a blocked [key=wedge] li…
The away-mode daemon's catch-all scan over a remote mate home writes no channel escalation and records no phantom parent-replies task, while a blocked genuine task still escalates ⏸️ untested no Not driven against a live daemon process. The test sourced the real bin/fm-supervise-daemon.sh and ran its housekeeping as a single pass over a fixture home, asserting the escalation buffer and the pe…
Fleet-wide status folds for a remote mate home (whole-file, cursor-backed incremental, presentation snapshot, unread surface) omit the home's own parent channel and keep the genuine task's decision, n… ⏸️ untested no Not driven against a live product process. The real fm-classify-lib.sh fold entry points were executed over a seeded remote mate state dir and their returned lines asserted (whole-file, cursor-backed…
Adversarial: a file merely named parent-replies.status in a main home or in a local mate home is still folded, woken, and escalated as an ordinary task log ⏸️ untested no Not driven against a live product process. The home-shape boundary was exercised through the real modules and the daemon's catch-all pass inside the test harness — exclusion is keyed on the remote rou…
Adversarial: a remote mate home left behind by an older, unfixed watcher (channel already folded and tracked as a task) does not resurface the phantom through the fixed drain ⏸️ untested no Not driven live by me this run. The test seeded stale state (.parent-replies.open-decisions-cursor plus a parent-replies row in .status-presentation-cursor) in a fixture home and ran the real dr…
Adversarial regression proof: with the exclusion removed, the phantom channel returns through every consumer of a remote mate home ✅ pass live probe-exclusion-is-load-bearing.log — with status_scan_parent_channel_exclude reduced to return 0, scan_signals enumerated the channel, the daemon's housekeeping wrote a `parent-replies.status: ..…
A live long-running watcher/away-mode daemon over a real remote mate home stays quiet about the home's own parent channel across a full poll interval ⏸️ untested no Never driven live. The recorded decision for this step instructs: 'Do not create a lab, a watcher, a daemon, or a new driver. From the repository root run only: bash tests/fm-parent-channel-scan-exclu…
  • bash tests/fm-parent-channel-scan-exclusion.test.sh (from the repository root, target commit 1109508) — 14/14 ok, exit 0; re-run after all probes, still exit 0
  • git checkout 549e07f37 -- bin/fm-classify-lib.sh bin/fm-parent-channel-lib.sh bin/fm-supervise-daemon.sh bin/fm-watch.sh &amp;&amp; bash tests/fm-parent-channel-scan-exclusion.test.sh — fails with status_scan_parent_channel_exclude: command not found (rc 127), then restored with git checkout HEAD -- &lt;same paths&gt;: the test depends on the new exclusion code, it is not vacuous
  • PROBE_ROOT=&#34;$PWD&#34; bash $EV/probe-exclusion-is-load-bearing.sh — temporarily neutered status_scan_parent_channel_exclude to return 0 (pre-fix behavior) and re-ran the real consumer paths, then restored the file byte-for-byte
  • FM_ROOT_OVERRIDE=&lt;inert&gt; FM_STATE_OVERRIDE=&lt;remote-mate&gt;/state FM_HOME=&lt;remote-mate&gt; bin/fm-wake-drain.sh against a hand-seeded disposable remote mate home — captured user-visible drain output and the persisted .status-presentation-cursor manifest
⚠️ **Document** - 1 info
  • ℹ️ bin/fm-session-start.sh:927 - Judgment call on the new invariant's scope, not a doc defect: the session-start digest's 'Orphan status logs (state/.status without matching .meta)' section enumerates "$STATE"/.status with no channel exclusion, so a remote mate home's startup digest still prints its own parent channel as an orphan task row named parent-replies. No maintained doc claims otherwise (docs/configuration.md only bounds the tail length), and docs/secondmate-parent-channel.md states the new contract as an explicit enumeration of the scans that exclude the resolved path, so nothing is factually wrong today. If the human decides the digest belongs to the same invariant, the fix is code plus one clause appended to that owner sentence; declining leaves the owner sentence accurate as written.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kesslerio
kesslerio force-pushed the fm/fm-parent-channel-scan-fix branch from 1515bf7 to ff1673b Compare September 22, 2026 11:30
@kesslerio kesslerio changed the title fix(bin): exclude a remote mate's parent channel from its own status scans fix(bin): exclude a remote mate's own parent channel from self-home scans Sep 22, 2026
@kesslerio

Copy link
Copy Markdown
Contributor Author

Friendly nudge on this one. It fixes the remote parent-channel scan gap from #5012: a remote mate's own replies.status was being swept by its parent's signal scan, which produced phantom needs-decision events. It has been open a little while, so if anything here needs changing to fit how you want it done, tell me and I will rework it.

@dsdevq

dsdevq commented Sep 30, 2026

Copy link
Copy Markdown

Field evidence for this fix from a production remote second mate, plus an offer of one more regression test.

Cost observed. On 2026-09-29 a remote second mate home spent 35 turns and 138 model calls waking on nothing but its own state/parent-replies.status appends. Those rows carry no task metadata, so they also re-surfaced as check: rearm-resurface wakes. They also make the supervision host's offer rule mark the whole scan unsafe, so routine wakes on that home can never be handed off.

End-to-end reproduction on current main (eb77f02). A remote-route mate home runs the real bin/fm-watch.sh with a child whose terminal ledger line the inactive reconcile publishes to the parent channel. Then bin/fm-secondmate-report.sh done <corr> ... and a charter-style echo 'needs-decision [key=...]: ...' >> state/parent-replies.status append more lines.

  • The unfixed watcher exits with signal: .../state/parent-replies.status.
  • With only the signal scan fixed, the heartbeat backstop exits with heartbeat.
  • fm-supervise-daemon.sh housekeeping escalates parent-replies.status: needs-decision ... (catch-all scan).

This matches the three scan sites this PR covers. On the drain folds: the parent's --resolve-key answer lands only in the parent's copy, so without your fold exclusion, a mate's upward needs-decision stays open forever in its own OPEN DECISIONS.

Offer. We have a regression test that drives the real watcher through all three writers above (publisher, report helper, raw echo). With FM_HEARTBEAT=1 it also asserts that the watcher stays alive and that no parent-replies row reaches the wake queue. It fits tests/fm-inactive-reconcile.test.sh next to test_watcher_poll_delivers_child_ledger_line_to_parent. Happy to contribute it here, or as a follow-up once this lands.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Excludes a remote mate's parent channel from status scans.

The production change appears safe to merge; the only remaining concerns are non-blocking cleanup artifacts from the two existing review threads.

Reviews (2) · Last reviewed commit: "no-mistakes(document): drop stale file-s..."

Comment thread bin/fm-classify-lib.sh
for f in "$state"/*.status; do
[ -e "$f" ] || continue
[ "$f" = "$exclude" ] && continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Legacy cursor remains orphaned

A remote mate upgraded from an older version can already have .parent-replies.open-decisions-cursor. This new early continue skips that file before cursor reconciliation, while drain-time cleanup never removes it. The cursor cannot surface channel content, but it remains as an inert file for the lifetime of the home. Please retire the excluded channel's cursor when resolving this special path.

Comment on lines +34 to +35
cleanup() { rm -rf -- "$TMP_ROOT"; }
trap cleanup EXIT

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Cleanup leaks temporary directory

This test registers both TMP_ROOT and FM_ROOT_OVERRIDE through fm_test_tmproot, but this custom EXIT trap replaces the shared cleanup and removes only TMP_ROOT. Every run therefore leaves FM_ROOT_OVERRIDE behind until orphan reaping. Use fm_test_cleanup so all registered temporary roots are removed.

Suggested change
cleanup() { rm -rf -- "$TMP_ROOT"; }
trap cleanup EXIT
cleanup() { fm_test_cleanup; }
trap cleanup EXIT

…cans

A remote secondmate home's outbound parent channel lives at state/parent-replies.status inside its own state dir, so the watcher's signal scan enumerated it as a task status file and the open-decisions fold classified it as a phantom task named parent-replies: every parent-channel append spun a spurious signal wake and a phantom open decision in the mate's own home.
fm-parent-channel-lib.sh gains fm_parent_channel_outbound_status, which resolves the channel into the mate's own state dir for the remote route only, and fm-classify-lib.sh's status_scan_parent_channel_exclude wraps it for the fleet-wide scans.
The watcher's scan_signals and heartbeat fail-safe backstop, the whole-file and incremental open-decisions folds, the presentation snapshot, and the unread-surface scan now skip exactly that resolved path.
The exclusion is home-shape-aware: a parent-replies.status in a main home or a local mate is an ordinary task log and keeps waking and folding, and every other status file is untouched.
…s/fm-contributions.test.sh ('reservation poll failed'). CI stderr showed bin/fm-contributions.sh:345 arithmetic 'DEADLINE - 6\n90077104: syntax error in expression': the fixture's fake date returned a torn two-line clock value. Root cause: the fake forge wrapper in wrap_forge advances the shared controllable clock via a non-atomic read-modify-write ('$(cat $FORGE/clock) + 6' with truncate-in-place '> $FORGE/clock') while concurrent background gh calls run and the fake date reads the same file; an interleaved truncate+write publishes a half-written value (CI's torn '6\n90077104', tail of 1790077104) or an emptied-read value ('6'), which either breaks the poll's arithmetic (nonzero exit -> 'reservation poll failed') or defeats the 15-second reservation defer. This is a pre-existing test-fixture race, not caused by the PR's diff (base..target touches no contributions code; the same commit passed this shard in run 35711207830 earlier the same day). Fixed the flaky fixture at its root: clock_bump() now writes each new value to a per-process mktemp file in the same directory and publishes it with mv (atomic rename), so concurrent forge callers and the fake date always read one complete old-or-new clock; fault patterns and deltas are unchanged. Verified: minimal 3-way concurrency repro shows the old wrapper corrupting (12/32/38 outcomes incl. empty-read) while the rename-based wrapper never corrupts (20/20 clean); the full tests/fm-contributions.test.sh passes twice (all 38 assertions ok, incl. the reservation, budget-exhaustion, genuine-failure, shared-once, and latency tests); 10 isolated reservation runs pass; shellcheck rc=0; worktree contains only this one-file change
@kesslerio
kesslerio force-pushed the fm/fm-parent-channel-scan-fix branch from 6ab68aa to c7df8ef Compare October 1, 2026 10:02
@kesslerio kesslerio changed the title fix(bin): exclude a remote mate's own parent channel from self-home scans fix(bin): exclude a remote mate's own parent channel from self-home status scans Oct 1, 2026

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: first stamp vs tip 549e07f37fd73aa01d74cd126b1111c99175abed. Body intent is the remote parent-channel scan gap from #5012 (field cost: phantom wakes on own parent-replies.status); GitHub closing refs empty (no Fixes keyword).

HEAD c7df8ef2a78da75960326c6993b502e07d3d07a3. Attestation MATCH. NM SUCCESS. Greptile SUCCESS 5/5 (P2: orphaned .parent-replies.open-decisions-cursor on upgrade; test EXIT cleanup uses custom trap — non-blocking). Behavior portable + Herdr green so far; Lint 1/2 and several serial shards still pending at stamp time.

contract-class: restore — tip still folds/wakes a remote mate's own outbound state/parent-replies.status as if it were a self-home task log, against the already-specified parent-channel design (remote reply adapter mirrors into the parent home; wrong-home detection already special-cases this path). Home-shape-aware status_scan_parent_channel_exclude restores that contract at every wake/fold scan.

VISION (compressed): One captain/interface — aligns (removes phantom captain-facing wakes/decisions). Authority — aligns (no new autonomy). Scripts/judgment — aligns. Restart — aligns (durable channel unchanged; scans skip correctly). Delegation — aligns (less noise). Fleet/vendor — aligns (secondmate remote route). Scope — aligns.

Needed: finish green CI (esp. Lint). If fully green with MATCH + CLEAN/MERGEABLE, this is auto-merge eligible as restore. Firstmate flag no. Workflow approvals this pass: none.

@kunchenguid
kunchenguid merged commit f593060 into kunchenguid:main Oct 1, 2026
21 checks passed

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @kesslerio — really appreciate you taking the time on this.

CI finished fully green (Lint 1/2 + all Behavior portable + Herdr + Greptile SUCCESS). Attestation MATCH. Squash merge f593060312a48dab651138e6e705147358eba5ce (was 1 commit behind tip after #6221; squash landed cleanly).

Firstmate flag no.