Skip to content

fix(pi): route needs-decision signals directly to main - #3680

Closed
kunchenguid wants to merge 19 commits into
mainfrom
fm/fm-needs-decision-main-only-r1
Closed

kunchenguid wants to merge 19 commits into
mainfrom
fm/fm-needs-decision-main-only-r1

Conversation

@kunchenguid

@kunchenguid kunchenguid commented Sep 4, 2026 •

Copy link
Copy Markdown
Owner

Intent

Make every needs-decision event bypass the supervision branch and wake the main session directly, including product decisions, destructive choices, captain holds, second-mate escalations, and no-mistakes ask-user findings. Update watcher classification, branch-dispatch eligibility, documentation, generated Pi protocol, and tests so needs-decision signals are main-only while ordinary task-local heartbeat, signal, and stale routing remains unchanged. Keep the implementation narrowly limited to the signal path: do not extend it to stale, heartbeat, push-transition, or blocked events, and preserve normal branch routing for mixed queues containing routine notifications.

What Changed

  • Mark actionable needs-decision signal rows and exclude their status keys from supervision-branch eligibility.
  • Route signal closes containing those decision files directly to main while preserving routine signal, stale, and heartbeat routing in mixed queues.
  • Update Pi supervision documentation and add regression coverage for decision-only, mixed, and reconciliation-required signals.

Risk Assessment

✅ Low: The change is narrowly scoped, preserves heartbeat independence and mixed-queue ownership rules, and introduces no substantiated correctness or security defects.

Testing

