Skip to main content

Module validate

Module validate 

Source
Expand description

validate — the validation engine.

The canonical issue-code vocabulary is SPEC.md § Validation (that table is the single source of truth). This module implements exactly those codes — no more, no fewer. If a code is added here it must be added to the SPEC table in the same change. The codes are exposed as the codes constants so call sites never spell a code as a bare string literal.

Two scopes. validate_working_set is the loop default: content files changed since since, plus any file whose wiki-links target a changed path. The changed set and the per-file checks are O(changed); the incoming linkers are found by a single embedded-ripgrep pass over the store for the whole changed set at once (Store::find_links_to_any, one scan — not a full read per changed object, and not the parse-the-tree walk --all does). On this changed-set path it never builds the global cross-file state.

The one exception is the vacuous-pass guard: when the change log records no objects since the cutoff and no explicit --since was given (a fresh store, a missing/empty log.md, or external edits never logged), the default call falls back to a single per-file content sweep (Store::walk) so an externally edited or freshly copied store cannot pass validation vacuously. That fallback is O(store) by design; the O(changed) guarantee is about the normal post-write path, not this safety net.

validate_all is the full SWEEP: it adds the checks that need the global cross-file state — entity-dedup DUP_*, every-index sync, and log.md ordering.

§Why this module is self-contained

Validation does its own frontmatter split, YAML parse, wiki-link scan, log-header parse, and file walk here, reading only the two public, caller-populated fields of a Store: Store::root and Store::config — rather than routing through the sibling modules (crate::parser, crate::store, crate::log, crate::index). Keeping the checks local lets the validator report precise, per-issue diagnostics (exact codes, file, and context) without coupling its output to incidental behavior of the shared readers; the public surface and the emitted issue vocabulary are the contract.

Modules§

codes
The canonical validation issue codes — one constant per row of the SPEC.md § Validation table. Call sites reference these instead of bare strings so the code and the SPEC table can never silently drift.

Structs§

DerivedFromIgnored
The result of the derived_from_ignored_type policy check: the derived_from target that resolves to an ignored-type record, plus that record’s type. Carries exactly what both the validate finding and the write-time warning need to render their message.
Issue
A single structured validation finding. Agent-primary and machine-parseable via --json; suggestion is a deterministic remediation hint the agent applies without guessing.

Enums§

Severity
Severity of a validation Issue. Any Severity::Error fails validation (non-zero exit); warnings and info do not.

Functions§

derived_from_ignored_type
The single authoritative ### Ignored types derivation check. Decides whether a conclusion record derives from an ignored-type record: the meta-type must be conclusion, ### Ignored types must be non-empty, and some derived_from target must resolve to a record whose type is in ignored_types. Returns the first such target (and its type), or None.
validate_all
Full SWEEP (O(store)). Validate every file, every link, and every index, adding the cross-file checks that need global state: entity-dedup DUP_*, every-index sync (md + jsonl), and log.md ordering. CI / recovery, not the loop.
validate_working_set
Loop default. Validate the working set: content files changed since since (default: the last validate entry in log.md), plus any file whose wiki-links target a changed/renamed/removed path. Per-file checks only — none of the cross-file global passes (entity-dedup, every-index sync, log.md ordering) that --all adds. If the default call finds no logged changed objects, it falls back to a per-file content sweep so an externally edited or freshly copied store cannot pass vacuously.