Skip to content

test(ci): retry Windows teardown EPERM and restart evaluate misses - #17780

Merged
nwparker merged 1 commit into
stablyai:mainfrom
nwparker:nwparker/slow-worktree-create-dizzy-eyes
Sep 1, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
nwparker:nwparker/slow-worktree-create-dizzy-eyes

Conversation

@nwparker

@nwparker nwparker commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

ELI5

Two CI harness races were reporting green work as failures.

  1. After a paired runtime restart, the renderer document can recycle. A poll that evaluates during that instant threw Execution context was destroyed and failed the spec. That error is now a pending miss so the wait continues; unrelated evaluate errors still fail.
  2. Windows test teardown deletes a temp dir right after force-killing a process tree. rmSync(..., { force: true }) only suppresses ENOENT, not EPERM from a handle the OS has not released yet. Teardowns in the Windows package lane now use the repo's maxRetries: 8 policy.

What the user sees

Nothing at runtime. package (windows) stops failing tests whose assertions already passed, and the restart-survival e2e stops dying on a one-shot recycled renderer.

Proof

  • Unit test drives the shipped restart-survival evaluate helpers: Execution context was destroyed resolves pending/null; a different error still rejects.
  • Unit test drives removeTreeSync: a transient EPERM is retried; force: true alone is not treated as enough; a non-lock error still throws.
  • Boundary test reads the Windows lane spec list out of .github/workflows/pr.yml and fails if a new spec hand-rolls recursive rm without retries.
  • windows-host-job.win32.test.ts afterAll calls removeTreeSync, not unretried rmSync.

Open PR #17227 already had this Windows teardown shape but is CONFLICTING with main; this lands the same shared policy on current main rather than a second copy.

Restart-survival polls treated a recycled renderer as a hard failure.
Wrap those evaluates so "Execution context was destroyed" is a pending
miss. Windows package-lane teardowns after a force-kill used rmSync
with force:true only, which does not absorb EPERM; put them on the
shared maxRetries:8 policy.
@pullfrog

pullfrog Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@greptile-apps

greptile-apps Bot commented Sep 1, 2026

Copy link
Copy Markdown

Greptile Summary

This PR centralizes Windows recursive-removal retry policy across CI teardown and makes restart-related renderer evaluation failures retryable. It also extracts browser restart-survival helpers and adds tests and a workflow-boundary ratchet.

  • Adds shared synchronous and asynchronous Windows tree-removal helpers.
  • Migrates Windows-lane test teardown and existing product removal options to the shared policy.
  • Treats destroyed renderer execution contexts as pending restart-state reads while preserving unrelated errors.
  • Adds unit and boundary coverage for retry behavior and Windows-lane teardown.

Confidence Score: 4/5

The PR should not merge until the post-restart browser-row read preserves pending renderer replacement instead of reporting a false empty result.

A destroyed execution context can be converted to an empty browser-row list and consumed by one-shot exact-count assertions, recreating a deterministic false-negative path in the restart-survival coverage; the boundary scanner also incompletely enforces its stated retry policy.

Files Needing Attention: tests/e2e/helpers/client-hosted-browser-fixture.ts; src/shared/windows-lane-tree-removal-boundary.test.ts

Important Files Changed

Filename Overview
src/shared/windows-transient-lock-removal.ts Introduces the centralized Windows recursive-removal retry policy and sync/async helpers.
src/shared/windows-lane-tree-removal-boundary.test.ts Adds a Windows workflow-spec scanner, but its broad maxRetries exemption does not enforce the stated shared policy.
tests/e2e/helpers/client-hosted-browser-fixture.ts Extracts shared browser restart helpers and retries destroyed-context reads, but one list helper collapses pending state into an empty result.
tests/e2e/paired-client-hosted-browser-restart-survival.spec.ts Refactors restart-survival coverage onto shared helpers while retaining detailed identity and placement assertions.
src/main/host-tree-removal.ts Reuses the centralized removal options without materially changing the existing host-removal retry behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Post-restart state read] --> B{page.evaluate result}
  B -->|value| C[Evaluate assertion]
  B -->|Execution context destroyed| D[Pending miss]
  D --> E[Retry poll]
  F[Windows test teardown] --> G[removeTree / removeTreeSync]
  G --> H[Recursive rm with Windows retries]
Loading

Reviews (1): Last reviewed commit: "test(ci): retry Windows teardown EPERM a..." | Re-trigger Greptile

}
return rows
}, worktreeId)
)) ?? []

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Pending read becomes empty state

