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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! `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 plus
//! curator-synthesized conclusions (`meta-type: conclusion`) in `records/`, 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`] on a
//! non-empty changed set. The one documented exception is
//! [`validate::validate_working_set`], which falls back to a full sweep only
//! when handed an empty changed set (the vacuous-pass guard). Whole-store
//! walks otherwise 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.
// The link.md CLIENT (feature `link`, default-on): the five interconnect
// verbs — resolve / sync / grant / propose / subscribe — spoken against a
// user-configured hub. One binary, two specs (the git precedent); the db.md
// FORMAT is untouched — a store never needs link.md to be valid db.md, and a
// format-only consumer drops this module (and its HTTP/TLS closure) with
// `default-features = false`. Deliberately NOT re-exported at the crate root:
// the root re-exports are the format toolkit's locked interface, and the wire
// client reads best module-qualified (`linkmd::HubConfig`).
// The embedded micro-harness (feature `harness`, off core's defaults; the
// `dbmd` binary requests it): `ask` / `do` / `build` — a stateless
// tool-calling loop running the USER'S OWN model endpoint against the store's
// verb surface. Client for user-supplied intelligence only: two hand-rolled
// wire protocols over the same `ureq` the link client uses, no SDK crates, no
// default vendor, key from the environment only. The db.md FORMAT is
// untouched — a store never needs a model to be valid db.md, and the verbs
// stay deterministic plumbing (AGENTS.md "Hard rules" carries the covenant).
// ── 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 ;
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.