1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! `dbmd-core` — the reference library for **db.md**, the open database in
//! plain files.
//!
//! db.md is one directory: raw evidence in `sources/`, atomic typed data in
//! `records/`, curator-synthesized narrative in `wiki/`, and a single `DB.md`
//! config file at the root. Records are markdown files with YAML frontmatter;
//! relationships are wiki-links; the index is the derived, write-through
//! `index.md` / `index.jsonl` catalog plus embedded ripgrep.
//!
//! This crate owns **all** toolkit logic. The `dbmd` binary (`dbmd-cli`) is a
//! thin wrapper that parses args, calls into here, and formats output. Any
//! Rust tool wanting to be db.md-aware can `cargo add dbmd-core` and get the
//! full library — the same shape as ripgrep, where the `grep`/`ignore` libs do
//! the work and `rg` is a thin CLI.
//!
//! # Hard invariants this crate is built to uphold
//!
//! - **Zero AI/LLM dependencies.** No provider SDKs, no API keys, no model
//! calls, no embeddings, no vectors, no ANN — anywhere, ever. The agent
//! driving `dbmd` is the semantic layer; `dbmd` is a deterministic tool.
//! - **The interactive loop is O(changed), never O(store).** Loop ops
//! ([`graph::backlinks`], [`validate::validate_working_set`],
//! [`index::Index::on_write`], …) never call [`store::Store::walk`]. Whole-
//! store walks belong only to SWEEP ops ([`validate::validate_all`],
//! [`index::Index::rebuild_all`], [`stats`]).
//! - **Wiki-links are full store-relative paths.** A short-form wiki-link is a
//! validation error ([`validate`] code `WIKI_LINK_SHORT_FORM`).
//! - **Embedded ripgrep.** Free-text body search uses the `grep` + `ignore`
//! crates in-process; the toolkit never bundles or shells out to `rg`.
//! Structured loop reads ([`graph::backlinks`], [`query::Query`]) ride the
//! `index.jsonl` sidecars instead, never a frontmatter tree scan.
// ── Shared public types, re-exported at the crate root ──────────────────────
//
// These are the locked interface every other crate and module builds against.
pub use ;
pub use ContextSlice;
pub use ;
pub use ;
pub use ;
pub use Query;
pub use ;
pub use ;
pub use now;
pub use ;
/// Crate-wide result alias over [`Error`].
pub type Result<T> = Result;
/// Top-level error for `dbmd-core` operations.
///
/// Module-specific errors ([`ParseError`], [`StoreError`], [`NotAStore`])
/// convert into this so a CLI command can bubble a single error type while
/// preserving the structured variant for `--json` rendering.