Skip to content

fix: correct Pi wake ownership and processing-turn handling - #5835

Merged
kunchenguid merged 9 commits into
kunchenguid:mainfrom
kesslerio:fm/upstream-5623-pr
Oct 15, 2026
Merged

kunchenguid merged 9 commits into
kunchenguid:mainfrom
kesslerio:fm/upstream-5623-pr

Conversation

@kesslerio

@kesslerio kesslerio commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Published head: 28662db9a09c836d1290649fd98b684f7a92eca5, rebased through the owning gate and independently re-reviewed.
  • Real dispatch CLI execution passed 54 cases and 38 exported scope checks, including allowed routing, ownership refusals and base-to-head reproduction.
  • bash tests/fm-pi-branch-extension.test.sh and bash tests/fm-pi-watch-extension.test.sh passed at this head; these are behavior checks, not authenticated Pi proof.
  • Gate documentation and lint passed. All final-head GitHub checks are green (CI run); formal maintainer approval is pending.
  • The generated validation record below is preserved unchanged.

What Changed

  • Resolve Orca terminal-keyed stale wakes to their owning task and project; keep ambiguous aliases and projectless owners on main.
  • Recognize queued processing turns across legacy, user, and custom Pi events while excluding custom messages from mirrored user dialog.
  • Document routing rules and expand regression coverage for alias ownership, processing turns, and wake replay across session replacements.

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.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Unique task, terminal and same-owner aliases route to their owning project ✅ pass live head28662-routing.log; head28662-base-and-owner.json
Unknown and uniquely projectless owners cannot authorize routing ✅ pass live head28662-routing.log
Missing or empty project claims make conflicting aliases fail closed in both discovery orders ✅ pass live head28662-routing.log
Prefixed and cross-key aliases cannot borrow another owner's project ✅ pass live head28662-routing.log; head28662-base-and-owner.json
Open decisions remain on main when attended; away routing requires valid ownership ✅ pass live head28662-routing.log; head28662-base-and-owner.json
Evidence: Current-head live routing CLI transcript

Source: Current-head live routing CLI transcript

SCENARIO 1: unique alias term-1
eligible=1
status=safe
corrupted=0
rows=1
tasks=a
unscoped=0

SCENARIO 2: unique alias fm-term-1
eligible=1
status=safe
corrupted=0
rows=1
tasks=a
unscoped=0

SCENARIO 3: unique alias fm-a
eligible=1
status=safe
corrupted=0
rows=1
tasks=a
unscoped=0

SCENARIO 4: unique alias a
eligible=1
status=safe
corrupted=0
rows=1
tasks=a
unscoped=0

SCENARIO 5: unique alias a.status
eligible=1
status=safe
corrupted=0
rows=1
tasks=a
unscoped=0

SCENARIO 6: unique alias a.turn-ended
eligible=1
status=safe
corrupted=0
rows=1
tasks=a
unscoped=0

SCENARIO 7: same-owner window and terminal alias
eligible=1
status=safe
corrupted=0
rows=1
tasks=a
unscoped=0

SCENARIO 8: unknown terminal
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 9: projectless unique owner
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 10: projectless collision a; competing-owner=z-other; field=""
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 11: projectless collision a.status; competing-owner=z-other; field=""
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 12: projectless collision a.turn-ended; competing-owner=z-other; field=""
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 13: projectless collision win-1; competing-owner=z-other; field=""
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 14: projectless collision term-1; competing-owner=z-other; field=""
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 15: projectless collision a; competing-owner=0-other; field=""
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 16: projectless collision a.status; competing-owner=0-other; field=""
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 17: projectless collision a.turn-ended; competing-owner=0-other; field=""
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 18: projectless collision win-1; competing-owner=0-other; field=""
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 19: projectless collision term-1; competing-owner=0-other; field=""
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 20: projectless exact owner cannot borrow prefixed project: fm-window
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 21: projectless exact owner cannot borrow prefixed project: fm-fm-window
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 22: projectless unique owner
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 23: projectless collision a; competing-owner=z-other; field="project=\n"
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 24: projectless collision a.status; competing-owner=z-other; field="project=\n"
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 25: projectless collision a.turn-ended; competing-owner=z-other; field="project=\n"
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 26: projectless collision win-1; competing-owner=z-other; field="project=\n"
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 27: projectless collision term-1; competing-owner=z-other; field="project=\n"
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 28: projectless collision a; competing-owner=0-other; field="project=\n"
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 29: projectless collision a.status; competing-owner=0-other; field="project=\n"
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 30: projectless collision a.turn-ended; competing-owner=0-other; field="project=\n"
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 31: projectless collision win-1; competing-owner=0-other; field="project=\n"
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 32: projectless collision term-1; competing-owner=0-other; field="project=\n"
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 33: projectless exact owner cannot borrow prefixed project: fm-window
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 34: projectless exact owner cannot borrow prefixed project: fm-fm-window
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 35: cross-key project-bearing conflict
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 36: cross-key project-bearing conflict
eligible=0
status=unsafe
corrupted=1
rows=
tasks=
unscoped=0

