Skip to main content

Module worktree_completion

Module worktree_completion 

Source
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§

InstallResult
What: Rewritten and kept paths of one completion. Why: AddedWorktreeInstallResult.
WorktreeFileIdentity
What: The identity of an unchanged original worktree file. Why: The replacement is installed only while the file still has exactly this identity.

Enums§

WorktreeFileState
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.