When the renderer document is recycled during this post-restart read, readRestartRendererState returns null, but this fallback converts it to []; the one-shot restart-survival assertions then report that the recovered browser tab is missing even when recovery succeeded.

Knowledge Base Used: Desktop application platform

Comment on lines +88 to +90
if (args.includes('maxRetries')) {
continue
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Retry-policy exemption is too broad

This check exempts every recursive removal containing maxRetries, including hand-written values other than eight, so the boundary test can pass while Windows-lane specs bypass the shared helper and retain weaker, independently maintained retry settings.

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!

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request adds shared Windows tree-removal helpers with transient-lock retries. It updates host-tree removal and replaces direct recursive cleanup calls across tests. New tests enforce the Windows-lane removal policy. Client-hosted browser fixtures now use restart-aware renderer-state reads. New unit tests cover destroyed renderer contexts and propagated evaluation failures. The restart-survival test imports the shared fixture helpers.

Merge Risk: 🔵 Low · up to 267b8

The Windows CI cleanup policy can still be bypassed by a future teardown that specifies zero retries, allowing transient file-lock failures to return. The change is otherwise mergeable with explicit follow-up to make the boundary test require the configured retry value.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the main changes, motivation, and test evidence, but it omits required template sections and checklist details, including a Linked Issue with Fixes #, a ## Visual Proof se… Add all missing template sections. Provide the linked issue using Fixes #<issue-number>, add ## Visual Proof with N/A and a reason because there is no UI or interaction change, document testing steps and platforms under ## Testing, …
Docstring Coverage ⚠️ Warning Docstring coverage is 44.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 18 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes both primary changes: retrying Windows teardown failures and handling restart-related evaluate misses.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the main changes, motivation, and test evidence, but it omits required template sections and checklist details, including a Linked Issue with Fixes #, a ## Visual Proof section with N/A and a reason, a ## Testing section with platform and test details, and the required review, boundary, notes, and checklist sections.

Resolution

Add all missing template sections. Provide the linked issue using Fixes #&lt;issue-number&gt;, add ## Visual Proof with N/A and a reason because there is no UI or interaction change, document testing steps and platforms under ## Testing, complete the Agent skill upstream boundary section, and complete the Notes and Checklist items.

  • Fix all pre-merge checks with AI

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: c0c0d282-5e45-4a37-abb5-e239c48d995c

📥 Commits

Reviewing files that changed from the base of the PR and between 406bd0e and 267b862.

📒 Files selected for processing (18)
  • config/scripts/rebuild-native-deps-node-pty.test.mjs
  • config/scripts/rebuild-native-deps.test.mjs
  • src/main/agent-hooks/windows-hook-payload-delivery.test.ts
  • src/main/cli/wsl-cli-powershell-boundary.test.ts
  • src/main/codex-accounts/codex-managed-home-lifecycle.ts
  • src/main/cursor/hook-service.test.ts
  • src/main/host-tree-removal.ts
  • src/main/orca-profiles/profile-index-store.test.ts
  • src/main/runtime/repo-worktree-admin-fingerprint.test.ts
  • src/main/windows/windows-host-job.win32.test.ts
  • src/shared/child-process/windows-command-line.win32.test.ts
  • src/shared/secure-file-fsync-flags.test.ts
  • src/shared/windows-lane-tree-removal-boundary.test.ts
  • src/shared/windows-transient-lock-removal.test.ts
  • src/shared/windows-transient-lock-removal.ts
  • tests/e2e/helpers/client-hosted-browser-fixture.ts
  • tests/e2e/helpers/client-hosted-browser-fixture.unit.test.ts
  • tests/e2e/paired-client-hosted-browser-restart-survival.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Comment on lines +88 to +89
if (args.includes('maxRetries')) {
continue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Require the configured retry value.

Line 88 exempts any raw recursive removal that contains maxRetries. For example, rmSync(dir, { recursive: true, maxRetries: 0 }) passes this test but does not apply the required Windows retry policy. Require WINDOWS_RM_MAX_RETRIES or reject all raw recursive removals in Windows-lane specs.

@nwparker
nwparker merged commit f116d2c into stablyai:main Sep 1, 2026
33 of 34 checks passed
nwparker added a commit to nwparker/orca that referenced this pull request Sep 1, 2026
…launch evaluate

main advanced 9 commits; none touch the orca-runtime.ts this branch splits, so
nothing needed porting.

CI failed twice on `Execution context was destroyed` thrown from
headless-paired-runtime-host's first `evaluate` after launch — a different spec
each run, which is the signature of the flake stablyai#17780 describes rather than a
regression. That commit added retryTransientMainEvaluate and adopted it in five
helpers but not this call site, even though its docblock names exactly this
case: the first evaluate after electron.launch() resolves, before the app is
ready. Wrapped it the same way.
nwparker added a commit that referenced this pull request Sep 1, 2026
…17605)

* refactor(runtime): split OrcaRuntimeService into focused modules

* test(runtime): cover admission tiers and strict worktree reconciliation

* fix(runtime): preserve owner and structured session visibility

* fix(runtime): port post-extraction compatibility fixes

* fix(runtime): preserve skill-share cancellation barrier

* test(runtime): update identity inventory after extraction

* fix(runtime): preserve hook transport environment cleanup

* fix(runtime): consolidate idle probe imports

* test(runtime): retire split file process allowlist entry

* fix(runtime): route child process types through shared boundary

* test(runtime): preserve worktree host metadata precedence

* fix(runtime): update extracted test seams

* fix(runtime): gate the split's ts-nocheck set and restore the stop-confirmed contract

Audit follow-ups for the OrcaRuntimeService split:

- Freeze the 171 @ts-nocheck files behind a ratchet so no new file can disable
  type checking. The split's linear mixin chain cannot express forward
  references yet, so the existing suppressions are grandfathered; the baseline
  may only shrink.
- Drop the stray @ts-nocheck at the end of orca-runtime-get-status.ts. It sat
  after the first statement, where TypeScript ignores it, so the module was
  already checked.
- Restore `retireRejectedPty(ptyId, stopConfirmed: boolean)` as a required
  argument. The split widened it to optional and patched the resulting error
  with `stopConfirmed === true`; an omitted argument would have silently taken
  the unverified-stop path instead of failing to compile.
- Guard that every orca-runtime-tests fragment is imported by the compatibility
  entrypoint. The fragments are .spec.ts, which no Vitest include glob matches,
  so one left out of the list would silently stop running.

* fix(runtime): restore four behaviors the OrcaRuntimeService split dropped

Audit findings against the refactor's true base (ad5ba25):

- retirePtyAgentLaunchAuthority collected pane keys after deleting the
  restored-authority receipt instead of before it. collectPaneKeysForPty reads
  that receipt, so a receipt-only pane lost its key and never had its agent-hook
  compatibility authority retired. on-pty-exit.ts already carried a comment
  naming this exact invariant.
- The PTY-exit path kept orchestrationMailboxNotifications.retirePty but lost
  the loop that schedules a debounced mail-pointer repoint for the dead pty's
  terminal handle and any run bound to its panes. Restores the schedule call
  count to 7, matching base.
- subscribeToPtyExit lost isPtyKnownExited's leaf fallback and its
  post-registration lifecycle-generation recheck. leavesByPtyId is rebuilt from
  the renderer graph independently of ptysById, so a leaf can outlive its pty
  record; without the fallback a caller waiting on an already-dead pty never
  gets released.
- The chain root declared `[key: string]: unknown`, which base had nowhere. It
  leaked through the exported runtime type into every consumer, so any misspelled
  member access typechecked as unknown instead of erroring, and it accounted for
  957 of the suppressed errors. Removing it costs zero type errors.

* fix(runtime): restore escalation prose and unscoped automation publication

Two more behaviors the split dropped, each with a regression test that fails
against the pre-fix code:

- The worker-exit escalation stopped deriving its title through
  buildOrchestrationTaskDisplayMetadata and inlined `task.spec` instead. That
  ignored an explicit task_title, dropped the single-line normalization and the
  80-character bound, and turned the no-spec case into a quoted, duplicated id.
  A multi-paragraph spec landed verbatim in the coordinator's banner. The
  existing 11 tests all use short single-line specs, where the derived title and
  the raw spec are identical, so none of them could see it.
  Also reverts an added `if (!handle) return` guard: the dispatch lookup is
  deliberately keyed on the pane as well, because a reminted handle no longer
  matches the row while the pane identity outlives the remint.
- updateAutomation stopped going through automationChangePublications and
  published `source` unconditionally while gating the fallback on a non-null
  destination. A destination the store can no longer name then published only
  the stale source, so subscribers scoped elsewhere kept rendering a row that
  had left them — the exact case the helper documents. The helper had been left
  with zero callers; all three sites use it again.

* fix(skills): stop swallowing lookup errors and hard-erroring on non-ssh hosts

Follow-ups from auditing the skill install path against the refactor's base:

- resolveWorktree wrapped showManagedWorktree in `.catch(() => null)`, so a
  transient git or IO failure surfaced to the user as
  skill-install-workspace-not-found with the real cause discarded. Errors
  propagate again; a genuine id mismatch still returns null.
- resolveSkillSshTarget threw skill-install-workspace-host-unavailable when the
  execution host was neither local nor ssh, on both the repo and folder
  branches. Base gated these on connectionId, so a runtime-owned repo simply
  was not an SSH install and fell through to the local path. Both return null
  again, and the error code the split invented is now unreferenced.
- listManagedSkillInstalls awaited the receipt walk and the worktree resolve in
  sequence. They are independent and either can hit disk, WSL, or an SSH scan,
  so Promise.all is restored.

Deliberately unchanged: resolving the worktree through listResolvedWorktrees
rather than showManagedWorktree, which disambiguates a worktree id colliding
across hosts and is covered by its own test, and the SSH-folder
skill-install-ssh-dispatch-required throw, which matches the repo branch.

* fix(runtime): merge duplicate worktree-logic imports

The #17448 port added a third import from ../ipc/worktree-logic, which the
code-quality oxlint config rejects under --deny-warnings. Plain oxlint does not
flag it, so it only surfaced in CI's static analysis job.

* ci: run the ts-nocheck ratchet in PR checks

pr-workflow-lint-parity requires every leaf command in `pnpm lint` to have a
matching step in pr.yml. The ratchet was wired into lint but not the workflow,
so PR CI would not have enforced it.

* Merge remote-tracking branch 'origin/main' and retry the paired-host launch evaluate

main advanced 9 commits; none touch the orca-runtime.ts this branch splits, so
nothing needed porting.

CI failed twice on `Execution context was destroyed` thrown from
headless-paired-runtime-host's first `evaluate` after launch — a different spec
each run, which is the signature of the flake #17780 describes rather than a
regression. That commit added retryTransientMainEvaluate and adopted it in five
helpers but not this call site, even though its docblock names exactly this
case: the first evaluate after electron.launch() resolves, before the app is
ready. Wrapped it the same way.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#17780)

Restart-survival polls treated a recycled renderer as a hard failure.
Wrap those evaluates so "Execution context was destroyed" is a pending
miss. Windows package-lane teardowns after a force-kill used rmSync
with force:true only, which does not absorb EPERM; put them on the
shared maxRetries:8 policy.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#17605)

* refactor(runtime): split OrcaRuntimeService into focused modules

* test(runtime): cover admission tiers and strict worktree reconciliation

* fix(runtime): preserve owner and structured session visibility

* fix(runtime): port post-extraction compatibility fixes

* fix(runtime): preserve skill-share cancellation barrier

* test(runtime): update identity inventory after extraction

* fix(runtime): preserve hook transport environment cleanup

* fix(runtime): consolidate idle probe imports

* test(runtime): retire split file process allowlist entry

* fix(runtime): route child process types through shared boundary

* test(runtime): preserve worktree host metadata precedence

* fix(runtime): update extracted test seams

* fix(runtime): gate the split's ts-nocheck set and restore the stop-confirmed contract

Audit follow-ups for the OrcaRuntimeService split:

- Freeze the 171 @ts-nocheck files behind a ratchet so no new file can disable
  type checking. The split's linear mixin chain cannot express forward
  references yet, so the existing suppressions are grandfathered; the baseline
  may only shrink.
- Drop the stray @ts-nocheck at the end of orca-runtime-get-status.ts. It sat
  after the first statement, where TypeScript ignores it, so the module was
  already checked.
- Restore `retireRejectedPty(ptyId, stopConfirmed: boolean)` as a required
  argument. The split widened it to optional and patched the resulting error
  with `stopConfirmed === true`; an omitted argument would have silently taken
  the unverified-stop path instead of failing to compile.
- Guard that every orca-runtime-tests fragment is imported by the compatibility
  entrypoint. The fragments are .spec.ts, which no Vitest include glob matches,
  so one left out of the list would silently stop running.

* fix(runtime): restore four behaviors the OrcaRuntimeService split dropped

Audit findings against the refactor's true base (9dd3804):

- retirePtyAgentLaunchAuthority collected pane keys after deleting the
  restored-authority receipt instead of before it. collectPaneKeysForPty reads
  that receipt, so a receipt-only pane lost its key and never had its agent-hook
  compatibility authority retired. on-pty-exit.ts already carried a comment
  naming this exact invariant.
- The PTY-exit path kept orchestrationMailboxNotifications.retirePty but lost
  the loop that schedules a debounced mail-pointer repoint for the dead pty's
  terminal handle and any run bound to its panes. Restores the schedule call
  count to 7, matching base.
- subscribeToPtyExit lost isPtyKnownExited's leaf fallback and its
  post-registration lifecycle-generation recheck. leavesByPtyId is rebuilt from
  the renderer graph independently of ptysById, so a leaf can outlive its pty
  record; without the fallback a caller waiting on an already-dead pty never
  gets released.
- The chain root declared `[key: string]: unknown`, which base had nowhere. It
  leaked through the exported runtime type into every consumer, so any misspelled
  member access typechecked as unknown instead of erroring, and it accounted for
  957 of the suppressed errors. Removing it costs zero type errors.

* fix(runtime): restore escalation prose and unscoped automation publication

Two more behaviors the split dropped, each with a regression test that fails
against the pre-fix code:

- The worker-exit escalation stopped deriving its title through
  buildOrchestrationTaskDisplayMetadata and inlined `task.spec` instead. That
  ignored an explicit task_title, dropped the single-line normalization and the
  80-character bound, and turned the no-spec case into a quoted, duplicated id.
  A multi-paragraph spec landed verbatim in the coordinator's banner. The
  existing 11 tests all use short single-line specs, where the derived title and
  the raw spec are identical, so none of them could see it.
  Also reverts an added `if (!handle) return` guard: the dispatch lookup is
  deliberately keyed on the pane as well, because a reminted handle no longer
  matches the row while the pane identity outlives the remint.
- updateAutomation stopped going through automationChangePublications and
  published `source` unconditionally while gating the fallback on a non-null
  destination. A destination the store can no longer name then published only
  the stale source, so subscribers scoped elsewhere kept rendering a row that
  had left them — the exact case the helper documents. The helper had been left
  with zero callers; all three sites use it again.

* fix(skills): stop swallowing lookup errors and hard-erroring on non-ssh hosts

Follow-ups from auditing the skill install path against the refactor's base:

- resolveWorktree wrapped showManagedWorktree in `.catch(() => null)`, so a
  transient git or IO failure surfaced to the user as
  skill-install-workspace-not-found with the real cause discarded. Errors
  propagate again; a genuine id mismatch still returns null.
- resolveSkillSshTarget threw skill-install-workspace-host-unavailable when the
  execution host was neither local nor ssh, on both the repo and folder
  branches. Base gated these on connectionId, so a runtime-owned repo simply
  was not an SSH install and fell through to the local path. Both return null
  again, and the error code the split invented is now unreferenced.
- listManagedSkillInstalls awaited the receipt walk and the worktree resolve in
  sequence. They are independent and either can hit disk, WSL, or an SSH scan,
  so Promise.all is restored.

Deliberately unchanged: resolving the worktree through listResolvedWorktrees
rather than showManagedWorktree, which disambiguates a worktree id colliding
across hosts and is covered by its own test, and the SSH-folder
skill-install-ssh-dispatch-required throw, which matches the repo branch.

* fix(runtime): merge duplicate worktree-logic imports

The stablyai#17448 port added a third import from ../ipc/worktree-logic, which the
code-quality oxlint config rejects under --deny-warnings. Plain oxlint does not
flag it, so it only surfaced in CI's static analysis job.

* ci: run the ts-nocheck ratchet in PR checks

pr-workflow-lint-parity requires every leaf command in `pnpm lint` to have a
matching step in pr.yml. The ratchet was wired into lint but not the workflow,
so PR CI would not have enforced it.

* Merge remote-tracking branch 'origin/main' and retry the paired-host launch evaluate

main advanced 9 commits; none touch the orca-runtime.ts this branch splits, so
nothing needed porting.

CI failed twice on `Execution context was destroyed` thrown from
headless-paired-runtime-host's first `evaluate` after launch — a different spec
each run, which is the signature of the flake stablyai#17780 describes rather than a
regression. That commit added retryTransientMainEvaluate and adopted it in five
helpers but not this call site, even though its docblock names exactly this
case: the first evaluate after electron.launch() resolves, before the app is
ready. Wrapped it the same way.
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.

1 participant