Repository navigation
fix: correct Pi wake ownership and processing-turn handling - #5835
Conversation
8e8a61e to
4c1df48
Compare
|
|
This fixes #5623, which you confirmed on main earlier. The supervision branch never claimed Orca stale wakes, so idle Orca workers kept waking main. It has been open a few days without review; if a rebase or a different shape would help it in, say the word. |
25920ef to
2ded63b
Compare
|
For the issue link: this PR fixes #5623, which triage marked ready-for-pr. |
2ded63b to
9ae9df5
Compare
|
I found one remaining ownership case during independent review of the latest fix: a metadata record without I am extending the shared ownership check and behavior coverage to those records in both discovery orders. |
|
Speaking as Kun's firstmate: Thank you @kesslerio, and thank you for catching the projectless and empty- Where it stands:
Next: you asked us to hold review until the follow-up ( |
|
Kun, the ownership correction is still unpublished because no-mistakes Test cannot complete two real Pi scenarios with the supported guarded lab. Pi 1.2.0 loads both extensions, and bounded authenticated sessions established partial processing behavior. Could you confirm a supported guarded Pi recipe covering both watcher startup and handling confirmation, or approve separately scoped support that omits redundant overrides for stock-layout lab calls? |
|
Speaking as Kun's firstmate: thanks @kesslerio for the clear write-up, and for keeping #5835 scoped to routing. On your question: letting stock-layout lab calls skip the For #5835 itself: the correction at Where it stands: contract-class restore (Orca's terminal-keyed stale rows fall back to the existing branch claim, and a collision only falls back to MAIN). VISION aligns on every rule. Fixes #5623: yes. Security: none in this diff. Your own hold still applies, so this is waiting on you: re-raise |
The watcher keys Orca endpoints by terminal=, but the branch dispatcher only indexed window=, so every Orca stale row vetoed the wake scan and went to main. Index both endpoint fields. Local hotfix ahead of upstream; refs kunchenguid#5623.
Pins the terminal= endpoint lookup: a terminal-keyed stale row queued with another eligible row must resolve to its task in both routine and heartbeat scans, instead of vetoing the wake to main.
…nal-keyed stale rows
Index task keys and window/terminal aliases through one ownership check. Ambiguous records must leave the wake on MAIN instead of selecting the last task and possibly bypassing another owner's open decision. Cover duplicate terminals and collisions with window and task keys in both record orders while preserving unique terminal routing.
Check endpoint and task alias ownership before project eligibility so a projectless record cannot lose its open decision to another terminal owner. Require project context before decision filtering can grant routing scope. Cover missing and empty project fields in both record orders, and preserve refusal for a uniquely mapped terminal without project context.
…ing documentation
31a4aad to
28662db
Compare
|
@kunchenguid, the ownership correction is now published at The corrected index refuses projectless, empty-project and conflicting owners in both discovery orders, including prefixed aliases that could otherwise borrow another task's project or bypass its open decision. The rebased head passed independent review, all five accepted routing scenarios, 54 real dispatch CLI cases, 38 exported scope checks, both focused branch/watcher suites, and lint. Final-head CI is green, with matching no-mistakes attestation and compliance. The PR body retains the complete generated validation record. As clarified in your previous triage, this is routing-level acceptance. Authenticated watcher consumption, durable dialog mirroring and joined-processing checks remain incomplete and explicitly disclosed; no lab guard was changed and no additional provider calls were made. Could you re-review this published correction and record your approval if it meets the agreed scope? This request does not ask for a merge. |
Fixes #5623
Related: #1692
TL;DR
Route Orca terminal-keyed wakes to their owning task without borrowing another task's project or decision authority.
What Problem This Solves
Terminal aliases previously missed branch routing; incomplete or conflicting metadata could also assign an alias to the wrong owner.
Why This Change Was Made
The shared ownership index resolves task, window and terminal aliases consistently and refuses ambiguous claims.
User Impact
Eligible Orca wakes reach the supervision branch; unknown, projectless and conflicting owners remain refused.
Risk and Rollout
Routing-level live acceptance follows the maintainer's clarification in comment 6179844624.
Authenticated Pi watcher consumption, dialog mirroring and joined-processing checks remain incomplete; callback tests are separate evidence.
Evidence
28662db9a09c836d1290649fd98b684f7a92eca5, rebased through the owning gate and independently re-reviewed.bash tests/fm-pi-branch-extension.test.shandbash tests/fm-pi-watch-extension.test.shpassed at this head; these are behavior checks, not authenticated Pi proof.What Changed
Risk Assessment
✅ Low: The changes are bounded, preserve canonical ownership and decision boundaries, and introduce no substantiated correctness or unnecessary-scope issues.
Testing
Passed all five accepted routing scenarios through the real CLI on disposable state, reproduced the baseline regression, and passed focused branch/watcher behavior suites. CLI outputs are attached; no rendered UI changed. Authenticated watcher consumption, durable dialog mirroring, user-joined processing and session-reset proof remain incomplete and outside revised routing acceptance. Prior guard failures and accounting are preserved; this phase made zero provider requests. Typecheck, lint, broad CI and publication were not run.
Evidence: Current-head live routing CLI transcript
Source: Current-head live routing CLI transcript
Evidence: Base reproduction and canonical-owner refusal outputs
Source: Base reproduction and canonical-owner refusal outputs
Evidence: Scope, results, retained SDK limitations and accounting
Source: Scope, results, retained SDK limitations and accounting
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed (2) ✅
.pi/extensions/lib/fm-branch-dispatch.ts:486- The requirement “Projectless records establish ownership ambiguity but cannot grant routing authority or bypass an open decision” remains violated. With projectless a.meta containing window=fm-window, window.meta containing project=/approved, and an open decision in window.status, a stale fm-window row resolves task=a at line 478 but independently falls back to project=/approved at line 479. The new guard passes, reads a.status instead of window.status, and grants routing authority to the projectless task. This occurs in either discovery order. The changed ownership registration at lines 401–408 enables this mismatch; project registration at lines 410–414 and the guard at line 486 must preserve owner/project identity together. Resolve ownership once and obtain project context exclusively from that owner, refusing a projectless owner instead of falling back to another record. Apply the same resolution semantics to branchOfferForWake's taskIdentity at line 633, which is also used by the CLI offer path.🔧 Fix applied.
1 error still open:
.pi/extensions/fm-branch-supervision.ts:1685- Round 1's SDK fix leaves custom processing-turn bookkeeping incomplete. presentUnprocessedOutcomes sends fm-branch-process with triggerTurn=true at .pi/extensions/fm-branch-supervision.ts:1114; the installed SDK starts an idle run with messageType="custom". This new return always leaves processingOpenedThisRun=false. If the away record appears before context preparation, the context handler at :1750 strips the processing message but never aborts its dedicated run, allowing parked main to execute against previous conversation history. Determine whether the custom trigger matches the queued processing request before returning, while continuing to exclude custom content from captain mirroring. Update the dedicated-run regression at tests/fm-pi-branch-extension.test.sh:2124 to exercise the actual custom event; its legacy prompt-only fixture currently misses this path.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ No issues found.
🔧 **Test** - 2 issues found → no changes applied (4) ✅
TMPDIR="$PWD/.test-validation-tmp" timeout -k 5s 240s bash tests/fm-pi-branch-extension.test.sh— passedTMPDIR="$PWD/.test-validation-tmp" timeout -k 5s 240s bash tests/fm-pi-watch-extension.test.sh— passednode ~/.no-mistakes/evidence/01M4SNZBKAAYXKDB2538NPVP6S/routing-live.mjs— 38 actual CLI offers and exported scope checks passedExecuted base and target dispatch CLIs against identical disposable terminal-keyed state; reproduced refusal on base and successful routing on targetLaunched actual Pi with isolated HOME and PI_CODING_AGENT_DIR, no tools, no session persistence, and discovery disabled — stopped for missing API keyRemoved disposable test state and confirmedgit status --shortwas clean🔧 No changes applied.
2 warnings still open:
git rev-parse HEADandgit status --short: confirmed immutable candidate and clean final worktree.Read the supplied R4 lifecycle, ownership, focused-suite and baseline-typecheck evidence; the named types-clean.log was absent, while focus-clean.log recorded the successful target typecheck.Retained this run's 38 actual CLI routing cases and exported scope checks without rerunning unrelated work.env -i PATH="$PATH" HOME="$PWD/.sdk-evidence-state" PI_CODING_AGENT_DIR="$PWD/.sdk-evidence-state/agent" FM_HOME="$PWD/.sdk-evidence-state" FM_ROOT_OVERRIDE="$PWD" FM_STATE_OVERRIDE="$PWD/.sdk-evidence-state/state" timeout -k 5s 60s node ~/.no-mistakes/evidence/01M4SNZBKAAYXKDB2538NPVP6S/public-sdk.mjs: exited 0.Removed disposable SDK state after normal process exit; no watcher or provider call was started.🔧 No changes applied.
2 warnings still open:
Checkedgit rev-parse HEADandgit status --porcelain: reviewed commit 845ee710513334868cbb4bd8ea6e66986c2f55fb, clean worktree.Read retained evidence for 38 actual CLI offers and exported scope checks, plus focused branch and watcher suites; did not rerun unrelated work.Audited public SDK and authenticated AgentSession evidence: five recorded provider requests, 512-token output cap, 860 reported total tokens.Ranps -p 2166705,2260707,2380579 -o pid,ppid,pgid,args: recorded probe processes were absent.Wrotetest-phase-final-boundary.json; made no new provider calls or source changes.🔧 No changes applied.
2 warnings still open:
node --experimental-strip-types ~/.no-mistakes/evidence/01M4SNZBKAAYXKDB2538NPVP6S/routing-live.mjs: 38 actual dispatch CLI offers and exported scope checks against disposable state.Read retained authenticated SDK results, sanitized provider transcript and cumulative budget boundary: seven requests previously used; zero additional requests.Inspected watcher startup and lab guard to verify the isolation conflict predates this change.ps -p 2977008,2977009,2380579 -o pid,pgid,args: recorded processes absent; routing fixtures removed;git status --shortclean.🔧 No changes applied.
✅ Re-checked - no issues remain.
Inspected the complete six-file base-to-head diff and fetched scope clarification withgh-axi api repos/kunchenguid/firstmate/issues/comments/6179844624.NODE_NO_WARNINGS=1 timeout -k 5s 60s node .../routing-live.mjs— 38 actual CLI offers and exported scope checks passed.NODE_NO_WARNINGS=1 timeout -k 5s 60s node .../test-routing-orders.mjs— 38 additional CLI offers and scope checks passed, with competing owners sorting before and after the canonical owner.Executed eight additional real CLI offers for missing/empty-project prefixed owners alongside another owner's open decision; all refused.Executed base and current-head dispatch CLIs against identical disposable terminal-keyed state; reproduced base refusal and head acceptance.TMPDIR="$PWD/.test-validation-tmp" timeout -k 5s 300s bash tests/fm-pi-branch-extension.test.sh— exit 0.TMPDIR="$PWD/.test-validation-tmp" timeout -k 5s 300s bash tests/fm-pi-watch-extension.test.sh— exit 0.Verified process completion, removed owned temporary fixtures, and confirmed a clean worktree.✅ No issues found.
Inspected the final base-to-head diff and fetched maintainer-account scope clarification withgh api repos/kunchenguid/firstmate/issues/comments/6179844624.node ~/.no-mistakes/evidence/01M4SNZBKAAYXKDB2538NPVP6S/test-routing-orders.mjs: 38 real CLI offers and exported scope checks.Executed 16 additional current-head CLI cases covering canonical projectless owners, both discovery orders, prefixed aliases, open decisions and away posture.Executed disposable base/head CLI comparison: reproduced base terminal-routing refusal and verified current-head acceptance.TMPDIR="$PWD/.test-validation-tmp" timeout -k 5s 240s bash tests/fm-pi-branch-extension.test.sh: passed; SDK callback fixtures, not authenticated live turns.TMPDIR="$PWD/.test-validation-tmp" timeout -k 5s 180s bash tests/fm-pi-watch-extension.test.sh: passed; SDK callback fixtures, not authenticated live turns.Confirmed owned branch process group exited, removed transient fixtures and cache, and verified clean worktree.✅ **Document** - passed
✅ No issues found.
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
✅ No issues found.