aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / crates / site-builder / src / components / research_status.rs
| 1 | //! The canonical research status source for the site. |
| 2 | //! |
| 3 | //! Every research status shown on aienos.com that is rendered by this |
| 4 | //! builder comes from one data file, `data/research_status.json`, which |
| 5 | //! holds the rows of the consolidated research status table word for word. |
| 6 | //! The file is compiled in with `include_str!` and parsed with serde_json, |
| 7 | //! then validated. A malformed file, an unknown status word, or a ladder |
| 8 | //! that contradicts its own current level makes the build and the tests |
| 9 | //! fail. Statuses change when the evidence changes, not when the copy does. |
| 10 | |
| 11 | use std::sync::OnceLock; |
| 12 | |
| 13 | use maud::{html, Markup}; |
| 14 | use serde::Deserialize; |
| 15 | |
| 16 | use super::boxlink::{foot, source_href, Target}; |
| 17 | |
| 18 | /// The qualification state record in the Omega repository, which the |
| 19 | /// data file cites as "QS:<line>". |
| 20 | pub const QS_RECORD: &str = "https://interplane.io/drakestapleton/omega-mv/blob/main/docs/turing/TURING_SCIENTIFIC_QUALIFICATION_STATE.md"; |
| 21 | /// The data file itself, for a row whose evidence has no home on the forge. |
| 22 | pub const DATA_FILE: &str = "crates/site-builder/data/research_status.json"; |
| 23 | |
| 24 | /// The raw data file, compiled into the binary. |
| 25 | pub const RAW: &str = include_str!("../../data/research_status.json"); |
| 26 | |
| 27 | /// The only status words a Turing row may carry. |
| 28 | pub const ALLOWED_STATUSES: [&str; 7] = [ |
| 29 | "PASS", |
| 30 | "FAIL", |
| 31 | "INCOMPLETE", |
| 32 | "BLOCKED", |
| 33 | "PARTIAL", |
| 34 | "NOT ESTABLISHED", |
| 35 | "NOT STARTED", |
| 36 | ]; |
| 37 | |
| 38 | /// The only states a ladder step may carry. |
| 39 | pub const ALLOWED_LADDER_STATES: [&str; 4] = |
| 40 | ["achieved", "partial", "not achieved", "not attempted"]; |
| 41 | |
| 42 | /// The only classes an implementation row may carry, in display order. |
| 43 | pub const ALLOWED_CLASSES: [&str; 5] = [ |
| 44 | "Implemented", |
| 45 | "Partially implemented", |
| 46 | "Experimental", |
| 47 | "Planned", |
| 48 | "Research hypothesis", |
| 49 | ]; |
| 50 | |
| 51 | /// The ladder levels, in order, exactly as the protocol defines them. |
| 52 | pub const LADDER_LEVELS: [&str; 8] = ["L0", "L1", "L2", "L3", "L4", "L5", "L6", "L7+"]; |
| 53 | |
| 54 | #[derive(Debug, Clone, Deserialize)] |
| 55 | #[serde(deny_unknown_fields)] |
| 56 | pub struct StatusData { |
| 57 | pub as_of: String, |
| 58 | pub source_table: String, |
| 59 | pub source_commits: SourceCommits, |
| 60 | pub evidence_hierarchy: String, |
| 61 | pub abbreviations: Vec<Abbreviation>, |
| 62 | pub caveats: Vec<String>, |
| 63 | pub independent_rechecks: IndependentRechecks, |
| 64 | pub turing_definition: String, |
| 65 | pub allowed_statuses: Vec<String>, |
| 66 | pub allowed_ladder_states: Vec<String>, |
| 67 | pub allowed_classes: Vec<String>, |
| 68 | pub current_level: CurrentLevel, |
| 69 | pub ladder: Vec<LadderStep>, |
| 70 | pub attempts: Vec<Attempt>, |
| 71 | pub turing_rows: Vec<TuringRow>, |
| 72 | pub implementation_rows: Vec<ImplementationRow>, |
| 73 | } |
| 74 | |
| 75 | /// The count of receipts rechecked by someone outside the project. The |
| 76 | /// count shown is the number of linked rechecks, so it changes only when |
| 77 | /// an outside person's recheck is linked. Reviews by agents under the same |
| 78 | /// operator are not rechecks and are never listed here. |
| 79 | #[derive(Debug, Clone, Deserialize)] |
| 80 | #[serde(deny_unknown_fields)] |
| 81 | pub struct IndependentRechecks { |
| 82 | pub as_of: String, |
| 83 | pub rule: String, |
| 84 | pub links: Vec<String>, |
| 85 | } |
| 86 | |
| 87 | #[derive(Debug, Clone, Deserialize)] |
| 88 | #[serde(deny_unknown_fields)] |
| 89 | pub struct SourceCommits { |
| 90 | pub omega: String, |
| 91 | pub aienos: String, |
| 92 | pub aien_architecture: String, |
| 93 | pub aienos_com: String, |
| 94 | } |
| 95 | |
| 96 | #[derive(Debug, Clone, Deserialize)] |
| 97 | #[serde(deny_unknown_fields)] |
| 98 | pub struct Abbreviation { |
| 99 | pub short: String, |
| 100 | pub long: String, |
| 101 | } |
| 102 | |
| 103 | #[derive(Debug, Clone, Deserialize)] |
| 104 | #[serde(deny_unknown_fields)] |
| 105 | pub struct CurrentLevel { |
| 106 | pub level: String, |
| 107 | pub summary: String, |
| 108 | pub outside_scope: String, |
| 109 | pub note: String, |
| 110 | pub meaning: String, |
| 111 | pub limitations: String, |
| 112 | pub evidence: String, |
| 113 | } |
| 114 | |
| 115 | #[derive(Debug, Clone, Deserialize)] |
| 116 | #[serde(deny_unknown_fields)] |
| 117 | pub struct LadderStep { |
| 118 | pub level: String, |
| 119 | pub name: String, |
| 120 | pub state: String, |
| 121 | pub detail: String, |
| 122 | pub basis: String, |
| 123 | /// The evidence on the forge, when the basis names something more exact |
| 124 | /// than a line of the qualification record. |
| 125 | #[serde(default)] |
| 126 | pub link: Option<String>, |
| 127 | } |
| 128 | |
| 129 | #[derive(Debug, Clone, Deserialize)] |
| 130 | #[serde(deny_unknown_fields)] |
| 131 | pub struct Attempt { |
| 132 | pub id: String, |
| 133 | pub beside: String, |
| 134 | pub outcome: String, |
| 135 | pub summary: String, |
| 136 | pub led_to: String, |
| 137 | } |
| 138 | |
| 139 | #[derive(Debug, Clone, Deserialize)] |
| 140 | #[serde(deny_unknown_fields)] |
| 141 | pub struct TuringRow { |
| 142 | pub id: String, |
| 143 | pub title: String, |
| 144 | pub status: String, |
| 145 | pub status_detail: String, |
| 146 | pub plain: String, |
| 147 | #[serde(default)] |
| 148 | pub headline: Option<String>, |
| 149 | #[serde(default)] |
| 150 | pub not_yield: Option<String>, |
| 151 | pub scope: String, |
| 152 | pub claim_level: String, |
| 153 | pub receipt: String, |
| 154 | pub commit: String, |
| 155 | pub date: String, |
| 156 | pub limitations: String, |
| 157 | pub next_dependency: String, |
| 158 | pub evidence: String, |
| 159 | /// The receipt on the forge. Absent, the link is derived from `evidence`. |
| 160 | #[serde(default)] |
| 161 | pub link: Option<String>, |
| 162 | } |
| 163 | |
| 164 | #[derive(Debug, Clone, Deserialize)] |
| 165 | #[serde(deny_unknown_fields)] |
| 166 | pub struct ImplementationRow { |
| 167 | pub id: String, |
| 168 | pub class: String, |
| 169 | pub status_detail: String, |
| 170 | pub scope: String, |
| 171 | pub claim_level: String, |
| 172 | pub receipt: String, |
| 173 | pub commit: String, |
| 174 | pub date: String, |
| 175 | pub limitations: String, |
| 176 | pub next_dependency: String, |
| 177 | pub evidence: String, |
| 178 | /// The receipt on the forge. Absent, the link is derived from `evidence`. |
| 179 | #[serde(default)] |
| 180 | pub link: Option<String>, |
| 181 | } |
| 182 | |
| 183 | /// Where a row's box links. An explicit `link` wins; otherwise the first |
| 184 | /// thing the evidence names is resolved: a "QS:<line>" citation goes to |
| 185 | /// that line of the qualification record, a repository path (with an |
| 186 | /// optional ":<line>") goes to that file on main, with "aienos", |
| 187 | /// "aien-architecture" or "atlas" in front naming the repository and |
| 188 | /// Omega the default. Anything else ("omega grep", "none", a repository not |
| 189 | /// on the forge) has no home on the forge, so the box links to the data |
| 190 | /// file and says so. An empty data link means the receipt has no Radicle copy. |
| 191 | pub fn evidence_box(link: &Option<String>, evidence: &str) -> (String, Target) { |
| 192 | if let Some(l) = link.as_ref().filter(|l| !l.is_empty()) { |
| 193 | return (l.clone(), Target::Evidence); |
| 194 | } |
| 195 | match forge_for_evidence(evidence) { |
| 196 | Some(url) => (url, Target::Evidence), |
| 197 | None => (source_href(DATA_FILE), Target::Source), |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | fn forge_for_evidence(evidence: &str) -> Option<String> { |
| 202 | let mut text = evidence.trim(); |
| 203 | let mut repo = "omega-mv"; |
| 204 | for (prefix, r) in [("aienos ", "aienux"), ("aien-architecture ", "aien-architecture-mv"), ("atlas ", "atlas"), ("omega ", "omega-mv")] { |
| 205 | if let Some(rest) = text.strip_prefix(prefix) { |
| 206 | repo = r; |
| 207 | text = rest; |
| 208 | break; |
| 209 | } |
| 210 | } |
| 211 | let token = text.split_whitespace().next()?.trim_end_matches([',', ';', ':']); |
| 212 | if let Some(n) = token.strip_prefix("QS:") { |
| 213 | let digits: String = n.chars().take_while(|c| c.is_ascii_digit()).collect(); |
| 214 | return Some(if digits.is_empty() { QS_RECORD.to_string() } else { format!("{QS_RECORD}#L{digits}") }); |
| 215 | } |
| 216 | if token == "QS" { |
| 217 | return Some(QS_RECORD.to_string()); |
| 218 | } |
| 219 | let (path, line) = match token.split_once(':') { |
| 220 | Some((p, l)) => (p, l.chars().take_while(|c| c.is_ascii_digit()).collect::<String>()), |
| 221 | None => (token, String::new()), |
| 222 | }; |
| 223 | let path = if path == "TURING_CURRENT_STATE.md" { "docs/turing/TURING_CURRENT_STATE.md" } else { path }; |
| 224 | let is_file = path.contains('/') && path.rsplit('.').next().map_or(false, |e| ["h", "c", "md", "sh", "json", "mk", "txt", "tsv"].contains(&e)); |
| 225 | if !is_file || path.contains("..") || path.starts_with('/') { |
| 226 | return None; |
| 227 | } |
| 228 | let anchor = if line.is_empty() { String::new() } else { format!("#L{line}") }; |
| 229 | Some(format!("{}/blob/main/{path}{anchor}", crate::forge::repo_url(repo)?)) |
| 230 | } |
| 231 | |
| 232 | impl StatusData { |
| 233 | pub fn turing_row(&self, id: &str) -> Option<&TuringRow> { |
| 234 | self.turing_rows.iter().find(|r| r.id == id) |
| 235 | } |
| 236 | |
| 237 | pub fn implementation_row(&self, id: &str) -> Option<&ImplementationRow> { |
| 238 | self.implementation_rows.iter().find(|r| r.id == id) |
| 239 | } |
| 240 | |
| 241 | pub fn step(&self, level: &str) -> Option<&LadderStep> { |
| 242 | self.ladder.iter().find(|s| s.level == level) |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | /// Parse and validate a data file. Used for the compiled-in file and, |
| 247 | /// in tests, for deliberately broken copies. |
| 248 | pub fn parse(raw: &str) -> Result<StatusData, String> { |
| 249 | if raw.contains('\u{2014}') || raw.contains('\u{2013}') { |
| 250 | return Err("research status data contains an em dash or en dash".to_string()); |
| 251 | } |
| 252 | let data: StatusData = |
| 253 | serde_json::from_str(raw).map_err(|e| format!("research status data does not parse: {e}"))?; |
| 254 | validate(&data)?; |
| 255 | Ok(data) |
| 256 | } |
| 257 | |
| 258 | /// Structural and honesty checks on the data. Any failure stops the build. |
| 259 | pub fn validate(d: &StatusData) -> Result<(), String> { |
| 260 | if d.allowed_statuses != ALLOWED_STATUSES { |
| 261 | return Err("allowed_statuses in the data file differs from the fixed set".to_string()); |
| 262 | } |
| 263 | if d.allowed_ladder_states != ALLOWED_LADDER_STATES { |
| 264 | return Err("allowed_ladder_states in the data file differs from the fixed set".to_string()); |
| 265 | } |
| 266 | if d.allowed_classes != ALLOWED_CLASSES { |
| 267 | return Err("allowed_classes in the data file differs from the fixed set".to_string()); |
| 268 | } |
| 269 | |
| 270 | let levels: Vec<&str> = d.ladder.iter().map(|s| s.level.as_str()).collect(); |
| 271 | if levels != LADDER_LEVELS { |
| 272 | return Err(format!("ladder levels must be exactly {:?}, found {:?}", LADDER_LEVELS, levels)); |
| 273 | } |
| 274 | for s in &d.ladder { |
| 275 | if !ALLOWED_LADDER_STATES.contains(&s.state.as_str()) { |
| 276 | return Err(format!("ladder step {} has unknown state {:?}", s.level, s.state)); |
| 277 | } |
| 278 | } |
| 279 | let links = d.ladder.iter().map(|s| (&s.level, &s.link)) |
| 280 | .chain(d.turing_rows.iter().map(|r| (&r.id, &r.link))) |
| 281 | .chain(d.implementation_rows.iter().map(|r| (&r.id, &r.link))); |
| 282 | for (id, link) in links { |
| 283 | if let Some(l) = link { |
| 284 | if !l.is_empty() && !l.starts_with(super::boxlink::FORGE) { |
| 285 | return Err(format!("{id}: link must be on the forge ({}) or empty, got {l:?}", super::boxlink::FORGE)); |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | for l in &d.independent_rechecks.links { |
| 290 | if !l.starts_with("https://") || l.contains("github.com") { |
| 291 | return Err(format!("independent recheck link must be an https URL, got {l:?}")); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | // The stated current level must be the top of the unbroken run of |
| 296 | // achieved steps from L0. A partial step above it does not count. |
| 297 | let mut top: Option<&str> = None; |
| 298 | for s in &d.ladder { |
| 299 | if s.state == "achieved" { |
| 300 | top = Some(s.level.as_str()); |
| 301 | } else { |
| 302 | break; |
| 303 | } |
| 304 | } |
| 305 | if top != Some(d.current_level.level.as_str()) { |
| 306 | return Err(format!( |
| 307 | "current_level {} does not match the highest unbroken achieved step {:?}", |
| 308 | d.current_level.level, top |
| 309 | )); |
| 310 | } |
| 311 | // No step above a gap may claim to be achieved. |
| 312 | let first_gap = d.ladder.iter().position(|s| s.state != "achieved"); |
| 313 | if let Some(g) = first_gap { |
| 314 | if let Some(s) = d.ladder[g..].iter().find(|s| s.state == "achieved") { |
| 315 | return Err(format!("ladder step {} is marked achieved above an unachieved step", s.level)); |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | let mut seen: Vec<&str> = Vec::new(); |
| 320 | for r in &d.turing_rows { |
| 321 | if seen.contains(&r.id.as_str()) { |
| 322 | return Err(format!("turing row {} appears more than once", r.id)); |
| 323 | } |
| 324 | seen.push(&r.id); |
| 325 | if !ALLOWED_STATUSES.contains(&r.status.as_str()) { |
| 326 | return Err(format!("turing row {} has status {:?} outside the allowed set", r.id, r.status)); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | let mut seen_impl: Vec<&str> = Vec::new(); |
| 331 | for r in &d.implementation_rows { |
| 332 | if seen_impl.contains(&r.id.as_str()) { |
| 333 | return Err(format!("implementation row {} appears more than once", r.id)); |
| 334 | } |
| 335 | seen_impl.push(&r.id); |
| 336 | if !ALLOWED_CLASSES.contains(&r.class.as_str()) { |
| 337 | return Err(format!("implementation row {} has class {:?} outside the allowed set", r.id, r.class)); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | for a in &d.attempts { |
| 342 | let row = d |
| 343 | .turing_row(&a.id) |
| 344 | .ok_or_else(|| format!("attempt {} has no matching turing row", a.id))?; |
| 345 | if row.status != a.outcome { |
| 346 | return Err(format!("attempt {} outcome {} disagrees with its row status {}", a.id, a.outcome, row.status)); |
| 347 | } |
| 348 | if d.step(&a.beside).is_none() { |
| 349 | return Err(format!("attempt {} sits beside unknown level {}", a.id, a.beside)); |
| 350 | } |
| 351 | if d.turing_row(&a.led_to).is_none() { |
| 352 | return Err(format!("attempt {} leads to unknown row {}", a.id, a.led_to)); |
| 353 | } |
| 354 | } |
| 355 | Ok(()) |
| 356 | } |
| 357 | |
| 358 | /// The compiled-in data, parsed once. Panics (failing the build run and |
| 359 | /// every test that touches it) if the file is broken. |
| 360 | pub fn data() -> &'static StatusData { |
| 361 | static DATA: OnceLock<StatusData> = OnceLock::new(); |
| 362 | DATA.get_or_init(|| parse(RAW).unwrap_or_else(|e| panic!("{e}"))) |
| 363 | } |
| 364 | |
| 365 | fn ty2() -> &'static TuringRow { |
| 366 | data().turing_row("TY-2").expect("TY-2 row missing from research status data") |
| 367 | } |
| 368 | |
| 369 | // ------------------------------------------------------------------ |
| 370 | // Lookups used by the older hand-written components (status, evidence, |
| 371 | // research). They return &'static str so those components keep their |
| 372 | // existing shapes. |
| 373 | // ------------------------------------------------------------------ |
| 374 | |
| 375 | pub fn ty2_status() -> &'static str { |
| 376 | ty2().status.as_str() |
| 377 | } |
| 378 | pub fn ty2_title() -> &'static str { |
| 379 | ty2().title.as_str() |
| 380 | } |
| 381 | pub fn ty2_headline() -> &'static str { |
| 382 | ty2().headline.as_deref().expect("TY-2 row needs a headline") |
| 383 | } |
| 384 | pub fn ty2_plain() -> &'static str { |
| 385 | ty2().plain.as_str() |
| 386 | } |
| 387 | pub fn ty2_date() -> &'static str { |
| 388 | ty2().date.as_str() |
| 389 | } |
| 390 | pub fn ty2_receipt() -> &'static str { |
| 391 | ty2().receipt.as_str() |
| 392 | } |
| 393 | pub fn ty2_scope() -> &'static str { |
| 394 | ty2().scope.as_str() |
| 395 | } |
| 396 | pub fn ty2_limitations() -> &'static str { |
| 397 | ty2().limitations.as_str() |
| 398 | } |
| 399 | |
| 400 | /// Map an implementation class onto the homepage layer vocabulary |
| 401 | /// (IMPLEMENTED, QUALIFIED, EXPERIMENTAL, BLOCKED, PLANNED). Never maps |
| 402 | /// anything to QUALIFIED: no row in the table carries that word. |
| 403 | pub fn layer_status_for_class(class: &str) -> &'static str { |
| 404 | match class { |
| 405 | "Implemented" => "IMPLEMENTED", |
| 406 | "Partially implemented" | "Experimental" => "EXPERIMENTAL", |
| 407 | _ => "PLANNED", |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | fn instrument_row(d: &StatusData) -> &ImplementationRow { |
| 412 | d.implementation_row("Turing measurement machinery") |
| 413 | .expect("Turing measurement machinery row missing") |
| 414 | } |
| 415 | |
| 416 | /// Homepage layer status for the Turing instrument, from a given data set. |
| 417 | pub fn turing_instrument_status_for(d: &StatusData) -> &'static str { |
| 418 | layer_status_for_class(&instrument_row(d).class) |
| 419 | } |
| 420 | |
| 421 | pub fn turing_instrument_status() -> &'static str { |
| 422 | turing_instrument_status_for(data()) |
| 423 | } |
| 424 | |
| 425 | /// One sentence for the homepage layer list: the instrument row plus the |
| 426 | /// current level, its limits and the TY-2 gain, all from a given data set. |
| 427 | pub fn turing_instrument_note_for(d: &StatusData) -> String { |
| 428 | let row = instrument_row(d); |
| 429 | let t = d.turing_row("TY-2").expect("TY-2 row missing from research status data"); |
| 430 | format!( |
| 431 | "{}. Current level: {}. {} {} TY-2 recorded {}. {}", |
| 432 | row.status_detail, |
| 433 | d.current_level.summary, |
| 434 | d.current_level.limitations, |
| 435 | d.current_level.outside_scope, |
| 436 | t.headline.as_deref().unwrap_or(""), |
| 437 | t.not_yield.as_deref().unwrap_or("") |
| 438 | ) |
| 439 | .trim_end() |
| 440 | .to_string() |
| 441 | } |
| 442 | |
| 443 | pub fn turing_instrument_note() -> &'static str { |
| 444 | static NOTE: OnceLock<String> = OnceLock::new(); |
| 445 | NOTE.get_or_init(|| turing_instrument_note_for(data())) |
| 446 | } |
| 447 | |
| 448 | /// Experiment roll call for the homepage layer list, e.g. |
| 449 | /// "EXP-001 FAIL, EXP-001R PASS, ... EXP-003 BLOCKED." |
| 450 | pub fn experiments_note_for(d: &StatusData) -> String { |
| 451 | let parts: Vec<String> = d |
| 452 | .turing_rows |
| 453 | .iter() |
| 454 | .filter(|r| r.id.starts_with("EXP-")) |
| 455 | .map(|r| format!("{} {}", r.id, r.status)) |
| 456 | .collect(); |
| 457 | format!("{}. Failures stay on the record.", parts.join(", ")) |
| 458 | } |
| 459 | |
| 460 | pub fn experiments_note() -> &'static str { |
| 461 | static NOTE: OnceLock<String> = OnceLock::new(); |
| 462 | NOTE.get_or_init(|| experiments_note_for(data())) |
| 463 | } |
| 464 | |
| 465 | /// The research paper card line on the homepage. |
| 466 | pub fn paper_note() -> &'static str { |
| 467 | static NOTE: OnceLock<String> = OnceLock::new(); |
| 468 | NOTE.get_or_init(|| { |
| 469 | let d = data(); |
| 470 | format!("The formal paper. {} Current level: {}.", d.turing_definition, d.current_level.summary) |
| 471 | }) |
| 472 | } |
| 473 | |
| 474 | /// The current level in one sentence, for embedding in other pages. |
| 475 | pub fn current_level_sentence() -> &'static str { |
| 476 | static NOTE: OnceLock<String> = OnceLock::new(); |
| 477 | NOTE.get_or_init(|| { |
| 478 | let c = &data().current_level; |
| 479 | format!("Current level: {}. {} {}", c.summary, c.outside_scope, c.note) |
| 480 | }) |
| 481 | } |
| 482 | |
| 483 | // ------------------------------------------------------------------ |
| 484 | // Rendering |
| 485 | // ------------------------------------------------------------------ |
| 486 | |
| 487 | fn slug(s: &str) -> String { |
| 488 | let mut out = String::new(); |
| 489 | for ch in s.chars() { |
| 490 | if ch.is_ascii_alphanumeric() { |
| 491 | out.push(ch.to_ascii_lowercase()); |
| 492 | } else if !out.ends_with('-') { |
| 493 | out.push('-'); |
| 494 | } |
| 495 | } |
| 496 | out.trim_matches('-').to_string() |
| 497 | } |
| 498 | |
| 499 | fn badge_modifier(status: &str) -> &'static str { |
| 500 | match status { |
| 501 | "PASS" => "pass", |
| 502 | "FAIL" => "fail", |
| 503 | "INCOMPLETE" => "incomplete", |
| 504 | "BLOCKED" => "blocked", |
| 505 | "PARTIAL" => "partial", |
| 506 | "NOT ESTABLISHED" => "not-established", |
| 507 | "NOT STARTED" => "not-started", |
| 508 | _ => "unknown", |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | fn badge(status: &str) -> Markup { |
| 513 | html! { |
| 514 | span class=(format!("rs-badge rs-badge--{}", badge_modifier(status))) { |
| 515 | (status) |
| 516 | } |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | /// The research ladder as a staircase. The list is in reading order |
| 521 | /// L0 to L7+ for screen readers; CSS draws it climbing upward. |
| 522 | pub fn render_ladder(d: &StatusData) -> Markup { |
| 523 | let current = d.current_level.level.as_str(); |
| 524 | html! { |
| 525 | div class="rs-ladder" { |
| 526 | p class="rs-current" { |
| 527 | strong { "Current level: " (d.current_level.summary) "." } |
| 528 | " " (d.current_level.outside_scope) " " (d.current_level.note) |
| 529 | } |
| 530 | p class="rs-current-meaning" { (d.current_level.meaning) } |
| 531 | p class="rs-ladder-hint" { "Read from the bottom up. Each step rests on the one below it. Filled steps are achieved, half-filled steps are partial, hollow steps are not achieved." } |
| 532 | ol class="rs-stairs" { |
| 533 | @for (i, step) in d.ladder.iter().enumerate() { |
| 534 | li class=(format!("rs-step rs-step--{}", slug(&step.state))) data-level=(step.level) data-state=(step.state) style=(format!("--i: {};", i)) { |
| 535 | span class="rs-step-mark" aria-hidden="true" {} |
| 536 | div class="rs-step-body" { |
| 537 | div class="rs-step-head" { |
| 538 | span class="rs-step-level" { (step.level) } |
| 539 | span class="rs-step-name" { (step.name) } |
| 540 | @if step.level == current { |
| 541 | span class="rs-here" { "Current level" } |
| 542 | } |
| 543 | } |
| 544 | p class="rs-step-state" { (step.state) } |
| 545 | p class="rs-step-detail" { (step.detail) } |
| 546 | p class="rs-step-basis" { "Evidence: " (step.basis) } |
| 547 | @let (href, target) = evidence_box(&step.link, &step.basis); |
| 548 | (foot(&href, target)) |
| 549 | @for a in d.attempts.iter().filter(|a| a.beside == step.level) { |
| 550 | div class="rs-attempt" data-attempt=(a.id) { |
| 551 | div class="rs-attempt-head" { |
| 552 | (badge(&a.outcome)) |
| 553 | strong { (a.id) } |
| 554 | span { "failed attempt, kept on the record" } |
| 555 | } |
| 556 | p { (a.summary) " Led to " (a.led_to) "." } |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | /// One card per Turing row. |
| 568 | pub fn render_cards(d: &StatusData) -> Markup { |
| 569 | html! { |
| 570 | div class="rs-cards" { |
| 571 | @for r in &d.turing_rows { |
| 572 | article class=(format!("rs-card rs-card--{}", badge_modifier(&r.status))) id=(format!("rs-{}", slug(&r.id))) data-row=(r.id) data-status=(r.status) { |
| 573 | div class="rs-card-top" { |
| 574 | (badge(&r.status)) |
| 575 | span class="rs-card-id" { (r.id) } |
| 576 | } |
| 577 | h3 class="rs-card-title" data-role="result-label" { (r.title) } |
| 578 | @if let Some(h) = &r.headline { |
| 579 | p class="rs-card-headline" data-role="result-label" { (h) } |
| 580 | } |
| 581 | @if let Some(n) = &r.not_yield { |
| 582 | p class="rs-card-callout" { (n) } |
| 583 | } |
| 584 | p class="rs-card-plain" { (r.plain) } |
| 585 | dl class="rs-facts" { |
| 586 | div { dt { "Status" } dd { (r.status_detail) } } |
| 587 | div { dt { "Scope" } dd { (r.scope) } } |
| 588 | div { dt { "Claim level" } dd { (r.claim_level) } } |
| 589 | div { dt { "Limitations" } dd { (r.limitations) } } |
| 590 | div { dt { "Next dependency" } dd { (r.next_dependency) } } |
| 591 | div { dt { "Evidence" } dd class="rs-mono" { (r.evidence) } } |
| 592 | div { dt { "Receipt" } dd class="rs-mono" { (r.receipt) } } |
| 593 | div { dt { "Commit" } dd class="rs-mono" { (r.commit) } } |
| 594 | div { dt { "Date" } dd { (r.date) } } |
| 595 | } |
| 596 | @let (href, target) = evidence_box(&r.link, &r.evidence); |
| 597 | (foot(&href, target)) |
| 598 | } |
| 599 | } |
| 600 | } |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | fn class_blurb(class: &str) -> &'static str { |
| 605 | match class { |
| 606 | "Implemented" => "Code and tests exist. Each entry says how far that goes.", |
| 607 | "Partially implemented" => "Some of it exists. The missing part is named.", |
| 608 | "Experimental" => "Being tried. Results so far, including failures, are on the record.", |
| 609 | "Planned" => "Written down as a plan or specification. No code yet.", |
| 610 | "Research hypothesis" => "Not built. An idea to test, not a feature.", |
| 611 | _ => "", |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | /// The implementation list, grouped by class. Research hypotheses get |
| 616 | /// their own visibly different group. |
| 617 | pub fn render_implementation(d: &StatusData) -> Markup { |
| 618 | html! { |
| 619 | div class="rs-impl" { |
| 620 | @for class in ALLOWED_CLASSES { |
| 621 | @let rows = d.implementation_rows.iter().filter(|r| r.class == class).collect::<Vec<&ImplementationRow>>(); |
| 622 | @if !rows.is_empty() { |
| 623 | section class=(format!("rs-group rs-group--{}", slug(class))) data-class=(class) { |
| 624 | h3 class="rs-group-title" { (class) span class="rs-group-count" { " (" (rows.len()) ")" } } |
| 625 | p class="rs-group-blurb" { (class_blurb(class)) } |
| 626 | ul class="rs-impl-list" { |
| 627 | @for r in &rows { |
| 628 | li class="rs-impl-item" data-impl=(r.id) { |
| 629 | div class="rs-impl-head" { |
| 630 | span class="rs-impl-name" { (r.id) } |
| 631 | span class="rs-impl-status" { (r.status_detail) } |
| 632 | } |
| 633 | p class="rs-impl-scope" { (r.scope) } |
| 634 | details class="rs-impl-more" { |
| 635 | summary { "Limits and evidence" } |
| 636 | dl class="rs-facts" { |
| 637 | div { dt { "Claim level" } dd { (r.claim_level) } } |
| 638 | div { dt { "Limitations" } dd { (r.limitations) } } |
| 639 | div { dt { "Next dependency" } dd { (r.next_dependency) } } |
| 640 | div { dt { "Evidence" } dd class="rs-mono" { (r.evidence) } } |
| 641 | div { dt { "Receipt" } dd class="rs-mono" { (r.receipt) } } |
| 642 | div { dt { "Commit" } dd class="rs-mono" { (r.commit) } } |
| 643 | div { dt { "Date" } dd { (r.date) } } |
| 644 | } |
| 645 | } |
| 646 | @let (href, target) = evidence_box(&r.link, &r.evidence); |
| 647 | (foot(&href, target)) |
| 648 | } |
| 649 | } |
| 650 | } |
| 651 | } |
| 652 | } |
| 653 | } |
| 654 | } |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | /// Compact block other pages can embed: the current level and the ladder, |
| 659 | /// with a link to the full status page. |
| 660 | pub fn render_research_status_summary() -> Markup { |
| 661 | let d = data(); |
| 662 | html! { |
| 663 | div class="rs-embed" { |
| 664 | (render_ladder(d)) |
| 665 | p class="rs-embed-link" { |
| 666 | a href="/research/status/" { "Every experiment, its receipt and its limits" } |
| 667 | } |
| 668 | } |
| 669 | } |
| 670 | } |
| 671 | |
| 672 | /// Body of the generated /research/status/ page. |
| 673 | pub fn render_research_status_page() -> Markup { |
| 674 | let d = data(); |
| 675 | let c = &d.source_commits; |
| 676 | html! { |
| 677 | div class="container rs-page" { |
| 678 | header class="rs-page-head" { |
| 679 | p class="rs-kicker" { "Research status" } |
| 680 | h1 class="rs-page-title" { "Where the research stands" } |
| 681 | p class="rs-standfirst" { (d.turing_definition) } |
| 682 | p class="rs-standfirst" { |
| 683 | "Every status on this page is rendered from one data file, built from the consolidated research status table. Failed and incomplete experiments are shown, not hidden. " |
| 684 | "As of " (d.as_of) "." |
| 685 | } |
| 686 | p class="rs-standfirst" id="independent-rechecks" { |
| 687 | "Independent rechecks: " (d.independent_rechecks.links.len()) |
| 688 | " (as of " (d.independent_rechecks.as_of) "). " (d.independent_rechecks.rule) |
| 689 | @for (i, l) in d.independent_rechecks.links.iter().enumerate() { |
| 690 | " " a href=(l) rel="noopener noreferrer" { "Recheck " (i + 1) } |
| 691 | } |
| 692 | } |
| 693 | nav class="rs-toc" aria-label="On this page" { |
| 694 | a href="#ladder" { "The ladder" } |
| 695 | a href="#experiments" { "Experiments" } |
| 696 | a href="#implementation" { "What is built" } |
| 697 | a href="#sources" { "Sources" } |
| 698 | a href="/research-status.json" { "Data file (JSON)" } |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | section id="ladder" class="rs-section" { |
| 703 | h2 class="rs-h2" { "The research ladder" } |
| 704 | (render_ladder(d)) |
| 705 | } |
| 706 | |
| 707 | section id="experiments" class="rs-section" { |
| 708 | h2 class="rs-h2" { "Experiment status" } |
| 709 | p class="rs-section-lede" { |
| 710 | "One card per result. The badge is the verdict; the lines below say what it covers, what it does not, and what it waits on." |
| 711 | } |
| 712 | (render_cards(d)) |
| 713 | } |
| 714 | |
| 715 | section id="implementation" class="rs-section" { |
| 716 | h2 class="rs-h2" { "What is built and what is still an idea" } |
| 717 | p class="rs-section-lede" { |
| 718 | "Implemented work and research hypotheses are kept apart. A hypothesis listed here is a question, not a feature." |
| 719 | } |
| 720 | (render_implementation(d)) |
| 721 | } |
| 722 | |
| 723 | section id="sources" class="rs-section rs-sources" { |
| 724 | h2 class="rs-h2" { "Sources and caveats" } |
| 725 | p { (d.source_table) "." } |
| 726 | p { |
| 727 | "Repository commits read: omega " span class="rs-mono" { (c.omega) } |
| 728 | ", aienos " span class="rs-mono" { (c.aienos) } |
| 729 | ", aien-architecture " span class="rs-mono" { (c.aien_architecture) } |
| 730 | ", aienos.com " span class="rs-mono" { (c.aienos_com) } "." |
| 731 | } |
| 732 | p { "Evidence ranks: " span class="rs-mono" { (d.evidence_hierarchy) } "." } |
| 733 | ul { |
| 734 | @for cv in &d.caveats { |
| 735 | li { (cv) } |
| 736 | } |
| 737 | li { (d.current_level.limitations) " Evidence for the current level: " span class="rs-mono" { (d.current_level.evidence) } } |
| 738 | } |
| 739 | h3 class="rs-h3" { "Abbreviations" } |
| 740 | dl class="rs-facts" { |
| 741 | @for a in &d.abbreviations { |
| 742 | div { dt { (a.short) } dd class="rs-mono" { (a.long) } } |
| 743 | } |
| 744 | } |
| 745 | } |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | #[cfg(test)] |
| 751 | mod tests { |
| 752 | use super::*; |
| 753 | |
| 754 | /// Turing row ids from the consolidated table, Table 1. |
| 755 | const TABLE_TURING_IDS: [&str; 13] = [ |
| 756 | "CAL-0", |
| 757 | "EXP-001", |
| 758 | "EXP-001R", |
| 759 | "TY-2", |
| 760 | "EXP-002A", |
| 761 | "EXP-002B", |
| 762 | "EXP-002C", |
| 763 | "EXP-002D", |
| 764 | "EXP-003", |
| 765 | "ENERGY-ATTRIBUTION", |
| 766 | "TURING-YIELD-TJ", |
| 767 | "BROWNIAN-CEILING", |
| 768 | "GENERAL-DISCOVERY", |
| 769 | ]; |
| 770 | |
| 771 | /// Ladder states from the consolidated table. Changing a state in the |
| 772 | /// data file without changing it here fails `ladder_matches_table`. |
| 773 | const TABLE_LADDER: [(&str, &str); 8] = [ |
| 774 | ("L0", "achieved"), |
| 775 | ("L1", "achieved"), |
| 776 | ("L2", "achieved"), |
| 777 | ("L3", "not achieved"), |
| 778 | ("L4", "not achieved"), |
| 779 | ("L5", "partial"), |
| 780 | ("L6", "not achieved"), |
| 781 | ("L7+", "not attempted"), |
| 782 | ]; |
| 783 | |
| 784 | fn real() -> StatusData { |
| 785 | parse(RAW).expect("real data must parse") |
| 786 | } |
| 787 | |
| 788 | /// The markup of one ladder step, from its opening attribute to </li>. |
| 789 | fn step_html<'a>(html: &'a str, level: &str) -> &'a str { |
| 790 | let key = format!("data-level=\"{level}\""); |
| 791 | let start = html.find(&key).unwrap_or_else(|| panic!("no step {level}")); |
| 792 | let end = html[start..].find("</li>").expect("step not closed") + start; |
| 793 | &html[start..end] |
| 794 | } |
| 795 | |
| 796 | fn card_html<'a>(html: &'a str, id: &str) -> &'a str { |
| 797 | let key = format!("data-row=\"{id}\""); |
| 798 | let start = html.find(&key).unwrap_or_else(|| panic!("no card {id}")); |
| 799 | let end = html[start..].find("</article>").expect("card not closed") + start; |
| 800 | &html[start..end] |
| 801 | } |
| 802 | |
| 803 | fn result_labels(card: &str) -> Vec<String> { |
| 804 | let key = "data-role=\"result-label\">"; |
| 805 | let mut out = Vec::new(); |
| 806 | let mut rest = card; |
| 807 | while let Some(i) = rest.find(key) { |
| 808 | let after = &rest[i + key.len()..]; |
| 809 | let end = after.find('<').unwrap_or(after.len()); |
| 810 | out.push(after[..end].to_string()); |
| 811 | rest = &after[end..]; |
| 812 | } |
| 813 | out |
| 814 | } |
| 815 | |
| 816 | fn achieved_levels_in(html: &str) -> Vec<String> { |
| 817 | let mut out = Vec::new(); |
| 818 | let mut rest = html; |
| 819 | while let Some(i) = rest.find("data-level=\"") { |
| 820 | let after = &rest[i + "data-level=\"".len()..]; |
| 821 | let end = after.find('"').unwrap(); |
| 822 | let level = after[..end].to_string(); |
| 823 | let tail = &after[end..]; |
| 824 | if tail.starts_with("\" data-state=\"achieved\"") { |
| 825 | out.push(level); |
| 826 | } |
| 827 | rest = tail; |
| 828 | } |
| 829 | out |
| 830 | } |
| 831 | |
| 832 | /// The "not achieved" check, as a function so a mutated copy can be |
| 833 | /// shown to fail it. |
| 834 | fn check_not_achieved(html: &str) -> Result<(), String> { |
| 835 | for level in ["L3", "L4", "L6"] { |
| 836 | if !step_html(html, level).contains(">not achieved<") { |
| 837 | return Err(format!("{level} is not rendered as not achieved")); |
| 838 | } |
| 839 | } |
| 840 | Ok(()) |
| 841 | } |
| 842 | |
| 843 | /// The TY-2 label check, as a function so a mutated copy can be shown |
| 844 | /// to fail it. |
| 845 | fn check_ty2_card(html: &str) -> Result<(), String> { |
| 846 | let card = card_html(html, "TY-2"); |
| 847 | let labels = result_labels(card); |
| 848 | if labels.is_empty() { |
| 849 | return Err("TY-2 card has no result label".to_string()); |
| 850 | } |
| 851 | if labels.iter().any(|l| l.to_lowercase().contains("turing yield")) { |
| 852 | return Err("TY-2 result label says Turing yield".to_string()); |
| 853 | } |
| 854 | if !labels.iter().any(|l| l.contains("gain")) { |
| 855 | return Err("TY-2 result label does not say gain".to_string()); |
| 856 | } |
| 857 | if !card.contains("T/J") || !card.contains("not established") { |
| 858 | return Err("TY-2 card does not say T/J is not established".to_string()); |
| 859 | } |
| 860 | Ok(()) |
| 861 | } |
| 862 | |
| 863 | #[test] |
| 864 | fn data_file_parses() { |
| 865 | let d = real(); |
| 866 | assert_eq!(d.as_of, "2026-10-01"); |
| 867 | assert_eq!(d.source_commits.omega, "38919c8"); |
| 868 | // Counterexample: a truncated file must not parse. |
| 869 | assert!(parse(&RAW[..RAW.len() / 2]).is_err()); |
| 870 | // Counterexample: an unknown field must not parse. |
| 871 | let extra = RAW.replacen("\"as_of\"", "\"surprise\": 1, \"as_of\"", 1); |
| 872 | assert!(parse(&extra).is_err()); |
| 873 | } |
| 874 | |
| 875 | #[test] |
| 876 | fn every_table_turing_row_present_exactly_once() { |
| 877 | let d = real(); |
| 878 | for id in TABLE_TURING_IDS { |
| 879 | let n = d.turing_rows.iter().filter(|r| r.id == id).count(); |
| 880 | assert_eq!(n, 1, "row {id} appears {n} times"); |
| 881 | } |
| 882 | assert_eq!(d.turing_rows.len(), TABLE_TURING_IDS.len(), "unexpected extra turing rows"); |
| 883 | // Counterexample: duplicating a row must be rejected. |
| 884 | let mut dup = d.clone(); |
| 885 | dup.turing_rows.push(dup.turing_rows[0].clone()); |
| 886 | assert!(validate(&dup).is_err()); |
| 887 | } |
| 888 | |
| 889 | #[test] |
| 890 | fn no_status_outside_allowed_set() { |
| 891 | let d = real(); |
| 892 | for r in &d.turing_rows { |
| 893 | assert!(ALLOWED_STATUSES.contains(&r.status.as_str()), "{} has {}", r.id, r.status); |
| 894 | } |
| 895 | for r in &d.implementation_rows { |
| 896 | assert!(ALLOWED_CLASSES.contains(&r.class.as_str()), "{} has {}", r.id, r.class); |
| 897 | } |
| 898 | // Counterexample: the old site word VERIFIED is not allowed. |
| 899 | let mut bad = d.clone(); |
| 900 | bad.turing_rows.iter_mut().find(|r| r.id == "TY-2").unwrap().status = "VERIFIED".into(); |
| 901 | assert!(validate(&bad).is_err()); |
| 902 | // Counterexample: an implementation class outside the set. |
| 903 | let mut bad2 = d.clone(); |
| 904 | bad2.implementation_rows[0].class = "Qualified".into(); |
| 905 | assert!(validate(&bad2).is_err()); |
| 906 | } |
| 907 | |
| 908 | const NEW_ROW_IDS: [&str; 6] = [ |
| 909 | "Dirac (DIRAC-0 and sealed exam ladder)", |
| 910 | "AEGIS", |
| 911 | "ARGUS (ARGUS-0, ARGUS-1)", |
| 912 | "FORGE (v1 and V2)", |
| 913 | "ATLAS (M1 ATLAS_BOOT and roadmap)", |
| 914 | "Typed result contracts", |
| 915 | ]; |
| 916 | |
| 917 | fn new_rows_have_evidence(d: &StatusData) -> Result<(), String> { |
| 918 | for id in NEW_ROW_IDS { |
| 919 | let n = d.implementation_rows.iter().filter(|r| r.id == id).count(); |
| 920 | if n != 1 { |
| 921 | return Err(format!("row {id} appears {n} times")); |
| 922 | } |
| 923 | let row = d.implementation_row(id).unwrap(); |
| 924 | if row.evidence.trim().is_empty() { |
| 925 | return Err(format!("row {id} has no evidence")); |
| 926 | } |
| 927 | } |
| 928 | Ok(()) |
| 929 | } |
| 930 | |
| 931 | #[test] |
| 932 | fn new_implementation_rows_present_once_with_evidence() { |
| 933 | let d = real(); |
| 934 | new_rows_have_evidence(&d).unwrap(); |
| 935 | // Counterexample: one row with its evidence blanked must fail. |
| 936 | let mut bad = d.clone(); |
| 937 | bad.implementation_rows |
| 938 | .iter_mut() |
| 939 | .find(|r| r.id == "AEGIS") |
| 940 | .unwrap() |
| 941 | .evidence = String::new(); |
| 942 | assert!(new_rows_have_evidence(&bad).is_err()); |
| 943 | } |
| 944 | |
| 945 | #[test] |
| 946 | fn ladder_matches_table() { |
| 947 | let d = real(); |
| 948 | for (level, state) in TABLE_LADDER { |
| 949 | assert_eq!(d.step(level).unwrap().state, state, "ladder {level}"); |
| 950 | } |
| 951 | assert_eq!(d.current_level.level, "L2"); |
| 952 | // Counterexample: flipping L3 to achieved breaks the current level rule. |
| 953 | let mut up = d.clone(); |
| 954 | up.ladder[3].state = "achieved".into(); |
| 955 | assert!(validate(&up).is_err()); |
| 956 | // Counterexample: claiming L6 while L3 is open is rejected. |
| 957 | let mut skip = d.clone(); |
| 958 | skip.ladder[6].state = "achieved".into(); |
| 959 | assert!(validate(&skip).is_err()); |
| 960 | } |
| 961 | |
| 962 | #[test] |
| 963 | fn rendered_ladder_marks_exactly_the_achieved_levels() { |
| 964 | let d = real(); |
| 965 | let html = render_ladder(&d).into_string(); |
| 966 | let want: Vec<String> = d |
| 967 | .ladder |
| 968 | .iter() |
| 969 | .filter(|s| s.state == "achieved") |
| 970 | .map(|s| s.level.clone()) |
| 971 | .collect(); |
| 972 | assert_eq!(achieved_levels_in(&html), want); |
| 973 | assert_eq!(want, vec!["L0", "L1", "L2"]); |
| 974 | check_not_achieved(&html).unwrap(); |
| 975 | assert!(html.contains("Current level: L2, Brownian scope only, instrument certification")); |
| 976 | |
| 977 | // Counterexample: a test copy with L3 flipped to achieved renders a |
| 978 | // different achieved set and fails the not-achieved check. |
| 979 | let mut up = d.clone(); |
| 980 | up.ladder[3].state = "achieved".into(); |
| 981 | let bad = render_ladder(&up).into_string(); |
| 982 | assert_ne!(achieved_levels_in(&bad), vec!["L0", "L1", "L2"]); |
| 983 | assert!(check_not_achieved(&bad).is_err()); |
| 984 | } |
| 985 | |
| 986 | #[test] |
| 987 | fn exp001_failure_is_on_the_ladder_and_its_card() { |
| 988 | let d = real(); |
| 989 | let ladder = render_ladder(&d).into_string(); |
| 990 | let l1 = step_html(&ladder, "L1"); |
| 991 | assert!(l1.contains("data-attempt=\"EXP-001\"")); |
| 992 | assert!(l1.contains(">FAIL<")); |
| 993 | assert!(l1.contains("EXP-001R")); |
| 994 | let cards = render_cards(&d).into_string(); |
| 995 | let card = card_html(&cards, "EXP-001"); |
| 996 | assert!(card.contains("data-status=\"FAIL\"")); |
| 997 | assert!(card.contains(">FAIL<")); |
| 998 | // Counterexample: an attempt whose outcome disagrees with its row. |
| 999 | let mut hidden = d.clone(); |
| 1000 | hidden.turing_rows.iter_mut().find(|r| r.id == "EXP-001").unwrap().status = "PASS".into(); |
| 1001 | assert!(validate(&hidden).is_err()); |
| 1002 | } |
| 1003 | |
| 1004 | #[test] |
| 1005 | fn ty2_card_says_gain_not_yield() { |
| 1006 | let d = real(); |
| 1007 | let html = render_cards(&d).into_string(); |
| 1008 | check_ty2_card(&html).unwrap(); |
| 1009 | // Counterexample: relabelling TY-2 as yield fails the check. |
| 1010 | let mut bad = d.clone(); |
| 1011 | bad.turing_rows.iter_mut().find(|r| r.id == "TY-2").unwrap().title = "TY-2 Turing yield".into(); |
| 1012 | assert!(check_ty2_card(&render_cards(&bad).into_string()).is_err()); |
| 1013 | // Counterexample: dropping the not-yield statement fails the check. |
| 1014 | let mut quiet = d.clone(); |
| 1015 | quiet.turing_rows.iter_mut().find(|r| r.id == "TY-2").unwrap().not_yield = None; |
| 1016 | assert!(check_ty2_card(&render_cards(&quiet).into_string()).is_err()); |
| 1017 | } |
| 1018 | |
| 1019 | /// Research hypothesis rows from the consolidated table, Table 2. |
| 1020 | const TABLE_HYPOTHESES: [&str; 5] = [ |
| 1021 | "General causal discovery", |
| 1022 | "Full active experimentation", |
| 1023 | "Equality saturation", |
| 1024 | "General representation discovery", |
| 1025 | "SUSY / Zeta rediscovery", |
| 1026 | ]; |
| 1027 | |
| 1028 | fn group_html<'a>(html: &'a str, class: &str) -> Option<&'a str> { |
| 1029 | let key = format!("data-class=\"{class}\""); |
| 1030 | let start = html.find(&key)?; |
| 1031 | let end = html[start..].find("</section>")? + start; |
| 1032 | Some(&html[start..end]) |
| 1033 | } |
| 1034 | |
| 1035 | /// The grouping check, as a function so a mutated copy can be shown |
| 1036 | /// to fail it: every table hypothesis renders inside the hypothesis |
| 1037 | /// group and inside no other group. |
| 1038 | fn check_grouping(html: &str) -> Result<(), String> { |
| 1039 | let hyp = group_html(html, "Research hypothesis").ok_or("hypothesis group missing")?; |
| 1040 | for id in TABLE_HYPOTHESES { |
| 1041 | let marker = format!("data-impl=\"{}\"", id.replace('/', "/")); |
| 1042 | let plain = format!("data-impl=\"{id}\""); |
| 1043 | let inside = hyp.contains(&plain) || hyp.contains(&marker); |
| 1044 | if !inside { |
| 1045 | return Err(format!("{id} is not in the research hypothesis group")); |
| 1046 | } |
| 1047 | for class in ALLOWED_CLASSES.iter().filter(|c| **c != "Research hypothesis") { |
| 1048 | if let Some(g) = group_html(html, class) { |
| 1049 | if g.contains(&plain) || g.contains(&marker) { |
| 1050 | return Err(format!("{id} also renders under {class}")); |
| 1051 | } |
| 1052 | } |
| 1053 | } |
| 1054 | } |
| 1055 | Ok(()) |
| 1056 | } |
| 1057 | |
| 1058 | #[test] |
| 1059 | fn research_hypotheses_are_grouped_apart() { |
| 1060 | let d = real(); |
| 1061 | check_grouping(&render_implementation(&d).into_string()).unwrap(); |
| 1062 | // Counterexample: a copy that reclassifies SUSY / Zeta as |
| 1063 | // Implemented renders it in the wrong group and fails the check. |
| 1064 | let mut bad = d.clone(); |
| 1065 | bad.implementation_rows |
| 1066 | .iter_mut() |
| 1067 | .find(|r| r.id == "SUSY / Zeta rediscovery") |
| 1068 | .unwrap() |
| 1069 | .class = "Implemented".into(); |
| 1070 | assert!(check_grouping(&render_implementation(&bad).into_string()).is_err()); |
| 1071 | } |
| 1072 | |
| 1073 | #[test] |
| 1074 | fn rendered_output_has_no_em_or_en_dash() { |
| 1075 | let page = render_research_status_page().into_string(); |
| 1076 | let embed = render_research_status_summary().into_string(); |
| 1077 | for s in [ |
| 1078 | page.as_str(), |
| 1079 | embed.as_str(), |
| 1080 | turing_instrument_note(), |
| 1081 | experiments_note(), |
| 1082 | paper_note(), |
| 1083 | current_level_sentence(), |
| 1084 | ] { |
| 1085 | assert!(!s.contains('\u{2014}'), "em dash in rendered output"); |
| 1086 | assert!(!s.contains('\u{2013}'), "en dash in rendered output"); |
| 1087 | } |
| 1088 | // Counterexample: a data file carrying an em dash is rejected. |
| 1089 | let dashed = RAW.replacen("Definition", "Definition \u{2014} zero", 1); |
| 1090 | assert!(parse(&dashed).is_err()); |
| 1091 | } |
| 1092 | |
| 1093 | #[test] |
| 1094 | fn independent_recheck_count_is_the_number_of_links() { |
| 1095 | let page = render_research_status_page().into_string(); |
| 1096 | assert!( |
| 1097 | page.contains("Independent rechecks: 0 (as of 2026-10-31). This changes only when an outside person's recheck is linked."), |
| 1098 | "independent recheck line missing from the status page" |
| 1099 | ); |
| 1100 | // The count follows the links: one linked recheck shows 1. |
| 1101 | let one = RAW.replacen("\"links\": []", "\"links\": [\"https://example.org/recheck\"]", 1); |
| 1102 | assert!(one != RAW); |
| 1103 | assert_eq!(parse(&one).unwrap().independent_rechecks.links.len(), 1); |
| 1104 | // Counterexample: a link that is not https is rejected. |
| 1105 | let bad = RAW.replacen("\"links\": []", "\"links\": [\"http://example.org/recheck\"]", 1); |
| 1106 | assert!(parse(&bad).is_err()); |
| 1107 | // Counterexample: a hand-set count field is not part of the schema. |
| 1108 | let count = RAW.replacen("\"links\": []", "\"links\": [], \"count\": 1", 1); |
| 1109 | assert!(parse(&count).is_err()); |
| 1110 | } |
| 1111 | |
| 1112 | /// The homepage lookup check, as a function so a mutated copy can be |
| 1113 | /// shown to fail it. |
| 1114 | fn check_homepage(d: &StatusData) -> Result<(), String> { |
| 1115 | if turing_instrument_status_for(d) != "IMPLEMENTED" { |
| 1116 | return Err(format!("instrument status is {}, table says Implemented", turing_instrument_status_for(d))); |
| 1117 | } |
| 1118 | let note = turing_instrument_note_for(d); |
| 1119 | if note.to_lowercase().contains("turing yield") || !note.contains("gain") { |
| 1120 | return Err("instrument note does not say gain, or says Turing yield".to_string()); |
| 1121 | } |
| 1122 | if !note.contains("checked against the private sealed records on 2026-10-01") { |
| 1123 | return Err("instrument note drops the sealed-records check statement".to_string()); |
| 1124 | } |
| 1125 | let exp = experiments_note_for(d); |
| 1126 | for want in ["EXP-001 FAIL", "EXP-002D INCOMPLETE", "EXP-003 BLOCKED"] { |
| 1127 | if !exp.contains(want) { |
| 1128 | return Err(format!("experiments note is missing {want}")); |
| 1129 | } |
| 1130 | } |
| 1131 | Ok(()) |
| 1132 | } |
| 1133 | |
| 1134 | #[test] |
| 1135 | fn homepage_lookups_never_upgrade() { |
| 1136 | let d = real(); |
| 1137 | check_homepage(&d).unwrap(); |
| 1138 | assert_eq!(turing_instrument_note(), turing_instrument_note_for(&d)); |
| 1139 | assert_eq!(experiments_note(), experiments_note_for(&d)); |
| 1140 | assert_ne!(layer_status_for_class("Research hypothesis"), "IMPLEMENTED"); |
| 1141 | // Counterexample: instrument row reclassified as a hypothesis. |
| 1142 | let mut hyp = d.clone(); |
| 1143 | hyp.implementation_rows |
| 1144 | .iter_mut() |
| 1145 | .find(|r| r.id == "Turing measurement machinery") |
| 1146 | .unwrap() |
| 1147 | .class = "Research hypothesis".into(); |
| 1148 | assert!(check_homepage(&hyp).is_err()); |
| 1149 | // Counterexample: EXP-003 quietly upgraded to PASS. |
| 1150 | let mut up = d.clone(); |
| 1151 | up.turing_rows.iter_mut().find(|r| r.id == "EXP-003").unwrap().status = "PASS".into(); |
| 1152 | assert!(check_homepage(&up).is_err()); |
| 1153 | // Counterexample: TY-2 headline relabelled as yield. |
| 1154 | let mut y = d.clone(); |
| 1155 | y.turing_rows.iter_mut().find(|r| r.id == "TY-2").unwrap().headline = |
| 1156 | // Built from two pieces so the repo-wide stale scan (status.rs) |
| 1157 | // keeps covering this file without flagging this counterexample. |
| 1158 | Some(["2,559,679.825 bits of Turing", " yield"].concat()); |
| 1159 | assert!(check_homepage(&y).is_err()); |
| 1160 | // Counterexample: the sealed-records check statement removed. |
| 1161 | let mut s = d.clone(); |
| 1162 | s.current_level.limitations = "L2 rests on private sealed records.".into(); |
| 1163 | assert!(check_homepage(&s).is_err()); |
| 1164 | } |
| 1165 | |
| 1166 | /// EXP-002A, B and C must each point at an aien-sealed commit. |
| 1167 | fn check_sealed_pointers(d: &StatusData) -> Result<(), String> { |
| 1168 | for (id, commits) in [ |
| 1169 | ("EXP-002A", &["760bfe9"][..]), |
| 1170 | ("EXP-002B", &["1310e06", "111a5ea"][..]), |
| 1171 | ("EXP-002C", &["f546162", "111a5ea"][..]), |
| 1172 | ] { |
| 1173 | let r = d.turing_row(id).ok_or_else(|| format!("{id} row missing"))?; |
| 1174 | if !r.receipt.contains("aien-sealed") { |
| 1175 | return Err(format!("{id} receipt does not name aien-sealed")); |
| 1176 | } |
| 1177 | for c in commits { |
| 1178 | if !r.receipt.contains(c) { |
| 1179 | return Err(format!("{id} receipt lacks aien-sealed commit {c}")); |
| 1180 | } |
| 1181 | } |
| 1182 | } |
| 1183 | Ok(()) |
| 1184 | } |
| 1185 | |
| 1186 | #[test] |
| 1187 | fn exp_002_rows_carry_sealed_commit_pointers() { |
| 1188 | let d = real(); |
| 1189 | check_sealed_pointers(&d).unwrap(); |
| 1190 | // Counterexample: each row in turn loses its pointers. |
| 1191 | for id in ["EXP-002A", "EXP-002B", "EXP-002C"] { |
| 1192 | let mut bad = d.clone(); |
| 1193 | bad.turing_rows.iter_mut().find(|r| r.id == id).unwrap().receipt = |
| 1194 | "PRIVATE aien-sealed R3-49 (not read)".into(); |
| 1195 | assert!(check_sealed_pointers(&bad).is_err(), "{id} without commit passed"); |
| 1196 | } |
| 1197 | } |
| 1198 | } |
| 1199 | |
| 1200 | #[cfg(test)] |
| 1201 | mod box_tests { |
| 1202 | use super::*; |
| 1203 | |
| 1204 | #[test] |
| 1205 | fn evidence_resolves_to_the_forge_or_honestly_to_the_data_file() { |
| 1206 | let qs = |n: &str| format!("{QS_RECORD}#L{n}"); |
| 1207 | assert_eq!(forge_for_evidence("QS:101 \"met\"; definition only"), Some(qs("101"))); |
| 1208 | assert_eq!(forge_for_evidence("QS:108-110"), Some(qs("108"))); |
| 1209 | assert_eq!(forge_for_evidence("QS section 6; explainer:7"), Some(QS_RECORD.to_string())); |
| 1210 | assert_eq!( |
| 1211 | forge_for_evidence("src/runtime/rx_world.h:2-8,73"), |
| 1212 | Some("https://interplane.io/drakestapleton/omega-mv/blob/main/src/runtime/rx_world.h#L2".into()) |
| 1213 | ); |
| 1214 | assert_eq!( |
| 1215 | forge_for_evidence("aienos native/argus/docs/ARGUS0_GATES.md:3; ARGUS1_GATES.md:6"), |
| 1216 | Some("https://interplane.io/drakestapleton/aienux/blob/main/native/argus/docs/ARGUS0_GATES.md#L3".into()) |
| 1217 | ); |
| 1218 | assert_eq!( |
| 1219 | forge_for_evidence("aien-architecture doctrine/ROADMAP.md rows M0-M40"), |
| 1220 | Some("https://interplane.io/drakestapleton/aien-architecture-mv/blob/main/doctrine/ROADMAP.md".into()) |
| 1221 | ); |
| 1222 | assert_eq!( |
| 1223 | forge_for_evidence("omega src/runtime/rx_contract.c, rx_contract.h"), |
| 1224 | Some("https://interplane.io/drakestapleton/omega-mv/blob/main/src/runtime/rx_contract.c".into()) |
| 1225 | ); |
| 1226 | assert_eq!( |
| 1227 | forge_for_evidence("TURING_CURRENT_STATE.md:56; spec/x.md"), |
| 1228 | Some("https://interplane.io/drakestapleton/omega-mv/blob/main/docs/turing/TURING_CURRENT_STATE.md#L56".into()) |
| 1229 | ); |
| 1230 | for none in ["omega grep", "grep hits in those two files", "none", "rx_cortex.h:1-14", "../etc/passwd.md", "", "atlas docs/x.md"] { |
| 1231 | assert_eq!(forge_for_evidence(none), None, "{none:?}"); |
| 1232 | } |
| 1233 | let (_, target) = evidence_box(&Some(String::new()), "omega grep"); |
| 1234 | assert_eq!(target, Target::Source, "an empty link is not a link"); |
| 1235 | let (href, target) = evidence_box(&None, "omega grep"); |
| 1236 | assert_eq!(target, Target::Source); |
| 1237 | assert!(href.ends_with(DATA_FILE)); |
| 1238 | let (href, target) = evidence_box(&Some("https://interplane.io/drakestapleton/omega-mv/commit/071a1e173d76".into()), "none"); |
| 1239 | assert_eq!((href.as_str(), target), ("https://interplane.io/drakestapleton/omega-mv/commit/071a1e173d76", Target::Evidence)); |
| 1240 | } |
| 1241 | |
| 1242 | #[test] |
| 1243 | fn every_step_card_and_item_links_to_the_forge() { |
| 1244 | let d = data(); |
| 1245 | let ladder = render_ladder(d).into_string(); |
| 1246 | assert_eq!(crate::components::boxlink::check_boxes(&ladder), Ok(d.ladder.len())); |
| 1247 | assert!(!ladder.contains("box-link-source"), "every ladder step cites a line of the qualification record"); |
| 1248 | let cards = render_cards(d).into_string(); |
| 1249 | assert_eq!(crate::components::boxlink::check_boxes(&cards), Ok(d.turing_rows.len())); |
| 1250 | assert!(!cards.contains("box-link-source"), "every experiment row has evidence on the forge"); |
| 1251 | let imp = render_implementation(d).into_string(); |
| 1252 | assert_eq!(crate::components::boxlink::check_boxes(&imp), Ok(d.implementation_rows.len())); |
| 1253 | let page = render_research_status_page().into_string(); |
| 1254 | let n = crate::components::boxlink::check_boxes(&page).unwrap(); |
| 1255 | assert_eq!(n, d.ladder.len() + d.turing_rows.len() + d.implementation_rows.len()); |
| 1256 | } |
| 1257 | |
| 1258 | #[test] |
| 1259 | fn a_link_off_the_forge_is_refused() { |
| 1260 | for off in ["https://example.com/x", "https://github.com/aien-dev/omega-mv/commit/071a1e173d76"] { |
| 1261 | let bad = RAW.replacen("\"link\": \"https://interplane.io/drakestapleton/omega-mv/commit/071a1e173d76\"", &format!("\"link\": \"{off}\""), 1); |
| 1262 | assert!(bad != RAW); |
| 1263 | assert!(parse(&bad).unwrap_err().contains("must be on the forge"), "{off}"); |
| 1264 | } |
| 1265 | } |
| 1266 | } |