Skip to content

fix: prevent stale supervision wake loops - #3672

Merged
kunchenguid merged 3 commits into
mainfrom
fm/fm-3604-cleanslate-fable-r1
Sep 4, 2026
Merged

kunchenguid merged 3 commits into
mainfrom
fm/fm-3604-cleanslate-fable-r1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

Captain: "gotcha, now it's ok to proceed. we should have the fable crewmate do a clean slate implementation on just the necessary parts and supersede it."

This is a CLEAN-SLATE reimplementation that supersedes PR #3604. PR #3604 over-built: an independent fidelity review found it correct in its first commit for items 1, 2, 3, and 7 but then piled on a locking machine, spawn-generation binding, a retired-task refusal (a real regression), and a teardown lock boundary that all should have stayed out. Do NOT cut back or touch the old PR - leave #3604 as-is; this is a FRESH branch from main implementing ONLY the necessary parts, which firstmate will use to supersede #3604.

Implement ONLY items 1, 2, 3, and 7 from the review (data/fm-3604-fidelity-complexity-s1/report.md), in their minimal first-commit form: (1) no speculative reports - a signal or stale wake reports only the tasks its own rows resolve to; (2) the exact ack command; (3) silence the false queued-wakes warning for the row being handled under the branch supervision actor; (7) teardown drops the leftover index, plus the one append-side index skip the review says item 7 needs. NO extra locking, NO spawn-generation binding, NO retired-task refusal, NO teardown lock boundary. Keep it minimal.

Firstmate's later decisions on the first review round, applied as the second commit: a signal or stale prompt reports only the tasks its own rows resolve to and fleet is refused there too; a heartbeat review is not scoped by task and refuses nothing by task id (no retired-task refusal); the outcome-index rebuild keeps no retired-task skip, the single append-side index skip is the one item-7 fix; the guard keeps the queued-wakes warning silent for the branch actor rather than printing a replacement note.

What Changed

  • Restrict signal and stale wake reports to tasks resolved from their claimed rows, including refusing fleet reports; heartbeat reviews remain unscoped.
  • Make no-op stale acknowledgements print the exact command for the current wake, and silence queued-wake warnings for the branch actor.
  • Remove retired tasks’ outcome indexes during teardown and avoid recreating them from post-teardown reports.

Risk Assessment

✅ Low: The change is narrowly scoped, matches the authoritative intent, and includes behavior-level regression coverage for report scoping, exact stale-ack recovery, guard silence, and teardown index cleanup.

Testing

Completed 1 recorded test check.

  • Outcome: ⚠️ 1 error across 1 run (42m37s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 error
  • 🚨 tests failed with exit code 1
  • bin/fm-test-run.sh --changed --exclude-family real-herdr-gated
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Clean-slate implementation of the four authorized recommendations from the
supervision-ghost-retrigger analysis (items 1, 2, 3, and 7), in their minimal
form, superseding PR #3604:

- fm_branch_report refuses a task the wake being handled never named. The
  extension fixes the reportable task set from the eligible rows before each
  prompt (signal and stale rows resolve to their tasks, a heartbeat allows any
  task with a live record, fleet is always allowed), so a report typed from
  memory about a task whose records teardown already removed is never stored
  or delivered.
- An acknowledgement that consumes nothing says "nothing was acknowledged
  through N" and prints the exact --ack-through / --recovery-generation
  command for the current presented wake, instead of "re-run the drain",
  which re-fed the same stale acknowledgement in a loop.
- bin/fm-guard.sh no longer tells the branch actor to drain queued wakes
  while it is handling them; it names the granted rows instead.
- Teardown removes state/.<task>.branch-outcome-index for ordinary tasks and
  descendants; the index rebuild and the append-side index write both skip a
  task with neither a live record nor a status log, so the branch's report of
  a teardown it just performed is stored without recreating the index.

No new locking, no spawn-generation binding, and no retired-task refusal: the
branch can still report the outcome of a task it just tore down, and the
teardown test now proves that path end to end.
…imal form

Apply the four review decisions on the clean-slate branch:

- A signal or stale prompt may report only the tasks its own rows resolve
  to; fleet is refused there too. A heartbeat review is not scoped by task
  at all, so the extension no longer tracks live task records and refuses
  nothing by task id during a fleet review.
- The outcome-index rebuild no longer skips retired tasks; the append-side
  skip alone keeps a torn-down task's index from being recreated.
- bin/fm-guard.sh keeps the queued-wakes warning silent for the branch actor
  instead of printing a replacement note.
@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge based on the reviewed changes, with no concrete changed-code defect identified.

The task-scoping, acknowledgement recovery, guard suppression, and teardown-index changes preserve row ownership and durable wake behavior across the reachable paths examined.

Reviews (1): Last reviewed commit: "no-mistakes(document): Align supervision..." | Re-trigger Greptile

@kunchenguid
kunchenguid merged commit f4d7875 into main Sep 4, 2026
15 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-3604-cleanslate-fable-r1 branch September 4, 2026 00:20
Puneet-Patwari pushed a commit to Puneet-Patwari/firstmate that referenced this pull request Sep 4, 2026
* fix(bin): stop the supervision branch's stale-ack and ghost-report loops

Clean-slate implementation of the four authorized recommendations from the
supervision-ghost-retrigger analysis (items 1, 2, 3, and 7), in their minimal
form, superseding PR kunchenguid#3604:

- fm_branch_report refuses a task the wake being handled never named. The
  extension fixes the reportable task set from the eligible rows before each
  prompt (signal and stale rows resolve to their tasks, a heartbeat allows any
  task with a live record, fleet is always allowed), so a report typed from
  memory about a task whose records teardown already removed is never stored
  or delivered.
- An acknowledgement that consumes nothing says "nothing was acknowledged
  through N" and prints the exact --ack-through / --recovery-generation
  command for the current presented wake, instead of "re-run the drain",
  which re-fed the same stale acknowledgement in a loop.
- bin/fm-guard.sh no longer tells the branch actor to drain queued wakes
  while it is handling them; it names the granted rows instead.
- Teardown removes state/.<task>.branch-outcome-index for ordinary tasks and
  descendants; the index rebuild and the append-side index write both skip a
  task with neither a live record nor a status log, so the branch's report of
  a teardown it just performed is stored without recreating the index.

No new locking, no spawn-generation binding, and no retired-task refusal: the
branch can still report the outcome of a task it just tore down, and the
teardown test now proves that path end to end.

* fix(bin): narrow the branch report scope and guard silence to the minimal form

Apply the four review decisions on the clean-slate branch:

- A signal or stale prompt may report only the tasks its own rows resolve
  to; fleet is refused there too. A heartbeat review is not scoped by task
  at all, so the extension no longer tracks live task records and refuses
  nothing by task id during a fleet review.
- The outcome-index rebuild no longer skips retired tasks; the append-side
  skip alone keeps a torn-down task's index from being recreated.
- bin/fm-guard.sh keeps the queued-wakes warning silent for the branch actor
  instead of printing a replacement note.

* no-mistakes(document): Align supervision docs with scoped wake handling
Valentino-Sole added a commit to Valentino-Sole/firstmate that referenced this pull request Sep 4, 2026