Skip to main content

Module capture_records

Module capture_records 

Source
Expand description

captured.json, landed-capture records, their recording and pruning. What: captured.json (a transaction’s position in its worktree’s capture order) and the landed-capture records, with recording after a landing and pruning. Why: Replay decides a path both a prepared commit and an earlier-landed commit captured from this worktree by capture order; a landed record is kept while any published transaction may replay over it and pruned after (src/policy-engine/commit-capture-order-journal.ts, commit-capture-order-records.ts, commit-capture-order-prune.ts).

In TS you’d write (pseudocode):

await recordLandedCaptureOrWarn({ gitDir, transactionDirectory, transactionId, landedOid });
await pruneLandedCaptures({ gitDir, registryRoot });

Structs§

CapturedRecord
What: captured.json: the capture stamp, the next sequence read before the preparation base, and the Latin-1 decoded paths the capture read from the worktree. Why: The record pins landed records against pruning and names the captured paths.
LandedCaptureRecord
What: One landed-capture record. Why: LandedCaptureRecord, written right after a compare-and-swap.

Constants§

CAPTURED_FILENAME
Capture-order record filename inside a transaction directory.
LANDED_DIRECTORY_NAME
Landed-record directory name inside the store.
LANDED_RECORD_SUFFIX
Landed-record filename suffix.
LANDED_SCHEMA_VERSION
Landed-record schema version.

Functions§

encode_captured_record
What: Encode captured.json in the incumbent’s field order, with a newline. Why: The capture writes exactly these bytes.
encode_landed_capture_record
What: Encode a landed record in the incumbent’s field order, with a newline. Why: landedRecordOf builds the object in this order before JSON.stringify.
landed_record_directory
What: The landed-record directory of a worktree. Why: landedRecordDirectory.
list_landed_record_names
What: The landed-record filenames, or none when the directory is absent. Why: listLandedRecordNames.
parse_captured_record
What: Parse captured.json. Why: parseCapturedRecord.
parse_landed_capture_record
What: Parse one landed record. Why: parseLandedCaptureRecord.
prune_landed_captures
What: Remove every landed record no published transaction can replay over; returns how many. Never fails: a failure is reported and the records stay for the next pruning. Why: pruneLandedCaptures runs after every transaction removes its directory and after startup recovery, so the last transaction leaves no record behind.
read_captured_record
What: A transaction’s captured.json, or nothing when it has not captured yet. Why: readCapturedRecord.
record_landed_capture
What: Record the capture of a commit that just landed, or that recovery found landed; returns whether the transaction had a capture to record. An existing record is kept. Why: recordLandedCapture: only after the compare-and-swap succeeded.
record_landed_capture_or_warn
What: Record a landed capture as record_landed_capture does, but report a failure as a warning instead of returning it. Why: recordLandedCaptureOrWarn: the commit already landed; a missing record only sends its paths through subsumption in later replays.