Module journal

Module journal 

Source
Expand description

Unified durable append-only journal (ledger-journal.jsonl), single-inode reader/writer flock guards on the repository’s permanent ledger lock, standalone pending-transaction recovery, and full .ctbnbdl bundle (id, tokens) verification.

Structs§

CompiledBundleDigests
Recorded SHA-256 inventories for unsplit and split .ctbnbdl bundle directories.
DurableTransactionOutcome
Output returned by execute_durable_ledger_transaction_with_planner.
JournalRecord
A single JSONL record (BATCH_PENDING or BATCH_COMMITTED) in ledger-journal.jsonl.
LedgerReadGuard
Shared reader lock guard (flock(LOCK_SH)) on the permanent ledger lock.
LedgerWriteGuard
Exclusive writer lock guard (flock(LOCK_EX)) on the permanent ledger lock.
ParsedJournal
Parsed state of ledger-journal.jsonl.
PlannedLedgerItem
A single planned node append item in a durable ledger transaction and/or manifest.
TransactionManifest
Precomputed deterministic transaction manifest used with --require-manifest.

Enums§

FaultInjectionPoint
Fault-injection hook for deterministic crash and recovery unit tests.

Constants§

JOURNAL_INITIALIZED_REL_PATH
Relative path from the repository root to the local post-initialization marker.
LEDGER_JOURNAL_REL_PATH
Relative path from the repository root to the unified durable ledger journal.
LOCK_CANARY_REL_PATH
Relative path from the repository root to the shared permanent lock canary file.

Functions§

chunk_filename_for_node_id
Returns the .ctbnodes chunk relative path ("85899_34592.ctbnodes", …, "85900/85900_34492.ctbnodes") that owns node_id.
compact_closed_ledger_chunks
Compacts ledger-journal.jsonl and removes closed-chunk .ctbnode-incoming (and legacy .dcsh) files from src/formats/dcdata/data-src/nodes/allocated/ for all .ctbnodes chunk files that have reached MAX_NODES_PER_CHUNK (100 nodes) and are therefore closed.
compact_closed_ledger_chunks_with_guard
Internal closed-chunk compaction operating under an already-held LedgerWriteGuard.
compile_nodes_slice_to_ctbnbdl_with_write_guard
Compiles nodes into tracked unsplit (assets/data/graph-bundles/*.ctbnbdl) and gitignored split (assets/data/graph-bundles/split/{live,history}/*.ctbnbdl) bundles under an already-held LedgerWriteGuard directly from the validated in-memory nodes slice, fsyncs all bundle files and directories, updates built/ staging directories if present, verifies the compiled bundles via verify_compiled_bundles_match_ledger, and returns CompiledBundleDigests.
compute_bundle_dir_sha256s
Computes a sorted map of <filename>.ctbnbdl -> sha256_hex for all .ctbnbdl files directly in dir.
compute_ledger_dir_sha256
Computes the canonical SHA-256 digest over all .ctbnodes chunk files in graph_dir, sorted by ascending chunk start ID (rel_path\0content\0).
compute_nodes_slice_ledger_sha256
Computes the canonical .ctbnodes directory SHA-256 digest from an in-memory slice of LedgerNodes.
decode_unicode_string_tokens
Decodes a UTF-8 string value node from its token slice if all tokens are Unicode codepoints.
ensure_ledger_journal_clean
execute_durable_ledger_transaction_with_planner
Shared durable transactional writer used by both process_inbox_nodes and update_system_graph_ledger.
fsync_dir
Invokes sync_all() on a directory path on Unix platforms.
fsync_file
Invokes sync_all() on a file path.
inspect_ledger_journal
Parses and validates ledger-journal.jsonl:
load_ledger_nodes_from_dir_with_write_guard
Loads .ctbnodes directly under an already-held LedgerWriteGuard without opening a second lock fd or running external reader-gate checks while BATCH_PENDING is open.
recover_pending_ledger_journal
Executes standalone recovery of any open BATCH_PENDING record, torn journal line, or verified CSV-provenanced .ctbnodes tail ahead of ledger-journal.jsonl.
recover_pending_ledger_journal_with_guard
Internal recovery implementation operating under an already-held LedgerWriteGuard.
repair_torn_journal_suffix
Truncates an unterminated trailing line from journal_path at valid_prefix_len and fsyncs both file and parent directory.
resolve_ctbnbdl_framing_dcs_from_nodes
Resolves the CtbnbdlFramingDcs from an in-memory slice of .ctbnodes LedgerNodes by bootstrapping from the "ProgrammaticIdentifier" string value node.
sha256_bytes_hex
Computes the lowercase hex SHA-256 digest of bytes.
sha256_file_hex
Computes the lowercase hex SHA-256 digest of a file on disk.
verify_compiled_bundles_match_ledger
Verifies that the tracked unsplit bundles (graph-bundles/*.ctbnbdl) and, when present or required, the gitignored split live (graph-bundles/split/live/*.ctbnbdl) and historical (graph-bundles/split/history/*.ctbnbdl) bundles match committed_nodes in: