Skip to content

fix: run archive hook for SSH CLI worktree removal - #18563

Closed
junited31 wants to merge 2 commits into
stablyai:mainfrom
junited31:fix/ssh-cli-archive-hook-on-removal-clean
Closed

junited31 wants to merge 2 commits into
stablyai:mainfrom
junited31:fix/ssh-cli-archive-hook-on-removal-clean

Conversation

@junited31

@junited31 junited31 commented Sep 4, 2026 •

Copy link
Copy Markdown

ELI5

When you delete an SSH-based worktree from the CLI with --run-hooks, the app was supposed to run your configured "archive hook" (e.g. a cleanup/release script) before deleting it — like it already does for local worktrees and for deletions done from the UI. It wasn't. This PR makes the CLI/SSH deletion path run that hook too, and — matching the failure-gating behavior #20153 added for local removal — blocks the deletion if the hook fails or its outcome can't be confirmed, unless explicitly waived.

What Changed

Two commits, rebased on current main after #20153 (fixes #19334) merged and added archive-hook failure gating for local removal:

  1. refactor(worktree): resolve remote archive hook owner explicitly — getArchiveHooksForRemoval/runRemoteArchiveHook now take an explicit, resolved connectionId argument instead of reading repo.connectionId. This fixes rows registered only as executionHostId: 'ssh:<target>' (no connectionId field), which previously no-oped the hook lookup. #20153's ArchiveHookRunResult shape, ARCHIVE_HOOK_TIMEOUT_MS, and observed-exit/exitCode semantics are unchanged. Infrastructure-only: runtime SSH removal is untouched by this commit.
  2. fix(worktree): run and gate SSH archive hooks before removal — removeRuntimeRegisteredRemoteWorktree now looks up and runs the configured archive hook over the resolved SSH connection, passes the result through #20153's gateWorktreeRemovalOnArchiveHook (a non-zero exit or an unobserved outcome blocks unless allowFailedArchiveHook is set), and — after the gate returns — unconditionally re-lists and revalidates the worktree's registration and lock state before acquiring the watcher, stopping PTYs, or calling removeWorktree, using the refreshed path/head. The now-unreachable temporary refusal (gateRemovalWhereArchiveHookCannotRun) and its dedicated test are removed.

Why

orca worktree rm --run-hooks removed SSH-backed worktrees without running their configured archive hook, while the app UI removal path handled it correctly. Archive hooks commonly release worktree-scoped resources (processes, sessions, external state); skipping them on every SSH removal leaks that state. After #20153 landed local-removal failure gating, the SSH path additionally needed to run the hook at all before that gate could mean anything, and needed to revalidate worktree state after the hook runs — the same ordering #20153 established for the local path, since an archive hook can itself unregister, lock, or move the worktree it was called on.

Linked Issue

Fixes #18558. That issue is currently closed as completed from #20153's merge, even though #20153 intentionally left this SSH path on a temporary refusal rather than executing the hook — this PR completes the fix by making the CLI/SSH path actually run the hook.

Visual Proof

N/A — this is a backend/CLI behavior fix (worktree removal hook dispatch over SSH). No UI or visual surface is touched.

Testing

Steps a reviewer can follow: add an SSH-backed repo with an archive script configured in orca.yaml, create a non-main worktree, run orca worktree rm <worktree> --run-hooks, and confirm the archive script runs before the worktree is removed. Confirm a failing hook blocks the removal (--allow-failed-archive-hook to override), and that omitting --run-hooks returns the skipped-hook warning, matching local removal.

  • Automated tests added/updated
    • src/main/runtime/runtime-registered-remote-worktree-removal.test.ts (new): 11 tests covering resolved-connection lookup/execution, skipped-hook warning, exited/unverifiable failure blocking with no mutation, force not waiving, allowFailedArchiveHook waiving and returning archiveHookOverride, a waived failure still revalidating fresh registration/lock state, refreshed-path/head usage for watcher/removal/branch preservation, and unconditional re-list even with no hook configured.
    • src/main/runtime/orca-runtime-tests/ssh-worktree-lifecycle-part-02.spec.ts: service-level cases proving runHooks: true executes the remote archive command before PTY stop/delete, and runHooks: false returns the warning without executing.
    • src/main/ipc/worktrees/removal/worktree-archive-hook.test.ts: explicit-owner execution, numeric exit code retention, and timeout/spawn-failure exitCode omission for runRemoteArchiveHook.

Verified locally (OCI Linux + a real Windows hpv2 host, at head 8910179a67):

  • pnpm test src/main/runtime/orca-runtime.test.ts — 1278/1278 passed on Windows (1277 passed / 1 skipped on Linux; the skip is a Windows-only case that ran on the Windows host).
  • pnpm test src/main/runtime/runtime-registered-remote-worktree-removal.test.ts src/main/ipc/worktrees/removal/worktree-archive-hook.test.ts src/main/ipc/worktrees-remove-archive-hooks.test.ts — 3 files, 35/35 passed.
  • pnpm tc:node — clean, no diagnostics, on both hosts.
  • oxlint on the 7 changed/existing TypeScript files — 0 warnings, 0 errors.
  • pnpm run check:code-quality:changed did not complete on the Windows verification host — it stalled past 90s even after raising diff.renameLimit, on two separate attempts. Not classified as a code issue: oxlint (the linter that script wraps) passed clean on the same files, and this is the one check I could not independently confirm pass/fail for.
  • The full repo-wide pnpm test was not run (out of scope for this diff); pnpm build was not run locally.

AI Disclosure

This PR was rebuilt from the reported author's original archive-hook design onto current main (post-#20153), with implementation and its test suite done via Claude Code (task role subagents, TDD red/green per commit), and design review via a separate GPT-based session before implementation began.

Review