SCENARIO 37: open decision remains on main despite other eligible task
eligible=0
status=safe
corrupted=0
rows=2
tasks=other
unscoped=0

SCENARIO 38: away open decision retains valid task ownership
eligible=1
status=safe
corrupted=0
rows=1
tasks=a
unscoped=0

Completed 38 real CLI offers plus exported scope checks.
Evidence: Base reproduction and canonical-owner refusal outputs

Source: Base reproduction and canonical-owner refusal outputs

{
  "head": "28662db9a09c836d1290649fd98b684f7a92eca5",
  "results": [
    {
      "version": "fc8972cdc16f988a84588ac6f4ce4e3b0abf20b9",
      "scenario": "unique terminal baseline reproduction",
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "version": "HEAD",
      "scenario": "unique terminal baseline reproduction",
      "output": "eligible=1\nstatus=safe\ncorrupted=0\nrows=1\ntasks=a\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "a",
      "empty_project": false,
      "key": "fm-window",
      "away": false,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "a",
      "empty_project": false,
      "key": "fm-window",
      "away": true,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "a",
      "empty_project": false,
      "key": "fm-fm-window",
      "away": false,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "a",
      "empty_project": false,
      "key": "fm-fm-window",
      "away": true,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "z",
      "empty_project": false,
      "key": "fm-window",
      "away": false,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "z",
      "empty_project": false,
      "key": "fm-window",
      "away": true,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "z",
      "empty_project": false,
      "key": "fm-fm-window",
      "away": false,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "z",
      "empty_project": false,
      "key": "fm-fm-window",
      "away": true,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "a",
      "empty_project": true,
      "key": "fm-window",
      "away": false,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "a",
      "empty_project": true,
      "key": "fm-window",
      "away": true,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "a",
      "empty_project": true,
      "key": "fm-fm-window",
      "away": false,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "a",
      "empty_project": true,
      "key": "fm-fm-window",
      "away": true,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "z",
      "empty_project": true,
      "key": "fm-window",
      "away": false,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "z",
      "empty_project": true,
      "key": "fm-window",
      "away": true,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "z",
      "empty_project": true,
      "key": "fm-fm-window",
      "away": false,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    },
    {
      "scenario": "canonical owner cannot borrow project or bypass decision",
      "owner": "z",
      "empty_project": true,
      "key": "fm-fm-window",
      "away": true,
      "output": "eligible=0\nstatus=unsafe\ncorrupted=1\nrows=\ntasks=\nunscoped=0\n"
    }
  ]
}
Evidence: Scope, results, retained SDK limitations and accounting

Source: Scope, results, retained SDK limitations and accounting