Completed 1 recorded test check.

  • Outcome: ⏭️ skipped across 1 run (33m5s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed (4) ✅
  • 🚨 .pi/extensions/fm-primary-pi-watch.ts:626 - A mixed signal close does not wake main for its needs-decision row. Concrete path: task A appends needs-decision while task B emits a routine signal during the same grace window; A is excluded from the branch grant, B makes this offer eligible, and after successful branch settlement deliverActionableWake returns without calling sendWake. A remains queued but can stall indefinitely until an unrelated main turn or wake. Preserving B's branch routing while directly waking main for A requires coordinated split delivery/ownership behavior, so confirm and authorize that remedy rather than restoring the previously rejected whole-queue veto.

🔧 Fix: Split mixed decision wakes between branch and main
1 error still open:

  • 🚨 .pi/extensions/fm-primary-pi-watch.ts:623 - The trigger correlation is key-wide rather than row-specific. Concrete path: an unread routine signal row for task-a.status remains queued, then the same task raises a needs-decision and closes as signal: task-a.status. scopeForUnreadWake reports the routine row as eligible and also includes that key in needsDecisionKeys; this line consequently treats the single trigger key as needs-decision-only, marks the offer ineligible, and sends both rows to main. That violates the required mixed-queue behavior that routine notifications remain branch-eligible. Preserve both classifications for a key and split delivery whenever its unread rows include both ordinary and needs-decision signals.

🔧 Fix: Preserve same-key mixed signal routing
1 error still open:

  • 🚨 .pi/extensions/fm-primary-pi-watch.ts:657 - Mixed routine/needs-decision wakes still do not wake main directly: delivery awaits the supervision branch's full model turn before calling sendWake. A slow or indefinitely pending branch prompt therefore delays the decision indefinitely without error. The new test masks this by accepting with an already-resolved settlement. Concurrent split delivery needs coordinated grant, pending-wake, and rejection semantics, so please authorize that behavior rather than extending the fixer machinery implicitly.

🔧 Fix: Route mixed decision batches wholly to main
1 warning still open:

  • ⚠️ docs/supervision-protocols/pi.md:22 - The requested generated Pi protocol was not updated. Its event-ownership paragraph still only refers generically to “main-only rows,” without stating that a needs-decision signal makes its coalesced signal/stale batch main-owned while heartbeat scans remain independent. This leaves the generated runtime contract less specific than the new behavior documented in docs/pi-supervision-branch.md; add the authorized routing rule here.

🔧 Fix: Document needs-decision routing in Pi protocol
✅ Re-checked - no issues remain.

⏭️ **Test** - skipped
  • 🚨 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.

@greptile-apps

greptile-apps Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge based on the established current behavior.

No blocking failure remains.

Reviews (32): Last reviewed commit: "no-mistakes(ci): Fixed the CI failure by..." | Re-trigger Greptile

Comment thread .pi/extensions/fm-primary-pi-watch.ts Resolved
@kunchenguid
kunchenguid force-pushed the fm/fm-needs-decision-main-only-r1 branch from 779435c to 3128e41 Compare September 4, 2026 04:55
@kunchenguid kunchenguid changed the title fix: route every needs-decision wake directly to main fix: route needs-decision signals directly to main Sep 4, 2026
Comment thread .pi/extensions/fm-primary-pi-watch.ts Resolved
Comment thread .pi/extensions/fm-branch-supervision.ts Resolved
@kunchenguid
kunchenguid force-pushed the fm/fm-needs-decision-main-only-r1 branch from 2f75036 to cf96007 Compare September 4, 2026 07:48
@kunchenguid kunchenguid changed the title fix: route needs-decision signals directly to main fix(pi): route decision-bearing wakes directly to main Sep 4, 2026
@kunchenguid
kunchenguid force-pushed the fm/fm-needs-decision-main-only-r1 branch 2 times, most recently from 31ced07 to 46f0386 Compare September 4, 2026 08:55
@kunchenguid kunchenguid changed the title fix(pi): route decision-bearing wakes directly to main fix(pi): route needs-decision signals directly to main Sep 4, 2026
@kunchenguid
kunchenguid force-pushed the fm/fm-needs-decision-main-only-r1 branch 3 times, most recently from 4fc3972 to f5acdb9 Compare September 4, 2026 11:16
@kunchenguid kunchenguid changed the title fix(pi): route needs-decision signals directly to main fix(pi): keep needs-decision wakes on main Sep 4, 2026
@kunchenguid
kunchenguid force-pushed the fm/fm-needs-decision-main-only-r1 branch from 678a929 to 4fc3972 Compare September 4, 2026 11:55
Comment thread .pi/extensions/fm-branch-supervision.ts Resolved
@kunchenguid
kunchenguid force-pushed the fm/fm-needs-decision-main-only-r1 branch from 4fc3972 to b8493bd Compare September 4, 2026 12:29
@kunchenguid kunchenguid changed the title fix(pi): keep needs-decision wakes on main fix: route needs-decision wakes to the main session Sep 4, 2026
Comment thread .pi/extensions/fm-branch-supervision.ts Outdated
Comment on lines +1230 to +1232
if (scope.needsDecisionKeys.length > 0) {
throw new Error("a needs-decision row requires main to drain the complete wake queue");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Mixed queue vetoes supervision

When a routine signal or stale wake is accepted while an unrelated needs-decision row is unread, this whole-queue check rejects the accepted branch delivery, causing the routine row to fall back to the main session instead of remaining branch-eligible.

Suggested change
if (scope.needsDecisionKeys.length > 0) {
throw new Error("a needs-decision row requires main to drain the complete wake queue");
}

Knowledge Base Used: Watch and wake workflows

@kunchenguid
kunchenguid force-pushed the fm/fm-needs-decision-main-only-r1 branch from e7645b6 to 4fc3972 Compare September 4, 2026 12:56
A needs-decision status append is a captain call - a product decision,
a destructive-action confirmation, a captain-hold, a secondmate
escalation - and must reach main directly, the same way a check-kind
wake already does, instead of taking the supervision-branch hop first.

The watcher now marks a needs-decision row's queued payload
"needs-decision:" instead of the ordinary "signal:" (including when
the classifier wraps a rejected-key transition in its
"reconciliation-required: " prefix). The wake message text itself
never changes, so every other harness-arm script keeps seeing the same
"signal:<files>" shape. The branch dispatcher excludes that
payload-marked row from what the branch may claim (reporting it via a
new needsDecisionKeys field) without vetoing an unrelated eligible row
sharing the queue, and the watch extension cross-references the
current trigger's own file list against those keys to force that
delivery to main, exactly like a check-kind trigger.
The needs-decision detector previously re-split the joined multi-event
display text on literal " ; " and reparsed each chunk, which misreads
a routine status note that happens to contain that exact text (for
example "done: migration complete ; needs-decision: documented in
follow-up") as a real needs-decision event.

The classifier now sets its needs-decision flag per line while walking
the actual status file, before the events are joined for display, and
returns it through an explicit output parameter instead of being
reparsed from the lossy joined text.

Scope stays limited to the signal path: this does not change how
stale, heartbeat, captain-held, push-transition, or any other wake
kind is routed.
…rtial branch grants, leaving the complete queue claimable by the already-woken main turn. Added a behavioral regression and updated documentation. Resolved ShellCheck SC2031 lint failures with targeted suppressions. Verified CI-mode lint, focused regression, Pi watcher tests, watch triage tests, and Pi type checks. The full branch-extension suite encountered an unrelated stock-rendering assertion failure
@kunchenguid
kunchenguid force-pushed the fm/fm-needs-decision-main-only-r1 branch from 4fc3972 to 1b341e4 Compare September 4, 2026 13:30
@kunchenguid kunchenguid changed the title fix: route needs-decision wakes to the main session fix(pi): keep needs-decision signal wakes on main Sep 4, 2026
Comment thread .pi/extensions/fm-branch-supervision.ts Resolved
…ted routine rows remain branch-eligible while decision rows stay main-owned. Updated docs and added a behavioral regression proving the branch prompts, grants only routine rows, and rejects undelivered settlement for watcher fallback. Targeted regression, strict Pi typecheck, bash syntax, and diff checks pass. The full extension suite remains blocked by a pre-existing stock-rendering fixture mismatch. The no-mistakes attestation failure is external: its test phase was marked skipped and requires the outer pipeline to rerun it
…s now remain branch-eligible when coalesced with needs-decision files, while all-needs-decision signal closes still route to main. Added an end-to-end watcher regression and updated documentation. Verified the full Pi watcher-extension suite, strict Pi typecheck, ShellCheck, bash syntax, and git diff checks. The no-mistakes attestation failure is external pipeline state (`test` was skipped), not a code defect
Comment thread .pi/extensions/fm-primary-pi-watch.ts Resolved
Comment thread .pi/extensions/fm-primary-pi-watch.ts Resolved
@kunchenguid
kunchenguid force-pushed the fm/fm-needs-decision-main-only-r1 branch from 2d284a1 to 2a14ac7 Compare September 4, 2026 14:58
@kunchenguid kunchenguid changed the title fix(pi): keep needs-decision signal wakes on main fix(pi): route needs-decision signals directly to main Sep 4, 2026
Comment thread .pi/extensions/fm-primary-pi-watch.ts Resolved
…ows remain branch-eligible, while excluded decision rows wake main after branch settlement, including same-key mixed rows. Updated protocol docs and regression coverage. Pi watcher tests, strict typecheck, lint, syntax checks, and diff checks pass. The full branch-extension suite remains blocked by an unrelated stock-rendering fixture failure. The no-mistakes attestation failure is external because its test phase was skipped
Comment thread .pi/extensions/fm-primary-pi-watch.ts Resolved
…each main immediately without waiting for routine branch settlement; branch failures still re-wake main to avoid stranded rows. Added behavioral regression coverage and updated protocol docs. `tests/fm-pi-watch-extension.test.sh` and `bin/fm-lint.sh` pass. The no-mistakes attestation failure is pipeline-state-related, not a code defect
Comment thread .pi/extensions/fm-primary-pi-watch.ts Resolved
…ch failures now retain a replayable, main-only pending wake across delivery rejection or session replacement. Extended behavioral coverage to verify immediate decision delivery, preserved branch eligibility for routine rows, and retry after fallback rejection. `tests/fm-pi-watch-extension.test.sh`, `bin/fm-lint.sh`, and `git diff --check` pass. The branch-extension suite remains blocked by the pre-existing stock-render fixture failure. The no-mistakes attestation failure is pipeline-state-related, not a code defect
Comment thread .pi/extensions/fm-primary-pi-watch.ts Resolved
…jection now reuses an unconsumed main wake instead of submitting an identical concurrent follow-up. Updated behavioral coverage for the race. Verified Pi watcher tests, focused mixed-queue branch test, lint, and diff checks. The no-mistakes attestation failure is pipeline-state-related (`test` was skipped), not a code defect
Comment thread .pi/extensions/fm-primary-pi-watch.ts Resolved
…ocessing when branch rejection marks an in-flight main wake as main-only. Added regression coverage proving a rejected main delivery retries after grant release without concurrent duplication. Watcher tests, focused mixed-queue branch tests, lint, syntax, and diff checks pass. The no-mistakes attestation failure is external pipeline state (`test` skipped)
Comment thread .pi/extensions/fm-primary-pi-watch.ts Resolved
… signals now wait for the branch’s routine-row grant before waking main, preventing main from claiming the whole queue. Cleanup requests now reschedule while restoration is active, preserving retries after rejected main delivery. Added behavioral regression coverage. Verified fm-pi-watch-extension, targeted branch tests, shell syntax, diff checks, and fm-lint. The full branch suite still hits an unrelated pre-existing calm-rendering assertion. The no-mistakes attestation failure is pipeline state (test marked skipped), not a code defect
Comment thread .pi/extensions/fm-primary-pi-watch.ts Resolved
…running branch turn. Eligible routine rows are now reserved immediately, allowing main to receive decision rows without waiting while preserving branch ownership of routine rows. Added reservation cleanup, stale-owner recovery, documentation, and behavioral regressions. Relevant Pi watcher, branch routing, wake queue, typecheck, lint, and documentation checks pass. The no-mistakes attestation failure is pipeline-state related (test marked skipped), not a code defect
Comment thread .pi/extensions/fm-primary-pi-watch.ts Resolved
…on wakes by comparing the full pending state rather than token lists, preserving `mainOnly` mutations across session replacement. Added behavioral coverage proving the replacement reload wakes main without re-offering supervision. Pi watcher tests, targeted branch routing tests, lint, shell syntax, and diff checks pass. The no-mistakes attestation failure remains pipeline-state related (`test` skipped), not a code defect
…up errors from masking the intended lock-ownership fallback after supervision loses the fleet lock. Mixed queues still route routine rows to the branch and needs-decision rows to main. Focused branch regressions, the Pi watcher suite, lint, shell syntax, and diff checks pass. The no-mistakes attestation failure is pipeline-state-related because its test phase was skipped
@kunchenguid

Copy link
Copy Markdown
Owner Author

Superseded by #3776, which landed the needs-decision main-only routing with live validation. Closing per captain.

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.

1 participant