From 185f7461a64dcc1255c49e5d935b66ea4e79ee5a Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 19:46:43 +0000 Subject: [PATCH 1/5] dashboard-check: one registry of ledger row IDs, checked Owner decision 2026-11-16, after two sessions each added T-10/T-11 with different meanings on parallel branches (#171 and #172; #172 renumbered its row to T-12 by hand). The status table in PROOF-NEEDS is now the registry of row IDs, and dashboard-check enforces it: - every status-table ID has the shape LETTERS-digits[lowercase] and appears exactly once; - every claims-ledger row that starts with `ID:` names a registered ID; - every registered ID has at least one ledger row; - a registered ID's status is one of its ledger rows' statuses. On the current ledger all 36 IDs pass. A replay of the T-10 collision (a second `| T-10 |` row after a clean merge) fails with "row ID T-10 is registered twice". Ledger rows with no ID prefix (10 today) are counted, not failed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX --- crates/dashboard-check/src/ids.rs | 256 +++++++++++++++++++++++++++++ crates/dashboard-check/src/main.rs | 13 ++ 2 files changed, 269 insertions(+) create mode 100644 crates/dashboard-check/src/ids.rs diff --git a/crates/dashboard-check/src/ids.rs b/crates/dashboard-check/src/ids.rs new file mode 100644 index 0000000..b26972f --- /dev/null +++ b/crates/dashboard-check/src/ids.rs @@ -0,0 +1,256 @@ +// SPDX-License-Identifier: MPL-2.0 +// SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell +// +// Ledger row IDs: one registry, checked (owner decision 2026-11-16). +// +// PROOF-NEEDS.adoc has two tables. The status table (`| ID | Claim | Status | +// Artefact`) holds one row per obligation ID, and the claims ledger holds one +// row per check, each starting `ID: …`. The status table is the registry of +// IDs. Two sessions that each add "T-10" with a different meaning on parallel +// branches used to merge cleanly into two T-10 rows; these rules make that +// collision fail CI instead of landing. +// +// Rules, each of which has a fixture below: +// - Every status-table ID has the form `-[]` +// (`T-10`, `E-1m`) and appears exactly once. +// - Every claims-ledger row that starts with `ID:` names a registered ID. +// - Every registered ID has at least one claims-ledger row. +// - A registered ID's status is one of its ledger rows' statuses, so the two +// tables cannot disagree about what an obligation has reached. +// Ledger rows with no `ID:` prefix are not checked here; the caller reports +// how many there are. + +use crate::claims::Claim; +use std::collections::BTreeMap; + +/// One row of the status table. +#[derive(Debug, Clone, PartialEq)] +pub struct Registered { + pub line: usize, + pub id: String, + pub status: String, +} + +const HEADER: &str = "| ID | Claim | Status | Artefact"; + +/// True for `T-10`, `E-1m`, `A-1`: capital letters, a hyphen, digits, then +/// optionally lowercase letters. +pub fn is_row_id(s: &str) -> bool { + let Some((prefix, rest)) = s.split_once('-') else { + return false; + }; + let digits = rest.trim_end_matches(|c: char| c.is_ascii_lowercase()); + !prefix.is_empty() + && prefix.chars().all(|c| c.is_ascii_uppercase()) + && !digits.is_empty() + && digits.chars().all(|c| c.is_ascii_digit()) +} + +/// The ID a claims-ledger row starts with (`T-8: …`), if any. +pub fn claim_id(claim: &str) -> Option<&str> { + let (head, _) = claim.split_once(':')?; + let head = head.trim(); + is_row_id(head).then_some(head) +} + +/// Parse the status table. Its header row must be exactly [`HEADER`]; a +/// missing table is an error, not an empty registry. +pub fn parse_status_table(src: &str) -> Result, Vec> { + let lines: Vec<&str> = src.lines().collect(); + let Some(header) = lines.iter().position(|l| l.trim() == HEADER) else { + return Err(vec![format!( + "PROOF-NEEDS.adoc has no status table (header '{HEADER}')" + )]); + }; + let mut rows = Vec::new(); + let mut errors = Vec::new(); + let mut closed = false; + for (i, raw) in lines.iter().enumerate().skip(header + 1) { + let n = i + 1; + let l = raw.trim(); + if l == "|===" { + closed = true; + break; + } + if l.is_empty() { + continue; + } + let cells: Vec<&str> = l + .trim_start_matches('|') + .split('|') + .map(str::trim) + .collect(); + if cells.len() < 3 { + errors.push(format!( + "PROOF-NEEDS.adoc:{n}: status-table rows must fit on one line (ID | Claim | Status | Artefact)" + )); + continue; + } + if !is_row_id(cells[0]) { + errors.push(format!( + "PROOF-NEEDS.adoc:{n}: '{}' is not a row ID (expected e.g. T-10 or E-1m)", + cells[0] + )); + continue; + } + rows.push(Registered { + line: n, + id: cells[0].to_string(), + status: cells[2].to_string(), + }); + } + if !closed { + errors.push("the status table is not closed with |===".into()); + } + if errors.is_empty() { + Ok(rows) + } else { + Err(errors) + } +} + +/// Check the registry against the claims ledger. Returns the problems found +/// and the number of ledger rows that carry no ID. +pub fn check_ids(registry: &[Registered], claims: &[Claim]) -> (Vec, usize) { + let mut problems = Vec::new(); + + let mut first: BTreeMap<&str, usize> = BTreeMap::new(); + for r in registry { + if let Some(prev) = first.insert(r.id.as_str(), r.line) { + problems.push(format!( + "PROOF-NEEDS.adoc:{}: row ID {} is registered twice (also line {prev}); \ + give one of them a new ID", + r.line, r.id + )); + } + } + + let mut statuses: BTreeMap<&str, Vec> = BTreeMap::new(); + let mut unprefixed = 0; + for c in claims { + match claim_id(&c.claim) { + Some(id) if first.contains_key(id) => statuses + .entry(id) + .or_default() + .push(format!("{:?}", c.status).to_uppercase()), + Some(id) => problems.push(format!( + "PROOF-NEEDS.adoc:{}: ledger row names {id}, which the status table does not register", + c.line + )), + None => unprefixed += 1, + } + } + + for r in registry { + match statuses.get(r.id.as_str()) { + None => problems.push(format!( + "PROOF-NEEDS.adoc:{}: {} is registered but has no claims-ledger row", + r.line, r.id + )), + Some(s) if !s.contains(&r.status) => problems.push(format!( + "PROOF-NEEDS.adoc:{}: {} is {} in the status table but its ledger rows are {}", + r.line, + r.id, + r.status, + s.join(", ") + )), + Some(_) => {} + } + } + (problems, unprefixed) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::claims::parse_ledger; + + const DOC: &str = "\ +[cols=\"1,3,1,2\",options=\"header\"] +|=== +| ID | Claim | Status | Artefact +| T-1 | Rollback restores | PROVEN | `x` +| E-1m | Model ignorance | OPEN | `y` +|=== + +=== Claims ledger + +|=== +|Claim |Status |Artefact |Command +|T-1: rollback restores |PROVEN |`a.agda::r` |`true` +|E-1m: ignorance |OPEN |`#1` |- +|An unregistered property test |TESTED |`src/a.rs::t` |`cargo test t` +|=== +"; + + fn run(doc: &str) -> (Vec, usize) { + let reg = parse_status_table(doc).unwrap(); + let claims = parse_ledger(doc).unwrap(); + check_ids(®, &claims) + } + + #[test] + fn row_id_shape() { + for ok in ["T-1", "T-10", "E-1m", "A-12"] { + assert!(is_row_id(ok), "{ok}"); + } + for bad in ["t-1", "T1", "T-", "-1", "T-1M", "T-x"] { + assert!(!is_row_id(bad), "{bad}"); + } + assert_eq!(claim_id("T-8: a log edit"), Some("T-8")); + assert_eq!(claim_id("Execute then undo: holds"), None); + } + + #[test] + fn a_consistent_ledger_passes_and_counts_unprefixed_rows() { + let (p, unprefixed) = run(DOC); + assert!(p.is_empty(), "{p:?}"); + assert_eq!(unprefixed, 1); + } + + #[test] + fn an_id_registered_twice_is_rejected() { + let doc = DOC.replace( + "| E-1m | Model ignorance | OPEN | `y`", + "| E-1m | Model ignorance | OPEN | `y`\n| T-1 | Something else | OPEN | `z`", + ); + let (p, _) = run(&doc); + assert!( + p.iter().any(|e| e.contains("T-1 is registered twice")), + "{p:?}" + ); + } + + #[test] + fn a_ledger_row_with_an_unregistered_id_is_rejected() { + let doc = DOC.replace("|T-1: rollback", "|T-9: rollback"); + let (p, _) = run(&doc); + assert!(p.iter().any(|e| e.contains("names T-9")), "{p:?}"); + assert!( + p.iter().any(|e| e.contains("T-1 is registered but has no")), + "{p:?}" + ); + } + + #[test] + fn disagreeing_statuses_are_rejected() { + let doc = DOC.replace( + "| T-1 | Rollback restores | PROVEN", + "| T-1 | Rollback restores | TESTED", + ); + let (p, _) = run(&doc); + assert!( + p.iter() + .any(|e| e + .contains("T-1 is TESTED in the status table but its ledger rows are PROVEN")), + "{p:?}" + ); + } + + #[test] + fn a_malformed_id_or_missing_table_is_an_error() { + let doc = DOC.replace("| T-1 | Rollback", "| T1 | Rollback"); + assert!(parse_status_table(&doc).unwrap_err()[0].contains("'T1' is not a row ID")); + assert!(parse_status_table("= nothing\n").is_err()); + } +} diff --git a/crates/dashboard-check/src/main.rs b/crates/dashboard-check/src/main.rs index db0c90f..4b41090 100644 --- a/crates/dashboard-check/src/main.rs +++ b/crates/dashboard-check/src/main.rs @@ -24,6 +24,7 @@ // non-zero with a report otherwise. `--check` is the default and only mode. mod claims; +mod ids; use std::path::{Path, PathBuf}; use std::process::ExitCode; @@ -317,6 +318,18 @@ fn check_claims(root: &Path, r: &mut Report) { return; } }; + match ids::parse_status_table(&ledger.text) { + Ok(registry) => { + let (problems, unprefixed) = ids::check_ids(®istry, &claims); + r.problems.extend(problems); + r.observed.push(format!( + "{} row IDs registered, each once, each with a ledger row; \ + {unprefixed} ledger rows carry no ID", + registry.len() + )); + } + Err(errors) => r.problems.extend(errors), + } for c in &claims { match claims::check_claim(root, c, &claims::run_command) { Ok(()) => r From d3752fb8790654fe59ec75620b5373d1fa2d10be Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 20:06:45 +0000 Subject: [PATCH 2/5] docs: the row-ID registry rule; test count 150 PROOF-NEEDS says the status table is the registry of row IDs and what dashboard-check refuses. The six new dashboard-check tests bring the measured count to 150 in READINESS, TOPOLOGY and STATE. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX --- .machine_readable/6a2/STATE.a2ml | 2 +- PROOF-NEEDS.adoc | 6 +++++- READINESS.adoc | 4 ++-- TOPOLOGY.adoc | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.machine_readable/6a2/STATE.a2ml b/.machine_readable/6a2/STATE.a2ml index 190b064..d21941d 100644 --- a/.machine_readable/6a2/STATE.a2ml +++ b/.machine_readable/6a2/STATE.a2ml @@ -44,7 +44,7 @@ property-tests = "9 (2026-04-03 assessment, not re-derived)" regression-tests = "5 (2026-04-03 assessment, not re-derived)" idris2-proofs = "12 PROVEN ledger rows (the former 30 counted lemmas before the tautology purge; PROOF-NEEDS.adoc is authoritative)" benchmarks = "5 Criterion groups (no baseline recorded)" -total = "144 tests + 5 benchmark groups + 12 PROVEN ledger rows — as declared in READINESS.adoc and measured by dashboard-check" +total = "150 tests + 5 benchmark groups + 12 PROVEN ledger rows — as declared in READINESS.adoc and measured by dashboard-check" [proof-grades] # Proof Witness Grades, standards 3-practice/PROOF-POLICY.adoc §8 (the diff --git a/PROOF-NEEDS.adoc b/PROOF-NEEDS.adoc index d8a17ab..5a45f5c 100644 --- a/PROOF-NEEDS.adoc +++ b/PROOF-NEEDS.adoc @@ -47,7 +47,11 @@ last three checks were added when these rows entered the claims ledger). Status rows, in the five-status vocabulary. A status moves only with a named module, lemma, fixture or log line. Every row is also a row of the claims ledger below, which `+dashboard-check+` runs on every pull request; the two -tables must agree. +tables must agree. This table is the registry of row IDs (owner decision +2026-11-16), and `+dashboard-check+` refuses an ID registered twice, a ledger +row whose `+ID:+` is not registered, a registered ID with no ledger row, and a +status here that none of its ledger rows has. Before adding a row, pick the +next free number in its series. [cols="1,3,1,2",options="header"] |=== diff --git a/READINESS.adoc b/READINESS.adoc index f3a9ff9..ad2e069 100644 --- a/READINESS.adoc +++ b/READINESS.adoc @@ -8,7 +8,7 @@ standards/testing-and-benchmarking/TESTING-TAXONOMY.adoc v1.0 === CRG Grade: D (Alpha — Unstable) -*Justification:* 144 tests declared (`cargo test --workspace --locked -- --list`; rust-ci runs them); the +*Justification:* 150 tests declared (`cargo test --workspace --locked -- --list`; rust-ci runs them); the Idris2 ABI typechecks and 12 proofs are checked (PROVEN ledger rows: ABI, grade, transaction-model and epistemic-model lemmas, not the security obligations); benchmarks exist (5 Criterion groups). But: no fuzz testing, no mutation testing, 241 unwrap() calls, E2E mostly skips, @@ -65,7 +65,7 @@ handling (run by idris-abi.yml, agda-proofs.yml and dashboard-check) |=== -*Total declared:* 144 tests + 5 benchmark groups; 12 proofs checked (PROVEN ledger rows; five are theory theorems under PROOF-POLICY §8, graded from the receipt: T-1 at PWG-1 and four at PWG-3, whose Rocq and Lean legs check but have no CI receipt yet — see `docs/theory/PROOF-GRADES.adoc`) *Total +*Total declared:* 150 tests + 5 benchmark groups; 12 proofs checked (PROVEN ledger rows; five are theory theorems under PROOF-POLICY §8, graded from the receipt: T-1 at PWG-1 and four at PWG-3, whose Rocq and Lean legs check but have no CI receipt yet — see `docs/theory/PROOF-GRADES.adoc`) *Total missing:* Fuzz, mutation, chaos, compatibility === Aspect Matrix diff --git a/TOPOLOGY.adoc b/TOPOLOGY.adoc index fcb8922..f6f8dd8 100644 --- a/TOPOLOGY.adoc +++ b/TOPOLOGY.adoc @@ -79,7 +79,7 @@ INTERFACES & RESEARCH MPR Methodology ████░░░░░░ ~40% Design documented; FORMAL PROOFS PENDING (Idris2 ABI typechecks; 12 proofs checked: ABI, grade, transaction-model and epistemic-model lemmas, not the security obligations; MPR not linked to the Rust) - Testing (READINESS matrix) ██████░░░░ ~60% 144 tests + 5 benches; missing fuzz, mutation, + Testing (READINESS matrix) ██████░░░░ ~60% 150 tests + 5 benches; missing fuzz, mutation, chaos, compatibility (Grade D) REPO INFRASTRUCTURE From 0c10d18d236c3a3df02825c619b072ee2fee8330 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 20:22:46 +0000 Subject: [PATCH 3/5] dashboard-check: refuse a malformed row-ID prefix and a mis-delimited registry row Codex review on #183: - A ledger row starting `T5:` or `T-5M:` was counted as a row with no ID, so a typo could slip past the registry while another row kept the ID satisfied. A head that looks like an ID (one word, a capital first letter, a digit) but is not one is now an error. The 10 rows with no ID all have spaces before their first colon, so none is caught. - A status-table row with no leading `|`, or with `||`, parsed as a normal row while AsciiDoc renders it differently. A row must now start with exactly one `|`. Two tests, each failing when its fix is reverted; the test count is 152. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX --- .machine_readable/6a2/STATE.a2ml | 2 +- PROOF-NEEDS.adoc | 5 ++- READINESS.adoc | 4 +- TOPOLOGY.adoc | 2 +- crates/dashboard-check/src/ids.rs | 70 ++++++++++++++++++++++++++++--- 5 files changed, 71 insertions(+), 12 deletions(-) diff --git a/.machine_readable/6a2/STATE.a2ml b/.machine_readable/6a2/STATE.a2ml index d21941d..a092a45 100644 --- a/.machine_readable/6a2/STATE.a2ml +++ b/.machine_readable/6a2/STATE.a2ml @@ -44,7 +44,7 @@ property-tests = "9 (2026-04-03 assessment, not re-derived)" regression-tests = "5 (2026-04-03 assessment, not re-derived)" idris2-proofs = "12 PROVEN ledger rows (the former 30 counted lemmas before the tautology purge; PROOF-NEEDS.adoc is authoritative)" benchmarks = "5 Criterion groups (no baseline recorded)" -total = "150 tests + 5 benchmark groups + 12 PROVEN ledger rows — as declared in READINESS.adoc and measured by dashboard-check" +total = "152 tests + 5 benchmark groups + 12 PROVEN ledger rows — as declared in READINESS.adoc and measured by dashboard-check" [proof-grades] # Proof Witness Grades, standards 3-practice/PROOF-POLICY.adoc §8 (the diff --git a/PROOF-NEEDS.adoc b/PROOF-NEEDS.adoc index 5a45f5c..a0e1bf7 100644 --- a/PROOF-NEEDS.adoc +++ b/PROOF-NEEDS.adoc @@ -49,8 +49,9 @@ module, lemma, fixture or log line. Every row is also a row of the claims ledger below, which `+dashboard-check+` runs on every pull request; the two tables must agree. This table is the registry of row IDs (owner decision 2026-11-16), and `+dashboard-check+` refuses an ID registered twice, a ledger -row whose `+ID:+` is not registered, a registered ID with no ledger row, and a -status here that none of its ledger rows has. Before adding a row, pick the +row whose `+ID:+` is not registered or is malformed (`+T5:+`, `+T-5M:+`), a +registered ID with no ledger row, a status here that none of its ledger rows +has, and a row here that does not start with exactly one `+|+`. Before adding a row, pick the next free number in its series. [cols="1,3,1,2",options="header"] diff --git a/READINESS.adoc b/READINESS.adoc index ad2e069..a87b9bf 100644 --- a/READINESS.adoc +++ b/READINESS.adoc @@ -8,7 +8,7 @@ standards/testing-and-benchmarking/TESTING-TAXONOMY.adoc v1.0 === CRG Grade: D (Alpha — Unstable) -*Justification:* 150 tests declared (`cargo test --workspace --locked -- --list`; rust-ci runs them); the +*Justification:* 152 tests declared (`cargo test --workspace --locked -- --list`; rust-ci runs them); the Idris2 ABI typechecks and 12 proofs are checked (PROVEN ledger rows: ABI, grade, transaction-model and epistemic-model lemmas, not the security obligations); benchmarks exist (5 Criterion groups). But: no fuzz testing, no mutation testing, 241 unwrap() calls, E2E mostly skips, @@ -65,7 +65,7 @@ handling (run by idris-abi.yml, agda-proofs.yml and dashboard-check) |=== -*Total declared:* 150 tests + 5 benchmark groups; 12 proofs checked (PROVEN ledger rows; five are theory theorems under PROOF-POLICY §8, graded from the receipt: T-1 at PWG-1 and four at PWG-3, whose Rocq and Lean legs check but have no CI receipt yet — see `docs/theory/PROOF-GRADES.adoc`) *Total +*Total declared:* 152 tests + 5 benchmark groups; 12 proofs checked (PROVEN ledger rows; five are theory theorems under PROOF-POLICY §8, graded from the receipt: T-1 at PWG-1 and four at PWG-3, whose Rocq and Lean legs check but have no CI receipt yet — see `docs/theory/PROOF-GRADES.adoc`) *Total missing:* Fuzz, mutation, chaos, compatibility === Aspect Matrix diff --git a/TOPOLOGY.adoc b/TOPOLOGY.adoc index f6f8dd8..cd73e85 100644 --- a/TOPOLOGY.adoc +++ b/TOPOLOGY.adoc @@ -79,7 +79,7 @@ INTERFACES & RESEARCH MPR Methodology ████░░░░░░ ~40% Design documented; FORMAL PROOFS PENDING (Idris2 ABI typechecks; 12 proofs checked: ABI, grade, transaction-model and epistemic-model lemmas, not the security obligations; MPR not linked to the Rust) - Testing (READINESS matrix) ██████░░░░ ~60% 150 tests + 5 benches; missing fuzz, mutation, + Testing (READINESS matrix) ██████░░░░ ~60% 152 tests + 5 benches; missing fuzz, mutation, chaos, compatibility (Grade D) REPO INFRASTRUCTURE diff --git a/crates/dashboard-check/src/ids.rs b/crates/dashboard-check/src/ids.rs index b26972f..e565344 100644 --- a/crates/dashboard-check/src/ids.rs +++ b/crates/dashboard-check/src/ids.rs @@ -53,6 +53,19 @@ pub fn claim_id(claim: &str) -> Option<&str> { is_row_id(head).then_some(head) } +/// A head before `:` that looks like an ID but is not one (`T5`, `T-5M`): one +/// word, starting with a capital letter, containing a digit. A typo like this +/// must not pass as a row with no ID. +pub fn malformed_id(claim: &str) -> Option<&str> { + let (head, _) = claim.split_once(':')?; + let head = head.trim(); + let looks_like_id = !head.is_empty() + && !head.contains(char::is_whitespace) + && head.starts_with(|c: char| c.is_ascii_uppercase()) + && head.contains(|c: char| c.is_ascii_digit()); + (looks_like_id && !is_row_id(head)).then_some(head) +} + /// Parse the status table. Its header row must be exactly [`HEADER`]; a /// missing table is an error, not an empty registry. pub fn parse_status_table(src: &str) -> Result, Vec> { @@ -75,11 +88,16 @@ pub fn parse_status_table(src: &str) -> Result, Vec> { if l.is_empty() { continue; } - let cells: Vec<&str> = l - .trim_start_matches('|') - .split('|') - .map(str::trim) - .collect(); + // Exactly one leading delimiter: AsciiDoc reads a row without one as + // continuation text and `||` as an empty first cell, so either would + // let the registry diverge from the table a reader sees. + let Some(body) = l.strip_prefix('|').filter(|b| !b.starts_with('|')) else { + errors.push(format!( + "PROOF-NEEDS.adoc:{n}: status-table rows must start with exactly one '|'" + )); + continue; + }; + let cells: Vec<&str> = body.split('|').map(str::trim).collect(); if cells.len() < 3 { errors.push(format!( "PROOF-NEEDS.adoc:{n}: status-table rows must fit on one line (ID | Claim | Status | Artefact)" @@ -137,7 +155,13 @@ pub fn check_ids(registry: &[Registered], claims: &[Claim]) -> (Vec, usi "PROOF-NEEDS.adoc:{}: ledger row names {id}, which the status table does not register", c.line )), - None => unprefixed += 1, + None => match malformed_id(&c.claim) { + Some(head) => problems.push(format!( + "PROOF-NEEDS.adoc:{}: ledger row starts with '{head}:', which is not a row ID (expected e.g. T-10 or E-1m)", + c.line + )), + None => unprefixed += 1, + }, } } @@ -247,6 +271,40 @@ mod tests { ); } + #[test] + fn a_typoed_ledger_prefix_is_rejected_not_counted_as_unprefixed() { + for typo in ["T5", "T-5M", "T-1X"] { + let doc = DOC.replace( + "|An unregistered property test", + &format!("|{typo}: a typo"), + ); + let (p, unprefixed) = run(&doc); + assert!( + p.iter() + .any(|e| e.contains(&format!("'{typo}:', which is not a row ID"))), + "{typo}: {p:?}" + ); + assert_eq!(unprefixed, 0, "{typo}"); + } + assert_eq!(malformed_id("Execute then undo: holds"), None); + assert_eq!(malformed_id("src/abi uses no proof bypass: x"), None); + } + + #[test] + fn a_registry_row_without_exactly_one_leading_bar_is_rejected() { + for bad in [ + "T-1 | Rollback restores | PROVEN | `x`", + "|| T-1 | Rollback restores | PROVEN | `x`", + ] { + let doc = DOC.replace("| T-1 | Rollback restores | PROVEN | `x`", bad); + let e = parse_status_table(&doc).unwrap_err(); + assert!( + e.iter().any(|e| e.contains("exactly one '|'")), + "{bad}: {e:?}" + ); + } + } + #[test] fn a_malformed_id_or_missing_table_is_an_error() { let doc = DOC.replace("| T-1 | Rollback", "| T1 | Rollback"); From efc2b72f8f331dea66511d2449fc3e4dfdacd46e Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 20:30:32 +0000 Subject: [PATCH 4/5] dashboard-check: read the status table the way AsciiDoc does Codex review on #183 (three findings, one cause: the registry parser was more lenient than AsciiDoc, so a table that renders differently could still pass): - the header must directly follow the table's opening |===; - rows are checked untrimmed (an indented line is not a table row); - every row has exactly four cells (three or five would flow into the neighbouring rendered rows). The real table already meets all three (36 rows, 4 cells each). One test covers them, and each rule's revert makes it fail. Test count 153. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX --- .machine_readable/6a2/STATE.a2ml | 2 +- READINESS.adoc | 4 +-- TOPOLOGY.adoc | 2 +- crates/dashboard-check/src/ids.rs | 50 +++++++++++++++++++++++++++---- 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/.machine_readable/6a2/STATE.a2ml b/.machine_readable/6a2/STATE.a2ml index a092a45..28ce3d1 100644 --- a/.machine_readable/6a2/STATE.a2ml +++ b/.machine_readable/6a2/STATE.a2ml @@ -44,7 +44,7 @@ property-tests = "9 (2026-04-03 assessment, not re-derived)" regression-tests = "5 (2026-04-03 assessment, not re-derived)" idris2-proofs = "12 PROVEN ledger rows (the former 30 counted lemmas before the tautology purge; PROOF-NEEDS.adoc is authoritative)" benchmarks = "5 Criterion groups (no baseline recorded)" -total = "152 tests + 5 benchmark groups + 12 PROVEN ledger rows — as declared in READINESS.adoc and measured by dashboard-check" +total = "153 tests + 5 benchmark groups + 12 PROVEN ledger rows — as declared in READINESS.adoc and measured by dashboard-check" [proof-grades] # Proof Witness Grades, standards 3-practice/PROOF-POLICY.adoc §8 (the diff --git a/READINESS.adoc b/READINESS.adoc index a87b9bf..39bf78f 100644 --- a/READINESS.adoc +++ b/READINESS.adoc @@ -8,7 +8,7 @@ standards/testing-and-benchmarking/TESTING-TAXONOMY.adoc v1.0 === CRG Grade: D (Alpha — Unstable) -*Justification:* 152 tests declared (`cargo test --workspace --locked -- --list`; rust-ci runs them); the +*Justification:* 153 tests declared (`cargo test --workspace --locked -- --list`; rust-ci runs them); the Idris2 ABI typechecks and 12 proofs are checked (PROVEN ledger rows: ABI, grade, transaction-model and epistemic-model lemmas, not the security obligations); benchmarks exist (5 Criterion groups). But: no fuzz testing, no mutation testing, 241 unwrap() calls, E2E mostly skips, @@ -65,7 +65,7 @@ handling (run by idris-abi.yml, agda-proofs.yml and dashboard-check) |=== -*Total declared:* 152 tests + 5 benchmark groups; 12 proofs checked (PROVEN ledger rows; five are theory theorems under PROOF-POLICY §8, graded from the receipt: T-1 at PWG-1 and four at PWG-3, whose Rocq and Lean legs check but have no CI receipt yet — see `docs/theory/PROOF-GRADES.adoc`) *Total +*Total declared:* 153 tests + 5 benchmark groups; 12 proofs checked (PROVEN ledger rows; five are theory theorems under PROOF-POLICY §8, graded from the receipt: T-1 at PWG-1 and four at PWG-3, whose Rocq and Lean legs check but have no CI receipt yet — see `docs/theory/PROOF-GRADES.adoc`) *Total missing:* Fuzz, mutation, chaos, compatibility === Aspect Matrix diff --git a/TOPOLOGY.adoc b/TOPOLOGY.adoc index cd73e85..d9fa516 100644 --- a/TOPOLOGY.adoc +++ b/TOPOLOGY.adoc @@ -79,7 +79,7 @@ INTERFACES & RESEARCH MPR Methodology ████░░░░░░ ~40% Design documented; FORMAL PROOFS PENDING (Idris2 ABI typechecks; 12 proofs checked: ABI, grade, transaction-model and epistemic-model lemmas, not the security obligations; MPR not linked to the Rust) - Testing (READINESS matrix) ██████░░░░ ~60% 152 tests + 5 benches; missing fuzz, mutation, + Testing (READINESS matrix) ██████░░░░ ~60% 153 tests + 5 benches; missing fuzz, mutation, chaos, compatibility (Grade D) REPO INFRASTRUCTURE diff --git a/crates/dashboard-check/src/ids.rs b/crates/dashboard-check/src/ids.rs index e565344..9d2e25d 100644 --- a/crates/dashboard-check/src/ids.rs +++ b/crates/dashboard-check/src/ids.rs @@ -66,21 +66,33 @@ pub fn malformed_id(claim: &str) -> Option<&str> { (looks_like_id && !is_row_id(head)).then_some(head) } -/// Parse the status table. Its header row must be exactly [`HEADER`]; a -/// missing table is an error, not an empty registry. +/// Parse the status table, reading it the way AsciiDoc does, so that the +/// registry this check sees is the table a reader sees: the line just above +/// the header is the table's opening `|===`; every row is one line that starts +/// (untrimmed) with exactly one `|` and has exactly four cells; and the table +/// is closed by `|===`. Blank lines inside the table are allowed. A missing +/// table is an error, not an empty registry. pub fn parse_status_table(src: &str) -> Result, Vec> { let lines: Vec<&str> = src.lines().collect(); - let Some(header) = lines.iter().position(|l| l.trim() == HEADER) else { + let Some(header) = lines.iter().position(|l| l.trim_end() == HEADER) else { return Err(vec![format!( "PROOF-NEEDS.adoc has no status table (header '{HEADER}')" )]); }; + if header == 0 || lines[header - 1].trim_end() != "|===" { + return Err(vec![format!( + "PROOF-NEEDS.adoc:{}: the status table header must directly follow the table's opening |===", + header + 1 + )]); + } let mut rows = Vec::new(); let mut errors = Vec::new(); let mut closed = false; for (i, raw) in lines.iter().enumerate().skip(header + 1) { let n = i + 1; - let l = raw.trim(); + // Only trailing whitespace is ignored: an indented line is not a table + // row to AsciiDoc. + let l = raw.trim_end(); if l == "|===" { closed = true; break; @@ -98,9 +110,10 @@ pub fn parse_status_table(src: &str) -> Result, Vec> { continue; }; let cells: Vec<&str> = body.split('|').map(str::trim).collect(); - if cells.len() < 3 { + if cells.len() != 4 { errors.push(format!( - "PROOF-NEEDS.adoc:{n}: status-table rows must fit on one line (ID | Claim | Status | Artefact)" + "PROOF-NEEDS.adoc:{n}: status-table rows need exactly four cells on one line (ID | Claim | Status | Artefact), found {}", + cells.len() )); continue; } @@ -305,6 +318,31 @@ mod tests { } } + #[test] + fn the_table_must_be_read_as_asciidoc_reads_it() { + let base = "| T-1 | Rollback restores | PROVEN | `x`"; + // An indented row, a row with three cells, a row with five. + for (bad, msg) in [ + ( + " | T-1 | Rollback restores | PROVEN | `x`", + "exactly one '|'", + ), + ("| T-1 | Rollback restores | PROVEN", "found 3"), + ( + "| T-1 | Rollback restores | PROVEN | `x` | extra", + "found 5", + ), + ] { + let e = parse_status_table(&DOC.replace(base, bad)).unwrap_err(); + assert!(e.iter().any(|e| e.contains(msg)), "{bad}: {e:?}"); + } + // The opening |=== displaced from just above the header. + let displaced = DOC.replacen("|===\n| ID |", "|===\n\n| ID |", 1); + assert!(parse_status_table(&displaced).unwrap_err()[0].contains("directly follow")); + let missing = DOC.replacen("|===\n| ID |", "| ID |", 1); + assert!(parse_status_table(&missing).unwrap_err()[0].contains("directly follow")); + } + #[test] fn a_malformed_id_or_missing_table_is_an_error() { let doc = DOC.replace("| T-1 | Rollback", "| T1 | Rollback"); From 6c1c8cab1335e03d43d59963263c29940d9a3dd0 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 20:38:27 +0000 Subject: [PATCH 5/5] dashboard-check: refuse an escaped pipe in a status-table row CodeRabbit review on #183: AsciiDoc reads `\|` as a literal pipe inside a cell, so splitting on every `|` counted cells differently from the rendered table (`| T-1 | Rollback \| PROVEN | x` is three cells, not four). The registry has no use for a literal pipe, so a row containing `\|` is refused, and the message names {vbar}. The real table has none. The table test gains the case and fails when the rule is reverted. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX --- crates/dashboard-check/src/ids.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/dashboard-check/src/ids.rs b/crates/dashboard-check/src/ids.rs index 9d2e25d..722dd3c 100644 --- a/crates/dashboard-check/src/ids.rs +++ b/crates/dashboard-check/src/ids.rs @@ -109,6 +109,15 @@ pub fn parse_status_table(src: &str) -> Result, Vec> { )); continue; }; + // AsciiDoc reads `\|` as a literal pipe inside a cell, so splitting on + // every `|` would count cells differently from the rendered table. The + // registry has no use for a literal pipe: refuse it, and name `{vbar}`. + if body.contains("\\|") { + errors.push(format!( + "PROOF-NEEDS.adoc:{n}: escaped '\\|' in a status-table row; write {{vbar}} for a literal pipe" + )); + continue; + } let cells: Vec<&str> = body.split('|').map(str::trim).collect(); if cells.len() != 4 { errors.push(format!( @@ -336,6 +345,15 @@ mod tests { let e = parse_status_table(&DOC.replace(base, bad)).unwrap_err(); assert!(e.iter().any(|e| e.contains(msg)), "{bad}: {e:?}"); } + // An escaped pipe: AsciiDoc renders three cells where a naive split sees four. + let escaped = DOC.replace(base, "| T-1 | Rollback \\| PROVEN | `x`"); + assert!( + parse_status_table(&escaped) + .unwrap_err() + .iter() + .any(|e| e.contains("{vbar}")), + "escaped pipe" + ); // The opening |=== displaced from just above the header. let displaced = DOC.replacen("|===\n| ID |", "|===\n\n| ID |", 1); assert!(parse_status_table(&displaced).unwrap_err()[0].contains("directly follow"));