{
  "head": "28662db9a09c836d1290649fd98b684f7a92eca5",
  "scope": "Routing acceptance per latest user decision and maintainer-account triage comment 6179844624; not formal approval or PR readiness.",
  "current_head_live_cli_cases": 54,
  "exported_scope_checks": 38,
  "baseline_comparison_cli_cases": 2,
  "branch_callback_suite_exit": 0,
  "watch_callback_suite_exit": 0,
  "callback_boundary": "SDK fixture callbacks; not authenticated Pi-turn proof.",
  "authenticated_sdk": "NOT RUN; outside revised routing live acceptance. Prior actual watcher consumption, durable captain/custom mirror, user-joined processing and session-reset proof remains incomplete because watcher path overrides are refused by the lab guard. No guard changes or new lab attempts.",
  "provider_requests_this_phase": 0,
  "prior_cumulative_requests": 7,
  "prior_cumulative_input_tokens": 1190,
  "prior_cumulative_output_tokens": 14,
  "prior_corrected_attempt_sdk_reported_cost": 0,
  "cost_caveat": "SDK reported cost does not establish free service. Prior evidence retained unchanged.",
  "omissions": [
    "No typecheck, lint or static analysis in this Test phase, as instructed.",
    "No full repository suite, harness launches, UI testing, review, publication or CI phase."
  ],
  "setup_correction": "Initial disposable baseline copy lacked fm-async-exec.ts; copied that dependency from the same revisions and reran successfully.",
  "cleanup": {
    "owned_branch_group_remaining": [],
    "temporary_directory_removed": true
  },
  "source_changes": false
}
- Outcome: 🔧 2 issues found → no changes applied (4) ✅ across 6 runs (38m52s)

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) ✅
  • ⚠️ Live routing passed, but authenticated Pi turns remain unverified for the changed wake-consumption, dialog-mirroring, and dedicated-processing behavior. The isolated CLI reported no API key. Focused callback tests passed, but cannot establish end-to-end SDK behavior. Provide an authorized provider credential for a disposable Pi environment to complete that validation.
  • ⚠️ live validation verdict: inconclusive (5 of 7 scenarios were driven live against the product); untested: User prompts consume operational wakes and mirror dialog while custom messages do neither, A matching custom processing turn aborts when away appears before context preparation; attended and unrelated custom turns remain allowed
  • Live validation: ⚠️ inconclusive - 5 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Unique terminal, task, status, turn-ended, and prefixed aliases route to their canonical owner ✅ pass live 38 real routing CLI scenarios; base-terminal-offer.log and target-terminal-offer.log
Repeated aliases belonging to the same task remain routable ✅ pass live 38 real routing CLI scenarios
Conflicting task and endpoint claims refuse routing, including missing or empty projects and another eligible row ✅ pass live 38 real routing CLI scenarios; focused branch suite verifies forced discovery orders
Unknown endpoints and projectless canonical owners cannot acquire routing authority through fallback aliases ✅ pass live 38 real routing CLI scenarios
An open decision keeps stale routing on main while attended and preserves valid ownership when away ✅ pass live 38 real routing CLI scenarios
User prompts consume operational wakes and mirror dialog while custom messages do neither ⏸️ untested no User, custom, and legacy callback behavior passed focused tests. An actual Pi CLI launch with disposable HOME and agent configuration failed because no provider API key was available there. Operator c…
A matching custom processing turn aborts when away appears before context preparation; attended and unrelated custom turns remain allowed ⏸️ untested no The focused regression passed for matching custom, unrelated custom, user, and legacy events. Live model-turn validation was blocked by the isolated Pi environment's missing provider credential. The c…
  • TMPDIR="$PWD/.test-validation-tmp" timeout -k 5s 240s bash tests/fm-pi-branch-extension.test.sh — passed
  • TMPDIR="$PWD/.test-validation-tmp" timeout -k 5s 240s bash tests/fm-pi-watch-extension.test.sh — passed
  • node ~/.no-mistakes/evidence/01M4SNZBKAAYXKDB2538NPVP6S/routing-live.mjs — 38 actual CLI offers and exported scope checks passed
  • Executed base and target dispatch CLIs against identical disposable terminal-keyed state; reproduced refusal on base and successful routing on target
  • Launched actual Pi with isolated HOME and PI_CODING_AGENT_DIR, no tools, no session persistence, and discovery disabled — stopped for missing API key
  • Removed disposable test state and confirmed git status --short was clean

🔧 No changes applied.
2 warnings still open:

  • ⚠️ The complete SDK acceptance boundary remains unverified. Public loading and runner lifecycle assertions passed, but branch creation refused missing disposable provider credentials before mirror delivery. Actual watcher consumption and authenticated turn cancellation remain unproven. Completing these checks requires an authorized isolated provider setup and provider-call permission, expressly excluded from this phase.
  • ⚠️ live validation verdict: inconclusive (5 of 7 scenarios were driven live against the product); untested: User prompts consume operational wakes and mirror dialog while custom messages do neither, A matching custom processing turn aborts when away appears before context preparation; attended and unrelated custom turns remain allowed
  • Live validation: ⚠️ inconclusive - 5 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Unique terminal and same-owner aliases route to their owning project ✅ pass live routing-live.log, cases 1–7; retained from this run
