Repository navigation
test: retire a dormant worker through host-owned status - #23686
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe end-to-end test verifies that the worker has no pane manager before completion. It seeds the Codex transcript and sends a completion marker through the runtime terminal API. The fake Codex process publishes recovery hook events. After normal exit, the test polls renderer state until it finds both the worker tab and recovery record. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The worker-recovery test has a narrow timing race that could make it unreliable. Awaiting hook publication before exit would make the test safer to merge. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change exercises the existing recovery path rather than changing application behavior. No new production exposure was identified, but the test does not establish how recovery behaves under every failure or repeated-event scenario. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
✅ No new issues found.
Reviewed changes
- Poll for settled renderer state after worker exit — the spec now wraps its pre-close
{ tabPresent, recoveryPresent }read inexpect.poll(...).toEqual({ tabPresent: true, recoveryPresent: true })instead of a one-shotexpect(await …), so it waits out the asynchronous renderer recovery update that follows the fixture's normal-exit marker. - Precondition for the transition recorder — this read is what the immediately following
store.subscribetransition capture assumes; waiting for{true, true}before subscribing keeps the laterarrayContaining([{true,true},{false,false}])assertion attributable to the close path rather than to a still-in-flight update.
Test-only change; no product, protocol, or execution-host surface. The assertions themselves are unchanged in value — only the read is retried (default poll budget resolves to tests/playwright.config.ts's expect: { timeout: 10_000 }). The added poll does not weaken the close-behavior checks, which still run after the close command is issued.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Publish worker recovery through authenticated hooks — the fake Codex worker now POSTs
UserPromptSubmitthenStopto/hook/codexwith its live launch authority (paneKey/tabId/worktreeId/launchToken/env/versionplussession_id/transcript_path) instead of the spec writing renderer status directly, so the test exercises the real host-owned recovery flow the PR body describes. - Per-run recovery config for the fake worker —
seedCurrentCodexTranscriptnow writesrecovery-config.json(session id + transcript path), which the worker reads when it receivesORCA_E2E_PUBLISH_DONE; the handler returns before the paste-ack path, whileORCA_E2E_EXIT_AFTER_DONEstill emitsnormal-exitand exits. - Retained async-recovery poll — the pre-close
{ tabPresent: true, recoveryPresent: true }expect.pollnow waits on host-published state; the removedsetAgentStatusseed and the now-unusedtranscriptPathlocal leave no dangling references.
The publish payload matches the established shape in tests/e2e/orchestration-worker-transcript-providers.spec.ts, and codex-events.ts confirms UserPromptSubmit → working / Stop → done, so the asserted { origin: 'live', state: 'done', providerSessionId } is what the real pipeline produces. Assertions are unchanged in value; the poll precondition is exactly what the following transition recorder assumes, and close is still issued after the subscription, so the true→false transition remains attributable to close. Test-only change with no product, protocol, or execution-host surface.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
| await expect | ||
| .poll(() => | ||
| orcaPage.evaluate( | ||
| ({ paneKey, tabId, worktreeId }) => { | ||
| const state = window.__store?.getState() | ||
| return { | ||
| tabPresent: Boolean( | ||
| state?.tabsByWorktree[worktreeId]?.some((tab) => tab.id === tabId) | ||
| ), | ||
| recoveryPresent: Boolean(state?.sleepingAgentSessionsByPaneKey[paneKey]) | ||
| } | ||
| }, | ||
| { paneKey: workerPaneKey, tabId: workerBefore.tabId, worktreeId: targetWorktreeId } | ||
| ) | ||
| ) | ||
| ).toEqual({ tabPresent: true, recoveryPresent: true }) | ||
| .toEqual({ tabPresent: true, recoveryPresent: true }) |
There was a problem hiding this comment.
Poll misses the exit
The test already confirms that the tab and recovery record are present before sending the exit command. After the worker writes normal-exit, this poll can therefore pass on that same pre-exit state, before the renderer receives the exit notification. Close can still begin too early, leaving the ordering race this test is meant to fix.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: c6183d28-be55-4641-8feb-907eea37c72c
📒 Files selected for processing (2)
tests/e2e/completed-worker-retirement-resume.spec.tstests/e2e/helpers/completed-worker-retirement-fixture.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| } | ||
| append({ event: 'input', input }) | ||
| if (input.includes('ORCA_E2E_PUBLISH_DONE')) { | ||
| void publishRecovery().catch((error) => process.stderr.write(String(error))) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect the test sequence between the completion marker and normal exit.
ast-grep outline tests/e2e/completed-worker-retirement-resume.spec.ts --view expanded
sed -n '190,310p' tests/e2e/completed-worker-retirement-resume.spec.tsRepository: stablyai/orca
Length of output: 4475
🏁 Script executed:
#!/bin/bash
sed -n '1,110p' tests/e2e/helpers/completed-worker-retirement-fixture.ts
printf '\n--- remaining relevant helper definitions ---\n'
sed -n '110,240p' tests/e2e/helpers/completed-worker-retirement-fixture.tsRepository: stablyai/orca
Length of output: 8417
🏁 Script executed:
sed -n '1,110p' tests/e2e/helpers/completed-worker-retirement-fixture.ts
printf '\n--- remaining relevant helper definitions ---\n'
sed -n '110,240p' tests/e2e/helpers/completed-worker-retirement-fixture.tsRepository: stablyai/orca
Length of output: 8417
🏁 Script executed:
rg -n -C 8 'ORCA_E2E_(PUBLISH_DONE|EXIT_AFTER_DONE)|publishRecovery|UserPromptSubmit|Stop' tests/e2e/helpers tests/e2e tests src | head -n 240Repository: stablyai/orca
Length of output: 20533
Await recovery publication before normal exit.
publishRecovery() sends the UserPromptSubmit and Stop requests sequentially, but the input handler does not retain its promise. The exit branch calls process.exit(0) independently. If the exit marker arrives while either request is pending, publication can be interrupted.
Suggested fix
+let recoveryPublication = Promise.resolve()
+
-process.stdin.on('data', (chunk) => {
+process.stdin.on('data', async (chunk) => {
...
- void publishRecovery().catch((error) => process.stderr.write(String(error)))
+ recoveryPublication = publishRecovery().catch((error) => {
+ process.stderr.write(String(error))
+ })
return
}
if (input.includes('ORCA_E2E_EXIT_AFTER_DONE')) {
+ await recoveryPublication
append({ event: 'normal-exit' })
process.exit(0)There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Kept the completed worker dormant instead of background-mounting it — the spec no longer dispatches
orca-background-mount-terminal-worktreenor polls__paneManagersfor the worker tab; it now asserts the pane manager is never mounted (toBe(false)) and the target worktree stays unactivated, so the close/release path runs against a genuinely never-opened background worker whose recovery record was published through the real host hooks (tests/e2e/completed-worker-retirement-resume.spec.ts:163).
The delta is test-only. The tab still exists in tabsByWorktree because terminal-tab creation is store-level (terminal-tab-creation.ts), independent of TerminalPane mount (use-terminal-pane-mount-lifecycle.ts), so the later tabPresent: true and the true→false transition assertions remain meaningful with no mounted pane. The one-shot negative read is safe at that point: no done/Stop hook has been published yet, so nothing has triggered a background wake of the tab.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
The worker-retirement test now checks a completed worker that has never been opened, matching the case it is meant to protect.
What Changed
The fake Codex worker publishes authenticated working/done hooks with its session identity. The test asserts its pane remains unmounted before the first activation. Both CLI close and worker release must remove the tab and recovery authority together, and later activation must not restart the worker.
Why
The old fixture wrote status directly to the renderer and then mounted the worker in the background. On Linux, normal foreground-shell cleanup removed the recovery record before the retirement action ran. Using host-owned status and keeping the worker dormant gives the test a valid recovery record to retire without bypassing production cleanup.
Linked Issue
CI failure: https://github.com/stablyai/orca/actions/runs/36479125813/job/109123429043
Visual Proof
N/A — fixture setup only; application behavior is unchanged.
Testing
ORCA_BACKGROUND_LAUNCH=1.Review
No product, protocol, execution-host, path, or platform changes.
Agent skill upstream boundary
Checklist