Prior CodeRabbit/Pullfrog review threads on the earlier head are resolved by this rebase: the branch previously accumulated 20+ commits from unrelated workstreams (Windows CI test fixes, WSL fixtures, rate-limit design docs) and had 6+ outstanding pnpm tc:node TS2304 errors from those unrelated commits. The branch has been reset to exactly the two archive-hook commits on top of current main; please re-review from a clean diff.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Security: No new attack surface — reuses the existing connection-resolution and remote-execution helpers already exercised by the UI removal path and by #20153's local-removal gate.
  • Cross-platform (Linux/Windows/Mac): Change is confined to main-process TypeScript with no platform-specific branching. Verified with a real test run on both Linux (OCI) and Windows (hpv2).
  • Remote SSH: This PR is the SSH fix — it closes the gap where the SSH/remote removal path ran no archive hook at all, and now shares #20153's failure-blocking/waiver contract.
  • Mobile: N/A, not touched.
  • Backwards compatibility: No RPC/wire shape changes. RemoveWorktreeResult's existing optional archiveHookOverride/warning fields are populated the same way the local path already populates them.
  • Performance: Negligible — one additional hook lookup/dispatch when a hook is configured, plus one additional listWorktrees re-list after the hook runs (mirroring the local path's existing re-validation).
  • Full-suite baseline: Focused suites covering every changed file pass on both Linux and Windows. Full repo-wide pnpm test/pnpm build and CI have not been run for this exact head; please let CI complete before merge.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — pnpm tc:node clean and focused pnpm test suites (38 tests total across both hosts) pass; oxlint on changed files is clean; check:code-quality:changed could not be completed locally (see Testing); full-repo pnpm test/pnpm build and CI have not run against this head yet.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 13c539e9-2066-42ae-b763-c39a19fc1020

📥 Commits

Reviewing files that changed from the base of the PR and between 3cf1f8e2a7041ff164a6014ec5dc83cdddaaee07 and 5ff14fd6edc427cb3eec946ba207e55d2bdd4403.

📒 Files selected for processing (4)
  • .gitignore
  • docs/superpowers/plans/2026-09-09-claude-rate-limit-precedence.md
  • docs/superpowers/specs/2026-09-09-claude-rate-limit-precedence-design.md
  • src/main/ipc/pty-login-shell-startup-commands.test.ts

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


📝 Walkthrough

Walkthrough

SSH registered-worktree removal now forwards runHooks and the resolved connection ID. Remote archive-hook lookup and execution use that connection ID, including for SSH-only routes without repo.connectionId. The removal result can include a warning when hooks are skipped. New tests cover enabled hooks, resolved SSH connections, and removal without --run-hooks.

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 5ff14

SSH worktree removal now runs configured archive hooks when explicitly requested and warns when hooks are skipped, matching local removal behavior. The covered change is ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes changes unrelated to issue #18558: a new Claude rate-limit precedence design and plan, an unrelated PTY shell startup test adjustment, and a .gitignore rule for linked worktrees. Remove the unrelated Claude design and plan documents, PTY test adjustment, and .gitignore change, or split them into separate pull requests. Keep only the SSH archive-hook fix and its relevant tests and documentation.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The implementation satisfies issue #18558 by forwarding runHooks, resolving the SSH connection ID, executing archive hooks when requested, returning a skipped-hook warning otherwise, and adding focuse…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 7 files. (3 skipped: 3 …
Title check ✅ Passed The title clearly and concisely describes the main change: running archive hooks during SSH CLI worktree removal.
Description check ✅ Passed The description follows the required template and provides clear scope, motivation, linked issue, testing details, platform coverage, AI disclosure, review notes, and checklist status. It also explain…
  • 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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 36339094-a52c-43b0-a11c-1ef293d5effb

📥 Commits

Reviewing files that changed from the base of the PR and between 7106101 and c5fe6c5f51db91c30efc13e0132f8cf593222506.

📒 Files selected for processing (3)
  • src/main/runtime/orca-runtime-remove-managed-worktree.ts
  • src/main/runtime/orca-runtime-tests/ssh-worktree-lifecycle-part-02.spec.ts
  • src/main/runtime/runtime-registered-remote-worktree-removal.ts

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

@pullfrog pullfrog 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.

Important

The archive hook still won't run for SSH repos that carry only executionHostId: 'ssh:<target>' with no connectionId field — the exact ssh:-only row shape the connectionId arg's own doc comment warns about. See the inline comment.

Reviewed changes

  • runHooks threading — removeManagedWorktree now forwards its runHooks flag into removeRuntimeRegisteredRemoteWorktree.
  • Archive hook over SSH — the remote removal path now runs the archive hook via the shared getArchiveHooksForRemoval/runRemoteArchiveHook helpers, gated by runHooks, and returns the same skipped-hook warning the local path returns when a hook is configured but --run-hooks was not passed.
  • Tests — two focused specs assert the hook runs (and runs before removeWorktree) under --run-hooks, and that the warning is returned otherwise.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior review, the connectionId routing fix landed and the test strategy was consolidated:

  • connectionId threading — getArchiveHooksForRemoval/runRemoteArchiveHook now take an explicit connectionId instead of reading repo.connectionId, so ssh:-only rows execute the archive hook against the resolved route and no longer silently no-op.
  • UI path preserved — execute-worktree-removal.ts hoists remoteConnectionId = repo.connectionId ?? undefined and forwards it, keeping existing UI removal behavior identical.
  • Test consolidation — the unreachable end-to-end regression was replaced with a direct unit test of removeRuntimeRegisteredRemoteWorktree that keys off the resolved connectionId (with repo.connectionId deliberately unset), and mocks are reset between cases.

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

@pullfrog pullfrog 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.

Important

The branch picked up six commits unrelated to the archive-hook fix; they should be dropped before merge.

Reviewed changes — since the prior Pullfrog review at cb78441, no archive-hook code changed; six unrelated commits landed on the branch:

  • Claude rate-limit docs — two new docs/superpowers/ files record a design and a step-by-step implementation plan for a separate Claude rate-limit precedence bug (src/main/rate-limits/service-fetch-policy.ts), plus three follow-up doc edits. None touch the archive-hook path.
  • .gitignore — added a .worktrees/ entry under a new # Linked worktrees comment.
  • pty-login-shell-startup-commands.test.ts — normalized the zsh wrapper ZDOTDIR assertion to .split(sep).join('/').

⚠️ Unrelated commits pollute this fix PR

The six commits landed since the last review — 6768017, 8585da3, fe529f5, 27881f2, 9483741, c275c1b — are all for a different workstream (a Claude rate-limit precedence bug, local-worktree housekeeping, and an unrelated test normalization). The PR body still states the branch "contains only the two commits for this fix," but it now carries twelve. Merging as-is would land a 341-line implementation plan and a 169-line design doc for an issue that is not even filed yet, under a PR titled as a worktree-removal fix.

Technical details
# Drop the six unrelated commits before merge

## Affected sites
- 6768017756 — docs: record Claude rate limit precedence design (new docs/superpowers/specs file, 169 lines)
- 8585da316c — docs: refine Claude rate limit review criteria
- fe529f5ef4 — docs: add Claude rate limit implementation plan (new docs/superpowers/plans file, 341 lines)
- 27881f2b6e — chore: ignore local linked worktrees (.gitignore `.worktrees/`)
- 9483741fff — docs: preserve Claude Fable data during live precedence
- c275c1baf3 — test: normalize zsh wrapper path expectation

## Required outcome
- The branch contains only the archive-hook fix commits (02d6c6a through 3cf1f8e) on top of main.

## Suggested approach
- Reset this branch back to 3cf1f8e (the docs-only docstring commit) and move the six unrelated commits onto their own branch/PR for the Claude rate-limit work.

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

@pullfrog pullfrog 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.

Important

The new commit is technically correct, but it is the seventh commit on this branch that is unrelated to the archive-hook fix.

Reviewed changes — since my prior review at c275c1b, one more commit landed:

  • 5ff14fd (test: match shell wrapper path construction) — revises the zsh ZDOTDIR test assertion from join(...).split(sep).join('/') to a ${getShellReadyWrapperRoot()}/zsh template literal, and drops the now-unused sep import.

⚠️ Scope contamination now spans seven commits

The assertion change is sound — it now matches the PTY production code verbatim (src/main/providers/local-pty-shell-ready.ts:89, ZDOTDIR: \${getShellReadyWrapperRoot()}/zsh`), and it also fixes the earlier .split(sep).join('/') form, which over-normalized separators on Windows. But it is another commit unrelated to the archive-hook fix, stacked on top of the six already flagged. The branch now carries seven unrelated commits (6768017, 8585da3, fe529f5, 27881f2, 9483741, c275c1b, 5ff14fd`) that should all be dropped before merge, per the prior review.

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

@junited31
junited31 force-pushed the fix/ssh-cli-archive-hook-on-removal-clean branch from cca7a6b to 7ece564 Compare September 10, 2026 05:34

@pullfrog pullfrog 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.

Important

The new commit is technically sound, but it is the eighth commit on this branch unrelated to the archive-hook fix — and the rebase requested in the prior reviews still hasn't happened.

Reviewed changes — since the prior review at 5ff14fd, one commit landed:

  • Windows symlink-test skip — cca7a6b adds a canCreateFileSymlinks() probe and an it.skipIf(...) guard so the three symlink-dependent tests in installer-utils.test.ts skip on Windows hosts lacking symlink privilege, and rethrow any non-privilege error everywhere else.

⚠️ Scope contamination now spans eight commits

The new commit is correct — the probe detects Windows file-symlink capability (the exact thing the three gated tests exercise), and non-Windows failures still fail loudly. But it has nothing to do with the SSH archive-hook fix: it modifies src/main/agent-hooks/installer-utils.test.ts, a file the fix never touches. It is now the eighth commit stacked on this branch from other workstreams, and the archive-hook code itself is unchanged since 3cf1f8e. The PR body still claims the branch "contains only the two commits for this fix," but it carries 14.

Technical details
# Drop the eight unrelated commits before merge

## Affected sites
- cca7a6b — test: skip symlink fixtures without Windows privilege (new, unrelated)
- 5ff14fd — test: match shell wrapper path construction
- c275c1b — test: normalize zsh wrapper path expectation
- 9483741 — docs: preserve Claude Fable data during live precedence
- 27881f2 — chore: ignore local linked worktrees
- fe529f5 — docs: add Claude rate limit implementation plan
- 8585da3 — docs: refine Claude rate limit review criteria
- 6768017 — docs: record Claude rate limit precedence design

## Required outcome
- The branch contains only the archive-hook fix commits (02d6c6a through 3cf1f8e) on top of main.

## Suggested approach
- Reset this branch back to 3cf1f8e and move the eight unrelated commits onto their own branch/PR.

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior review at cca7a6b, the branch was rebased to drop the eight unrelated commits, and one test-only commit landed:

  • Scope cleanup — the eight unrelated commits flagged in prior reviews (the Claude rate-limit design/plan/spec docs, the .gitignore .worktrees/ entry, the zsh test tweaks, and the symlink-test skip) are gone. The branch now carries only the six archive-hook fix commits plus one new test commit, matching the PR body's claim.
  • POSIX-stable watcher fixtures — 7ece564 switches the absolutePath fixture helper in src/main/ipc/worktree-base-directory-watcher.test.ts from join(sep, ...) to pathPosix.join('/', ...) so fixture paths are deterministic POSIX across platforms, and swaps the sep import for posix as pathPosix.

The new commit is test-only and sound: posix.join('/', ...) yields /workspace/... everywhere, the mocked realpath returns paths unchanged, and PROJECT_GIT_COMMON_DIR is computed once and used consistently, so no assertion depends on the platform separator. The archive-hook fix itself is unchanged and correct.

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior review at 7ece564, two more test-only commits landed, both Windows CI robustness fixes:

  • Symlink fixture guard — 2f5460a adds a canCreateFileSymlinks() probe plus an it.skipIf(...) guard and converts the symlink-dependent tests to symlinkIt(...) in src/main/agent-hooks/installer-utils.test.ts and config/scripts/shared-electron-dist-cache.test.ts, so they skip on Windows hosts lacking symlink privilege while rethrowing any non-privilege error elsewhere.
  • Windows path normalization — 8f987308 makes shared-electron-dist-cache.test.ts compute expectedGitCommonDir = path.resolve('/repo/.git') and use it in the cacheRoot/entryPath assertions (matching the execFile mock now returning the resolved path), and makes repo-icon-autodetect.test.ts normalize filePath.replaceAll('\\', '/') before the /package.json suffix check.

Both changes are sound and test-only. The probe correctly treats a EPERM/EACCES on win32 as "skip" and rethrows otherwise; the path-resolution change makes the fixture and its expected value go through the same path.resolve/path.join, so they agree on Windows; and the replaceAll normalization matches backslash-terminated Windows paths. No production code is touched, and the archive-hook fix itself is unchanged and correct. The prior scope contamination is resolved — the branch now carries only the six archive-hook fix commits plus three small test-only Windows CI robustness commits.

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior review at 8f987308, one test-only commit landed:

  • POSIX-stable git common-dir fixture — 6d2cbc4 aliases join = pathPosix.join in src/main/ipc/worktree-base-directory-watcher.test.ts, so PROJECT_GIT_COMMON_DIR is computed with POSIX separators just like WORKTREE_ROOT/PROJECT_ROOT.

The change completes the fixture-consistency work started in 7ece564: absolutePath already used pathPosix.join, but PROJECT_GIT_COMMON_DIR still used the platform join from node:path, which on Windows produced \-separated segments inconsistent with the POSIX fixture roots. Aliasing join closes that gap. It is test-only with no production surface; no assertion depends on a specific separator, so behavior is unchanged on POSIX and internally consistent on Windows.

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

@pullfrog pullfrog 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.

✅ No new issues found. The two new commits are test-only Windows CI robustness fixes and are sound.

Reviewed changes — since the prior review at 6d2cbc4, two test-only commits landed:

  • Structured-session fixture isolation — c25e41e mocks codex-structured-turn-processes in structured-agent-session-integration.test.ts so the fake app-server (which has no child process) never triggers host-specific descendant enumeration during cancellation; the real functions remain covered by codex-structured-turn-processes.integration.test.ts.
  • Windows SSH fixture path derivation — e413729 derives SYSTEM_SSH_PATH from SystemRoot/WINDIR via win32.join, matching production systemSshPaths in src/main/ssh/system-ssh-binary.ts rather than hardcoding C:\Windows.

ℹ️ PR body claim is stale

The body still states the branch "contains only the two commits for this fix," but it now carries twelve commits — the six archive-hook fix commits plus six test-only Windows CI commits. Worth a one-line body update before merge; nothing blocks.

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior review at e413729, one test-only commit landed:

  • Relay symlink fixture guard — fcb7b54 adds the same canCreateFileSymlinks() probe and symlinkIt = it.skipIf(...) guard already used in the other test files, converting the three symlink-dependent FsHandler tests (retargeted-symlink rejection, lstat, realpath) to skip on Windows hosts lacking symlink privilege while rethrowing any other error.

Sound and consistent with the previously accepted symlink-guard pattern; no production surface.

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

@pullfrog pullfrog 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.

Important

Commit 89d9dec swaps the WslCodexAuthBatchReader type import for WslPaths, but two tests still reference typeof WslCodexAuthBatchReader, so pnpm tc:node fails with two TS2304 errors — despite the PR body claiming it is clean. See the inline comment.

Reviewed changes

  • Local WSL path fixture — 89d9dec added mockLocalWslPathBridge, which mocks ../../shared/wsl-paths so the six wslHome-based tests map Linux paths to local temp dirs instead of \\wsl.localhost\... UNC paths.
  • Mock reset between cases — 2a540ac added vi.doUnmock('../../shared/wsl-paths') in afterEach, keeping the mock from leaking into the two mounted-drive tests that still exercise the real module.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

Important

This new commit is sound, but it does not address the typecheck failure raised in the immediately-prior review — pnpm tc:node still reports two TS2304: Cannot find name 'WslCodexAuthBatchReader' errors (now at lines 559 and 668). The PR remains blocked until the WslCodexAuthBatchReader type import is restored.

Reviewed changes

  • Isolated WSL fixture processes — 3922392 added vi.doMock stubs for wsl-codex-session-bridge and legacy-wsl-runtime-auth-drain inside mockLocalWslPathBridge, so the six local-path-bridge tests no longer spawn the real bridge/drain background processes.

The new change is test-only and correct: the two added mocks resolve immediately, and the "waits for the legacy drain" test still overrides them with its own custom startLegacyWslRuntimeAuthDrain, so its gate assertions are unaffected.

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

@pullfrog pullfrog 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.

Important

Commit f71aaae drops the const processKill = mockProcessGroupSignals() declaration when converting the two process-group tests to it.skipIf(...), so pnpm tc:node fails with four new TS2304: Cannot find name 'processKill' errors. See the inline comment.

Reviewed changes

  • Windows process-group skip — f71aaae converted the two gh/glab process-group timeout tests in runner-command-exec.test.ts from it(...) to it.skipIf(process.platform === 'win32')(...), since POSIX process-group signaling (process.kill(-pid)) has no Windows equivalent.

The skip itself is correct — the negative-PID process-group assertion is genuinely POSIX-only. The problem is purely the dropped processKill declaration, which leaves four dangling references and would also make the assertion a no-op against an undefined mock even if it compiled.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

Important

This commit is sound, but the PR still fails pnpm tc:node on six TS2304 errors from prior commits — two WslCodexAuthBatchReader and four processKill — none of which this commit addresses. Those prior review threads remain open and block merge.

Reviewed changes

  • Skip remaining POSIX gh probes on Windows — c5ee050 converted the "kills an active gh execution" and "honors explicit gh timeouts" tests to it.skipIf(process.platform === 'win32')(...), this time correctly retaining each const processKill = mockProcessGroupSignals() declaration.

The new change is test-only and correct: both conversions preserve the processKill declaration, and the skip is genuinely warranted since both tests assert negative-PID process-group signaling that has no Windows equivalent.

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

@pullfrog pullfrog 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.

Important

The new commit is sound, but it does not address the typecheck failures that still block this PR. pnpm tc:node still reports six TS2304 errors — the missing WslCodexAuthBatchReader import (runtime-home-wsl-managed-accounts.test.ts:559,668) and the dropped processKill declarations (runner-command-exec.test.ts:317,319,338,340) — so the two open review threads from prior reviews remain unresolved.

Reviewed changes — since the prior review at c5ee050, one test-only commit landed:

  • Windows daemon pipe wait after respawn — 46edb9c adds a waitForEndpointReachable helper to daemon-endpoint-reachability-test-harness.ts that polls the production probeSocketConnect until the endpoint reports connected, and makes restartServerOnRespawn async so it awaits server.start() and (on win32) the reachability poll; all three call sites now await it.

The change is sound and test-only: probeSocketConnect already handles win32 named pipes via node:net connect({ path }), the helper throws after a 2s deadline on a still-unreachable endpoint, and no production code is touched.

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

@pullfrog pullfrog 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.

Important

Commit 44733a0 removed the spawnProcess type import but left two references behind, adding two new TS2304: Cannot find name 'spawnProcess' errors. pnpm tc:node now fails with eight errors across three files — the two pre-existing typecheck threads remain open, and this commit adds two more — so the PR body's "pnpm tc:node — clean" claim is still false.

Reviewed changes — since the prior Pullfrog review at 46edb9c, one test-only commit landed:

  • Codex connection teardown isolation on Windows — 44733a0 mocks codex-app-server-process-teardown on win32 so the connection tests exercise a synthetic SIGKILL teardown instead of the real taskkill, and makes the concurrent-close assertion platform-aware.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

Important

The new commit is sound, but the PR is still not mergeable — pnpm tc:node fails on the eight TS2304 errors left by prior commits, and this delta does not address them.

Reviewed changes — since the prior review at 44733a0, one test-only commit landed:

  • Relay symlink fixture guard (subprocess.test.ts) — 2193761a69 adds the canCreateFileSymlinks() probe and symlinkIt = it.skipIf(...) guard already accepted in the sibling relay/installer tests, converting the "reads files via symlinks resolving outside the workspace" test to skip on Windows hosts lacking symlink privilege while rethrowing any other error.

The delta itself introduces no new issues: symlinkSync is correctly hoisted to the top-level node:fs import (the local require was dropped), rmSync is imported for the probe's cleanup, and the 10_000 timeout is preserved.

⚠️ Typecheck failures from prior commits still block merge

No new issues in this delta. The remaining blocker is the typecheck failure already flagged in three open review threads — the missing WslCodexAuthBatchReader and spawnProcess type imports, and the dropped processKill declarations — none of which this commit touches.

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

@pullfrog pullfrog 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.

Important

The two new commits are sound, but the PR is still not mergeable — pnpm tc:node continues to fail on the typecheck errors already flagged in the open review threads, which this delta does not touch.

Reviewed changes — since the prior review at 2193761a, two test-only commits landed in src/renderer/src/app-startup-routing.test.ts:

  • Whitespace-tolerant checkpoint assertion — 423556a runs checkpointBlock.replace(/\s+/g, ' ') before the buildWorkspaceSessionHostSnapshots(...) toContain, so the assertion no longer depends on the generated code's exact line-wrapping.
  • Whitespace-tolerant shutdown-source assertion — 8c2dc630fe applies the same normalization to the ORCA_RENDERER_SHUTDOWN_CHECKPOINT_ABORTED_EVENT source assertion.

Both are correct: the normalization collapses any whitespace run to a single space while still pinning the exact call and argument names, so the assertions stop being brittle to formatting without becoming tautological. No production surface is touched.

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior Pullfrog review at 8c2dc630fe, a single commit landed that resolves all three open typecheck threads:

  • WslCodexAuthBatchReader import restored — runtime-home-wsl-managed-accounts.test.ts re-adds the type import the two mounted-drive tests still reference via importOriginal<typeof WslCodexAuthBatchReader>().
  • spawnProcess import restored — codex-app-server-connection.test.ts re-adds the type import alongside the new CodexAppServerProcessTeardownModule import.
  • processKill declarations restored — runner-command-exec.test.ts folds mockProcessGroupSignals() into mockWedgedCliSpawn's return value so all four call sites recover their processKill spy.

pnpm tc:node now passes clean (verified against a12e259). The three prior Pullfrog threads are replied-to and resolved. No production code changed; the archive-hook fix itself is unchanged and correct.

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

@pullfrog pullfrog 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.

Important

The "isolate watcher lifecycle from native subprocess" commit introduces two failing tests in filesystem-watcher-local-unsubscribe.test.ts — pnpm vitest run src/main/ipc/filesystem-watcher-local-unsubscribe.test.ts now fails 2 of 24 tests (passes 24/24 at the parent commit). See the inline comment.

Reviewed changes — since the prior Pullfrog review at a12e259, two test-only commits landed:

  • Per-host watcher fixture paths — 3606167f replaces the hardcoded '/tmp/repo'/'/tmp/other' strings with WORKTREE_PATH/OTHER_WORKTREE_PATH (both path.resolve('/tmp', ...)) so the fixtures resolve consistently on Windows.
  • Watcher lifecycle isolation from native subprocess — f46aac88 hoists subscribeParcelWatcherMock/subscribeViaWatcherProcessMock and rewires beforeEach so subscribeViaWatcherProcess delegates to the in-process subscribeParcelWatcher mock.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior Pullfrog review at f46aac8, one test-only commit landed:

  • Watcher abort modelling — ef312c3 rewrites the beforeEach subscribeViaWatcherProcess delegation to forward the 4th hooks argument and model the abort signal: it rejects on hooks.signal, unsubscribes the orphaned subscription when the underlying subscribeParcelWatcher resolves after an abort, and removes the listener on settle.

This resolves the two-test regression flagged in the prior review — pnpm vitest run src/main/ipc/filesystem-watcher-local-unsubscribe.test.ts now passes 24/24, and pnpm tc:node is clean. No production code changed; the archive-hook fix is unchanged and correct.

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior review at ef312c3, one test-only commit landed:

  • Codex probe abort termination on Windows — 8bc0d8a makes the abort test in codex-fetcher.test.ts exercise the force-termination path on every host: rpcChild.stdin.end is made a no-op so the fake child survives graceful stdin shutdown (the default fake exitNow would resolve the graceful path and never call child.kill, failing the toHaveBeenCalledTimes(1) assertion on Windows), and timers advance past the 5s CODEX_PROBE_SHUTDOWN_DRAIN_MS drain window.

The change is sound and test-only. Traced through terminateCodexProbeChild: on POSIX the no-op stdin.end still lets child.kill('SIGTERM') exit the fake immediately (kill once), while on win32 the 5s advance drains the shutdown window and falls through to the force child.kill() (also once). No production surface is touched, and the archive-hook fix itself remains unchanged and correct.

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior review at 8bc0d8a, one test-only commit landed:

  • Codex probe timeout termination on Windows — a19dabd adds the timeout analog of the abort test in codex-fetcher.test.ts: the same no-op stdin.end keeps the fake alive through graceful shutdown so the force-termination path runs on every host, then timers advance 30s (the RPC init deadline, since no initialize response is emitted) plus 5s (the CODEX_PROBE_SHUTDOWN_DRAIN_MS drain window).

The change is sound and test-only. It pins kill to exactly one call, asserts the stdout/stderr/error/close listeners are all removed after settle runs cleanupListeners, and confirms no PTY fallback with allowPtyFallback: false. The error string 'RPC timeout' matches armRpcDeadline verbatim. No production surface is touched, and the archive-hook fix itself remains unchanged and correct.

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Merged main — synced upstream main (2bf298d) into the branch via a merge commit; the archive-hook fix is unchanged, and the three test-file conflicts resolved cleanly.
  • WSL validation mock — the first account-sync test in service-wsl-accounts.test.ts now mocks node:child_process (execFileSync returns the WSL home path, spawn a no-op) so Windows CI never spawns a real wsl.exe during validation, matching the pattern already used by the other seven tests in the file.

Verified pnpm tc:node is clean and the affected suites pass: service-wsl-accounts (8), codex-app-server-connection (28), ssh-system-fallback (49), and runtime-registered-remote-worktree-removal (2).

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Relay spawn refactor — src/relay/subprocess.test.ts extracts a waitForRelaySentinel helper and collapses every relay = spawn(); await relay.sentinelReceived pair into relay = await waitForRelaySentinel(spawn()); purely mechanical, no behavior change.
  • Cross-version wire Windows cleanup — cross-version-agent-session-wire.unit.test.ts hoists host to the describe scope and flushes the structured host's streamed events in afterEach before rm(root), so Windows cleanup no longer trips over a locked file handle.

The archive-hook fix is unchanged. Verified pnpm tc:node clean and src/relay/subprocess.test.ts passes 32/32. The cross-version spec can't run in this shallow clone (no release tags), but the 4-line change is typecheck-clean and trivially correct.

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

@pullfrog pullfrog 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.

Caution

This PR's latest commit deletes the operations counter declaration that the cross-version wire test still reads, breaking the file at both typecheck and runtime.

Reviewed changes — since the prior Pullfrog review at 88e69ba, one test-only commit landed:

  • Warm cross-version release checkout — cdb86dc bumps SUITE_TIMEOUT_MS from 180s to 300s and hoists releasedCurrent = await loadAgentSessionWireBuild('HEAD') into beforeAll, replacing the lazy per-test load so the baseline release checkout is warmed once ahead of the first pairing.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

ℹ️ No new issues in this delta — the commit is sound. The one minor suggestion from a prior review (test coverage for normalizeWindowsDiffHeaders, still open on config/scripts/xterm-patch-text.mjs:61) remains unaddressed.

Reviewed changes — since the prior Pullfrog review at c47bc89, one test-only commit landed:

  • Windows recovery-command quoting — orchestration-gate-cli.test.ts and orchestration-timeout-cli.test.ts now build their expected recovery/resume commands through the production renderCommand helper instead of hardcoding POSIX-form strings, so the assertions match cmd's argument quoting on Windows.

The change is sound. The timeout test renders the exact array question-handler.ts:102 builds (renderCommand([resolveOrchestrationCliExecutable(), 'orchestration', 'ask', '--from', …, '--resume', messageId, '--timeout-ms', …])), so expected and actual now flow through the same shell-aware renderer and agree on every platform. The gate test renders the --retry-request <id> tail, which is a substring of the message's renderCommand(retryCommand) on both POSIX and cmd. Verified both files pass 26/26; no production surface is touched, and the archive-hook fix itself is unchanged and correct.

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

@pullfrog pullfrog 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.

ℹ️ No new issues in this delta — the two new test files are sound. The one minor suggestion from a prior review (test coverage for normalizeWindowsDiffHeaders, still open on config/scripts/xterm-patch-text.mjs:61) remains unaddressed.

Reviewed changes — since the prior Pullfrog review at 37676af, two test-only commits landed:

  • Orchestration mutation-recovery unit tests — added src/cli/orchestration-mutation-recovery.test.ts, pinning dispatch-vs-retry ordering, exact argv replay, legacy command-text parsing, --retry-request identity reuse, Windows cmd/PowerShell and POSIX quoting, a real /bin/sh round-trip, and secret-stripping that blocks recovery.
  • RuntimeClient recovery-identity integration tests — added src/cli/runtime/client-recovery.test.ts, exercising real RPC failure responses over node:net (unix socket / named pipe) plus durable-prompt retry and downgraded/legacy runtime paths.

Both files are test-only and pass (24/24 total). The nextSteps assertions now route through renderCommand (matching the production orchestrationMutationRecoveryError renderer), while the plain --retry-request <id> assertions target the prompt-recovery path (terminal-prompt-mutation-recovery.ts), which interpolates literally rather than through renderCommand, so they hold on every platform. The runtimeEndpoint helper selects named pipes on win32 and unix sockets elsewhere, matching the transport kind writeRuntimeConnection emits. No production surface is touched, and the archive-hook fix itself is unchanged and correct.

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

@pullfrog pullfrog 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.

ℹ️ No new issues in this delta — the change is a correct test-only skip. The one minor suggestion from a prior review (test coverage for normalizeWindowsDiffHeaders, still open on config/scripts/xterm-patch-text.mjs:61) remains unaddressed.

Reviewed changes — since the prior Pullfrog review at d0dd9b1, one test-only commit landed:

  • Skip POSIX hook execution on Windows — hook-script-outside-orca.test.ts wraps the "managed hook outside an Orca terminal" suite in describe.skipIf(process.platform === 'win32'), since those four cases spawnSync('/bin/sh', …) and have no Windows equivalent. The platform-independent antigravity out-of-band event name suite is correctly left ungated.

The change is sound: the whole gated block is POSIX-only, and the skip condition matches the spawnSync('/bin/sh') dependency. Verified the file passes 5/5 on Linux; no production surface is touched, and the archive-hook fix itself is unchanged and correct.

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

@pullfrog pullfrog 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.

ℹ️ No new issues in this delta — the commit is sound. The one minor suggestion from a prior review (test coverage for normalizeWindowsDiffHeaders, still open on config/scripts/xterm-patch-text.mjs:61) remains unaddressed.

Reviewed changes — since the prior Pullfrog review at 1e731373, one test-only commit landed:

  • POSIX spool-test gating — spool.test.ts wraps the "spools when the endpoint is present but the receiver is unavailable" test in it.skipIf(process.platform === 'win32'), since it execFileSyncs /bin/sh through a POSIX managed script and has no Windows equivalent.
  • Windows cleanup retry — windows-hook-post-interpreter.test.ts adds maxRetries: 5, retryDelay: 100 to its two afterEach rmSync calls so a transient EPERM/EBUSY during teardown retries instead of failing.

Both changes are sound and test-only. The spool skip matches the same pattern as 1e731373 (the spawnSync('/bin/sh') suite in hook-script-outside-orca.test.ts), and the rmSync retry options mirror the repo's existing maxRetries/retryDelay cleanup idiom. No production surface is touched, and the archive-hook fix itself is unchanged and correct.

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

@pullfrog pullfrog 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.

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes — since the prior Pullfrog review at eefcedf3, two commits landed:

  • normalizeWindowsDiffHeaders rewrite — the header normalizer now tracks hunk state and requires an a//b/ prefix, so ---/+++ lines inside hunk bodies (e.g. a deleted --- \server\deleted) are no longer rewritten. This fixes a real bug in the earlier implementation and is pinned by a new exact-output test.
  • runGit EOL isolation — regenerate-xterm-patches.mjs centralizes -c core.autocrlf=false -c core.eol=lf plus pnpmDiffEnvironment into a runGit helper and routes every git call through it; diffFolders gets the same EOL isolation.
  • Symlink gating refinement — space-sharing-copy.test.ts swaps the whole-suite describeWithSymlinks skip for per-test it.skipIf(!symlinksAvailable) gating, and makeTree only creates the link when the host supports it, so exactly the three symlink-reading tests are gated.
  • Recovery-command assertion — the gate-cli recovery test now renders the full orca orchestration gate-create … --retry-request command (matching production retryCommand = [...originalCommand, '--retry-request', requestId]) instead of the tail.
  • Cleanup retry tuning — windows-hook-post-interpreter.test.ts bumps the teardown rmSync retry to maxRetries: 20, retryDelay: 250.

The normalizeWindowsDiffHeaders coverage thread from the prior review is now addressed and resolved. The archive-hook fix itself is unchanged and correct.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior Pullfrog review at 5aa012d, two commits landed, both confined to config/scripts/ build/test code (no production surface; the archive-hook fix is unchanged and correct):

  • runGit config scoping — runGit gains an ambientConfig flag, and git remote add/git fetch opt out of pnpmDiffEnvironment so a developer's url.*.insteadOf rewrites and config-file http.proxy are honored during --write. This resolves the fetch-config-isolation thread left open by the prior review; init/checkout/reset/apply/diff correctly stay on the isolated EOL environment.
  • Git C-quote path decoding — normalizeWindowsDiffHeaders now decodes Git C-style escapes through a new decodeGitQuotedPath (simple escapes plus octal \303\251 byte sequences), so quoted non-ASCII Windows headers normalize to the committed UTF-8 form instead of leaking backslash/octal text into the patch.
  • Portable escape assertion — the new escape-decoding test builds é from String.fromCodePoint(0xe9) rather than a literal non-ASCII char, keeping the test file pure ASCII.

The decodeGitQuotedPath reader matches Git's quote_c_style byte escapes (3-digit octal for control/high bytes; the 1–3-digit read is a safe superset), and the existing inHunk guard already keeps --- \server\deleted hunk-body content out of the decoder. Verified pnpm vitest run config/scripts/regenerate-xterm-patches.test.mjs passes 35/35.

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior Pullfrog review at 504acb7, two commits landed, both confined to config/scripts/ build/test code (no production surface; the archive-hook fix is unchanged and correct):

  • Quote-delimiter stripping — normalizeWindowsDiffHeaders now strips Git's outer quote delimiters via a new stripGitHeaderQuoteDelimiters state machine instead of the blunt .replaceAll('"', ''), so a literal " inside a filename is preserved rather than silently dropped. Escaping is decided by counting preceding backslashes (odd = escaped), so \" and even-backslash runs before a closing delimiter are handled correctly.
  • Two new tests — one pins literal-quote preservation (a/with"quote/name), one pins delimiter stripping after even backslash runs (a/dir\\ → a/dir/).
  • Comment — spool.test.ts gains a note explaining why the POSIX spool replay stays skipIf(win32).

Traced the state machine against both new cases and the pre-existing a/lib\\widget.js case: delimiters are removed, escaped quotes and backslashes survive into decodeGitQuotedPath, and the diff --git two-path space separator is preserved. Verified pnpm vitest run config/scripts/regenerate-xterm-patches.test.mjs passes 37/37.

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

@junited31
junited31 force-pushed the fix/ssh-cli-archive-hook-on-removal-clean branch from 6f6856c to 17d50ce Compare September 10, 2026 14:38

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior review at 6f6856c9ca, the branch was rebased cleanly on upstream/main, dropping the Windows CI test-only tail, and now carries only the six archive-hook fix commits:

  • Archive hook over SSH — removeRuntimeRegisteredRemoteWorktree runs the archive hook via the shared getArchiveHooksForRemoval/runRemoteArchiveHook helpers, gated by runHooks, returning the same skipped-hook warning the local path returns.
  • Resolved-route connectionId — both helpers now take an explicit connectionId, so ssh:-only rows (executionHostId with no connectionId) run the hook against the resolved route instead of silently no-opping.
  • Direct unit test — the unconstructible end-to-end regression was replaced with a direct unit test of removeRuntimeRegisteredRemoteWorktree keyed off the resolved connectionId, with mocks reset between cases.
  • Docstrings — added to the touched functions.

Verified pnpm tc:node clean and the two affected suites pass (11 tests total).

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

@nwparker

Copy link
Copy Markdown
Contributor

Cross-linking from #20153 (fixes #19334), since these two touch the same archive-hook code from opposite directions and neither of us should be surprised at merge time.

This PR makes the runtime registered remote/SSH removal path run the archive hook, which it currently does not. #20153 makes a failing archive hook block the removal instead of being logged and stepped over — and its path table deliberately lists that same runtime remote path as "runs no hook at all, unchanged", precisely because of that gap.

So the two are complementary rather than competing, with one consequence worth stating: once this lands, that path starts running a hook that #20153 does not gate. Whoever merges second should wire gateWorktreeRemovalOnArchiveHook into removeRuntimeRegisteredRemoteWorktree, or a failed archive hook on an SSH worktree will still delete the checkout — the original bug, surviving in the one path that just gained the hook.

Textual overlap is four files: execute-worktree-removal.ts, worktree-archive-hook.ts, orca-runtime-remove-managed-worktree.ts, ssh-worktree-lifecycle-part-02.spec.ts. Note that #20153 changes removeManagedWorktree from positional arguments to a named options object, so the call in your diff will need that shape if #20153 lands first.

No action needed from you right now — flagging so the second merge is a deliberate rebase rather than a surprise.

@nwparker

Copy link
Copy Markdown
Contributor

Update from #20153 (fixes #19334) now that my approach has settled, since it changes what you'll find in removeRuntimeRegisteredRemoteWorktree when you rebase.

#20153 now makes that path refuse a hooks-requested removal, rather than deleting with the archive step silently skipped. Reasoning: #20153 advertises a runtime capability, worktree.archive-failure-blocking.v1, that the issue reporter's integration gates on. Advertising it unconditionally while this one path ran no hook at all would have told them "a failing archive hook cannot delete your checkout here" in exactly the case where it could. Refusing was the only way to make the claim true everywhere without duplicating your work.

That refusal is meant to be temporary, and your PR is what retires it. Once this path actually runs the hook, the right move is to delete gateRemovalWhereArchiveHookCannotRun from it and call gateWorktreeRemovalOnArchiveHook on the hook's result instead — same gate the local and IPC paths use, so a failing hook blocks rather than the path itself blocking. The refusal is modelled as outcome: 'unverifiable' precisely because nothing ran; once something runs you get real exited/unverifiable verdicts.

Concretely, what to expect on rebase if #20153 lands first:

  • removeRuntimeRegisteredRemoteWorktree gained a runHooks: boolean arg, already threaded from removeManagedWorktree — so the plumbing your change needs is in place.
  • removeManagedWorktree moved from positional args to a named options object, so its call sites read removeManagedWorktree(selector, { force, runHooks, allowUnverifiedPtyStop, allowFailedArchiveHook, hostId }).
  • getArchiveHooksForRemoval returns { hooks, hookConfigUnreadable } instead of OrcaHooks | null.
  • runHook now goes through runHookScriptWithDeadline, which withholds the exit code when a hook times out. Worth knowing if you assert on hook results: a timed-out hook is unverifiable, not a zero exit.

No action needed from you now — flagging so the interaction is a deliberate decision at review time rather than a surprise. Happy to do the retirement edit myself as a follow-up to yours if that's easier.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior pullfrog review at 17d50ce, one commit landed (b093ad4), which re-validates the SSH worktree after the archive hook runs:

  • Post-hook re-validation — removeRuntimeRegisteredRemoteWorktree now re-lists the execution host's worktrees after the archive hook and re-runs findRegisteredDeletableWorktree/assertWorktreeUnlockedForRemoval, throwing Worktree registration changed during deletion if the hook unregistered the row and the formatted locked-worktree error if it left the row locked. Unconditional, matching the local removal path.
  • Refreshed row drives deletion — removal, watcher-gate acquisition, and preserveBranchHead now use the refreshed row instead of the stale pre-hook registeredWorktree, so a hook that moved the branch preserves the refreshed head. preserveHead fills preservedBranch.head before finishRemoval's remember, so the refreshed head reaches the preserved-branch cleanup.
  • Regression tests — three unit cases cover unregistered-after-hook, locked-after-hook, and moved-head preservation. All are falsifiable: each fails against the pre-commit code (old code would not re-list, and would pass the pre-hook head). Integration coverage is unchanged and still passes.

Verified locally: pnpm tc:node clean; runtime-registered-remote-worktree-removal.test.ts 5/5; the archive-hook integration tests 5/5 via pnpm test src/main/runtime/orca-runtime.test.ts -t "archive hook".

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

@nwparker

Copy link
Copy Markdown
Contributor

Correction to one line above, after a simplification pass on #20153.

I wrote that runHook "now goes through runHookScriptWithDeadline". That module no longer exists — it was collapsed back into runHook itself. The behaviour it described is unchanged and still relevant to you: a hook that outruns its deadline withholds its exit code, so it classifies as unverifiable rather than as a zero exit. If you assert on hook results in the SSH path, that distinction still matters.

Everything else in that comment holds against the final shape:

  • removeRuntimeRegisteredRemoteWorktree takes a runHooks: boolean, threaded from removeManagedWorktree — the plumbing your change needs.
  • removeManagedWorktree takes a named options object rather than positional arguments.
  • getArchiveHooksForRemoval returns { hooks, hookConfigUnreadable }.
  • The SSH refusal (gateRemovalWhereArchiveHookCannotRun) is what your PR retires: once that path runs the hook, delete it and call gateWorktreeRemovalOnArchiveHook on the result instead, so a failing hook blocks rather than the path itself blocking.

One detail worth having if you touch hook execution: runProcess is not usable for orca.yaml scripts. It refuses shell: true by design, so a script string has to be passed as argv, and cmd.exe takes /d /s /c rather than -c. I tried that migration and reverted it — hooks.test.ts catches it if you try.

nwparker added a commit that referenced this pull request Sep 14, 2026
A repo's orca.yaml archive hook is the user's last chance to save work off a
checkout Orca is about to delete. A failed hook was logged as advisory and
stepped over, so the removal went ahead with nothing archived — and the caller
could still be told it succeeded.

The hook is now a blocking precondition, evaluated while the checkout, its Git
registration, its agents and Orca's ownership evidence are all still intact: it
sits ahead of the registration re-read, the lock/dirty preflights, stopPtys()
and removeWorktree in every orchestrator that runs it.

Failure is typed (worktree_archive_hook_failed) and carries the worktree path,
outcome, exit code where one was observed, and the hook's output. unverifiable
stays distinct from exited, so loss of contact is never read as a pass. The
waiver rides its own field at every layer and is never implied by --force, which
already carries the PTY-stop waiver; when used, the waived failure comes back on
result.archiveHookOverride rather than being swallowed.

worktree.archive-failure-blocking.v1 is advertised so an integration can tell
"accepts --run-hooks" from "safely propagates a failing hook" without risking the
data loss to find out. The runtime's SSH path cannot run a hook at all, so rather
than delete with the archive step silently skipped it refuses — waivable like
every other refusal here. #18563 retires that gate by making the path run the
hook for real.

Stacked on #20559, which makes a timed-out hook report honestly; without it a
hook that traps SIGTERM and exits 0 would defeat this gate.

Fixes #19334
nwparker added a commit that referenced this pull request Sep 14, 2026
A repo's orca.yaml archive hook is the user's last chance to save work off a
checkout Orca is about to delete. A failed hook was logged as advisory and
stepped over, so the removal went ahead with nothing archived — and the caller
could still be told it succeeded.

The hook is now a blocking precondition, evaluated while the checkout, its Git
registration, its agents and Orca's ownership evidence are all still intact: it
sits ahead of the registration re-read, the lock/dirty preflights, stopPtys()
and removeWorktree in every orchestrator that runs it.

Failure is typed (worktree_archive_hook_failed) and carries the worktree path,
outcome, exit code where one was observed, and the hook's output. unverifiable
stays distinct from exited, so loss of contact is never read as a pass. The
waiver rides its own field at every layer and is never implied by --force, which
already carries the PTY-stop waiver; when used, the waived failure comes back on
result.archiveHookOverride rather than being swallowed.

worktree.archive-failure-blocking.v1 is advertised so an integration can tell
"accepts --run-hooks" from "safely propagates a failing hook" without risking the
data loss to find out. The runtime's SSH path cannot run a hook at all, so rather
than delete with the archive step silently skipped it refuses — waivable like
every other refusal here. #18563 retires that gate by making the path run the
hook for real.

Stacked on #20559, which makes a timed-out hook report honestly; without it a
hook that traps SIGTERM and exits 0 would defeat this gate.

Fixes #19334
nwparker added a commit that referenced this pull request Sep 15, 2026
A repo's orca.yaml archive hook is the user's last chance to save work off a
checkout Orca is about to delete. A failed hook was logged as advisory and
stepped over, so the removal went ahead with nothing archived — and the caller
could still be told it succeeded.

The hook is now a blocking precondition, evaluated while the checkout, its Git
registration, its agents and Orca's ownership evidence are all still intact: it
sits ahead of the registration re-read, the lock/dirty preflights, stopPtys()
and removeWorktree in every orchestrator that runs it.

Failure is typed (worktree_archive_hook_failed) and carries the worktree path,
outcome, exit code where one was observed, and the hook's output. unverifiable
stays distinct from exited, so loss of contact is never read as a pass. The
waiver rides its own field at every layer and is never implied by --force, which
already carries the PTY-stop waiver; when used, the waived failure comes back on
result.archiveHookOverride rather than being swallowed.

worktree.archive-failure-blocking.v1 is advertised so an integration can tell
"accepts --run-hooks" from "safely propagates a failing hook" without risking the
data loss to find out. The runtime's SSH path cannot run a hook at all, so rather
than delete with the archive step silently skipped it refuses — waivable like
every other refusal here. #18563 retires that gate by making the path run the
hook for real.

Stacked on #20559, which makes a timed-out hook report honestly; without it a
hook that traps SIGTERM and exits 0 would defeat this gate.

Fixes #19334
nwparker added a commit that referenced this pull request Sep 15, 2026
A repo's orca.yaml archive hook is the user's last chance to save work off a
checkout Orca is about to delete. A failed hook was logged as advisory and
stepped over, so the removal went ahead with nothing archived — and the caller
could still be told it succeeded.

The hook is now a blocking precondition, evaluated while the checkout, its Git
registration, its agents and Orca's ownership evidence are all still intact: it
sits ahead of the registration re-read, the lock/dirty preflights, stopPtys()
and removeWorktree in every orchestrator that runs it.

Failure is typed (worktree_archive_hook_failed) and carries the worktree path,
outcome, exit code where one was observed, and the hook's output. unverifiable
stays distinct from exited, so loss of contact is never read as a pass. The
waiver rides its own field at every layer and is never implied by --force, which
already carries the PTY-stop waiver; when used, the waived failure comes back on
result.archiveHookOverride rather than being swallowed.

worktree.archive-failure-blocking.v1 is advertised so an integration can tell
"accepts --run-hooks" from "safely propagates a failing hook" without risking the
data loss to find out. The runtime's SSH path cannot run a hook at all, so rather
than delete with the archive step silently skipped it refuses — waivable like
every other refusal here. #18563 retires that gate by making the path run the
hook for real.

Stacked on #20559, which makes a timed-out hook report honestly; without it a
hook that traps SIGTERM and exits 0 would defeat this gate.

Fixes #19334
nwparker added a commit that referenced this pull request Sep 15, 2026
A repo's orca.yaml archive hook is the user's last chance to save work off a
checkout Orca is about to delete. A failed hook was logged as advisory and
stepped over, so the removal went ahead with nothing archived — and the caller
could still be told it succeeded.

The hook is now a blocking precondition, evaluated while the checkout, its Git
registration, its agents and Orca's ownership evidence are all still intact: it
sits ahead of the registration re-read, the lock/dirty preflights, stopPtys()
and removeWorktree in every orchestrator that runs it.

Failure is typed (worktree_archive_hook_failed) and carries the worktree path,
outcome, exit code where one was observed, and the hook's output. unverifiable
stays distinct from exited, so loss of contact is never read as a pass. The
waiver rides its own field at every layer and is never implied by --force, which
already carries the PTY-stop waiver; when used, the waived failure comes back on
result.archiveHookOverride rather than being swallowed.

worktree.archive-failure-blocking.v1 is advertised so an integration can tell
"accepts --run-hooks" from "safely propagates a failing hook" without risking the
data loss to find out. The runtime's SSH path cannot run a hook at all, so rather
than delete with the archive step silently skipped it refuses — waivable like
every other refusal here. #18563 retires that gate by making the path run the
hook for real.

Stacked on #20559, which makes a timed-out hook report honestly; without it a
hook that traps SIGTERM and exits 0 would defeat this gate.

Fixes #19334
nwparker added a commit that referenced this pull request Sep 15, 2026
A repo's orca.yaml archive hook is the user's last chance to save work off a
checkout Orca is about to delete. A failed hook was logged as advisory and
stepped over, so the removal went ahead with nothing archived — and the caller
could still be told it succeeded.

The hook is now a blocking precondition, evaluated while the checkout, its Git
registration, its agents and Orca's ownership evidence are all still intact: it
sits ahead of the registration re-read, the lock/dirty preflights, stopPtys()
and removeWorktree in every orchestrator that runs it.

Failure is typed (worktree_archive_hook_failed) and carries the worktree path,
outcome, exit code where one was observed, and the hook's output. unverifiable
stays distinct from exited, so loss of contact is never read as a pass. The
waiver rides its own field at every layer and is never implied by --force, which
already carries the PTY-stop waiver; when used, the waived failure comes back on
result.archiveHookOverride rather than being swallowed.

worktree.archive-failure-blocking.v1 is advertised so an integration can tell
"accepts --run-hooks" from "safely propagates a failing hook" without risking the
data loss to find out. The runtime's SSH path cannot run a hook at all, so rather
than delete with the archive step silently skipped it refuses — waivable like
every other refusal here. #18563 retires that gate by making the path run the
hook for real.

Stacked on #20559, which makes a timed-out hook report honestly; without it a
hook that traps SIGTERM and exits 0 would defeat this gate.

Fixes #19334
nwparker added a commit that referenced this pull request Sep 15, 2026
* fix(worktree): block removal when the archive hook fails

A repo's orca.yaml archive hook is the user's last chance to save work off a
checkout Orca is about to delete. A failed hook was logged as advisory and
stepped over, so the removal went ahead with nothing archived — and the caller
could still be told it succeeded.

The hook is now a blocking precondition, evaluated while the checkout, its Git
registration, its agents and Orca's ownership evidence are all still intact: it
sits ahead of the registration re-read, the lock/dirty preflights, stopPtys()
and removeWorktree in every orchestrator that runs it.

Failure is typed (worktree_archive_hook_failed) and carries the worktree path,
outcome, exit code where one was observed, and the hook's output. unverifiable
stays distinct from exited, so loss of contact is never read as a pass. The
waiver rides its own field at every layer and is never implied by --force, which
already carries the PTY-stop waiver; when used, the waived failure comes back on
result.archiveHookOverride rather than being swallowed.

worktree.archive-failure-blocking.v1 is advertised so an integration can tell
"accepts --run-hooks" from "safely propagates a failing hook" without risking the
data loss to find out. The runtime's SSH path cannot run a hook at all, so rather
than delete with the archive step silently skipped it refuses — waivable like
every other refusal here. #18563 retires that gate by making the path run the
hook for real.

Stacked on #20559, which makes a timed-out hook report honestly; without it a
hook that traps SIGTERM and exits 0 would defeat this gate.

Fixes #19334

* fix(worktree): close the skip-confirm dead end and the client/hook timeout gap

Four review findings on the gate.

A retry from the failure toast could fail for a DIFFERENT reason than the one
the user had just answered, and that second failure got a bare toast with no
buttons. With skipDeleteWorktreeConfirm set, the delete helpers pass no force, so
waiving a failed archive hook on a dirty checkout landed on the dirty preflight
and stopped there. Retry failures now re-enter the same failure toast, so every
retry stays as actionable as the first attempt. Third instance of this class.

The renderer gave worktree.rm a 60s budget while an archive hook may run for
120s. A hook that took 90s and succeeded timed the client out and reported
failure while the host went on to delete — telling the user their delete failed
and their checkout was gone. The budget is now derived from the hook's, and only
when a hook can run.

The SSH fail-open is logged rather than silent, and the capability's doc comment
scopes what it claims: a hook that RUNS and fails cannot delete the checkout; it
is not a promise the hook was found.

The SSH owner-resolution test now reads a real remote orca.yaml through a stubbed
provider and asserts the returned script is the remote one. It previously stopped
at the lookup key, which is the coverage that let this path break twice. It fails
against the row-only resolution.

* fix(worktree): name a signalled hook exit, and state why prunable cleanup skips the gate

Two things the rebase onto #20617 and #20576 surfaced, both found by rerunning
the real-repo harness rather than by reading the diff.

- #20617 added a registration-cleanup branch that returns before the archive
  gate. That ordering is correct — both of its arms describe a row with no
  checkout behind it, so there is nothing to archive and running the hook would
  fail on the missing cwd — but the gate's ordering invariant is documented, so
  the exception should be too.
- A signalled hook reported `Command failed with exit code null.`, which reads
  as a reporting glitch rather than the `unverifiable` verdict it is about to
  produce. It now says the command was terminated without reporting an exit
  code. Introduced by #20576; the withheld `exitCode` itself was always right.

Fixes #19334
@junited31
junited31 force-pushed the fix/ssh-cli-archive-hook-on-removal-clean branch from b093ad4 to 8910179 Compare September 15, 2026 11:29

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes — since the prior pullfrog review at b093ad4, the branch was rebased onto a main that now carries #20153's archive-hook gate, and the SSH fix was re-implemented in two commits:

  • Explicit hook owner — runRemoteArchiveHook takes a required connectionId rather than reading repo.connectionId, and the UI removal path passes repo.connectionId explicitly.
  • SSH removal runs and gates the hook — removeRuntimeRegisteredRemoteWorktree reads the execution host's hooks via getArchiveHooksForRemoval(repo, connectionId), runs runRemoteArchiveHook under runHooks, and passes the result through gateWorktreeRemovalOnArchiveHook, so a failed or unverifiable hook throws before any mutation unless allowFailedArchiveHook waives it; when hooks are configured but not requested it returns the same skipped-hook warning as the local path.
  • Post-hook re-validation — the execution host is re-listed unconditionally, findRegisteredDeletableWorktree/assertWorktreeUnlockedForRemoval re-run, and the refreshed row drives watcher acquisition, removal, and preserveBranchHead, so a hook that moved the branch preserves the refreshed head.
  • Retired the "cannot run" gate — gateRemovalWhereArchiveHookCannotRun and worktree-archive-hook-cannot-run.test.ts are deleted, replaced by the real hook run.
  • Tests — 11 cases in runtime-registered-remote-worktree-removal.test.ts, 4 new runRemoteArchiveHook cases, and 2 integration cases.

Verified this run: pnpm tc:node clean; both changed unit suites pass 19/19; the archive-hook integration tests pass 13/13. The refreshed head does reach preservedBranch cleanup (runtime-preserved-branch-cleanup.ts:42), and the worktree.archive-failure-blocking.v1 doc comment already scopes its claim to a hook that runs.

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

ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
)

* fix(worktree): block removal when the archive hook fails

A repo's orca.yaml archive hook is the user's last chance to save work off a
checkout Orca is about to delete. A failed hook was logged as advisory and
stepped over, so the removal went ahead with nothing archived — and the caller
could still be told it succeeded.

The hook is now a blocking precondition, evaluated while the checkout, its Git
registration, its agents and Orca's ownership evidence are all still intact: it
sits ahead of the registration re-read, the lock/dirty preflights, stopPtys()
and removeWorktree in every orchestrator that runs it.

Failure is typed (worktree_archive_hook_failed) and carries the worktree path,
outcome, exit code where one was observed, and the hook's output. unverifiable
stays distinct from exited, so loss of contact is never read as a pass. The
waiver rides its own field at every layer and is never implied by --force, which
already carries the PTY-stop waiver; when used, the waived failure comes back on
result.archiveHookOverride rather than being swallowed.

worktree.archive-failure-blocking.v1 is advertised so an integration can tell
"accepts --run-hooks" from "safely propagates a failing hook" without risking the
data loss to find out. The runtime's SSH path cannot run a hook at all, so rather
than delete with the archive step silently skipped it refuses — waivable like
every other refusal here. stablyai#18563 retires that gate by making the path run the
hook for real.

Stacked on stablyai#20559, which makes a timed-out hook report honestly; without it a
hook that traps SIGTERM and exits 0 would defeat this gate.

Fixes stablyai#19334

* fix(worktree): close the skip-confirm dead end and the client/hook timeout gap

Four review findings on the gate.

A retry from the failure toast could fail for a DIFFERENT reason than the one
the user had just answered, and that second failure got a bare toast with no
buttons. With skipDeleteWorktreeConfirm set, the delete helpers pass no force, so
waiving a failed archive hook on a dirty checkout landed on the dirty preflight
and stopped there. Retry failures now re-enter the same failure toast, so every
retry stays as actionable as the first attempt. Third instance of this class.

The renderer gave worktree.rm a 60s budget while an archive hook may run for
120s. A hook that took 90s and succeeded timed the client out and reported
failure while the host went on to delete — telling the user their delete failed
and their checkout was gone. The budget is now derived from the hook's, and only
when a hook can run.

The SSH fail-open is logged rather than silent, and the capability's doc comment
scopes what it claims: a hook that RUNS and fails cannot delete the checkout; it
is not a promise the hook was found.

The SSH owner-resolution test now reads a real remote orca.yaml through a stubbed
provider and asserts the returned script is the remote one. It previously stopped
at the lookup key, which is the coverage that let this path break twice. It fails
against the row-only resolution.

* fix(worktree): name a signalled hook exit, and state why prunable cleanup skips the gate

Two things the rebase onto stablyai#20617 and stablyai#20576 surfaced, both found by rerunning
the real-repo harness rather than by reading the diff.

- stablyai#20617 added a registration-cleanup branch that returns before the archive
  gate. That ordering is correct — both of its arms describe a row with no
  checkout behind it, so there is nothing to archive and running the hook would
  fail on the missing cwd — but the gate's ordering invariant is documented, so
  the exception should be too.
- A signalled hook reported `Command failed with exit code null.`, which reads
  as a reporting glitch rather than the `unverifiable` verdict it is about to
  produce. It now says the command was terminated without reporting an exit
  code. Introduced by stablyai#20576; the withheld `exitCode` itself was always right.

Fixes stablyai#19334
@junited31

Copy link
Copy Markdown
Author

Closing this. #20153 settled the SSH archive-hook path in a different direction (gate/refuse removal when the hook can't run), and rebasing this approach on top of it no longer fits. Thanks @nwparker for the cross-links.

@junited31 junited31 closed this Sep 27, 2026
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.

CLI worktree rm --run-hooks skips archive hooks for SSH repos

2 participants