Expand description
index — the hierarchical content catalog.
A uniform three-level tree: root + per-layer + per-type-folder. Two
artifacts per type-folder: the human index.md (capped 500, recency
browse) and the machine index.jsonl (complete, structured — one JSON
object per file). Both read summary + key frontmatter fields + links
directly from each file — there is no extraction logic here.
Maintained write-through by the write commands (Index::on_write /
Index::on_rename / Index::on_remove — the loop path, O(changed), no
store walk); Index::rebuild_all is the from-scratch SWEEP repair.
Key invariant: write-through must produce a byte-identical index.md
and (post-compaction) index.jsonl to a full Index::rebuild_all over
the same end state — the loop path can never drift from the repair path.
§Implementation notes (deviations the reader should know)
- Self-contained, by design. This module does its own shard-aware folder
walk, its own minimal frontmatter read, and its own atomic write, using
only
store.root(a public field) and theserde_yml/serde_json/chrono/walkdircrates rather than routing through the siblingstore/parserhelpers (Store::walk_type_folder,Store::recent_in_type_folder, [parser::read_file], …). The index has to stamp a deterministicupdated:and emit a canonical, compactedindex.jsonl(see the two notes below); keeping the read/walk/write local is what makes the byte-identity invariant a true byte comparison, free of any incidental formatting the shared readers might introduce. The public signatures inlib.rsare untouched. - Deterministic
updated:on the index files themselves. An index’s ownupdatedfrontmatter is derived as the maxupdatedover the files it catalogs (max over children for root/layer) — NOT wall-clock-now. This is what makes the byte-identity invariant a true byte comparison: a write-through write and arebuild_allover the same end state stamp the same value. (The SPEC’s rendered examples show a wall-clock-looking value; the conventions list only requiresupdated: <RFC3339>, and the property-tested invariant dominates.) index.jsonlis always compacted. Write-through rewrites the affected type-folder’s jsonl in canonical form (one current line per path, recency order) rather than appending superseded/tombstone lines, so the jsonl is byte-identical torebuild_allimmediately (a strictly stronger guarantee than the SPEC’s “post-compaction”). This keeps the loop cost at one sidecar read + one rewrite per touched type-folder — O(folder), the sanctioned loop primitive, never a whole-Store::walk.- Root/layer entry styling follows plan §index (
(N)numeric counts; layer headings in the root carry the layer’s total count) which is more specific than the SPEC’s illustrative(42 files)prose example. Type folders are listed alphabetically (a deterministic order a derived artifact needs);scope: type-folderfollows the conventions list, not the one SPEC example that wrotescope: folder.
Structs§
- Index
- A built (or being-built) catalog for one
IndexLevel, with both rendered artifacts available. Pure data until written viaIndex::write_level. - Index
Record - One record in a type-folder’s
index.jsonl— the complete, structured twin of a singleindex.mdbrowse entry.
Enums§
- Index
Level - Which level of the catalog an
Indexrepresents.