Expand description
Bringing added paths’ worktree copies to their landed bytes.
What:
Bringing each added path’s worktree copy to the landed bytes after a commit landed,
with
descriptor-bound checks that never overwrite a concurrent edit.
Why:
An added path’s committed bytes differ from its worktree copy (a policy corrected it);
the
copy is replaced only while it still holds the original bytes,
through a same-directory
temporary file.
A copy holding neither is kept and reported,
since the commit already
landed (src/policy-engine/commit-transaction-added-paths.ts,
-worktree-check.ts,
-worktree-replace.ts).
In TS you’d write (pseudocode):
await installAddedWorktreeFiles({ gitPath, cwd, repositoryRoot, records, objectDirectory });Structs§
- Install
Result - What:
Rewritten and kept paths of one completion.
Why:
AddedWorktreeInstallResult. - Worktree
File Identity - What: The identity of an unchanged original worktree file. Why: The replacement is installed only while the file still has exactly this identity.
Enums§
- Worktree
File State - What:
The exact post-commit state of one worktree copy.
Why:
WorktreeFileState.
Functions§
- inspect_
worktree_ file - What:
Classify a worktree copy as original,
intended or conflict.
Why:
inspectWorktreeFile: missing, linked and concurrently replaced paths are conflicts, not recovery failures. - install_
added_ worktree_ files - What:
Bring every added path’s worktree copy to its landed bytes.
Why:
installAddedWorktreeFiles: a copy already holding the landed bytes is left alone, which makes recovery idempotent; a changed copy is kept and reported. - is_
conflict_ error - What:
Whether an error means “the worktree changed under us” rather than a failure.
Why:
WORKTREE_CONFLICT_CODES:ENOENT,ENOTDIR,ELOOP,EACCES. - replace_
worktree_ file - What:
Replace one unchanged worktree file through a same-directory temporary file;
returns
whether it was installed without an observed conflict.
Why:
replaceWorktreeFile: the destination is checked again after the replacement is ready.