Unknown and projectless owners cannot grant routing authority ✅ pass live routing-live.log, cases 8, 9 and 22
Missing or empty project claimants make conflicting aliases fail closed in either creation order ✅ pass live routing-live.log, cases 10–19 and 23–32
Prefixed and cross-key aliases cannot borrow another owner's project ✅ pass live routing-live.log, cases 20–21 and 33–36
Stale aliases preserve open-decision routing and valid away ownership ✅ pass live routing-live.log, cases 37–38
User prompts consume operational wakes and mirror dialog while custom messages do neither ⏸️ untested no Public SDK loading succeeded, but real branch dispatch refused missing configured credentials before mirror delivery. Callback tests do not prove actual watcher consumption. Disposable provider creden…
A matching custom processing turn aborts when away appears before context preparation; attended and unrelated custom turns remain allowed ⏸️ untested no The installed public loader and ExtensionRunner passed matching, attended, unrelated, joined, settlement and session-reset checks. The public embedding callback recorded the abort request; no running…
  • git rev-parse HEAD and git 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:

  • ⚠️ The authorized authenticated lab exhausted its 300-second limit before proving watcher wake consumption, durable dialog mirroring, joined processing, and session reset. The earlier setup omitted .wake-queue and created the ownership lock after session binding. Completing the original acceptance scenarios requires authorization for a new bounded isolated lab window with corrected setup; no source defect was established.
  • ⚠️ live validation verdict: inconclusive (0 of 7 scenarios were driven live against the product); untested: Unique task, terminal and same-owner aliases route to their owning project, Unknown and uniquely projectless owners cannot authorize routing, Missing or empty project claims make conflicting aliases fail closed in both discovery orders, Prefixed and cross-key aliases cannot borrow another owner's project, Open decisions retain their routing boundary and valid ownership, User prompts consume operational wakes and mirror dialog while custom messages do neither, Matching dedicated custom processing aborts when away appears before context; attended, unrelated and user-joined processing remain allowed
  • Live validation: ⚠️ inconclusive - 0 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Unique task, terminal and same-owner aliases route to their owning project ⏸️ untested no The prior payload cited retained routing cases 1–7 but recorded live=false and no rerun in this turn, so it did not establish a live result for this scenario.
Unknown and uniquely projectless owners cannot authorize routing ⏸️ untested no The prior payload cited retained routing cases 8–9 and 22 but recorded live=false and no rerun in this turn, so it did not establish a live result for this scenario.
Missing or empty project claims make conflicting aliases fail closed in both discovery orders ⏸️ untested no The prior payload cited retained routing cases 10–19 and 23–32 but recorded live=false and no rerun in this turn, so it did not establish a live result for this scenario.
Prefixed and cross-key aliases cannot borrow another owner's project ⏸️ untested no The prior payload cited retained routing cases 20–21 and 33–36 but recorded live=false and no rerun in this turn, so it did not establish a live result for this scenario.
Open decisions retain their routing boundary and valid ownership ⏸️ untested no The prior payload cited retained routing cases 37–38 but recorded live=false and no rerun in this turn, so it did not establish a live result for this scenario.
User prompts consume operational wakes and mirror dialog while custom messages do neither ⏸️ untested no The authenticated attempt loaded both extensions but failed mirror setup because .wake-queue was absent; the watcher was not armed because its lock was created after binding. The recorded 300-second a…
Matching dedicated custom processing aborts when away appears before context; attended, unrelated and user-joined processing remain allowed ⏸️ untested no Retained authenticated evidence proves dedicated cancellation and attended/unrelated completion, but not user-joined processing or session reset. The authorized lab deadline was exhausted; completing…
  • Checked git rev-parse HEAD and git 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.
  • Ran ps -p 2166705,2260707,2380579 -o pid,ppid,pgid,args: recorded probe processes were absent.
  • Wrote test-phase-final-boundary.json; made no new provider calls or source changes.

🔧 No changes applied.
2 warnings still open:

  • ⚠️ Complete SDK acceptance evidence remains unavailable: the corrected authenticated lab's actual watcher supplies path overrides rejected by the lab guard. A supported guarded watcher lab path is needed; bypassing protection or changing immutable source is outside this phase. No introduced source defect was established.
  • ⚠️ live validation verdict: inconclusive (5 of 7 scenarios were driven live against the product); untested: User prompts consume operational wakes and mirror dialog while custom messages do neither, Matching dedicated custom processing aborts when away appears before context; attended, unrelated and user-joined processing remain allowed
  • Live validation: ⚠️ inconclusive - 5 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Unique task, terminal and same-owner aliases route to their owning project ✅ pass live Fresh routing CLI replay
