Skip to main content

Module capture_store

Module capture_store 

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

CaptureError
What: A malformed or unreadable capture-order state, with its message. Why: The incumbent’s CaptureOrderRecordError and TypeErrors 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)) === digits admits 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: readStoreFile reads with 'utf8', which never fails on bytes. A missing file is Ok(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.