Repository navigation
fix(agent-hooks): ignore status posts from an extension Orca did not launch - #17243
brennanb2025 wants to merge 5 commits into
Conversation
Greptile SummaryThis PR adds a provisional fence that delays tokenless agent-status posts until a managed poster confirms or fails to supersede them. It also propagates unmanaged-extension detections through the preload boundary, adds a renderer warning, and supplies launch identity for detached Codex restarts.
Confidence Score: 4/5The PR is not yet safe to merge because unmanaged-extension detections can still be permanently lost while the main window is closed. The app-scoped hook server continues classifying posts after the window detaches its listener, while reportOnce marks a pane/source reported before the optional callback runs; reopening the window installs a listener without replaying that consumed detection, leaving the user-facing warning permanently absent. Files Needing Attention: src/main/agent-hooks/unmanaged-status-extension-fence.ts, src/main/index.ts
|
| Filename | Overview |
|---|---|
| src/main/agent-hooks/unmanaged-status-extension-fence.ts | Introduces bounded ownership and provisional holding for tokenless status posts, including timeout, eviction, retirement, and detection bookkeeping. |
| src/main/agent-hooks/server.ts | Integrates the fence into the shared local and remote status-disposition path and re-routes released posts through current gates. |
| src/main/index.ts | Connects unmanaged-extension detections to telemetry and renderer IPC across the main-window lifecycle. |
| src/renderer/src/hooks/ipc-events/unmanaged-status-extension-notice.ts | Adds a persistent, per-source warning toast for confirmed unmanaged status extensions. |
| src/renderer/src/components/terminal-pane/codex-detached-pane-restart.ts | Adds an Orca launch token to detached Codex account-switch respawns. |
Sequence Diagram
sequenceDiagram
participant U as Unmanaged extension
participant F as Status fence
participant M as Managed extension
participant R as Renderer
U->>F: Tokenless status post
F->>F: Hold post
alt Managed poster responds
M->>F: Tokened status post
F->>F: Discard held post
F-->>R: Unmanaged-extension notice
else Confirmation window lapses
F->>F: Forget owner
F->>F: Re-deliver held post
end
Reviews (6): Last reviewed commit: "test(agent-hooks): pin the fence's teard..." | Re-trigger Greptile
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds token-based detection for unmanaged status extensions. The agent hook server holds eligible tokenless posts and releases them after the confirmation window. The main process records telemetry and forwards notifications through preload and web APIs. The renderer displays translated notices with dismissal support. Codex detached restarts now receive launch tokens. Tests cover ownership, source isolation, relaunch behavior, deferred posts, teardown, and notification deduplication. Merge Risk: 🟡 Moderate · up to This PR defers and filters agent-status updates and adds launch-token handling for restarted agents, but unresolved lifecycle and deferred-delivery paths can still leave panes stuck, lose valid completion updates, or apply stale status after teardown or pane transfer. The change is not merge-ready until these bounded correctness issues are fixed or explicitly accepted; the launch token also provides cooperative rather than independently verified provenance. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 15 files. (1 skipped: 1 unsupported.) Full details: Description checkExplanation The description is detailed and directly explains the problem, implementation, behavior, testing, and limitations. However, it omits the required Linked Issue, does not provide the required visual attachments for this behavior/UI change, and does not complete the template checklist and review sections. Resolution Add the required issue reference after “Fixes #”. Attach before-and-after screenshots or a video, or provide the exact required N/A statement if visual proof is not applicable. Complete the Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections as applicable.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/agent-hooks/server.ts (1)
1904-1980: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winMaintain fence state for every pane-key transition.
transferPaneAuthoritymoves the status and alias state but leaves the fence owner underpreviousOwnerPaneKey. Later posts are alias-normalized totoPaneKey, so a tokenless unmanaged post can bypass the old owner and update the transferred pane.clearPaneStatealso leaves the owner intact, so a reused tokenless launch is suppressed after ordinary PTY teardown.
src/main/agent-hooks/server.ts#L1904-L1980: move the fence entry frompreviousOwnerPaneKeytotoPaneKeywith the other pane-keyed state.src/main/agent-hooks/server.ts#L3008-L3030: forget fence entries for every cleared physical and resolved pane key.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d4539707-8179-48eb-b711-541fa675ae18
📒 Files selected for processing (12)
src/main/agent-hooks/server-unmanaged-status-extension.test.tssrc/main/agent-hooks/server.tssrc/main/agent-hooks/unmanaged-status-extension-fence.tssrc/main/index.tssrc/preload/api/agent-status-api.tssrc/preload/index.tssrc/renderer/src/hooks/ipc-events/agent-status-listeners.tssrc/renderer/src/hooks/ipc-events/unmanaged-status-extension-notice.tssrc/renderer/src/hooks/useIpcEvents-lifecycle.test.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/web/preload-api/web-agent-status-api.tssrc/shared/telemetry-events.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| // Why: detach the hook listener on close so the server never fires into destroyed webContents before reopen, and replay runs only on deliberate recreations. | ||
| agentHookServer.setListener(null) | ||
| agentHookServer.setPaneStatusClearListener(null) | ||
| agentHookServer.setUnmanagedStatusExtensionListener(null) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep unmanaged-extension reports deliverable after window teardown.
Line 1700 removes the listener while the fence remains active. The fence marks a (paneKey, source) as reported before it invokes the optional listener. A post received while no window exists is therefore suppressed permanently without the warning, telemetry, or renderer notice. Reopening a window installs a new listener but does not replay the report.
Keep a main-process reporter active across window recreation, and retain pending source notices until a renderer can receive them.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/agent-hooks/server.ts (1)
3048-3084: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winCancel held posts when their pane authority is cleared.
A held tokenless post survives these teardown paths. When its timer expires, it re-enters disposition after the old process or connection is gone. The post can then recreate a stale
workingor terminal status.
src/main/agent-hooks/server.ts#L3048-L3084: callunmanagedExtensionFence.forgetPanefor the resolved pane and every cleared alias before cache cleanup.src/main/agent-hooks/server.ts#L2888-L2937: cancel holds for each pane whose connection is being cleared before removing its status state.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 7a3ec998-88e9-48f7-b030-2cac7f793ac9
📒 Files selected for processing (6)
src/main/agent-hooks/server-unmanaged-status-extension.test.tssrc/main/agent-hooks/server.tssrc/main/agent-hooks/unmanaged-status-extension-fence.tssrc/renderer/src/components/terminal-pane/codex-detached-pane-restart.test.tssrc/renderer/src/components/terminal-pane/codex-detached-pane-restart.tssrc/renderer/src/hooks/ipc-events/unmanaged-status-extension-notice.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
574b7cb to
b1d4bf9
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/agent-hooks/server.ts (1)
1954-1960: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftMigrate fence state when pane authority moves.
transferPaneAuthoritymoves token-related state frompreviousOwnerPaneKeytotoPaneKey, but it leavesunmanagedExtensionFencestate on the old key. Later posts are alias-resolved totoPaneKey, so a tokenless post from the unmanaged extension is treated asunattributedand can settle the moved pane.Add a fence transfer operation that moves owner, held-post, and report state to
toPaneKey.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2e5f0650-40b7-4b81-a474-5930d98c879a
📥 Commits
Reviewing files that changed from the base of the PR and between 574b7cb and b1d4bf99f9dbb4969b69a28ad654dc8fb7de185e.
📒 Files selected for processing (4)
src/main/agent-hooks/server-unmanaged-status-extension.test.tssrc/main/agent-hooks/server.tssrc/main/agent-hooks/unmanaged-status-extension-fence.test.tssrc/main/agent-hooks/unmanaged-status-extension-fence.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| launchToken: envelope.launchToken, | ||
| // Why re-enter rather than replay the tail: every gate below this point must be re-checked | ||
| // against the pane as it stands when the hold lapses, not as it stood when it was taken. | ||
| releaseIfUnconfirmed: () => { | ||
| this.ingestRemote(envelope, connectionId) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Validate the remote post before it can replace a held post.
A valid tokenless completion can be held after a tokened owner posts. A later tokenless relay envelope with an invalid payload replaces that hold here. The delayed callback then re-enters ingestRemote, fails normalizeAgentStatusPayload, and loses the original valid completion. The pane can remain working.
Move fencing until after payload validation, or prevent an unvalidated envelope from replacing an existing hold.
86447ac to
a7010ed
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e2e71e2e-2c2c-40db-87b6-993601acff87
📥 Commits
Reviewing files that changed from the base of the PR and between b1d4bf99f9dbb4969b69a28ad654dc8fb7de185e and b1cd969.
📒 Files selected for processing (1)
src/main/agent-hooks/unmanaged-status-extension-fence.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| if (sources.size === 0) { | ||
| this.ownerHashByPaneKey.delete(paneKey) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Clear report state when the final owner expires.
When the confirmation timer calls forgetOwner, Line 216 removes the last owner but leaves reportedSourcesByPaneKey retained. These orphaned report sets are no longer bounded by MAX_TRACKED_PANES. Repeated panes that report once and later lapse can accumulate entries until pane retirement.
Proposed fix
if (sources.size === 0) {
this.ownerHashByPaneKey.delete(paneKey)
+ this.reportedSourcesByPaneKey.delete(paneKey)
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (sources.size === 0) { | |
| this.ownerHashByPaneKey.delete(paneKey) | |
| if (sources.size === 0) { | |
| this.ownerHashByPaneKey.delete(paneKey) | |
| this.reportedSourcesByPaneKey.delete(paneKey) |
…launch Pi/OMP auto-discover every file in the agent's extensions dir. When a user-owned `orca-agent-status.ts` already holds that name, `writeManagedExtension` refuses to overwrite it (no `@orca-managed-pi-extension` marker) and Orca side-loads its managed copy with `-e` instead. Both then run in the same process and post the same pane key to `/hook/omp` — but the user-owned copy is frozen at whatever Orca version wrote it, so it can post a completion the managed copy deliberately withheld and settle a pane that is still working. Measured against omp 17.0.5 with both copies live: the unmanaged copy is discovered with no flag, its `agent_end` lands *before* the managed one, and only the managed copy carries a `launchToken` in the post body. Fence the pane on that token. A tokened post always wins and becomes the pane's owner; a tokenless post is dropped only once the same pane and source have proven a tokened poster is live. Fails open in every other direction — with no tokened post the gate never arms, so a bare shell (where the managed copy itself posts `launchToken: ''`) cannot be stranded on "working". Orca does not touch the user's file. A one-shot toast names the agent so the user can find and remove it themselves.
…a's relaunch a token The fence dropped tokenless status posts permanently once a tokened poster had been seen on a pane, so a managed poster that posted once and then died left the pane claiming work forever. Measured against main with the same post sequence: main settles to done, the fence stranded on working. Suppression is now provisional. A tokenless post is held, not dropped: a following tokened post discards it -- and is the only real proof that two posters share one pane, so that is when the warning fires -- while silence past the confirmation window re-opens the gate and delivers the held post. Every held post is therefore superseded or delivered, so no sequence of posts can strand a pane. Orca's detached Codex account-switch restart respawned into the same pane key without ORCA_AGENT_LAUNCH_TOKEN, so Orca's own replacement read as a poster Orca did not launch. Mint the token there: it is the contract every token-keyed gate depends on, not just this fence.
Eviction destroyed the held tokenless post instead of resolving it, so the pane claimed 'working' forever. Measured against a control: 512 filler panes stranded on ['working'] where 10 delivered ['working','done'].
…a pane at quit The fence's own doc named pane retirement as the only path that ends a hold without delivering it. Server teardown does too. It is safe for a different reason than replay: hydrate re-stamps every non-done row restoredUnconfirmed, and the freshness gates refuse to read that as live work. Comment only; no behaviour change.
…h nothing caught dispose(), its stop() call site, and holdPost's latest-only supersede each reddened 0 of 775 in src/main/agent-hooks. Controls: dispose() is reached by 200 tests and once with a hold outstanding, its stop() route by 199, and the hold machinery by 5 - but a throw on a second hold for the same pane and source reddened 0, so that path was never reached at all.
…it spawns The relay builds each PTY's env from its own process.env, and a relay is routinely started *from* an Orca pane — so that pane's ORCA_PANE_KEY, TAB_ID, WORKTREE_ID and ORCA_AGENT_LAUNCH_TOKEN rode into every pane the relay spawned, fresh or revived. The launch token is the damaging member: it is Orca's only in-band proof of authorship, and the retired-pane status fence is keyed on it, so one leaked token let any pane on the relay satisfy a fence a different pane had set. The daemon already scrubbed exactly these four keys. Hoist that scrub into src/shared/pane-identity-env.ts and give the relay the same call, so the two PTY hosts cannot drift again. Adds a spawn-site ratchet: 52 files name the launch token but nothing stated the rule producing it, and two paths shipped without it (#17243's detached-pane restart, and this one) — each found by accident. A new pane-identity env site now has to be classified deliberately instead of silently joining the broken half.
b1cd969 to
b1c73e9
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/agent-hooks/server-unmanaged-status-extension.test.ts (1)
345-356: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGuard the server shutdown with
try/finallyin this test.This is the only test in the file that calls
server.stop()outside afinallyblock. If the assertion at Line 352 fails,stop()never runs. The HTTP server then stays listening and the held-post timer stays armed for the remainder of the run, which can keep the Vitest worker alive after the failure.♻️ Proposed cleanup guard
server._setUnmanagedExtensionConfirmationWindowMsForTests(40) - const seen = await runOmpPosts(server, [ - { hookEventName: 'agent_start', launchToken: LAUNCH_TOKEN }, - { hookEventName: 'agent_end' } - ]) - expect(states(seen)).toEqual(['working']) - server.stop() - await new Promise((resolve) => setTimeout(resolve, 120)) - expect(server.getStatusSnapshotForPane(PANE)).toEqual([]) + try { + const seen = await runOmpPosts(server, [ + { hookEventName: 'agent_start', launchToken: LAUNCH_TOKEN }, + { hookEventName: 'agent_end' } + ]) + expect(states(seen)).toEqual(['working']) + } finally { + server.stop() + } + await new Promise((resolve) => setTimeout(resolve, 120)) + expect(server.getStatusSnapshotForPane(PANE)).toEqual([])
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 99c8a0d9-7703-4a16-a4a3-d0dde254af1e
📒 Files selected for processing (4)
src/main/agent-hooks/server-unmanaged-status-extension.test.tssrc/main/agent-hooks/unmanaged-status-extension-fence.test.tssrc/preload/index.tssrc/renderer/src/i18n/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/i18n/locales/en.json
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
…it spawns The relay builds each PTY's env from its own process.env, and a relay is routinely started *from* an Orca pane — so that pane's ORCA_PANE_KEY, TAB_ID, WORKTREE_ID and ORCA_AGENT_LAUNCH_TOKEN rode into every pane the relay spawned, fresh or revived. The launch token is the damaging member: it is Orca's only in-band proof of authorship, and the retired-pane status fence is keyed on it, so one leaked token let any pane on the relay satisfy a fence a different pane had set. The daemon already scrubbed exactly these four keys. Hoist that scrub into src/shared/pane-identity-env.ts and give the relay the same call, so the two PTY hosts cannot drift again. Adds a spawn-site ratchet: 52 files name the launch token but nothing stated the rule producing it, and two paths shipped without it (#17243's detached-pane restart, and this one) — each found by accident. A new pane-identity env site now has to be classified deliberately instead of silently joining the broken half.
|
The older-copy status conflict needs a fresh issue and a current reproduction before this branch is closed. The current fix should establish which reporter owns the status rather than delay competing reports for thirty seconds. The remaining problem is tracked in #27666. |
ELI5
Orca's OMP/Pi status extension lives in the agent's own extensions folder, and OMP loads every file it finds there. If a copy of
orca-agent-status.tsis already sitting in that folder that Orca didn't write, Orca deliberately refuses to overwrite it — it's the user's file — and side-loads its own managed copy with-einstead.So both run. In the same process. Posting the same pane's status to the same endpoint.
That's fine while the two agree. It stops being fine the moment Orca ships a fix to the extension, because the old copy doesn't have it. The old copy posts
agent_endunconditionally; a current one can withhold it (for example while OMP has an automatic continuation scheduled). The old copy's post lands first, the pane settles, and the user — who just installed the fix — watches their pane go quiet mid-turn and concludes the fix didn't work.Orca can tell the two apart, because Orca stamps a launch token into every process it starts and the old copy predates that field. But "I once saw a post with a token" is not the same as "the copy with the token is still alive". So the discrimination is written as a delay, not a veto: a post without a token is held, and it is delivered anyway unless the copy with the token speaks up and contradicts it.
Before / after, for a user
What was measured
Against the shipped
omp 17.0.5binary, in a tempPI_CODING_AGENT_DIR(nothing in~was read, written, moved, or removed):<agentDir>/extensions/, one passed with-e. Load-time markers from both landed.omp --helpdocuments--no-extensionsas "Disable extension discovery (explicit -e paths still work)", which is the same statement from the other side.paneKey, through/hook/omp, in one turn:before_agent_start,agent_start,agent_endfrom each.agent_endlands first. It won the race in the captured ordering.launchToken; the unmanaged copy omits the field entirely.Correction to an earlier claim in this description
An earlier revision said the discrimination turns on absent vs present-but-empty: with
ORCA_AGENT_LAUNCH_TOKENunset the managed copy still sendslaunchToken: '', while an unmanaged copy omits the key.That is true on the wire and false at the gate.
readEnvelopeString(src/shared/agent-hook-listener/hook-envelope.ts:89-96) trims the value and returnsundefinedfor anything empty, so by the time the fence is called the two cases are already the same value. Nothing in this PR can rely on that distinction, and nothing in it does — the gate reads "non-empty token" vs "no usable token", which is the only fact that survives parsing. Recovering the distinction would need a wire/parse change, which is not in scope here.What the review loops found, and how each is fixed
1. Armed, then died — the pane stranded on "working" forever
The original fence dropped tokenless posts permanently once a tokened poster had been seen on a pane. Measured with the identical post sequence (
agent_startwith a token, then a tokenlessagent_end, then silence):main(a1f198be0d)done— 1 check passed2c2415735dworking, no TTL at all — 1 check failedSo the first cut traded a pane that settles too early for one that never settles. That is not the better failure: a pane wrongly stuck on "working" is invisible, permanent, and has no user recovery. The claim in the earlier description that it "fails open in every other direction" was wrong, and this is the direction it was wrong about.
The fix: suppression is provisional. A tokenless post on an owned pane is held, not dropped.
UNMANAGED_POST_CONFIRMATION_WINDOW_MS(30s) re-opens the gate, forgets the owner, and delivers the held post through the same gates it would have passed originally.Every held post is therefore either superseded by the managed poster or delivered — but that only became true of every removal path in defect 3 below. This line, as originally written, asserted an invariant the PR did not hold; see there for what falsified it.
The shipped window had no committed reader
Every window test ran on the 40ms test seam, so
UNMANAGED_POST_CONFIRMATION_WINDOW_MShad zero readers — the 30s that actually ships was untested, and an edit to the constant or to the constructor default that wires it would have left every test green.Closed by exercising the real constant rather than only asserting the wiring, because fake timers make that free.
unmanaged-status-extension-fence.test.ts(new) drives a default-constructed fence and advances toUNMANAGED_POST_CONFIRMATION_WINDOW_MS - 1(no release), then+1(release). That is a real reader of the shipped value and a wiring assertion, in ~150ms of wall clock rather than 30s. A second check pins the value between the two bounds that justify it — above the sub-second band in which the managed copy supersedes, below the realAGENT_STATUS_STALE_AFTER_MSrather than a copy of it.The two are separately load-bearing, which the ablations show: unwiring the constructor default reddens only the first, changing the constant's value reddens only the second.
Why 30s: both copies run in one process off one hook event, so the managed copy's superseding post lands in the same millisecond band as the unmanaged one. Even the deliberately-withheld
agent_endis re-checked every 25–250ms until idle, and an auto-continuation postsagent_startas soon as it is scheduled. 30s is orders of magnitude above that, and far below the 30-minuteAGENT_STATUS_STALE_AFTER_MSat which Orca stops believing a "working" claim anyway — so a lapse means the managed poster is gone, not merely quiet. Verified end-to-end against the real constant with no test seam: the pane settles at 33s.The property this PR exists for is kept: while the managed copy is alive and posting, every stale post is superseded, so a stale extension still cannot settle a pane that is genuinely still working.
2. Orca's own relaunch posted without a token, and got warned about
codex-detached-pane-restart.ts— Orca's driver for an accepted Codex account-switch restart on an unmounted pane — kill-and-respawns Codex into the same pane key viabuildPaneIdentityEnv, which setORCA_PANE_KEY/ORCA_TAB_ID/ORCA_WORKTREE_IDbut notORCA_AGENT_LAUNCH_TOKEN. Codex's hook script postslaunchToken=${ORCA_AGENT_LAUNCH_TOKEN}, so the replacement posted tokenless into a pane the previous (tokened) Codex had already armed. Result: Orca suppressed its own replacement's status and toasted the user about "an extension Orca did not install" — for a process Orca launched. Unactionable, and worse than the bug it was guarding.This is a gap in the token contract, not in the fence. The launch token is Orca's only in-band proof of authorship, and every gate keyed on it reads a tokenless post as foreign — the retired-pane fence (
restartedStatusLaunchTokenHashByPaneKey) as much as this one. Teaching one fence to recognise one relaunch path would leave the other gates wrong and would need a new exemption for every future path. So the fix is at the source: that path now mints a launch token, like every other Orca agent spawn.Surveyed all four renderer
pty.spawncall sites; this was the only one that named alaunchAgentand shipped no token.launch-worktree-background-terminals.tsalso omits it but launches no agent, so it arms nothing.Note that fix 1 independently removes the toast here (a relaunch never produces the interleaved tokened post that confirmation requires), but it would still have left ~30s of suppressed status on Orca's own process. Both halves are needed.
3. The owner cap destroyed a held post instead of releasing it
The fence tracks at most
MAX_TRACKED_PANES(512) pane owners and evicts the least-recently-tokened one. That eviction calleddiscardPaneHolds, which cleared the pane's hold timer and dropped the entry without calling its release — so the held post was destroyed with nothing left to resolve it, and the pane claimedworkingpermanently.Measured against a control: two arms, one variable, identical hold window and identical waits, with the filler loop asserted to finish inside the window so the lapse could not be the discriminator.
['working']['working', 'done']Swapping in a releasing variant flips arm A to
['working', 'done']. The shipped suite stayed 10/10 green either way — nothing pinned it.The fix: eviction resolves the hold instead of destroying it. Eviction is not a delivery event, so it is treated exactly as the lapse is — the owner is forgotten, the gate re-opens, and the held post is released down the same re-entrant path. The releases run after the eviction loop, because a release re-enters
classifyand must not mutate the owner map mid-iteration.Every path that can remove a held post, enumerated. This is the third mechanism to break one invariant, so the check is exhaustive rather than incremental:
classify)holdPost, latest-only)forgetPane)rememberOwner)dispose)index.ts. Nothing held here is what the next launch reads: what survives is the pane's persisted status row, and hydrate re-stamps every non-donerowrestoredUnconfirmed(server.ts:3321-3323), whichisFreshNonDoneAgentStatusrefuses to read as live work. See the correction below. Now pinned (rows N and O) — the reasoning was right and nothing tested itSo the invariant now holds on every path: no reachable sequence of posts can leave a pane permanently claiming work that has finished.
Correction to the explanation of the last row
The invariant is confirmed. The reason given for the teardown row was not, and this is the third revision of this description to assert something false about its own invariant while landing on the right conclusion — which is exactly how a wrong explanation survives review.
Two things were wrong. The sentence above it said the single path that ends a hold without delivering it retires the pane's row; there are two — pane retirement and server teardown. And teardown was said to be safe because what persists "is re-read on the next launch as a replay, which this fence does not gate at all". A replay is a different thing in this code (
isReplay, fenced byhydratedLaunchTokenHashByPaneKey), and "the fence does not gate it" explains only why the fence is irrelevant — not why the pane is safe.The mechanism that actually makes it safe is a restore path keyed on
restoredUnconfirmed:working.if (entry.payload.state !== 'done') entry.restoredUnconfirmed = true(src/main/agent-hooks/server.ts:3321-3323; the field is declared at:142-143and is deliberately not persisted — it is stripped on write at:3449so hydrate always re-stamps it).isFreshNonDoneAgentStatus(src/shared/agent-status-types.ts:252-263),isExplicitAgentStatusFresh(src/renderer/src/lib/pane-agent-evidence.ts:17-25), and the sidebar, tab-bar and palette readers that call them.server.ts:1641-1645), or the row is retired by the ended-process / hydrated-authority machinery.So a hold lost at quit cannot produce a standing "working" claim, because the row that comes back is explicitly marked as not-live-truth until something live confirms it. The code comment asserted the old, wrong reason too; both it and the class doc's "only pane retirement" line are corrected in
b1cd969660. No behaviour changed — comment text only, verified by stripping comments from both revisions of the file and diffing the remainder (identical), withsrc/main/agent-hooks+src/shared/agent-hook-listenerat 952 checks, 0 red (6 skipped, 92 files),pnpm tcexit 0 / 0error TSrun cold after clearing the build cache,oxlintexit 0 with stdout retained and empty, andoxfmt --checkreporting the file correctly formatted.4. Three live paths that nothing protected — coverage, not behaviour
Three more pieces of this change reddened 0 of 775 in
src/main/agent-hooks— the wholesuite passed with each of them removed:
dispose()clearing the held posts' timers,this.unmanagedExtensionFence.dispose()instop(),holdPost's latest-only supersede, thediscardHeldPostthat drops an older holdbefore installing a newer one.
A 0-red is a question, not an answer, so each was classified against a whole-function
control before anything was written. Controls first, then the verdicts:
dispose()throws unconditionallydispose()throws only when a hold is outstandingstop()call removed anddispose()throwsstop()is the route for 199 of those 200 reachesholdPostreturns immediately (never holds)holdPostthrows on a second hold for the same pane and sourcedispose()clears held timersstop()disposes the fenceholdPostlatest-only supersedeNone of the three is unreachable code, so none warrants a tripwire or a deletion: the
remedy in every case is a test that reaches the path and fails if it changes.
The
stop()pin needed the right observable.stop()setsthis.onAgentStatus = nullbefore it reaches the fence, so a hold that outlives teardown never calls back — a
listener-based assertion would have passed either way and been vacuous. What it does instead
is re-enter the routing path and write a fresh row for a pane whose row
stop()justcleared, so the pin reads
getStatusSnapshotForPane(PANE)and requires it to stay empty.With the three pins in place the same three mutations redden 2 / 1 / 1 of 778. The
dispose mutation reddens two because both new teardown pins depend on that one clearTimeout.
Blast radius
Orca does still write to that directory today —
installManagedExtensionswrites<sourceAgentDir>/extensions/orca-agent-status.tson every OMP/Pi launch, wheresourceAgentDirdefaults to~/.omp/agent. But it writes only when the file already there carries the@orca-managed-pi-extensionmarker. An unmarked file is treated as user-owned, is never replaced, and Orca falls back touserData/omp-managed-status-extension/.That means the condition is permanent once it exists. It does not heal on upgrade. Every subsequent Orca release side-loads a second extension alongside the stale one, and each release widens the behavioural gap between them.
How a marker-less copy gets there:
userData/…-agent-overlays/, not into~/.<agent>/agent/extensions. The legacy overlay migration that copies that state home explicitly skips the three managed extension filenames.omp install/omp plugin link, a copy out of an overlay or another machine, or a user editing the managed file and dropping the marker line — that last one silently converts Orca's own extension into a permanently-stale one.Verdict: not everyone who upgraded, but not a closed set either. This is pre-existing. It is not caused by the OMP settle work, but it can mask it.
What changed
src/main/agent-hooks/unmanaged-status-extension-fence.ts— the classifier. Holds instead of drops, discards a held post when a tokened post supersedes it, reports only on that confirmation, and releases the held post when the window lapses or when the owner LRU evicts its pane.MAX_TRACKED_PANESis exported so the eviction test names the boundary instead of hard-coding 512.src/main/agent-hooks/server.ts— threads a re-delivery thunk intogetAgentStatusDisposition, which is the single choke point both the local HTTP path and the relayingestRemotepath already funnel through. The local path is now a re-entrantrouteLocalHookStatus, so a released hold re-runs every gate against the pane as it stands at release time rather than replaying a stale decision.stop()disposes held timers.src/renderer/src/components/terminal-pane/codex-detached-pane-restart.ts— mintsORCA_AGENT_LAUNCH_TOKENfor the respawn.src/main/agent-hooks/unmanaged-status-extension-fence.test.ts,server-unmanaged-status-extension.test.ts— tests only. Three pins for the teardown and supersede paths that reddened 0 of 775 (see finding 4).src/main/agent-hooks/unmanaged-status-extension-fence.ts(b1cd969660) — comment only. The class doc named pane retirement as the only path that ends a hold without delivering it; server teardown does too, anddispose()now states the reason it is safe (therestoredUnconfirmedrestore path) instead of the replay claim that was wrong.Orca does not delete, move, rename, or rewrite the user's file, and this PR adds no code that could. Detection and discrimination only.
Surfacing
A quiet filter would leave someone staring at their own extension being ignored for no stated reason. So the drop is announced, once per pane and source, and only once two posters are actually proven:
console.warnin main naming the source and pane, plusagent_hook_unmanaged_extensiontelemetry carrying the source only — the pane key and the file's contents are user data.The one-shot property lives in the renderer's per-source dedupe, not in the fence: main reports per pane and source, so 13 affected panes produce 13 detections that the renderer collapses to 1 toast. Both halves are now pinned by tests (they previously had none), and both redden under ablation.
Verification
Every number below was observed in the foreground, on this head, after the branch was refreshed onto
main. The rebase pulled inmain's pnpm 12 and oxlint/oxfmt upgrades, so every gate was re-run from a clean install rather than carried over.pnpm tc: exit 0, 0error TS, run cold —node_modules/.tmpremoved and every*.tsbuildinfodeleted first, because it is incremental and a warm cache has returned exit 0 on a tree that does not typecheck. Proven non-vacuous the same cold way: plantingconst orcaTcProbe2f45: number = 'not a number'in the fence gives exit 1 and 2error TSnaming that file at line 245.oxlint1.80.0 on the two changed test files: exit 0, stdout and stderr retained and both empty. Proven non-vacuous: planting adebuggergives exit 1 andeslint(no-debugger)naming line 54; removing it returns exit 0. (Run directly, retaining stdout — oxlint writes configuration failures there, and the changed-code quality gate brace-slices that stdout, which Node 26 pollutes with an engine warning.) Versions read fromorigin/mainat the rebase target rather than a worktree: pnpm 12.0.0, oxlint ^1.80.0, oxfmt ^0.65.0; installed binaries report 12.0.0 / 1.80.0 / 0.65.0.oxfmton the two changed test files, plus the repo's own staged-file hook (oxlint, react-doctor,oxfmt --write) running clean at commit time.main1 check, 0 red; the first cut 1 check, 1 red (['working'], nodone).ORCA_AGENT_LAUNCH_TOKENisundefined— 1 red. Relaunch toast probe: 1 red then, passes now.['working']), 10 filler panes 0 red (['working', 'done']), with the filler loop asserted to finish inside the hold window so the lapse was not the discriminator.server-unmanaged-status-extension.test.ts12 checks, 0 red;unmanaged-status-extension-fence.test.ts4 checks, 0 red — 16 together in 1.7s.src/main/agent-hooks→ 778 checks, 0 red (6 skipped, 77 files).src/main/agent-hooks+src/shared/agent-hook-listener→ 961 checks, 0 red (6 skipped, 92 files).diverged, ahead 4 / behind 18, while GitHub reportedMERGEABLE— the label is not a currency signal. After the refresh ontomain(0a995cc30d):ahead, ahead 5,behind_by0. CI re-earned on that base: 19 pass, 7 skipping, 0 failed — all eighttest / tests node 24shards,static analysis,packageandpackage (windows)included.Ablations
Gate level, one mutation at a time, each verified applied by diff before the run (an edit that silently misses reads as 0-red), tree restored and asserted clean between runs, run serially.
Rows J–M re-measured on this head. Rows A–I were measured at the previous head
574b7cbf97and are reproduced here unchanged; they have not been re-run since the rebase.release()on lapsedispose()stops clearing the held posts' timersstop()stops disposing the fenceholdPoststops superseding the older holdRows N–P are new in this round, each measured on the rebased head against a 778-check population; all three reddened 0 of 775 before their pins existed. Each of J–M reddens exactly its own gate and nothing else, which is what separates them: J and M are the two halves of "which removal paths release"; K and L are the two halves of "which edits to the shipped window get caught". J also reddens only the new test — the ten shipped tests stayed green under it, which is why the defect survived two rounds.
G reddened 0 on its first run in the previous round: the retired-pane gate suppressed the released post anyway, so the test named a line it did not exercise. It was rewritten to revive the pane through omp's real new-turn boundary (
before_agent_start) — a reused pane key settling on the previous turn's completion — and now reddens 1.Outstanding
The toast's rendered appearance still has not been checked. This change alters only when it fires, not its copy, styling, or markup, so no rendered-UI claim is made here. The
$electronskill is present and well-formed in this worktree (.claude/skills/electron/SKILL.md), unlike the lane that wrote the first revision, where it returnedUnknown skill.