Unknown and uniquely projectless owners cannot authorize routing ✅ pass live Fresh routing CLI replay
Missing or empty project claims make conflicting aliases fail closed in both discovery orders ✅ pass live Fresh routing CLI replay
Prefixed and cross-key aliases cannot borrow another owner's project ✅ pass live Fresh routing CLI replay
Open decisions retain their routing boundary and valid ownership ✅ pass live Fresh routing CLI replay
User prompts consume operational wakes and mirror dialog while custom messages do neither ⏸️ untested no The corrected authenticated AgentSession attempt loaded both extensions and completed provider turns, but actual watcher startup was refused by fm_gate_lab_permitted because startArm supplies path ove…
Matching dedicated custom processing aborts when away appears before context; attended, unrelated and user-joined processing remain allowed ⏸️ untested no Prior real SDK cancellation and attended/unrelated controls are retained, but user-joined processing and session reset remain unproved. The corrected attempt stopped at the watcher isolation refusal b…
  • 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 --short clean.

🔧 No changes applied.
✅ Re-checked - no issues remain.

  • Live validation: ✅ go - 5 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Unique task, terminal, prefixed and same-owner aliases route to their owning project ✅ pass live test-routing-orders.log; test-base-reproduction.json
Unknown and uniquely projectless owners cannot authorize routing ✅ pass live test-routing-orders.log
Missing or empty project claims make conflicting aliases fail closed in both discovery orders ✅ pass live test-routing-orders.log
Prefixed and cross-key aliases cannot borrow another owner's project ✅ pass live test-routing-orders.log; test-canonical-owner.json
Open decisions preserve attended refusal and valid away routing without granting projectless authority ✅ pass live test-routing-orders.log; test-canonical-owner.json
User prompts consume operational wakes and mirror dialog while custom messages do neither ⏸️ untested no Authenticated execution NOT RUN under the latest routing-only live acceptance decision. Focused callback tests passed. Prior authenticated attempts encountered watcher path overrides rejected by the l…
Dedicated custom processing aborts when away appears before context; attended, unrelated and user-joined processing remain allowed ⏸️ untested no Authenticated execution NOT RUN under the revised scope. Focused executable tests passed for custom, user and legacy events. Prior partial AgentSession evidence is preserved, but authenticated joined…
  • Inspected the complete six-file base-to-head diff and fetched scope clarification with gh-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.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Unique task, terminal and same-owner aliases route to their owning project ✅ pass live head28662-routing.log; head28662-base-and-owner.json
Unknown and uniquely projectless owners cannot authorize routing ✅ pass live head28662-routing.log
Missing or empty project claims make conflicting aliases fail closed in both discovery orders ✅ pass live head28662-routing.log
Prefixed and cross-key aliases cannot borrow another owner's project ✅ pass live head28662-routing.log; head28662-base-and-owner.json
Open decisions remain on main when attended; away routing requires valid ownership ✅ pass live head28662-routing.log; head28662-base-and-owner.json
  • Inspected the final base-to-head diff and fetched maintainer-account scope clarification with gh 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.

@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Extends task routing to recognize Orca terminal identifiers.

The PR appears safe to merge; no outstanding findings remain.

Reviews (4) · Last reviewed commit: "no-mistakes(document): Update supervisio..."

@kesslerio

Copy link
Copy Markdown
Contributor Author

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.

@kesslerio
kesslerio force-pushed the fm/upstream-5623-pr branch 2 times, most recently from 25920ef to 2ded63b Compare October 1, 2026 09:55
@kesslerio kesslerio changed the title fix(pi): let the supervision branch claim Orca stale wakes fix(pi): let the supervision branch claim terminal-keyed Orca stale wakes Oct 1, 2026
@kesslerio

Copy link
Copy Markdown
Contributor Author

For the issue link: this PR fixes #5623, which triage marked ready-for-pr.

@kesslerio
kesslerio force-pushed the fm/upstream-5623-pr branch from 2ded63b to 9ae9df5 Compare October 13, 2026 03:21
@kesslerio kesslerio changed the title fix(pi): let the supervision branch claim terminal-keyed Orca stale wakes fix: resolve Orca terminal aliases in branch wake routing Oct 13, 2026
@kesslerio

Copy link
Copy Markdown
Contributor Author

I found one remaining ownership case during independent review of the latest fix: a metadata record without project=, or with an empty project, can still claim a terminal also named by another task.
At published head 9ae9df5e28d8e89f76bd87fee33714510b83d60e, that can select the other task and bypass the projectless owner's open decision.
This is a synthetic corruption reproduction, not an observed fleet incident.

