Expand description
The per-worktree capture store:
location,
sequence and identity.
What:
The per-worktree capture store:
its location,
its sequence file and its identity file,
read as the incumbent reads them.
Why:
Every commit transaction captures under a short per-worktree lock and takes the next
sequence number,
so sequence numbers order the captured disk states of one worktree.
Recovery and pruning read the store;
both wrappers share it
(src/policy-engine/commit-capture-order-store.ts):
<git-dir>/cli-git-captures/{capture.lock/, worktree-id, sequence, landed/<oid>.json}.
In TS you’d write (pseudocode):
const next = await readNextCaptureSequence(gitDir);Structs§
- Capture
Error - What:
A malformed or unreadable capture-order state,
with its message.
Why:
The incumbent’s
CaptureOrderRecordErrorandTypeErrors of the store; recovery and pruning report them and continue.
Constants§
- CAPTURE_
LOCK_ NAME - Capture lock directory name inside the store.
- CAPTURE_
STORE_ NAME - Capture store directory name inside the worktree’s Git directory.
- SEQUENCE_
FILENAME - Sequence filename inside the store.
- WORKTREE_
ID_ FILENAME - Worktree identity filename inside the store.
Functions§
- capture_
store_ path - What:
The capture store directory of a worktree.
Why:
captureStorePath. - ensure_
capture_ store - What:
Create the store directory as a private,
non-linked directory when it is missing.
Why:
ensureCaptureStore, through the registry’s root creation. - parse_
sequence - What:
The value of a sequence file:
canonical decimal digits of a safe integer,
then one
newline.
Why:
parseSequence:String(Number.parseInt(digits, 10)) === digitsadmits no sign, no leading zero and no whitespace; anything else is a malformed store. - read_
next_ capture_ sequence - What:
The next capture sequence number the store would allocate,
read without the lock;
an
absent store or sequence file reads as 1.
Why:
readNextCaptureSequence: landings record it after their compare-and-swap. - read_
store_ file - What:
The text of a small regular store file read without following a link,
decoded as
UTF-8 with replacement characters.
Why:
readStoreFilereads with'utf8', which never fails on bytes. A missing file isOk(None). - read_
worktree_ id - What:
The store’s worktree identity without creating one,
or nothing when absent.
Why:
readWorktreeId: a record of another store generation is unusable.