struct Claim {
operation: &'static str,
fixture: &'static str,
metric: &'static str,
value: &'static str,
text: &'static str,
doc_name: &'static str,
doc: &'static str,
bench_group: &'static str,
decision: &'static str,
status: Status,
}
enum Status {
Live,
Superseded {
by: &'static str,
},
Contested {
with: &'static str,
owner: &'static str,
},
}
use Status::{Contested, Live, Superseded};
const README: &str = include_str!("../README.md");
const QUICKREF: &str = include_str!("../docs/quickref.md");
const S5: &str = include_str!("../docs/architecture/s5-modules.md");
const S9: &str = include_str!("../docs/architecture/s6-s10-flows-to-dependencies.md");
const CONNECTION: &str = include_str!("../src/connection.rs");
const BUDGETS: &str = include_str!("../benches/budgets.rs");
const REGISTER: &str = include_str!("../docs/architecture/s13-decision-register.md");
const APPENDICES: &str = include_str!("../docs/architecture/appendices.md");
const CHUNK_DIAG: &str = include_str!("../examples/chunk_diag.rs");
const CHUNK_MATRIX: &str = include_str!("../examples/chunk_matrix.rs");
mod fx {
pub const WARM: &str = "warm handle, 2,000 concepts, no links (write_path/assert_edge)";
pub const PER_ITER: &str =
"database rebuilt per iteration, Shape::StarOfStars at 0 / 2,000 / 8,000 edges";
pub const EMPTY: &str = "empty database (chunk_budget, concepts seeded, no links)";
pub const SEEDED: &str = "8,000-edge table (chunk_budget's seeded arm, W4.13)";
pub const MATRIX: &str = "all four D-088 shapes, each populated to 8,000 edges (chunk_matrix)";
}
const LATENCY: &str = "latency, median, reference hardware";
const ATTRIBUTION: &str = "share of growth 0 -> 8,000 edges, median of three sessions";
const DERIVED: &str = "largest chunk size within the 3 ms bound, populated database";
const DERIVED_EDGES: &str =
"20 rows on all four D-088 shapes, against a constant of 90 that is deliberately not changed";
const ATTRIBUTED: &str = "89% of the growth is links_current secondary-index maintenance; the \r
single-open guard contributes none";
const FLOOR_COST: &str = "3.11-3.43 ms at 35 rows, all four shapes, two sessions";
const WORST_STALL: &str = "longest hold, adaptive against fixed ceiling-sized chunks";
const WORST_STALL_VALUE: &str = "7.7-10.2 ms against 7.6-15.2 ms (0.67-1.01x)";
const TYPICAL_STALL: &str = "mean hold, adaptive against fixed ceiling-sized chunks";
const TYPICAL_STALL_VALUE: &str = "3.4-3.7 ms against 7.1-8.3 ms (2.1-2.4x shorter)";
const REGISTRY: &[Claim] = &[
Claim {
operation: "single edge assertion",
fixture: fx::WARM,
metric: LATENCY,
value: "224 µs",
text: "224 µs, and the caveat is **retired on measurement** (D-134)",
doc_name: "README.md",
doc: README,
bench_group: "write_path",
decision: "d-134",
status: Live,
},
Claim {
operation: "single edge assertion",
fixture: fx::WARM,
metric: LATENCY,
value: "224 µs",
text: "| Single assertion | ≤ 5 ms | 224 µs |",
doc_name: "docs/quickref.md",
doc: QUICKREF,
bench_group: "write_path",
decision: "d-134",
status: Live,
},
Claim {
operation: "single edge assertion",
fixture: fx::WARM,
metric: LATENCY,
value: "258 µs",
text: "single assertion **258 µs** on this fixture",
doc_name: "docs/architecture/s6-s10-flows-to-dependencies.md",
doc: S9,
bench_group: "write_path",
decision: "d-127",
status: Superseded { by: "d-134" },
},
Claim {
operation: "single edge assertion",
fixture: fx::PER_ITER,
metric: LATENCY,
value: "983 / 920 / 882 µs — sub-millisecond and flat in out-degree",
text: "at 983 / 920 / 882 µs, median of three sessions against a 1.52 µs control",
doc_name: "README.md",
doc: README,
bench_group: "overlap_guard",
decision: "d-134",
status: Live,
},
Claim {
operation: "single edge assertion",
fixture: fx::PER_ITER,
metric: LATENCY,
value: "983 / 920 / 882 µs — sub-millisecond and flat in out-degree",
text: "measured into tables of 0 / 2,000 / 8,000 edges — hub out-degree \
0 / 666 / 2,666 — with no rise",
doc_name: "docs/quickref.md",
doc: QUICKREF,
bench_group: "overlap_guard",
decision: "d-134",
status: Live,
},
Claim {
operation: "single edge assertion",
fixture: fx::PER_ITER,
metric: LATENCY,
value: "983 / 920 / 882 µs — sub-millisecond and flat in out-degree",
text: "sub-millisecond into tables of 0 / 2,000 / 8,000 edges, at which \
the probed hub carries out-degree 0 / 666 / 2,666",
doc_name: "docs/architecture/s6-s10-flows-to-dependencies.md",
doc: S9,
bench_group: "overlap_guard",
decision: "d-134",
status: Live,
},
Claim {
operation: "single edge assertion",
fixture: fx::PER_ITER,
metric: LATENCY,
value: "983 / 920 / 882 µs — sub-millisecond and flat in out-degree",
text: "Measured into tables of 0 / 2,000 / 8,000 edges — hub out-degree \
0 / 666 / 2,666 on this same fixture — it does not move.",
doc_name: "docs/architecture/s5-modules.md",
doc: S5,
bench_group: "overlap_guard",
decision: "d-134",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::EMPTY,
metric: LATENCY,
value: "2.39 ms",
text: "| Chunk commit (edges, 90 rows) | ≤ 3 ms | 2.39 ms |",
doc_name: "README.md",
doc: README,
bench_group: "chunk_budget",
decision: "d-058",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::EMPTY,
metric: LATENCY,
value: "2.39 ms",
text: "| Chunk commit, edges 90 rows | ≤ 3 ms | ~2.39 ms |",
doc_name: "docs/quickref.md",
doc: QUICKREF,
bench_group: "chunk_budget",
decision: "d-058",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::EMPTY,
metric: LATENCY,
value: "2.39 ms",
text: "| Edges (`bulk_import`) | 90 | ~2.39 ms |",
doc_name: "docs/quickref.md",
doc: QUICKREF,
bench_group: "chunk_budget",
decision: "d-058",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::EMPTY,
metric: LATENCY,
value: "2.39 ms",
text: "2.39 ms **on an empty database**",
doc_name: "docs/architecture/s6-s10-flows-to-dependencies.md",
doc: S9,
bench_group: "chunk_budget",
decision: "d-058",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::EMPTY,
metric: LATENCY,
value: "2.39 ms",
text: "each at its own size: edges **2.39 ms**",
doc_name: "src/connection.rs",
doc: CONNECTION,
bench_group: "chunk_budget",
decision: "d-058",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::EMPTY,
metric: LATENCY,
value: "2.71 ms — the 0.10.0 column's figure, since explained as an elevated-control session",
text: "**2.71 ms — see below**",
doc_name: "README.md",
doc: README,
bench_group: "chunk_budget",
decision: "d-145",
status: Superseded { by: "d-145" },
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::SEEDED,
metric: LATENCY,
value: "9.06 ms — the 3 ms bound missed by ~3×, residual attributed to the links_current sync trigger",
text: "**9.06 ms into an 8,000-edge table**",
doc_name: "docs/architecture/s6-s10-flows-to-dependencies.md",
doc: S9,
bench_group: "chunk_budget",
decision: "d-136",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::SEEDED,
metric: LATENCY,
value: "9.06 ms — the 3 ms bound missed by ~3×, residual attributed to the links_current sync trigger",
text: "90-edge chunk takes **9.06 ms** into an 8,000-edge table",
doc_name: "src/connection.rs",
doc: CONNECTION,
bench_group: "chunk_budget",
decision: "d-136",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::SEEDED,
metric: LATENCY,
value: "9.06 ms — the 3 ms bound missed by ~3×, residual attributed to the links_current sync trigger",
text: "edges into an 8,000-edge table take **9.06 ms**",
doc_name: "src/connection.rs",
doc: CONNECTION,
bench_group: "chunk_budget",
decision: "d-136",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::SEEDED,
metric: ATTRIBUTION,
value: ATTRIBUTED,
text: "89% of it secondary-index maintenance on `links_current`",
doc_name: "docs/architecture/s6-s10-flows-to-dependencies.md",
doc: S9,
bench_group: "example:chunk_diag/sync",
decision: "d-142",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::SEEDED,
metric: ATTRIBUTION,
value: ATTRIBUTED,
text: "89% of the growth is maintenance of `idx_lc_traversal_cover`",
doc_name: "src/connection.rs",
doc: CONNECTION,
bench_group: "example:chunk_diag/sync",
decision: "d-142",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::SEEDED,
metric: ATTRIBUTION,
value: ATTRIBUTED,
text: "89% of the growth from an empty table to an 8,000-edge one",
doc_name: "docs/architecture/appendices.md",
doc: APPENDICES,
bench_group: "example:chunk_diag/sync",
decision: "d-142",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::MATRIX,
metric: DERIVED,
value: DERIVED_EDGES,
text: "**the largest size within the bound is 20**, not 90",
doc_name: "docs/architecture/s6-s10-flows-to-dependencies.md",
doc: S9,
bench_group: "example:chunk_matrix/edges",
decision: "d-143",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::MATRIX,
metric: DERIVED,
value: DERIVED_EDGES,
text: "the largest size meeting the bound is **20**",
doc_name: "src/connection.rs",
doc: CONNECTION,
bench_group: "example:chunk_matrix/edges",
decision: "d-143",
status: Live,
},
Claim {
operation: "chunk commit, edges, 90 rows",
fixture: fx::MATRIX,
metric: DERIVED,
value: DERIVED_EDGES,
text: "the largest size within the bound is **20**, against a constant of 90",
doc_name: "docs/architecture/appendices.md",
doc: APPENDICES,
bench_group: "example:chunk_matrix/edges",
decision: "d-143",
status: Live,
},
Claim {
operation: "chunk commit, edges, 35 rows (the floor)",
fixture: fx::MATRIX,
metric: LATENCY,
value: FLOOR_COST,
text: "A 35-row chunk costs **3.11–3.43 ms**",
doc_name: "src/connection.rs",
doc: CONNECTION,
bench_group: "example:chunk_matrix/converge",
decision: "d-146",
status: Live,
},
Claim {
operation: "chunk commit, edges, 35 rows (the floor)",
fixture: fx::MATRIX,
metric: LATENCY,
value: FLOOR_COST,
text: "a 35-row chunk costs **3.11–3.43 ms** across the four shapes over two sessions",
doc_name: "docs/architecture/s5-modules.md",
doc: S5,
bench_group: "example:chunk_matrix/converge",
decision: "d-146",
status: Live,
},
Claim {
operation: "chunk commit, edges, 35 rows (the floor)",
fixture: fx::MATRIX,
metric: LATENCY,
value: FLOOR_COST,
text: "measured at **3.11–3.43 ms** on the four D-088 shapes",
doc_name: "docs/quickref.md",
doc: QUICKREF,
bench_group: "example:chunk_matrix/converge",
decision: "d-146",
status: Live,
},
Claim {
operation: "chunk commit, edges, 35 rows (the floor)",
fixture: fx::MATRIX,
metric: LATENCY,
value: FLOOR_COST,
text: "**3.11–3.43 ms** across four shapes and two sessions",
doc_name: "docs/architecture/s13-decision-register.md",
doc: REGISTER,
bench_group: "example:chunk_matrix/converge",
decision: "d-146",
status: Live,
},
Claim {
operation: "bulk_import of 900 edges",
fixture: fx::MATRIX,
metric: WORST_STALL,
value: WORST_STALL_VALUE,
text: "**7.7–10.2 ms** against **7.6–15.2 ms** for fixed ceiling-sized chunks",
doc_name: "docs/architecture/s5-modules.md",
doc: S5,
bench_group: "example:chunk_matrix/converge",
decision: "d-146",
status: Live,
},
Claim {
operation: "bulk_import of 900 edges",
fixture: fx::MATRIX,
metric: WORST_STALL,
value: WORST_STALL_VALUE,
text: "(7.7–10.2 vs 7.6–15.2 ms)",
doc_name: "docs/quickref.md",
doc: QUICKREF,
bench_group: "example:chunk_matrix/converge",
decision: "d-146",
status: Live,
},
Claim {
operation: "bulk_import of 900 edges",
fixture: fx::MATRIX,
metric: WORST_STALL,
value: WORST_STALL_VALUE,
text: "**7.7–10.2 ms against 7.6–15.2 ms**",
doc_name: "docs/architecture/s13-decision-register.md",
doc: REGISTER,
bench_group: "example:chunk_matrix/converge",
decision: "d-146",
status: Live,
},
Claim {
operation: "bulk_import of 900 edges",
fixture: fx::MATRIX,
metric: TYPICAL_STALL,
value: TYPICAL_STALL_VALUE,
text: "mean hold **3.4–3.7 ms against 7.1–8.3 ms**, a 2.1–2.4× shorter wait",
doc_name: "docs/architecture/s5-modules.md",
doc: S5,
bench_group: "example:chunk_matrix/converge",
decision: "d-146",
status: Live,
},
Claim {
operation: "bulk_import of 900 edges",
fixture: fx::MATRIX,
metric: TYPICAL_STALL,
value: TYPICAL_STALL_VALUE,
text: "mean hold **3.4–3.7 ms against 7.1–8.3 ms** fixed, a 2.1–2.4× shorter typical stall",
doc_name: "docs/quickref.md",
doc: QUICKREF,
bench_group: "example:chunk_matrix/converge",
decision: "d-146",
status: Live,
},
Claim {
operation: "bulk_import of 900 edges",
fixture: fx::MATRIX,
metric: TYPICAL_STALL,
value: TYPICAL_STALL_VALUE,
text: "mean hold **3.4–3.7 ms against 7.1–8.3 ms**, 2.1–2.4× shorter",
doc_name: "docs/architecture/s13-decision-register.md",
doc: REGISTER,
bench_group: "example:chunk_matrix/converge",
decision: "d-146",
status: Live,
},
];
fn flat(s: &str) -> String {
s.split_whitespace().collect::<Vec<_>>().join(" ")
}
#[test]
fn every_claim_still_appears_in_its_document() {
for c in REGISTRY {
assert!(
flat(c.doc).contains(&flat(c.text)),
"{} / {} — {}\n no longer contains: {:?}\n \
The claim was edited or moved without updating the registry. If \
the number changed, every other entry under this key changed with \
it (see D-139).",
c.doc_name,
c.operation,
c.fixture,
c.text
);
}
}
#[test]
fn every_claim_names_a_bench_group_that_exists() {
for c in REGISTRY {
if let Some(rest) = c.bench_group.strip_prefix("example:") {
let (file, experiment) = rest.split_once('/').unwrap_or_else(|| {
panic!(
"{}: example evidence must be \"example:<file>/<experiment>\", got {:?}",
c.operation, c.bench_group
)
});
let source = match file {
"chunk_diag" => CHUNK_DIAG,
"chunk_matrix" => CHUNK_MATRIX,
other => panic!(
"{}: no example source is registered under {other:?}. Add it \
beside CHUNK_DIAG — an unknown name must not pass silently.",
c.operation
),
};
let arm = format!("\"{experiment}\" =>");
assert!(
source.contains(&arm),
"{}: claims are substantiated by examples/{file}.rs experiment \
{experiment:?}, which that file does not select. A renamed or \
deleted experiment leaves the claim standing on nothing.",
c.operation
);
continue;
}
let decl = format!("controlled_group(c, \"{}\")", c.bench_group);
assert!(
BUDGETS.contains(&decl),
"{}: claims are substantiated by criterion group {:?}, which \
benches/budgets.rs does not declare. A renamed or deleted bench \
leaves the claim standing on nothing.",
c.operation,
c.bench_group
);
}
}
#[test]
fn every_claim_names_a_decision_that_exists() {
for c in REGISTRY {
let anchor = format!("<a id=\"{}\"></a>", c.decision);
assert!(
REGISTER.contains(&anchor),
"{}: cites {} , which has no anchor in the decision register",
c.operation,
c.decision
);
if let Superseded { by } = c.status {
let anchor = format!("<a id=\"{by}\"></a>");
assert!(
REGISTER.contains(&anchor),
"{}: recorded as superseded by {by}, which has no anchor in the \
decision register",
c.operation
);
}
}
}
#[test]
fn one_operation_fixture_metric_key_carries_one_value() {
let exempt = |s: &Status| matches!(s, Superseded { .. } | Contested { .. });
for c in REGISTRY {
if exempt(&c.status) {
continue;
}
for other in REGISTRY {
if exempt(&other.status) {
continue;
}
let same_key = c.operation == other.operation
&& c.fixture == other.fixture
&& c.metric == other.metric;
assert!(
!same_key || c.value == other.value,
"one fact, two values.\n operation: {}\n fixture: {}\n \
metric: {}\n {} says {:?}\n {} says {:?}\n\
Either these are the same measurement and one document is \
stale, or they are different measurements and the fixtures \
must say so (D-139).",
c.operation,
c.fixture,
c.metric,
c.doc_name,
c.value,
other.doc_name,
other.value
);
}
}
}
#[test]
fn every_contested_claim_names_who_reconciles_it() {
for c in REGISTRY {
if let Err(why) = contested_is_well_formed(c, REGISTRY) {
panic!("{}: {why}", c.doc_name);
}
}
let peer = || Claim {
operation: "synthetic",
fixture: "synthetic",
metric: "synthetic",
value: "1.00 ms",
text: "",
doc_name: "none",
doc: "",
bench_group: "chunk_budget",
decision: "d-145",
status: Live,
};
let contested = |with, owner| Claim {
status: Contested { with, owner },
value: "2.00 ms",
..peer()
};
let well_formed = [contested("1.00 ms", "d-145"), peer()];
assert!(
contested_is_well_formed(&well_formed[0], &well_formed).is_ok(),
"a contest naming a value its peer publishes, and a real anchor, must pass"
);
let no_peer = [contested("9.99 ms", "d-145"), peer()];
assert!(
contested_is_well_formed(&no_peer[0], &no_peer).is_err(),
"a contest against a value nobody publishes must fail"
);
let no_owner = [contested("1.00 ms", "d-nonexistent"), peer()];
assert!(
contested_is_well_formed(&no_owner[0], &no_owner).is_err(),
"a contest whose owner anchor resolves to nothing must fail"
);
}
fn contested_is_well_formed(c: &Claim, registry: &[Claim]) -> Result<(), String> {
let Contested { with, owner } = c.status else {
return Ok(());
};
let peer = registry.iter().any(|o| {
o.operation == c.operation
&& o.fixture == c.fixture
&& o.metric == c.metric
&& o.value.contains(with)
});
if !peer {
return Err(format!(
"contests {with:?}, and no other entry under this key publishes it. Either the conflict is stale or the peer entry was deleted."
));
}
let heading = format!("<a id=\"{owner}\"></a>");
let slug = format!("#{owner}");
if !(REGISTER.contains(&heading) || APPENDICES.contains(&slug) || REGISTER.contains(&slug)) {
return Err(format!(
"contested, and its reconciliation owner {owner:?} resolves to nothing. A recorded conflict with no owner is an excuse."
));
}
Ok(())
}
#[test]
fn the_registry_covers_the_claims_that_drifted() {
for (operation, least) in [
("single edge assertion", 5),
("chunk commit, edges, 90 rows", 8),
] {
let n = REGISTRY.iter().filter(|c| c.operation == operation).count();
assert!(
n >= least,
"{operation} has {n} registry entries and had at least {least}. \
Entries are deleted when a claim is retired from a document — \
check that the text really went, rather than that this test was \
in the way."
);
}
let superseded = REGISTRY
.iter()
.filter(|c| matches!(c.status, Superseded { .. }))
.count();
assert!(
superseded >= 1,
"no Superseded entry remains. §9's D-127 paragraph publishes 258 µs \
for an operation whose live figure is 224 µs, deliberately — if that \
history was deleted, the register's own practice changed and D-139 \
needs revisiting."
);
}