Repository navigation
fix(git): cache unsupported capabilities per host - #8109
Conversation
Old Git worktree, ref-search, and merge-tree fallbacks retried unsupported flags on recurring operations, flooding subprocess traces. Centralize capability probing per native, WSL, and SSH execution host, coalesce concurrent probes, and retry periodically for in-place Git upgrades.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (9)
📝 WalkthroughWalkthroughAdds a host-scoped 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/relay/git-handler-worktree-remove.ts (1)
88-106: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winImport
readRelayWorktreeListfromgit-handler-worktree-ops.tsinstead of duplicating it.This local
readRelayWorktreeListis identical to the exported version insrc/relay/git-handler-worktree-ops.ts(lines 121–138).git-handler-local-base-ref-refresh.tsalready imports and uses the canonical version. Maintaining two copies risks silent divergence if one is updated and the other is not.♻️ Proposed refactor
Remove the local
readRelayWorktreeListand import the canonical version fromgit-handler-worktree-ops.ts:-async function readRelayWorktreeList( - git: GitExec, - repoPath: string, - capabilities: GitCapabilityCache -): Promise<RelayWorktreeInfo[]> { - return capabilities.runWithFallback( - 'worktree-list-z', - async () => { - const { stdout } = await git(['worktree', 'list', '--porcelain', '-z'], repoPath) - return normalizeRelayWorktrees(parseWorktreeList(stdout, { nulDelimited: true })) - }, - async () => { - // Why: `-z` preserves newlines; fallback keeps Git <2.36 compatible. - const { stdout } = await git(['worktree', 'list', '--porcelain'], repoPath) - return normalizeRelayWorktrees(parseWorktreeList(stdout)) - }, - isUnsupportedWorktreeListZError - ) -}Add
readRelayWorktreeListto the existing import from./git-handler-worktree-ops(or create one if it does not exist):+import { readRelayWorktreeList } from './git-handler-worktree-ops'
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f70f0b4b-3824-4e6a-b0de-34a164c50a3c
📒 Files selected for processing (25)
docs/reference/git-compatibility.mdsrc/main/git/git-capability-state.tssrc/main/git/remove-worktree.test.tssrc/main/git/repo-search-ref-compat.test.tssrc/main/git/repo.tssrc/main/git/worktree-git-capabilities.test.tssrc/main/git/worktree.test.tssrc/main/git/worktree.tssrc/main/github/conflict-summary.test.tssrc/main/github/conflict-summary.tssrc/main/ipc/repos-remote.test.tssrc/main/ipc/repos.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/relay/git-handler-branch-cleanup.tssrc/relay/git-handler-local-base-ref-refresh.tssrc/relay/git-handler-worktree-git-capabilities.test.tssrc/relay/git-handler-worktree-ops.tssrc/relay/git-handler-worktree-remove.tssrc/relay/git-handler.tssrc/shared/git-branch-cleanup.test.tssrc/shared/git-branch-cleanup.tssrc/shared/git-capability-cache.test.tssrc/shared/git-capability-cache.tssrc/shared/git-merge-tree-capability.ts
| const repeatedResult = await runtime.searchRepoRefs('id:remote-repo', '', 1) | ||
|
|
||
| expect(result).toEqual({ | ||
| refs: ['origin/main'], | ||
| refDetails: [{ refName: 'origin/main', localBranchName: 'main' }], | ||
| truncated: true | ||
| }) | ||
| expect(repeatedResult).toEqual(result) | ||
| const forEachRefCalls = provider.exec.mock.calls.filter( | ||
| (call) => (call[0] as string[])[0] === 'for-each-ref' | ||
| ) | ||
| expect(forEachRefCalls).toHaveLength(2) | ||
| expect(forEachRefCalls).toHaveLength(3) | ||
| expect(forEachRefCalls[0][0]).toContain('--exclude=refs/remotes/**/HEAD') | ||
| expect(forEachRefCalls[1][0]).not.toContain('--exclude=refs/remotes/**/HEAD') | ||
| expect(forEachRefCalls[1][0]).toContain('--count=108') | ||
| expect(forEachRefCalls[2][0]).not.toContain('--exclude=refs/remotes/**/HEAD') |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check whether orca-runtime.test.ts resets git capability state in its test setup.
rg -n 'clearGitCapabilityStateForTests|beforeEach' src/main/runtime/orca-runtime.test.ts | head -30Repository: stablyai/orca
Length of output: 264
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find the helper definition and any capability-reset calls in the test file.
rg -n 'resetRuntimeTestMocks|clearGitCapabilityStateForTests|gitCapability|capabilityState' src/main/runtime/orca-runtime.test.ts
# Show the setup block around the beforeEach.
sed -n '680,740p' src/main/runtime/orca-runtime.test.tsRepository: stablyai/orca
Length of output: 2438
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '523,718p' src/main/runtime/orca-runtime.test.ts
printf '\n---\n'
rg -n 'clearGitCapabilityStateForTests|resetGitCapabilityState|GitCapabilityState' src/main/runtime src/mainRepository: stablyai/orca
Length of output: 10150
Reset git capability state in the shared test setup. resetRuntimeTestMocks() doesn’t clear git-capability-state, so this test can inherit cached --exclude support and skip the initial probe. Add clearGitCapabilityStateForTests() to that shared hook.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/relay/git-handler-worktree-ops.test.ts (1)
3-12: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider extracting the
removeWorktreeWithCapabilityCachehelper to a shared test fixture.This 6-line wrapper is duplicated identically in
git-handler-worktree-paths.test.ts:7-12andgit-handler-branch-cleanup.test.ts:8-13. IfremoveWorktreeOp's signature changes again, all three files require the same update. Extracting to a shared file (e.g.relay-worktree-test-fixture.ts) would reduce maintenance overhead.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 45ac4770-1780-4eca-bf5f-c413c59b14ae
📒 Files selected for processing (21)
.github/workflows/pr.ymlAGENTS.mdconfig/scripts/git-binary-compatibility-workflow.test.mjsdocs/reference/git-compatibility.mdsrc/main/git/git-capability-state.test.tssrc/main/git/repo.tssrc/main/git/worktree.tssrc/main/github/conflict-summary.test.tssrc/main/github/conflict-summary.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/relay/git-handler-branch-cleanup.test.tssrc/relay/git-handler-local-base-ref-refresh.tssrc/relay/git-handler-utils.tssrc/relay/git-handler-worktree-git-capabilities.test.tssrc/relay/git-handler-worktree-list.tssrc/relay/git-handler-worktree-ops.test.tssrc/relay/git-handler-worktree-ops.tssrc/relay/git-handler-worktree-paths.test.tssrc/relay/git-handler-worktree-remove.tssrc/relay/git-handler.ts
✅ Files skipped from review due to trivial changes (1)
- docs/reference/git-compatibility.md
🚧 Files skipped from review as they are similar to previous changes (7)
- src/main/runtime/orca-runtime.test.ts
- src/main/github/conflict-summary.test.ts
- src/main/git/repo.ts
- src/main/runtime/orca-runtime.ts
- src/main/git/worktree.ts
- src/relay/git-handler.ts
- src/main/github/conflict-summary.ts
# Conflicts: # src/renderer/src/store/slices/store-cascades.test.ts
# Conflicts: # src/relay/git-handler-worktree-remove.ts
|
Verified against current main across native, WSL, SSH, and relay ownership paths. Review also caught and fixed supported-capability probe serialization, preserving parallel ref searches after the first successful probe. Local full suite, typecheck, lint, relay build, and Electron boot passed; CI is green with Git 2.25.5, 2.38.1, and 2.49.1 compatibility coverage, the full test suite, unpacked build, and packaged CLI smoke. Docker SSH e2e was unavailable locally, so relay integration tests and CI provide that transport coverage. |
* fix(git): cache unsupported capabilities per host Old Git worktree, ref-search, and merge-tree fallbacks retried unsupported flags on recurring operations, flooding subprocess traces. Centralize capability probing per native, WSL, and SSH execution host, coalesce concurrent probes, and retry periodically for in-place Git upgrades. * fix(git): recognize real old-Git merge-tree rejection * test(git): enforce real binary compatibility matrix * fix(ci): preserve Git compatibility test ownership * fix(git): retain supported capability state
Summary
Investigation context
This came from investigating two Slack crash bundles. Both bundles were from Orca 1.4.131, not the newly released 1.4.132:
Neither crash points to a new Orca release regression. The same diagnostics did reveal a separate reproducible compatibility problem: Git before 2.36 rejected worktree list -z 1,436 times, consuming 2.96 MB of a 4 MiB diagnostic bundle. The broader command audit also found recurring probes for path-format and for-each-ref exclude, plus Git before 2.38 lacking merge-tree write-tree entirely.
Why not simple-git
simple-git still shells out to the Git installed on the execution host and forwards custom/raw arguments. It cannot make a newer flag work on an older native, WSL, or SSH Git binary, nor choose Orca's semantic fallback. A migration would also have to preserve Orca's routing, cancellation, tracing, redaction, process cleanup, and output bounds, so it would move rather than remove this compatibility layer.
Performance and safety
A known unsupported capability now costs at most one failed probe per execution host during the 30-minute retry window. The retry allows an in-place Git upgrade to self-heal. Concurrent first probes share one result. Each cache holds only the five registered capability states, and SSH state is weakly keyed by provider lifetime.
Git before 2.38 cannot produce Orca's real-merge conflict summary. That optional summary now degrades quietly, while branch cleanup remains conservative and never force-deletes without proof.
Validation
Follow-up
The strongest additional guard would be a small real-binary CI matrix for Git 2.25, a pre-2.36 release, and current Git. The unit contracts remain necessary for localized errors, concurrency, and native/WSL/SSH isolation.
Crash-triage summary
Description
During investigation of Linux crash report
2dc6f755-ccc7-408f-b394-80623df7f32f, the renderer SIGKILL itself could not be reproduced or attributed to Orca, but the diagnostic bundle exposed a separate deterministic Git compatibility defect: the host Git rejectedworktree list --porcelain -z1,436 times. This PR adds a Git 2.25-compatible line-block fallback and remembers unsupported capabilities per native, WSL, SSH, or relay execution host so recurring scans do not repeat known-invalid commands.Clear, undeniable fix evidence
unknown switch zfailures, consuming 2.96 MB of its 4 MiB diagnostic cap while renderer heap remained stable at 18/22 MB.-zcommand only on Git 2.36+, recognizes the narrow unsupported error below that boundary, and proves plainworktree list --porcelainremains available.This evidence proves the Git compatibility/fanout fix. It does not claim the fix caused or prevents the externally reported renderer SIGKILL.
ELI5
Orca asked every Git installation a newer-version question. Older Git answered “I don’t understand,” but Orca kept asking on every refresh. Orca now asks once, falls back to the older wording, remembers that answer for the specific machine or remote host, and periodically retries so an upgraded Git can self-heal.
Trade-offs