176821c2e7
The 3020-line docs/DESIGN.md is replaced by the design/ ledger:
design/INDEX.md (sole addressable spine, typed Contracts+Models tables,
polymorphic links — prose file OR authoritative source //!), 14
design/contracts/*.md test-linked invariants + 3 source-link-only
contracts (mangling/env-construction/qualified-xref, no prose file —
code is SoT), 5 design/models/*.md whitepapers, and
docs/journals/2026-05-19-design-decision-records.md (the
relitigation-guard archive — every why/rejected/does-not-do/rollback/
empirical ### moved out at ###-granularity). Clean cut: git rm
docs/DESIGN.md, no stub.
RED-first crates/ailang-core/tests/design_index_pin.rs — the 4-clause
anti-regrowth spine (DESIGN.md-gone / every-INDEX-link-resolves /
every-contract-names-a-resolvable-ratifier /
contracts-carry-no-decision-record-prose) — demonstrably RED before,
GREEN after. Build-atomic by task ordering: design_schema_drift.rs's
include_str! (the only compile-time consumer) retargeted to
design/contracts/data-model.md BEFORE the deletion; its
## Data model/## Pipeline slicer dropped (a simplification the split
enables). 2 NoInstance diagnostics + 2 lockstep E2Es retargeted to
design/contracts/{float-semantics,typeclasses}.md. ~12 agent reading
lists + 5 SKILL bodies + CLAUDE.md + skills/README.md + ~25
code/C/.ail/spec comment xrefs retargeted; OQ7 dangling 'Iter 13b'
cite deleted (no forward target — a pointer would be fiction).
honesty-rule.md rewritten so the rule names the new home
(rationale->journals), resolving the recon-found internal
contradiction; the two docs_honesty_pin.rs:70,72 pinned phrases kept
verbatim+contiguous.
Boss-verified independently: cargo test --workspace 646 passed /
0 failed; design_index_pin 4/4; acceptance grep CLEAN of live
DESIGN.md refs (residuals = only the spec-mandated clause-4
deletion-enforcer). 2 DONE_WITH_CONCERNS routed to the mandatory
milestone-close audit: (a) str-abi.md:23 '(iter str-concat,
2026-05-13)' provenance stamp trips advisory architect_sweeps Sweep-1
— Boss-confirmed byte-identical to DESIGN.md@deeffb1:2062-2065, a
faithfully-migrated PRE-EXISTING anchor (regexes verbatim, only path
retargeted), NOT split-introduced — RATIFY-or-tidy at audit; (b) a
now stale-direction intra-prose 'see Str ABI below' cross-ref in
float-semantics.md — audit-adjudication candidate. Plan defect noted:
Task 9 Step 4's verbatim acceptance grep used a ^./ anchor not
matching the system's grep -rIn output; substance re-verified CLEAN.
Spec grounding-check PASS x2. Journals INDEX + decision-records
pointer appended (Boss-only).
158 lines
4.8 KiB
Rust
158 lines
4.8 KiB
Rust
//! Structural pin for the design/ ledger. Sibling of
|
|
//! docs_honesty_pin.rs. Fails RED the instant the design/ split
|
|
//! re-conflates contract + rationale + narrative, an INDEX row
|
|
//! dangles, a contract loses its ratifying test, or docs/DESIGN.md
|
|
//! is resurrected. Spec: docs/specs/2026-05-19-design-md-rolesplit.md.
|
|
|
|
use std::fs;
|
|
use std::path::PathBuf;
|
|
|
|
fn root() -> PathBuf {
|
|
PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR"), "/../../"))
|
|
}
|
|
|
|
fn read(rel: &str) -> String {
|
|
fs::read_to_string(root().join(rel))
|
|
.unwrap_or_else(|e| panic!("read {rel}: {e}"))
|
|
}
|
|
|
|
fn norm(s: &str) -> String {
|
|
s.split_whitespace().collect::<Vec<_>>().join(" ")
|
|
}
|
|
|
|
/// Parse the two pipe-tables out of design/INDEX.md.
|
|
/// Returns (contracts, models) as rows of trimmed cells.
|
|
fn index_tables() -> (Vec<Vec<String>>, Vec<Vec<String>>) {
|
|
let idx = read("design/INDEX.md");
|
|
let mut contracts = Vec::new();
|
|
let mut models = Vec::new();
|
|
let mut section = "";
|
|
for line in idx.lines() {
|
|
let t = line.trim();
|
|
if t.starts_with("## Contracts") {
|
|
section = "c";
|
|
continue;
|
|
}
|
|
if t.starts_with("## Models") {
|
|
section = "m";
|
|
continue;
|
|
}
|
|
if !t.starts_with('|') {
|
|
continue;
|
|
}
|
|
let cells: Vec<String> = t
|
|
.trim_matches('|')
|
|
.split('|')
|
|
.map(|c| c.trim().to_string())
|
|
.collect();
|
|
// skip header + separator rows
|
|
if cells.iter().any(|c| c.starts_with("---")) {
|
|
continue;
|
|
}
|
|
if cells.first().map(|c| c.as_str()) == Some("id") {
|
|
continue;
|
|
}
|
|
match section {
|
|
"c" => contracts.push(cells),
|
|
"m" => models.push(cells),
|
|
_ => {}
|
|
}
|
|
}
|
|
(contracts, models)
|
|
}
|
|
|
|
/// A link cell may be a design/ path, a source path, a dual-link
|
|
/// "A + B", or carry a trailing "(in-source ...)" / "§..." note.
|
|
/// Resolve to the first concrete path token and check it exists.
|
|
fn link_target_exists(cell: &str) -> bool {
|
|
let first = cell.split(" + ").next().unwrap_or(cell).trim();
|
|
// strip a trailing parenthetical or §-note
|
|
let path = first
|
|
.split(" (")
|
|
.next()
|
|
.unwrap_or(first)
|
|
.split(" §")
|
|
.next()
|
|
.unwrap_or(first)
|
|
.trim()
|
|
.trim_end_matches("//!")
|
|
.trim();
|
|
!path.is_empty() && root().join(path).exists()
|
|
}
|
|
|
|
#[test]
|
|
fn design_md_is_gone() {
|
|
// clause 4 — clean-cut pin
|
|
assert!(
|
|
!root().join("docs/DESIGN.md").exists(),
|
|
"docs/DESIGN.md was resurrected; the split is clean-cut"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn every_index_link_resolves() {
|
|
// clause 1
|
|
let (contracts, models) = index_tables();
|
|
assert!(contracts.len() >= 15, "expected >=15 contract rows, got {}", contracts.len());
|
|
assert!(models.len() >= 5, "expected >=5 model rows, got {}", models.len());
|
|
for row in contracts.iter().chain(models.iter()) {
|
|
let link = row.last().expect("row has a link cell");
|
|
assert!(
|
|
link_target_exists(link),
|
|
"INDEX link does not resolve: {:?} (row {:?})",
|
|
link,
|
|
row
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn every_contract_names_a_resolvable_ratifying_test() {
|
|
// clause 2 — ratifying-test token resolves to a real file under
|
|
// crates/**/tests, crates/**/src (in-source #[cfg(test)] mod
|
|
// tests are first-class ratifiers — spec OQ1/OQ2), bench/, or
|
|
// skills/**/SKILL.md.
|
|
let (contracts, _) = index_tables();
|
|
for row in &contracts {
|
|
// columns: id | consumer/lifetime | ratifying-test | link
|
|
let rt = &row[2];
|
|
// take the path token (before any " (" note)
|
|
let path = rt.split(" (").next().unwrap_or(rt).trim();
|
|
assert!(
|
|
root().join(path).exists(),
|
|
"ratifying-test does not resolve to a real file: {:?} (contract {:?})",
|
|
path,
|
|
row[0]
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn contracts_carry_no_decision_record_prose() {
|
|
// clause 3 — the conflation tripwire.
|
|
let dir = root().join("design/contracts");
|
|
let markers = [
|
|
"we rejected",
|
|
"an earlier draft",
|
|
"Why not other",
|
|
"was retired in iter",
|
|
"rollback plan",
|
|
"previously all",
|
|
];
|
|
for entry in fs::read_dir(&dir).expect("design/contracts/ exists") {
|
|
let p = entry.unwrap().path();
|
|
if p.extension().and_then(|e| e.to_str()) != Some("md") {
|
|
continue;
|
|
}
|
|
let body = norm(&fs::read_to_string(&p).unwrap());
|
|
for m in &markers {
|
|
assert!(
|
|
!body.contains(m),
|
|
"decision-record marker {:?} found in contract {:?} — re-conflation",
|
|
m,
|
|
p.file_name().unwrap()
|
|
);
|
|
}
|
|
}
|
|
}
|