Repository navigation
perf(worktree): accelerate worktree creation & worktree-on-send across Git, main process, renderer, and native file I/O - #868
Conversation
…dex, and localStore gating
… smooth transitions
There was a problem hiding this comment.
Important
Three correctness regressions should be addressed before merging: provisioned file data is no longer durably flushed, pre-hook clean-status seeds can hide setup changes, and zero-spawn admission can bypass repository-config revocation.
Reviewed changes Reviewed the complete 40-file change set across Git, main-process orchestration, renderer cache/transition behavior, native file I/O, and focused tests.
- Git and admission — Combined discovery and streamed Git output, parallelized worktree creation, moved capacity admission under the mutation queue, seeded post-create metadata, and added pure-filesystem managed-worktree validation.
- Provisioning and lifecycle — Narrowed
.worktreeincludediscovery, introduced the batched APFS clone/read-write helper protocol, and threaded rollback/provision reserves through desktop and CLI worktree creation. - Main-process fast paths — Added cached global skill discovery, Pi journal directory indexing, portable-config hardening signatures, and inline workspace returns from first-message creation.
- Renderer transitions — Coalesced workspace/chat reads, added one-shot promoted-chat freshness, seeded draft worktree defaults, moved pending sends into
MessageList, and split artifact state from core environment context. - Verification surfaces — Reviewed the changed Git, admission, lifecycle, native-helper, and renderer tests, including whether their assertions exercise the claimed safety properties.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
…che invalidation, config-gated pure-FS admission)
There was a problem hiding this comment.
Important
The config-gated admission fix is incomplete for Git configuration loaded through existing include files, so one managed-worktree capability check can still bypass repository revocation.
Reviewed changes Reviewed the two commits added since the prior Pullfrog review, including the three corrective paths and the merge reconciliation.
-
Restored provision durability — Added file-level
fsyncbarriers for both APFS clone and read/write provisioning before parent-directory synchronization and success reporting. -
Invalidated post-hook status — Returned executed hook names, invalidated main and CLI Git display caches after awaited setup hooks, and removed renderer-side clean-status seeds.
-
Gated pure-FS admission — Added a Git-verified repository identity signature, per-worktree config fallback, and a focused direct
.git/configrevocation test. -
Reconciled current main — Merged the latest base changes around the
MessageListvisual context without changing the worktree-send behavior.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
There was a problem hiding this comment.
Important
The include-free proof still misses custom global and system config filenames, so zero-spawn admission can continue past repository-config revocation.
Reviewed changes Reviewed the config-proof commit added since the prior Pullfrog review, including its production path and focused admission coverage.
-
Expanded config proof: Added signatures for local, global, and system Git config paths and disabled pure-FS admission when recognized config files contain include directives.
-
Extended revocation coverage: Added a regression case for a local
include.pathtarget changing after Git-verified admission.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
… scan custom GIT_CONFIG_* files
There was a problem hiding this comment.
Important
The latest config-proof fix still misses system config files selected by alternate Git installations, so zero-spawn admission can survive repository revocation.
Reviewed changes Reviewed the two commits added since the prior Pullfrog review, including the config-proof correction and current-main merge.
- Generalized config scanning: Separated config files from routing identity paths so arbitrary
GIT_CONFIG_GLOBALandGIT_CONFIG_SYSTEMfilenames are inspected for include directives. - Scoped proof publication: Moved verified proof publication to managed-worktree admission and creation, with environment-selected path and signature rechecks before pure-FS returns.
- Extended regression coverage: Added a custom-named global config include case that exercises fallback after its included target changes.
- Merged current main: Reconciled the branch with the latest base without altering the incremental worktree behavior.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
…ure-FS admission proof
There was a problem hiding this comment.
Important
The system-config origin cache can retain a stale path after the active Git executable changes, so zero-spawn admission can still survive system-config revocation.
Reviewed changes Reviewed the system-config-origin correction added in 5a7137063 since the prior Pullfrog review.
- Probed active system config: Replaced hard-coded platform guesses with
git config --system --list --show-origin -zand signed the reported origins into the pure-filesystem admission proof. - Expanded alternate-installation coverage: Added behavioral cases for existing, initially missing, and empty system config files selected by a custom Git executable.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
There was a problem hiding this comment.
Important
The executable-identity fix still lets dynamic wrappers or shims retain a stale system-config proof, so the admission bypass remains for a supported Git binary shape.
Reviewed changes Reviewed the executable-identity and system-config proof correction added in f26db8f34 since the prior Pullfrog review.
- Reprobed system origins: Removed the process-lifetime origin cache so each fresh proof asks the active Git command for its system-config origins.
- Bound proofs to executable identity: Added before/after executable filesystem signatures during proof construction and rechecked the signature before every pure-filesystem admission.
- Expanded rerouting coverage: Added a behavioral case that rewrites a direct-path wrapper from config A to config B and verifies that corrupting B falls back to Git.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
…e-3c19a5bf # Conflicts: # renderer/components/message-list.tsx
|
Run failed. View the logs →
|
There was a problem hiding this comment.
Important
The new direct-binary proof disables zero-spawn admission on a stock Debian/Ubuntu Git layout and fails the focused admission suite. The prior delegated-routing concern also remains open for native shims placed at an allowlisted path.
Reviewed changes Reviewed the executable-proof hardening and current-main merge added since the prior Pullfrog review.
- Restricted proof eligibility — Limited proof publication to standard install paths, native Mach-O/ELF files, signed symlink chains, and environments without selected executable-routing overrides.
- Verified direct Git identity — Added fresh-versus-memoized resolution checks and required the selected binary to self-identify through its Git exec path.
- Expanded adversarial coverage — Added cases for mutable wrappers, compiled shims, spoofed exec paths, repointed multi-hop symlinks, and
GIT_EXEC_PATHoverrides. - Merged current main — Reconciled the branch with current transcript activity-transition behavior.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the trusted-Git identity correction added in 17f288474 since the prior Pullfrog review, with the complete PR diff checked for context.
- Authenticated trusted Git installs — Restricted pure-filesystem proof publication to Apple-signed CLT/Xcode Git or root-owned, non-writable Linux
/usr/bin/gitinstallations, closing the remaining native-shim routing gap. - Restored stock Linux admission — Added bounded SHA-256 equivalence for Debian/Ubuntu's distinct-inode
/usr/bin/gitand exec-path copy, restoring the advertised zero-spawn path while preserving fail-closed wrapper behavior. - Verified focused behavior — Confirmed the executable/admission suite passes
33/33, TypeScript and focused lint pass, and both previously open Pullfrog threads are resolved.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the test-only dc0456e40 delta that landed after the prior Pullfrog review.
- Pinned Apple Git coverage — Selected
/usr/bin/giton macOS so Homebrew-first hosts still exercise the Apple-signed CLT/Xcode zero-spawn admission path. - Preserved cross-platform coverage — Kept Linux behavior unchanged and retained explicit wrapper, shim, config-revocation, and
GIT_EXEC_PATHassertions; the focused suite still passes33/33and focused lint is clean.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏
…e-3c19a5bf # Conflicts: # docs/plans/README.md
…e-3c19a5bf # Conflicts: # renderer/components/message-list.tsx # renderer/lib/chat-draft.ts # renderer/main/chat-transition.test.tsx # renderer/main/root-view.tsx
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the two merge commits added since the prior Pullfrog review, including every conflict resolution and the complete PR diff for context.
- Preserved plan inventory — Kept both the worktree performance entry and the newly merged iPhone Duo entry while reconciling
docs/plans/README.md. - Reconciled draft state — Combined Quick Chat's ephemeral and attachment handoff state with the PR's seeded worktree draft options without allowing the unsupported
ephemeral + worktreerequest. - Reconciled transcript rendering — Preserved compact Quick Chat layout and handoff coverage alongside the pending worktree row and zero-remount prompt promotion.
- Verified exact-head behavior — Confirmed the focused draft, Quick Chat contract, and transition tests pass
68/68; TypeScript and focused ESLint are clean.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏

Summary
Implements Tier 1 and Tier 2 worktree creation performance optimizations across four phases—making explicit worktree creation, worktree-on-send, and
.worktreeincludeprovisioning dramatically faster and visually smoother while preserving every ownership, admission, TOCTOU, snapshot, and disk-capacity safety invariant.Each phase was independently audited by two adversarial review passes, with every finding fixed and covered by behavioral tests before advancing.
Before vs. After Performance Benchmarks
Measured head-to-head on
aiden-macos(6,497 tracked files, Apple Silicon APFS, 5-run uncontended medians,origin/main6555f1767vs. this PR):origin/main)createIn+createWorktree)git.info(worktreePath)managedWorktreeUsable).worktreeinclude(31 ignored files, clean repo).worktreeinclude(31 ignored files + 5,000-filenode_modules)output_limit> 1 MiB)Changes by Phase
Phase 1 — Backend Git Core &
.worktreeincludeFast PathGitService.repository()from 3rev-parsespawns (2 serial rounds) to 1 spawn (rev-parse --is-inside-work-tree --show-toplevel --git-common-dir) with newline-in-path fallback.git check-attrloop (~102 spawns) inmanagedWorktreeCheckoutByteswith 1 streaminggit check-attr --cached -z --all --stdinparser on rawBufferslices (O(1) memory, immune to 1 MiB buffer overflow, still honorsinfo/attributes, global config, andincludeIf).additionalAllocationBytesintogit.createWorktree(enforced atomically insideenqueueMutation(repo.commonDir)beforemkdir/worktree add).checkout.workers = min(4, cpus),checkout.thresholdForParallelism = 50) on allworktree addsites.<wt>/.git↔<admin>/{gitdir,commondir,HEAD}inspection ininspectNewlyCreatedWorktree()(with fallback), parallelized independent base-ref / branch reads with linkedAbortControllercleanup, and streamedfor-each-refinresolveWorktreeBase..worktreeincludediscovery (ls-files --exclude-from=.worktreeinclude→ short-circuit if empty →git check-ignore -z --stdinwith./-prefixing to neutralize:pathspec magic), eliminating thenode_modulesoutput_limitcrash.Phase 2 — Main-Process 0-Spawn Admission, Cached Skills, Pi
dirIndex& Store GatingmanagedWorktreeUsable(O_RDONLY | O_NOFOLLOW | O_NONBLOCK, loose +packed-refs,reftablefallback, fenced withwhile (this.mutations.has(commonDir))+mutationEpochs).repositoryCache/infoCache/repositoryIdentitiesfor newly created worktrees (fenced by pre/postrepoRemoteHintSignatureandmutationEpochs).discoverSkillCandidatesWithCachedGlobals) keyed on[home, aidenDir, globalPluginConfigs]while keepingresolveFresh()uncached.lstat-signatureddirIndex+ monotonicdirMutationVersionconcurrency fence inPiCompactionSessionStoreso brand-new chats skip migration/list scans.protectLocal()rescans on warmportable-config-coreloads whenownedPaths.length === 0 && archivePublicationPaths.size === 0while keepingensurePrivateDirectory(root)live and checkinglstat(nlink === 1n, mode, uid, mtime/ctime) onconfig.jsonand recorded secondary files.Phase 3 — Renderer Perceived Speed, IPC Coalescing & Smooth Transitions
FirstMessageWorktreeResultwith optionalworkspaceand narrowedworkspaces:changedon creation ({ kind: "created", workspace }), sharingupsertCreatedWorkspaceInCacheacrossroot-view.tsxandchat-pane.tsxto skip blockingworkspaces:list/ redundantchats:listrefetches on worktree addition (keeping full invalidation for removals/restores).chats:createWithFirstMessagewhenskillsEnabled !== false(without touching workspace folders).markChatRecentlyPromotedfreshness inuseChatso draft → live promotion reuses the seeded snapshot without a redundantchats:getIPC, while leaving and revisiting always re-reads.MessageList(keepForkWrapper+"draft-prompt"key handoff) for zero-remount bubble promotion; bypassed blocking pre-sendfolderPresenceIPC when cached presence is not missing (still re-checking live if cached"missing"); added frame-0seedDraftWorktreeFromGitInfoseeding for⌥↵and/worktree.useWorkspaceArtifactsstate intoEnvironmentArtifactsContext(useEnvironmentPanelCore()forChatPane,ChatSidebar,RootView,HistoryNavButtons,DesignLayout) and gateduseGitWorktreesinGitBranchPicker.Phase 4 — Native Batched CoW
provision(native/worktree-file-io/main.c)copyandrestore(with SHA-256) untouched for snapshot capture/restore.provisionsubcommand reading NUL-delimited paths fromstdin(1 spawn for all.worktreeincludefiles), using APFSfclonefileat(..., CLONE_NOFOLLOW | CLONE_NOOWNERCOPY)into a random temp file when eligible, clearingfchflags(cloned, 0)beforefchmod(cloned, mode & 0777), verifyingflistxattr(cloned) == 0+same_provision_source, installing atomically withrenameatx_np(..., RENAME_EXCL), falling back toread/writeonEXDEV/ENOTSUP/EACCES/EPERM, and deduplicating parent directoryfsyncs (capped at 64 open FDs).SIGTERMhandling inmain.c+ close-gatedAbortSignalsettlement inprovisionManagedWorktreeFilesBatchso disk installs stay strictly 1:1 withonProvisionedrollback tracking.Verification
npx tsc --noEmit— passnpm run lint— pass (0 errors, 0 warnings)node --test scripts/worktree-file-io.test.mjs— 19/19 passnpx tsx --test main/services/git.test.ts main/services/managed-worktree-admission.test.ts— 123/123 passnpx tsx --test main/services/managed-worktree-lifecycle.test.ts main/services/workspace-worktree-application-service.test.ts— 57/57 passnpm run test:aiden-service-boundary— passnpm run test:worktree-on-send— passnpm run test:aiden-remote— 1,268/1,268 + 7/7 passnpm run test:cli— passdocs/plans/worktree-creation-performance.md,docs/plans/README.md,.memory/worktree-creation-performance.mdFlaky CI Observations
e78f45b55,tests/e2e/crash-reporting.spec.ts:41(uncaught errors, process deaths and a fatal main crash are reported, sanitized, across a relaunch) failed attempt 1 withError: Target crashed/electronApplication.evaluate: Target page, context or browser has been closedand passed on retry Use catalog-driven runtime model limits #1 (run 44978492821 / job 137082618807). Unrelated to worktree creation; passed cleanly onba55fa2ce.84717cdd1,Desktop tests (runtime-subagents)hung afteraiden-remote-sealed-envelope.test.ts(X25519 agreement refuses low-order peer keys) and hit the 25-minute job cancellation timeout (run 44990828956 / job 137111372226). Unrelated to worktree creation; passed cleanly onba55fa2ceande78f45b55.5a7137063,Desktop tests (renderer-other)failed in untouchedrenderer/components/workspace-picker.test.tsx(closing the menu mid-clone cancels the clone,Unable to find a label with the text of: Git URL or owner/repo, run 45002201436 / job 137146069694). Passes 21/21 locally and passed onba55fa2ce,e78f45b55, and84717cdd1.