Expand description
On-disk integrity check (M11 #90).
IntegrityReport is the structured output of
crate::pager::Pager-level walks that verify every documented
invariant of the .obj file format. The public driver lives in
the obj crate (obj::Db::integrity_check); this module hosts
the data types and the obj-core-internal helpers that do the
heavy lifting.
§Power-of-ten posture
- Rule 2. Every walk is bounded by
page_count(the page- reachability sweep),crate::btree::MAX_BTREE_DEPTH(the B-tree descent), orcrate::btree::MAX_RANGE_NODES(the B-tree iteration). - Rule 4. Each entry point is short; the implementation factors per-tree / per-index helpers.
- Rule 7. No
unwrap/expecton the production path. I/O failures bubble up viaResult::Err; invariant violations are recorded into the report’sfailuresvector and the walk continues. - Rule 9. No
dyn: every helper is generic overF: FileBackend(no trait-object dispatch on the hot path).
Structs§
- Integrity
Report - Structured result of an integrity check.
- Tree
Context - Snapshot of the on-disk shape needed to walk a single B-tree. Used by the obj layer’s wrapper to thread per-tree context (label, root) into the obj-core helper.
Enums§
- Integrity
Failure - Categorical reasons an integrity walk records a failure. Every variant carries the locus of the problem (page id, collection, index name, document id) so an operator can root-cause without re-running the check.
Functions§
- check_
catalog_ pointers - Confirm the catalog descriptor’s
primary_root+ eachActiveindex’sroot_page_idpoint at pages within1..page_count. RecordsDanglingCatalogPointerfailures for every miss. - check_
primary_ to_ index - Build the set of every primary id that has AT LEAST ONE
surviving index entry across the collection’s
Activeindexes, and emitMissingIndexEntryfailures for any primary id that is NOT referenced by an index whose kind isStandard,Unique, orComposite.Eachindexes are exempted — they legally reference zero entries when the source sequence is empty. - collect_
primary_ ids - Walk every entry in the primary B-tree of
descriptor, inserting each id intoprimary_idsand recording any per-page failures (CRC, sort, depth) along the way. Returns the number of leaf entries scanned. - cross_
reference_ index - Verify every entry in an
Activeindex B-tree (Standard,Each,Composite: the trailing 8-byte key suffix is the id;Unique: the value is the id) references a primary id that exists in the primary B-tree. - fresh_
descent_ stack - Helper: ensure
pathis the canonical descent stack shape used by the integrity walk’s caller. Re-exported for the obj crate’s per-T extension so it does not have to reimplement theHeaplessVec<PageId, MAX_BTREE_DEPTH>pattern. - quick_
check - Compute the fast subset of the integrity walk: validate the file-header invariants and walk the catalog tree (and only the catalog tree), without descending into any per-collection primary or index.
- walk_
btree - Walk a single B-tree from
ctx.root, recording any per-node invariant violations intofailuresand inserting every visited node page-id intoreachable. Returns the number of pages this walk inspected. - walk_
freelist - Walk the freelist chain starting at
head, inserting every link page intoreachableand recording any chain breakage intofailures. Returns the number of freelist link pages walked.