Skip to content

[Bug]: nested pi inherits ORCA_PI_STATUS_OWNED and silently reports no status - #500

Merged
lab-agent-np[bot] merged 1 commit into
mainfrom
nplez1/issue-480
Nov 28, 2026
Merged

lab-agent-np[bot] merged 1 commit into
mainfrom
nplez1/issue-480

Conversation

@lab-agent-np

@lab-agent-np lab-agent-np Bot commented Nov 28, 2026

Copy link
Copy Markdown

Fixes #480

Summary

A pi process reports status for its pane unless an inherited ORCA_PI_STATUS_OWNED marker says another live PID already has it. That marker is plain env, so it reaches the whole descendant tree and could not tell the pane's own nested subagent — which must stay silent, or stablyai#8545's false "agent finished" notifications come back — from a session that inherited the marker but reports for a different pane. The second case was muted for as long as the owner lived, silently: no session_start, no turn events, no scheduled_work, and Orca showed the pane idle while pi looked healthy.

Both lanes now decide ownership from the PID and the pane that PID claimed:

  • src/main/pi/agent-status-owner-liveness-source.ts replaces the bare liveness test with yieldsPaneOwnership / claimPaneOwnership / notePaneOwnerStandDown. A claim records the claimant's ORCA_PANE_KEY in <ownerKey>_PANE; a marker inherited from another pane is no claim on this one. A claim also drops the pane record when the process has none, so a stale pane can never pair with a new owner.
  • agent-status-handler-source.ts and titlebar-extension-source.ts both use the shared predicate, so the two lanes cannot drift (the reason the shared generator exists, [Bug]: The titlebar marker owner check has no liveness test, so a pi with a dead inherited owner never paints π ! and its ask card reads Working #229).
  • pi-process-owner-env.ts strips the three _PANE companion keys at every pane boundary, beside the keys they belong to, so a new pane, a daemon host and an older remote host cannot inherit a claim.
  • The stand-down is no longer silent, which is one of the three things [Bug]: nested pi inherits ORCA_PI_STATUS_OWNED and silently reports no status #480 asked for: it is recorded on globalThis under Symbol.for('orca.pi.pane-owner.stand-down') keyed by lane (owner pid, its pane, our pane, our pid, a reason), and warned once per process when stderr is a TTY or ORCA_PI_STATUS_DEBUG is set. A piped subagent that nobody asked to debug stays quiet.

Deliberately not done: keying the marker on process ancestry. Env only ever flows down, so "alive but not an ancestor" means either PID reuse or an orphaned descendant (nohup/setsid behind a shell, a tmux server started from pi) — and claiming for an orphaned subagent runner puts a second reporter, and a false completion, on the lead's pane. The ppid chain cannot separate those two, and a CIM walk would block pi's synchronous factory on Windows.

Verification

  • pnpm tc — pass (exit 0).
  • pnpm check:changed (format, oxlint, typecheck, every path ratchet, and the unit tests that import the change) — 31/31 pass.
  • node local/gate-lint.mjs --fast — PASS, 16/16 steps, including check-upstream-file-comments at the frozen total 4843/4843.
  • pnpm test src/main/pi/agent-status-owner-pane.test.ts --maxWorkers=2 — 15/15 pass (3 lanes × 5 inherited states).
  • Focused suites for the neighbouring status/extension behaviour, all pass: agent-status-session-owner 22, agent-status-scheduled-work 19, agent-status-async-subagent 23, agent-status-restart-reannounce 11, agent-status-restart-watch-session 11, agent-status-input-redaction 20, omp-model-command-source 4, agent-status-omp-autolearn-capture 2, agent-hook-cancel-verdict-latch 1.
  • Mutation checks, so the assertions are known to discriminate: reverting the pane comparison fails 6 of the 15 unit cases; reverting the liveness return fails 6.
  • node tests/tools/pi-owner-runtime-smoke.mjs with real @earendil-works/[email protected] on darwin — 15/15 scenarios as expected for pi, omp and prime-agent: dead owner claims and posts once; a live owner recorded for this pane mutes with the marker kept; a live owner recorded for another pane claims, posts once and records its own pane; both baseline mutations mute. "Pi owner runtime verification" is disabled_manually on this fork, so this was run locally, not in PR CI.
  • Titlebar lane, loaded once by hand from the generated orca-titlebar-spinner.ts in a VM with a stubbed process (no committed test — it has no existing suite to extend): kind pi with no marker claims and records pane-1; a live owner recorded for pane-1 stands down and keeps the owner; a live owner recorded for pane-2 claims and records pane-1; an owner with no pane record stands down. Kind omp carries no marker block and leaves the env untouched.
  • Unit gate: not required — the diff touches only src/main/pi/**, src/main/pty/shell-startup/** and tests/tools/**, none of which is a global input.

Decisions

  1. Pane-keyed ownership rather than a process-ancestry walk (the issue offered both). The walk only flips "alive but not an ancestor", which is either PID reuse or an orphaned descendant, and claiming for an orphan re-breaks the fix(pi): suppress subagent agent_end so nested sessions don't fire false notifications stablyai/orca#8545 invariant the marker exists for. Rejected on blast radius, not on size.
  2. A same-pane descendant still stands down. Two reporters on one pane is the false-completion failure fix(pi): suppress subagent agent_end so nested sessions don't fire false notifications stablyai/orca#8545 fixes, and a child cannot observe an owner that outlives its turn. What changes is that the stand-down is now diagnosable — including for the report's own repro, a pi -p run, which is diagnosed by re-running it with ORCA_PI_STATUS_DEBUG=1 rather than by unmuting it by default.
  3. A missing pane record on either side means "same pane". Older writers recorded only a PID, and a process with no ORCA_PANE_KEY posts nothing anyway; guessing "different pane" would un-mute subagents across every mixed-version host.
  4. The titlebar lane is in scope, with its own _PANE key. It gates the π ! needs-input marker from the same inherited env, and a pane that loses its marker also loses the ask-card lane ([Bug]: The titlebar marker owner check has no liveness test, so a pi with a dead inherited owner never paints π ! and its ask card reads Working #229). Separate keys mean neither lane's claim can rewrite the other's verdict by load order. It records no stand-down of its own, so a muted nested session still prints one line, not two.
  5. A user who types pi in a live pane's shell is made diagnosable, not unmuted. It inherits the lead's pane key, so it has no pane of its own to report to, and clearing the marker would give that pane two reporters — which the warning now says out loud instead of recommending. A session that wants its own status belongs in its own pane, where the marker is already stripped.
  6. No process queries anywhere, so Windows, WSL, remote and daemon hosts behave identically and the extension's synchronous load cost is unchanged.
  7. PID reuse stays a residual: it needs a start-time identity (ps -o lstart=), not ancestry. Noted here rather than half-solved.

One known NIT, left in the code deliberately rather than opening a third review round: if a process stands down and later claims (the owner died, then /reload), claimPaneOwnership does not delete the stale globalThis stand-down record. Nothing reads that record except a person inspecting it.

Review

Reviewed by claude/opus, high: R1 (2 blocking fixed), delta clean on R2.

R1 found two blocking items — the stand-down warning recommended clearing the marker, which would have re-broken stablyai#8545 by putting two reporters on one pane, and the diff added comment lines to tests/tools/pi-owner-runtime-smoke.mjs, an upstream-owned file, pushing the fork's check-upstream-file-comments total past its frozen baseline. Both are fixed: the warning now states what happened and why clearing the marker is unsafe, and the smoke file's comments are gone (4843/4843). R1's three MINORs and one NIT were addressed in the same pass: the warning is once per process, piped runs are diagnosable behind ORCA_PI_STATUS_DEBUG, the titlebar lane was verified by loading its generated source, and the record carries a reason.

@lab-agent-np

lab-agent-np Bot commented Nov 28, 2026

Copy link
Copy Markdown
Author

The gatekeeper did not merge (it never merges on a failed gate).

  • the branch is behind main; rebase on it and push

…the PID alone (#480)

An inherited ORCA_PI_STATUS_OWNED naming a live PID muted the whole descendant
tree, so a session that inherited the marker but reports for another pane sent
nothing at all — no session_start, no turn events, no scheduled_work — while
Orca showed the pane idle. Env only reaches descendants, so the bare PID could
not separate the pane's own nested subagent (which must stay silent, stablyai#8545) from
a different pane's reporter.

A claim now records the claimant's ORCA_PANE_KEY beside its PID, and an inherited
marker recorded for another pane is no claim on this one; a claim with no pane
record of its own deletes the stale one, so a new owner never pairs with an old
pane. Both lanes use the shared predicate, so the status and titlebar lanes
cannot drift (#229). The three _PANE companion keys are stripped at every pane
boundary beside the keys they belong to.

The stand-down is no longer silent: it is recorded on globalThis keyed by lane,
and warned once per process when stderr is a TTY or ORCA_PI_STATUS_DEBUG is set.
A piped subagent nobody asked to debug stays quiet.
@lab-agent-np
lab-agent-np Bot merged commit eb06b99 into main Nov 28, 2026
10 checks passed
@lab-agent-np
lab-agent-np Bot deleted the nplez1/issue-480 branch November 28, 2026 06:45
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.

[Bug]: nested pi inherits ORCA_PI_STATUS_OWNED and silently reports no status

1 participant