I am extending the shared ownership check and behavior coverage to those records in both discovery orders.
The current CI run covers the preceding fix; it does not prove this remaining case is fixed.
I am holding the maintainer review request until the follow-up is validated and published through no-mistakes.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Thank you @kesslerio, and thank you for catching the projectless and empty-project= ownership case yourself. That kind of review is exactly what keeps this routing safe.

Where it stands:

  • I read the published head 9ae9df5e. terminal= is now indexed alongside window=, and conflicting task or endpoint aliases keep the whole wake on MAIN. Decision-owned and captain-held rows still go to MAIN. There are no workflow changes and no security concerns. Fixes Urgent: Pi supervision branch never claims Orca stale wakes, so every idle Orca worker wakes main #5623: yes.
  • Attestation MATCH for 9ae9df5e. Live evidence: 5/5 routing scenarios across 34 real CLI cases. You've disclosed that this is metadata routing, not an authenticated Pi turn.
  • CI: parallel 1 is the Pi 1.2 BeforeAgentStartEvent.prompt drift that is also red on main, and serial 2 was cancelled at the known 30-minute limit. Neither one counts against your change.
  • My read: contract-class restore. The Pi supervision branch already claims routine stale wakes. Orca's terminal-keyed rows were falling through to MAIN, and a collision only falls back to the existing MAIN path. On VISION, it aligns with every rule.

Next: you asked us to hold review until the follow-up (845ee710) is published through no-mistakes, so this is waiting on you, with no rush. Once that head is raised and the attestation matches it, I'll re-review just that change.

@kesslerio

Copy link
Copy Markdown
Contributor Author

Kun, the ownership correction is still unpublished because no-mistakes Test cannot complete two real Pi scenarios with the supported guarded lab.
At candidate 845ee710513334868cbb4bd8ea6e66986c2f55fb, Test remains inconclusive at 5/7.

Pi 1.2.0 loads both extensions, and bounded authenticated sessions established partial processing behavior.
The actual watcher then refuses the lab before state mutation: startArm always supplies root/config overrides, and confirmHandlingDelivery supplies state/root overrides, while fm_gate_lab_permitted rejects every nonempty FM_*_OVERRIDE, including lab-contained paths.
That integration is unchanged from the base; #7248 fixes the SDK type errors without changing it.
Wake consumption, durable dialog mirroring and joined-processing proof remain incomplete.

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?
The guard must retain marked-home ownership and refuse unmarked homes or foreign paths before mutation.
I will keep #5835 focused on routing and hold final review until the required proof and publication are complete.

@kunchenguid

Copy link
Copy Markdown
Owner

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 FM_*_OVERRIDE refusal in fm_gate_lab_permitted would change the lab safety guard itself. That's a captain-level choice, so triage can't approve it from a routing PR, and I won't confirm a recipe that works around the guard. The best way to get it decided is a separate issue. It should describe the mismatch you found: the watcher's startArm and confirmHandlingDelivery always pass root/config/state overrides, and the guard rejects any nonempty override, so a guarded Pi run can't reach wake consumption. Include the guard properties you listed too (marked-home ownership, and refusing unmarked or foreign paths before anything changes). That way it gets judged on its own, and #5835 isn't held up by it.

For #5835 itself: the correction at 845ee710 is still metadata routing, the same scope as the published head. There I accepted routing-level live evidence (the real bin/fm-branch-dispatch.mjs CLI across your 34 cases), with the authenticated Pi turn openly listed as out of scope. The same scope is fine for the correction from triage's side. If no-mistakes won't complete without the two Pi-turn scenarios, say so here and I'll pass that along rather than leave you stuck. Also, the parallel 1 Pi type errors are fixed on main by #7248, so a rebase in the re-raise should clear that check.

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 845ee710 (rebased) through no-mistakes with a matching attestation. No rush.

@kesslerio kesslerio changed the title fix: resolve Orca terminal aliases in branch wake routing fix: correct Pi wake routing and custom-message handling Oct 15, 2026
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.
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.
@kesslerio
kesslerio force-pushed the fm/upstream-5623-pr branch from 31a4aad to 28662db Compare October 15, 2026 20:16
@kesslerio kesslerio changed the title fix: correct Pi wake routing and custom-message handling fix: correct Pi wake ownership and processing-turn handling Oct 15, 2026
@kesslerio

Copy link
Copy Markdown
Contributor Author

@kunchenguid, the ownership correction is now published at 28662db9a09c836d1290649fd98b684f7a92eca5, rebased through no-mistakes onto fc8972cd. My earlier author hold for the unpublished projectless-owner fix is resolved.

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.