interplane.Get Omega
Read in your language

aienos.com

Source of www.aienos.com, served from my own hardware

Brought by drakestapleton

branch main Branches Tags History

aienos.com / crates / site-builder / src / components / machines.rs

3476 lines · 139775 bytes Raw Blame History
1//! The machines and the speeds: what the project runs on today and how
2//! fast its own engine goes, with a receipt beside every number.
3//!
4//! One data file, `data/machines.json`, compiled in with `include_str!`
5//! and validated at build time and in the tests. Every machine and every
6//! speed row must carry a public link; a row without one fails the build.
7//! Numbers stand beside the physical ceiling of the machine they ran on
8//! and beside my own previous run. A comparison with another project is
9//! allowed when the same sentence has a real ISO date and a link to an
10//! aien-dev receipt or to that project's own published numbers. Overclaims
11//! and unsourced comparisons are refused. The one allowlisted sentence is
12//! "Slower than I want."
13//! The homepage shows both sections; /machine/ shows the machines first,
14//! before the theory, so the page describes real hardware.
15
16use std::sync::OnceLock;
17
18use maud::{html, Markup};
19use serde::Deserialize;
20
21use super::boxlink::{foot, Target};
22
23/// The raw data file, compiled into the binary.
24pub const RAW: &str = include_str!("../../data/machines.json");
25
26/// Phrases matched case-insensitively, with a word boundary on each side.
27/// These are claims on their own. "faster than", "half", "twice", "parity",
28/// and "beat" are context-bound: they count only in `context_is_claim`.
29pub const COMPARISON_PHRASES: &[&str] = &[
30 "better than",
31 "worse than",
32 "slower than",
33 "level with",
34 "ahead of",
35 "same speed as",
36 "as fast as",
37 "factor of",
38 "comparable to",
39 "competitive with",
40 "edges out",
41];
42
43/// Whole words, case-insensitively. Not stems. A claim on their own.
44/// Bare "behind" is ordinary English, so it is not a claim.
45/// "match", "matched", "tie", "ties", "tied", "equal", "equals", "equaled",
46/// "equalled", "tied with", "equal to" and "on par with" are context-bound,
47/// in `TIE_WORDS` and `TIE_PHRASES`: they count beside an outside name, a
48/// rival noun, a multiplier, or the "best measured CUDA number" bar.
49/// "rivals", "rivaled" and "rivalled" are comparison words on their own.
50/// Superlatives ("fastest", "slowest", "quickest", "best", "worst") count only
51/// beside a project name, in `has_guarded_word`.
52/// "beat", "parity", "trails" and "lags" are context-bound, in `CONTEXT_WORDS`.
53pub const COMPARISON_WORDS: &[&str] = &["outdoes", "tops", "rivals", "rivaled", "rivalled"];
54
55/// Count only when the same sentence also names an outside system, a rival
56/// noun, or a number glued to the comparative ("2x faster", "half as fast").
57const CONTEXT_PHRASES: &[&str] = &[
58 "faster than",
59 "quicker than",
60 "cheaper than",
61 "more efficient than",
62];
63
64const CONTEXT_WORDS: &[&str] = &[
65 "half", "twice", "double", "parity", "trails", "lags",
66 "beat", "beats", "beating", "beaten",
67];
68
69/// Tie words. Same targets as the other context words, plus a multiplier
70/// or the bar phrase "best measured CUDA number". A different word in a
71/// CUDA bar sentence does not stay on the exact-sentence list.
72const TIE_WORDS: &[&str] = &[
73 "match", "matches", "matching", "matched",
74 "tie", "ties", "tied",
75 "equal", "equals", "equaled", "equalled",
76];
77
78const TIE_PHRASES: &[&str] = &["tied with", "equal to", "on par with", "on a par with"];
79
80/// Connectors. They count when the same sentence names a rival.
81const CONNECTORS: &[&str] = &[
82 "versus",
83 "compared with",
84 "compared to",
85 "relative to",
86 "speedup over",
87];
88
89/// A generic rival. Not a project name. Context-bound words count beside one of these.
90const RIVAL_NOUNS: &[&str] = &[
91 "competitors",
92 "the competition",
93 "alternatives",
94 "other systems",
95 "other frameworks",
96 "other stacks",
97 "other compilers",
98 "other runtimes",
99 "the industry",
100 "state of the art",
101 "sota",
102 "incumbent",
103 "leader",
104 "leading",
105 "market leader",
106 "gpu stack",
107 "gpu stacks",
108 "the field",
109 "everyone else",
110 "existing tools",
111 "rival",
112];
113
114/// A word that starts with one of these, case-insensitively: outperforms,
115/// outpaced, surpasses, exceeded. "rival" is a noun in `RIVAL_NOUNS`, not a
116/// stem: "holds back every rival" is not a comparison. The verb "rivals" is
117/// a comparison word on its own.
118pub const COMPARISON_STEMS: &[&str] = &["outperform", "outpace", "surpass", "exceed"];
119
120/// Overclaims. These stay banned even when a date and a link sit beside them.
121/// Phrases are lowercase; callers compare a lowercased string.
122pub const OVERCLAIMS: [&str; 5] = [
123 "replacement for cuda",
124 "everything cuda gives you",
125 "omega's replacement and its status",
126 "beating cuda",
127 "matching and then",
128];
129
130/// The only sentence that may say "slower than" with no date and no link.
131const OWNED_SLOWER: &str = "Slower than I want.";
132
133fn is_owned_slower(s: &str) -> bool {
134 let t = s.trim();
135 t == OWNED_SLOWER || t == "Slower than I want"
136}
137
138fn is_real_date(year: i32, month: u32, day: u32) -> bool {
139 if !(1..=9999).contains(&year) || !(1..=12).contains(&month) || day == 0 {
140 return false;
141 }
142 let leap = year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
143 let dim = match month {
144 1 | 3 | 5 | 7 | 8 | 10 | 12 => 31,
145 4 | 6 | 9 | 11 => 30,
146 2 if leap => 29,
147 2 => 28,
148 _ => return false,
149 };
150 day <= dim
151}
152
153/// A real calendar date written YYYY-MM-DD. `2026-02-31` and `2026-13-01`
154/// do not count. A digit glued on either side does not count.
155fn has_real_iso_date(s: &str) -> bool {
156 let b = s.as_bytes();
157 if b.len() < 10 {
158 return false;
159 }
160 for i in 0..=b.len() - 10 {
161 if i > 0 && b[i - 1].is_ascii_digit() {
162 continue;
163 }
164 if i + 10 < b.len() && b[i + 10].is_ascii_digit() {
165 continue;
166 }
167 let w = &b[i..i + 10];
168 if w[4] != b'-' || w[7] != b'-' {
169 continue;
170 }
171 if !w[..4].iter().all(u8::is_ascii_digit)
172 || !w[5..7].iter().all(u8::is_ascii_digit)
173 || !w[8..10].iter().all(u8::is_ascii_digit)
174 {
175 continue;
176 }
177 let year: i32 = std::str::from_utf8(&w[..4]).unwrap().parse().unwrap();
178 let month: u32 = std::str::from_utf8(&w[5..7]).unwrap().parse().unwrap();
179 let day: u32 = std::str::from_utf8(&w[8..10]).unwrap().parse().unwrap();
180 if is_real_date(year, month, day) {
181 return true;
182 }
183 }
184 false
185}
186
187/// Domains that publish the other project's own numbers.
188pub const PROJECT_SOURCE_DOMAINS: &[&str] = &[
189 "docs.vllm.ai",
190 "vllm.ai",
191 "developer.nvidia.com",
192 "pytorch.org",
193 "huggingface.co",
194];
195
196/// Outside systems. "cuda" does not match when "++" follows it: CUDA++ is this project.
197/// "nvidia" is an outside system only when the sentence compares against it
198/// (`nvidia_is_target`). A descriptive mention ("NVIDIA GPUs", "no NVIDIA software")
199/// does not, by itself, turn "half" or "parity" into a claim. Superlatives and
200/// "vs" still see every token here, including a descriptive NVIDIA.
201const PROJECT_TOKENS: &[&str] = &[
202 "cuda", "nvidia", "vllm", "llama.cpp", "llama", "tensorrt", "pytorch", "triton", "cudnn",
203 "chatgpt", "openai", "gemini", "claude", "tgi", "sglang", "cutlass",
204 "ollama", "mlx", "rocm", "groq",
205];
206
207/// Multi-word rival names. "onnx runtime" is not a single token.
208const PROJECT_PHRASES: &[&str] = &["onnx runtime"];
209
210fn url_is_allowed(url: &str) -> bool {
211 let lower = url.to_ascii_lowercase();
212 let Some(rest) = lower
213 .strip_prefix("https://")
214 .or_else(|| lower.strip_prefix("http://"))
215 else {
216 return false;
217 };
218 let rest = rest.strip_prefix("www.").unwrap_or(rest);
219 let cut = rest.find(|c: char| c.is_whitespace() || matches!(c, '"' | '\'' | '<' | '>')).unwrap_or(rest.len());
220 let rest = &rest[..cut];
221 let (host, path) = match rest.find('/') {
222 Some(i) => (&rest[..i], &rest[i..]),
223 None => (rest, ""),
224 };
225 let host = host.split('@').next_back().unwrap_or(host);
226 let host = host.split(':').next().unwrap_or(host);
227 // My own record lives on the forge; GitHub is never a source link.
228 if (host == "interplane.io" && path.starts_with("/drakestapleton/"))
229 || (host == "aienos.com" && path.starts_with("/forge/drakestapleton/"))
230 {
231 return true;
232 }
233 PROJECT_SOURCE_DOMAINS.iter().any(|d| host == *d || host.ends_with(&format!(".{d}")))
234}
235
236fn each_url(s: &str, mut f: impl FnMut(&str)) {
237 let lower = s.to_ascii_lowercase();
238 let bytes = lower.as_bytes();
239 let mut i = 0;
240 while i < bytes.len() {
241 let rest = &lower[i..];
242 let http = rest.find("http://");
243 let https = rest.find("https://");
244 let at = match (http, https) {
245 (Some(a), Some(b)) => Some(a.min(b)),
246 (Some(a), None) => Some(a),
247 (None, Some(b)) => Some(b),
248 (None, None) => None,
249 };
250 let Some(at) = at else { break };
251 let start = i + at;
252 let url = &s[start..];
253 let end = url.find(|c: char| c.is_whitespace() || matches!(c, '"' | '\'' | '<' | '>')).unwrap_or(url.len());
254 f(&url[..end]);
255 i = start + end.max(1);
256 }
257}
258
259/// A receipt on an aien-dev host, or the other project's own domain, in this same sentence.
260/// The bare words "receipt" and "published" are not a link. An unrelated https URL is not a source.
261fn has_allowed_source(s: &str) -> bool {
262 let mut ok = false;
263 each_url(s, |url| {
264 if url_is_allowed(url) {
265 ok = true;
266 }
267 });
268 ok
269}
270
271fn is_word_char(c: char) -> bool {
272 c.is_ascii_alphanumeric() || c == '_'
273}
274
275fn boundary_phrase(lower: &str, phrase: &str) -> bool {
276 let mut from = 0;
277 while let Some(at) = lower[from..].find(phrase) {
278 let i = from + at;
279 let before_ok = i == 0 || !is_word_char(lower.as_bytes()[i - 1] as char);
280 let after = i + phrase.len();
281 let after_ok = after >= lower.len() || !is_word_char(lower.as_bytes()[after] as char);
282 if before_ok && after_ok {
283 return true;
284 }
285 from = i + phrase.len();
286 }
287 false
288}
289
290fn has_word_form(lower: &str) -> bool {
291 for word in lower.split(|c: char| !is_word_char(c)) {
292 if word.is_empty() {
293 continue;
294 }
295 if COMPARISON_WORDS.contains(&word) || COMPARISON_STEMS.iter().any(|stem| word.starts_with(stem)) {
296 return true;
297 }
298 }
299 false
300}
301
302/// A project token on a word boundary. "cuda" followed by "++" is CUDA++, this project, and does not count.
303fn token_present(lower: &str, token: &str) -> bool {
304 let mut from = 0;
305 while let Some(rel) = lower[from..].find(token) {
306 let i = from + rel;
307 let before_ok = i == 0 || !is_word_char(lower[..i].chars().next_back().unwrap());
308 let after = i + token.len();
309 let after_ok = after >= lower.len() || !is_word_char(lower[after..].chars().next().unwrap());
310 let cuda_plus = token == "cuda" && lower[after..].starts_with("++");
311 if before_ok && after_ok && !cuda_plus {
312 return true;
313 }
314 from = i + token.len().max(1);
315 }
316 false
317}
318
319fn word_ending_at(lower: &str, at: usize) -> Option<(usize, &str)> {
320 let trimmed = lower[..at].trim_end_matches(|c: char| !is_word_char(c));
321 if trimmed.is_empty() {
322 return None;
323 }
324 let start = trimmed
325 .rfind(|c: char| !is_word_char(c))
326 .map(|i| i + trimmed[i..].chars().next().unwrap().len_utf8())
327 .unwrap_or(0);
328 Some((start, &trimmed[start..]))
329}
330
331/// NVIDIA is the thing being compared, not a description of hardware or a missing stack.
332/// "faster than NVIDIA", "parity with NVIDIA", "twice NVIDIA", and "half of NVIDIA" count.
333/// "NVIDIA GPUs", "no NVIDIA software", and "with no NVIDIA user-space" do not.
334fn nvidia_is_target(lower: &str) -> bool {
335 const MARKERS: &[&str] = &[
336 "than", "with", "versus", "against", "vs", "of",
337 "twice", "double", "half",
338 "beat", "beats", "beating", "beaten",
339 "parity", "trails", "lags",
340 "faster", "quicker", "cheaper",
341 ];
342 let mut from = 0;
343 while let Some(rel) = lower[from..].find("nvidia") {
344 let i = from + rel;
345 let before_ok = i == 0 || !is_word_char(lower[..i].chars().next_back().unwrap());
346 let after = i + "nvidia".len();
347 let after_ok = after >= lower.len() || !is_word_char(lower[after..].chars().next().unwrap());
348 if before_ok && after_ok {
349 let mut word = word_ending_at(lower, i);
350 if matches!(word, Some((_, "the" | "a" | "an"))) {
351 if let Some((start, _)) = word {
352 word = word_ending_at(lower, start);
353 }
354 }
355 if let Some((_, w)) = word {
356 if MARKERS.contains(&w) {
357 return true;
358 }
359 }
360 }
361 from = i + "nvidia".len();
362 }
363 false
364}
365
366/// A comparison word other than "half", "twice" or "double". Those three stay
367/// descriptive in "GPU half" and do not, by themselves, make a nearby NVIDIA a rival.
368fn comparison_word_activates_nvidia(lower: &str) -> bool {
369 const WORDS: &[&str] = &[
370 "parity", "trails", "lags",
371 "beat", "beats", "beating", "beaten",
372 "match", "matches", "matching", "matched",
373 "tie", "ties", "tied",
374 "equal", "equals", "equaled", "equalled",
375 "slower", "faster", "quicker", "cheaper",
376 ];
377 if lower.split(|c: char| !is_word_char(c)).any(|word| {
378 WORDS.contains(&word)
379 || COMPARISON_WORDS.contains(&word)
380 || COMPARISON_STEMS.iter().any(|stem| word.starts_with(stem))
381 }) {
382 return true;
383 }
384 if CONTEXT_PHRASES.iter().any(|phrase| boundary_phrase(lower, phrase))
385 || TIE_PHRASES.iter().any(|phrase| boundary_phrase(lower, phrase))
386 || COMPARISON_PHRASES.iter().any(|phrase| boundary_phrase(lower, phrase))
387 || CONNECTORS.iter().any(|phrase| boundary_phrase(lower, phrase))
388 {
389 return true;
390 }
391 has_attached_comparative(lower) || has_vs(lower)
392}
393
394fn has_outside_system(lower: &str) -> bool {
395 if nvidia_is_target(lower) || (token_present(lower, "nvidia") && comparison_word_activates_nvidia(lower)) {
396 return true;
397 }
398 PROJECT_TOKENS.iter().any(|token| *token != "nvidia" && token_present(lower, token))
399 || PROJECT_PHRASES.iter().any(|phrase| boundary_phrase(lower, phrase))
400}
401
402/// Every rival name, in any position. NVIDIA counts here too. Used when the
403/// sentence already has a connector or a `<rival>: Nx` multiplier, so a
404/// descriptive NVIDIA sentence with no comparison word never reaches this.
405fn names_rival(lower: &str) -> bool {
406 PROJECT_TOKENS.iter().any(|token| token_present(lower, token))
407 || PROJECT_PHRASES.iter().any(|phrase| boundary_phrase(lower, phrase))
408 || has_rival(lower)
409}
410
411fn has_rival(lower: &str) -> bool {
412 RIVAL_NOUNS.iter().any(|noun| boundary_phrase(lower, noun))
413}
414
415fn project_near(lower: &str, at: usize) -> bool {
416 let start = lower.floor_char_boundary(at.saturating_sub(48));
417 let end = lower.ceil_char_boundary((at + 48).min(lower.len()));
418 let window = &lower[start..end];
419 PROJECT_TOKENS.iter().any(|token| token_present(window, token))
420}
421
422/// Superlatives only when a project name sits nearby.
423/// Bare uses ("the quickest walkthrough", "the best way") are not claims.
424/// "twice", "double", and "half" are context-bound, not superlatives.
425fn has_guarded_word(lower: &str) -> bool {
426 const GUARDED: &[&str] = &["best", "worst", "fastest", "slowest", "quickest"];
427 let mut from = 0;
428 while from < lower.len() {
429 let rest = &lower[from..];
430 let mut found: Option<(usize, usize)> = None;
431 for word in GUARDED {
432 if let Some(at) = rest.find(word) {
433 let i = from + at;
434 let before_ok = i == 0 || !is_word_char(lower.as_bytes()[i - 1] as char);
435 let after = i + word.len();
436 let after_ok = after >= lower.len() || !is_word_char(lower.as_bytes()[after] as char);
437 if before_ok && after_ok && found.map(|(p, _)| at < p).unwrap_or(true) {
438 found = Some((at, word.len()));
439 }
440 }
441 }
442 let Some((at, len)) = found else { break };
443 let i = from + at;
444 if project_near(lower, i) {
445 return true;
446 }
447 from = i + len;
448 }
449 false
450}
451
452fn has_vs(lower: &str) -> bool {
453 let b = lower.as_bytes();
454 let mut i = 0;
455 while i + 2 <= b.len() {
456 if &b[i..i + 2] == b"vs" {
457 let before = i == 0 || b[i - 1].is_ascii_whitespace();
458 let mut end = i + 2;
459 if end < b.len() && b[end] == b'.' {
460 end += 1;
461 }
462 let after_ok = end >= b.len()
463 || b[end].is_ascii_whitespace()
464 || matches!(b[end], b')' | b']' | b',' | b';' | b':' | b'!' | b'?');
465 if before && after_ok && project_near(lower, i) {
466 return true;
467 }
468 }
469 i += 1;
470 }
471 false
472}
473
474fn has_within_percent(lower: &str) -> bool {
475 let bytes = lower.as_bytes();
476 let mut from = 0;
477 while let Some(at) = lower[from..].find("within") {
478 let i = from + at;
479 let before_ok = i == 0 || !is_word_char(bytes[i - 1] as char);
480 let mut j = i + "within".len();
481 if !before_ok || j >= bytes.len() || !bytes[j].is_ascii_whitespace() {
482 from = i + "within".len();
483 continue;
484 }
485 while j < bytes.len() && bytes[j].is_ascii_whitespace() {
486 j += 1;
487 }
488 if j >= bytes.len() || !bytes[j].is_ascii_digit() {
489 from = i + "within".len();
490 continue;
491 }
492 while j < bytes.len() && bytes[j].is_ascii_digit() {
493 j += 1;
494 }
495 if j + 1 < bytes.len() && bytes[j] == b'.' && bytes[j + 1].is_ascii_digit() {
496 j += 2;
497 while j < bytes.len() && bytes[j].is_ascii_digit() {
498 j += 1;
499 }
500 }
501 while j < bytes.len() && bytes[j].is_ascii_whitespace() {
502 j += 1;
503 }
504 if j < bytes.len() && bytes[j] == b'%' {
505 j += 1;
506 while j < bytes.len() && bytes[j].is_ascii_whitespace() {
507 j += 1;
508 }
509 if lower[j..].starts_with("of") {
510 let after = j + 2;
511 if after >= lower.len() || !is_word_char(lower.as_bytes()[after] as char) {
512 return true;
513 }
514 }
515 }
516 from = i + "within".len();
517 }
518 false
519}
520
521fn is_timezone(word: &str) -> bool {
522 matches!(word, "cdt" | "cst" | "edt" | "est" | "mdt" | "mst" | "pdt" | "pst" | "utc" | "gmt")
523}
524
525/// `19:3x`, `~19:30` and a trailing timezone are clock tokens. They are not
526/// multipliers. A later `3x faster` in the same sentence still counts.
527fn is_clock_multiplier(chars: &[char], number_start: usize, after_mark: usize) -> bool {
528 if number_start > 0 && chars[number_start - 1] == ':' {
529 let mut k = number_start - 1;
530 if k > 0 {
531 k -= 1;
532 if chars[k].is_ascii_digit() {
533 let mut digits = 1usize;
534 while k > 0 && chars[k - 1].is_ascii_digit() && digits < 2 {
535 k -= 1;
536 digits += 1;
537 }
538 let before = if k == 0 { None } else { Some(chars[k - 1]) };
539 if matches!(before, None | Some('~')) || before.is_some_and(|c| c.is_whitespace()) {
540 return true;
541 }
542 }
543 }
544 }
545 let mut m = after_mark;
546 while m < chars.len() && chars[m] == ' ' {
547 m += 1;
548 }
549 if m >= chars.len() {
550 return false;
551 }
552 let rest: String = chars[m..].iter().collect();
553 let word = rest.split(|c: char| !is_word_char(c)).next().unwrap_or("");
554 is_timezone(word)
555}
556
557fn is_x_tail(c: char) -> bool {
558 c.is_whitespace()
559 || matches!(c, '.' | ',' | ';' | ':' | '!' | '?' | ')' | ']' | '"' | '\'' | '\u{201d}' | '\u{2019}')
560}
561
562fn without_urls(s: &str) -> String {
563 let mut out = String::with_capacity(s.len());
564 let mut rest = s;
565 loop {
566 let http = rest.find("http://");
567 let https = rest.find("https://");
568 let i = match (http, https) {
569 (Some(a), Some(b)) => Some(a.min(b)),
570 (Some(a), None) => Some(a),
571 (None, Some(b)) => Some(b),
572 (None, None) => None,
573 };
574 let Some(i) = i else {
575 out.push_str(rest);
576 break;
577 };
578 out.push_str(&rest[..i]);
579 rest = &rest[i..];
580 let end = rest.find(char::is_whitespace).unwrap_or(rest.len());
581 rest = &rest[end..];
582 out.push(' ');
583 }
584 out
585}
586
587fn negated_before(lower: &str, at: usize) -> bool {
588 let start = lower.floor_char_boundary(at.saturating_sub(48));
589 let mut window = &lower[start..at];
590 if let Some(i) = window.rfind(['.', '!', '?']) {
591 window = &window[i + 1..];
592 }
593 for word in ["not", "never", "no"] {
594 if boundary_phrase(window, word) {
595 return true;
596 }
597 }
598 false
599}
600
601fn phrase_claim(lower: &str) -> bool {
602 for phrase in COMPARISON_PHRASES {
603 let mut from = 0;
604 while let Some(at) = lower[from..].find(phrase) {
605 let i = from + at;
606 let before_ok = i == 0 || !is_word_char(lower.as_bytes()[i - 1] as char);
607 let after = i + phrase.len();
608 let after_ok = after >= lower.len() || !is_word_char(lower.as_bytes()[after] as char);
609 if before_ok && after_ok {
610 // "ahead of time" is an idiom, not a comparison. "ahead of NVIDIA" still is.
611 if *phrase == "ahead of" {
612 let rest = lower[after..].trim_start();
613 if rest.starts_with("time") {
614 let n = "time".len();
615 let boundary = n >= rest.len() || !is_word_char(rest[n..].chars().next().unwrap());
616 if boundary {
617 from = i + phrase.len();
618 continue;
619 }
620 }
621 }
622 let denial = (*phrase == "comparable to" || *phrase == "competitive with") && negated_before(lower, i);
623 if !denial {
624 return true;
625 }
626 }
627 from = i + phrase.len();
628 }
629 }
630 false
631}
632
633fn has_context_word(lower: &str) -> bool {
634 lower.split(|c: char| !is_word_char(c)).any(|word| CONTEXT_WORDS.contains(&word))
635}
636
637fn has_context_phrase(lower: &str) -> bool {
638 CONTEXT_PHRASES.iter().any(|phrase| boundary_phrase(lower, phrase))
639}
640
641fn adjective_at(rest: &str, words: &[&str]) -> bool {
642 words.iter().any(|adj| {
643 rest.starts_with(adj)
644 && (adj.len() >= rest.len() || !is_word_char(rest[adj.len()..].chars().next().unwrap()))
645 })
646}
647
648/// "half as fast", "2x faster", "40% cheaper", "N times faster".
649/// A bare "2x" or "137 times" is not attached.
650fn has_attached_comparative(lower: &str) -> bool {
651 const LOOSE: &[&str] = &[
652 "faster", "slower", "cheaper", "quicker", "more efficient",
653 "fast", "slow", "cheap", "quick", "efficient",
654 ];
655 for lead in ["half as", "twice as", "double as"] {
656 let mut from = 0;
657 while let Some(rel) = lower[from..].find(lead) {
658 let i = from + rel;
659 let before_ok = i == 0 || !is_word_char(lower[..i].chars().next_back().unwrap());
660 let after = i + lead.len();
661 let after_ok = after >= lower.len() || !is_word_char(lower[after..].chars().next().unwrap());
662 if before_ok && after_ok {
663 let rest = lower[after..].trim_start_matches(' ');
664 if adjective_at(rest, LOOSE) {
665 return true;
666 }
667 }
668 from = i + lead.len().max(1);
669 }
670 }
671 const TIGHT: &[&str] = &["faster", "slower", "cheaper", "quicker", "more efficient"];
672 let chars: Vec<char> = lower.chars().collect();
673 let mut i = 0;
674 while i < chars.len() {
675 let start_ok = chars[i].is_ascii_digit() && (i == 0 || !is_word_char(chars[i - 1]));
676 if !start_ok {
677 i += 1;
678 continue;
679 }
680 let mut j = i + 1;
681 while j < chars.len() && chars[j].is_ascii_digit() {
682 j += 1;
683 }
684 if j + 1 < chars.len() && chars[j] == '.' && chars[j + 1].is_ascii_digit() {
685 j += 2;
686 while j < chars.len() && chars[j].is_ascii_digit() {
687 j += 1;
688 }
689 }
690 let mut k = j;
691 while k < chars.len() && chars[k] == ' ' {
692 k += 1;
693 }
694 let rest_at = |m: usize| chars[m..].iter().collect::<String>();
695 if chars.get(k) == Some(&'%') {
696 let mut m = k + 1;
697 while m < chars.len() && chars[m] == ' ' {
698 m += 1;
699 }
700 if adjective_at(&rest_at(m), TIGHT) {
701 return true;
702 }
703 }
704 if k < chars.len() && (chars[k] == 'x' || chars[k] == '\u{00d7}') {
705 let mut m = k + 1;
706 while m < chars.len() && chars[m] == ' ' {
707 m += 1;
708 }
709 if adjective_at(&rest_at(m), TIGHT) {
710 return true;
711 }
712 }
713 if k > j {
714 let rest = rest_at(k);
715 if rest.starts_with("times") {
716 let after_times = "times".len();
717 let boundary = after_times >= rest.len()
718 || !is_word_char(rest[after_times..].chars().next().unwrap());
719 if boundary {
720 let mut m = k + "times".chars().count();
721 while m < chars.len() && chars[m] == ' ' {
722 m += 1;
723 }
724 if adjective_at(&rest_at(m), TIGHT) {
725 return true;
726 }
727 }
728 }
729 }
730 i = j;
731 }
732 false
733}
734
735fn has_nx_own(lower: &str) -> bool {
736 let chars: Vec<char> = lower.chars().collect();
737 let mut i = 0;
738 while i < chars.len() {
739 let start_ok = chars[i].is_ascii_digit() && (i == 0 || !is_word_char(chars[i - 1]));
740 if !start_ok {
741 i += 1;
742 continue;
743 }
744 let mut j = i + 1;
745 while j < chars.len() && chars[j].is_ascii_digit() {
746 j += 1;
747 }
748 if j + 1 < chars.len() && chars[j] == '.' && chars[j + 1].is_ascii_digit() {
749 j += 2;
750 while j < chars.len() && chars[j].is_ascii_digit() {
751 j += 1;
752 }
753 }
754 let mut k = j;
755 while k < chars.len() && chars[k] == ' ' {
756 k += 1;
757 }
758 if k < chars.len() && (chars[k] == 'x' || chars[k] == '\u{00d7}') {
759 let mut m = k + 1;
760 while m < chars.len() && chars[m] == ' ' {
761 m += 1;
762 }
763 let rest: String = chars[m..].iter().collect();
764 for phrase in ["its own", "our own"] {
765 if rest.starts_with(phrase) {
766 let n = phrase.len();
767 let after_ok = n >= rest.len() || !is_word_char(rest[n..].chars().next().unwrap());
768 if after_ok {
769 return true;
770 }
771 }
772 }
773 }
774 i = j;
775 }
776 false
777}
778
779/// "faster than its own frozen starting point" and "20.3x its own baseline".
780/// A word such as "frozen" may sit between "own" and the baseline noun.
781fn is_self_baseline(lower: &str) -> bool {
782 for phrase in ["than its own", "than our own"] {
783 let mut from = 0;
784 while let Some(rel) = lower[from..].find(phrase) {
785 let i = from + rel;
786 let before_ok = i == 0 || !is_word_char(lower[..i].chars().next_back().unwrap());
787 let after = i + phrase.len();
788 let after_ok = after >= lower.len() || !is_word_char(lower[after..].chars().next().unwrap());
789 if before_ok && after_ok {
790 let end = (after + 80).min(lower.len());
791 let window = &lower[after..end];
792 if ["starting point", "baseline", "previous"].iter().any(|noun| boundary_phrase(window, noun)) {
793 return true;
794 }
795 }
796 from = i + phrase.len();
797 }
798 }
799 has_nx_own(lower)
800}
801
802/// A bare `20x`, `3 times`, or `20.3-fold` names a rival only when that rival
803/// follows the number. "2x vLLM" and "20.3-fold vLLM" count. "Claude Max 20x plan"
804/// does not: Claude is the product, and 20x is the plan name.
805fn bare_multiplier_targets_rival(lower: &str) -> bool {
806 let chars: Vec<char> = lower.chars().collect();
807 let mut i = 0;
808 while i < chars.len() {
809 let start_ok = chars[i].is_ascii_digit() && (i == 0 || !is_word_char(chars[i - 1]));
810 if !start_ok {
811 i += 1;
812 continue;
813 }
814 let mut j = i + 1;
815 while j < chars.len() && chars[j].is_ascii_digit() {
816 j += 1;
817 }
818 if j + 1 < chars.len() && chars[j] == '.' && chars[j + 1].is_ascii_digit() {
819 j += 2;
820 while j < chars.len() && chars[j].is_ascii_digit() {
821 j += 1;
822 }
823 }
824 let mut k = j;
825 while k < chars.len() && chars[k] == ' ' {
826 k += 1;
827 }
828 let mut tail_at: Option<usize> = None;
829 if chars.get(j) == Some(&'-') {
830 let rest: String = chars[j + 1..].iter().collect();
831 if rest.starts_with("fold") {
832 let after = "fold".len();
833 if after >= rest.len() || !is_word_char(rest[after..].chars().next().unwrap_or(' ')) {
834 tail_at = Some(j + 1 + "fold".chars().count());
835 }
836 }
837 }
838 if k < chars.len() && (chars[k] == 'x' || chars[k] == '\u{00d7}') {
839 let zero = chars[i..j].iter().all(|c| *c == '0' || *c == '.');
840 let hex = zero && chars[k] == 'x';
841 if !hex {
842 let after = k + 1;
843 if (after >= chars.len() || is_x_tail(chars[after])) && !is_clock_multiplier(&chars, i, after) {
844 tail_at = Some(after);
845 }
846 }
847 }
848 if k > j {
849 let rest: String = chars[k..].iter().collect();
850 if rest.starts_with("times") {
851 let after = "times".len();
852 if after >= rest.len() || !is_word_char(rest[after..].chars().next().unwrap_or(' ')) {
853 tail_at = Some(k + "times".chars().count());
854 }
855 }
856 }
857 if let Some(at) = tail_at {
858 let tail: String = chars[at..].iter().collect();
859 if names_rival(&tail) {
860 return true;
861 }
862 }
863 i = j;
864 }
865 false
866}
867
868fn has_tie(lower: &str) -> bool {
869 lower.split(|c: char| !is_word_char(c)).any(|word| TIE_WORDS.contains(&word))
870 || TIE_PHRASES.iter().any(|phrase| boundary_phrase(lower, phrase))
871}
872
873fn has_multiplier(lower: &str) -> bool {
874 let chars: Vec<char> = lower.chars().collect();
875 let mut i = 0;
876 while i < chars.len() {
877 if !(chars[i].is_ascii_digit() && (i == 0 || !is_word_char(chars[i - 1]))) {
878 i += 1;
879 continue;
880 }
881 let mut j = i + 1;
882 while j < chars.len() && chars[j].is_ascii_digit() {
883 j += 1;
884 }
885 if j + 1 < chars.len() && chars[j] == '.' && chars[j + 1].is_ascii_digit() {
886 j += 2;
887 while j < chars.len() && chars[j].is_ascii_digit() {
888 j += 1;
889 }
890 }
891 let mut k = j;
892 while k < chars.len() && chars[k] == ' ' {
893 k += 1;
894 }
895 if k < chars.len() && (chars[k] == 'x' || chars[k] == '\u{00d7}') {
896 let after = k + 1;
897 if after >= chars.len() || is_x_tail(chars[after]) {
898 let zero = chars[i..j].iter().all(|c| *c == '0' || *c == '.');
899 if !(zero && chars[k] == 'x') && !is_clock_multiplier(&chars, i, after) {
900 return true;
901 }
902 }
903 }
904 if chars.get(j) == Some(&'-') {
905 let rest: String = chars[j + 1..].iter().collect();
906 if rest.starts_with("fold") {
907 let n = "fold".len();
908 if n >= rest.len() || !is_word_char(rest[n..].chars().next().unwrap_or(' ')) {
909 return true;
910 }
911 }
912 }
913 if k > j {
914 let rest: String = chars[k..].iter().collect();
915 if rest.starts_with("times") {
916 let n = "times".len();
917 if n >= rest.len() || !is_word_char(rest[n..].chars().next().unwrap_or(' ')) {
918 return true;
919 }
920 }
921 }
922 i = j;
923 }
924 false
925}
926
927/// `<rival>: Nx`, including `llama.cpp: 1.8x` and `speedup over vLLM: 2x`.
928/// The rival sits before the colon. A colon that is not followed by a multiplier
929/// is not this form, so "Game 2: Beat the memorizer" is not a multiplier claim.
930fn colon_nx_targets_rival(lower: &str) -> bool {
931 let chars: Vec<char> = lower.chars().collect();
932 let mut i = 0;
933 while i < chars.len() {
934 if chars[i] != ':' {
935 i += 1;
936 continue;
937 }
938 let mut k = i + 1;
939 while k < chars.len() && chars[k] == ' ' {
940 k += 1;
941 }
942 if k >= chars.len() || !chars[k].is_ascii_digit() {
943 i += 1;
944 continue;
945 }
946 let mut j = k + 1;
947 while j < chars.len() && chars[j].is_ascii_digit() {
948 j += 1;
949 }
950 if j + 1 < chars.len() && chars[j] == '.' && chars[j + 1].is_ascii_digit() {
951 j += 2;
952 while j < chars.len() && chars[j].is_ascii_digit() {
953 j += 1;
954 }
955 }
956 let mut m = j;
957 while m < chars.len() && chars[m] == ' ' {
958 m += 1;
959 }
960 let times = m < chars.len() && (chars[m] == 'x' || chars[m] == '\u{00d7}');
961 if !times || is_clock_multiplier(&chars, k, m + 1) {
962 i += 1;
963 continue;
964 }
965 let after = m + 1;
966 if after < chars.len() && !is_x_tail(chars[after]) {
967 i += 1;
968 continue;
969 }
970 let before: String = chars[..i].iter().collect();
971 if names_rival(&before) {
972 return true;
973 }
974 i += 1;
975 }
976 false
977}
978
979fn has_connector(lower: &str) -> bool {
980 CONNECTORS.iter().any(|phrase| boundary_phrase(lower, phrase)) && names_rival(lower)
981}
982
983fn context_is_claim(lower: &str) -> bool {
984 let tie = has_tie(lower);
985 let word_or_phrase = has_context_word(lower) || has_context_phrase(lower) || tie;
986 let attached = has_attached_comparative(lower);
987 let aimed = bare_multiplier_targets_rival(lower) || colon_nx_targets_rival(lower);
988 if !word_or_phrase && !attached && !aimed {
989 return false;
990 }
991 if is_self_baseline(lower) && !has_outside_system(lower) && !has_rival(lower) {
992 return false;
993 }
994 if attached {
995 return true;
996 }
997 let bar = lower.contains("best measured cuda number");
998 if word_or_phrase && (has_outside_system(lower) || has_rival(lower) || (tie && (bar || has_multiplier(lower)))) {
999 return true;
1000 }
1001 aimed
1002}
1003
1004fn is_comparison_claim(s: &str) -> bool {
1005 let scanned = without_urls(&s.to_ascii_lowercase());
1006 if phrase_claim(&scanned)
1007 || has_word_form(&scanned)
1008 || has_guarded_word(&scanned)
1009 || has_vs(&scanned)
1010 || has_connector(&scanned)
1011 || has_within_percent(&scanned)
1012 {
1013 return true;
1014 }
1015 context_is_claim(&scanned)
1016}
1017
1018/// One exact sentence the checker allows, with the source and the reason.
1019/// A different wording is not on the list, so it is checked like any other sentence.
1020struct FixedSentence {
1021 sentence: &'static str,
1022 source: &'static str,
1023 reason: &'static str,
1024 /// The omega page prints these bars as `Done when: {sentence}`.
1025 done_when_prefix: bool,
1026 /// Dist paths where this exact sentence is allowed. `public/` and a
1027 /// trailing slash are the same page. A llms.txt catalogue line is allowed
1028 /// only when its URL maps to one of these pages.
1029 pages: &'static [&'static str],
1030}
1031
1032/// Published chemistry results, scoped to the scholar page.
1033/// Removed Omega performance, benchmark and letter comparisons are not allowances.
1034/// The chemistry sentences match only as written. They are the scholar body in
1035/// public/data/engineer.json; each source link follows its result.
1036const FIXED_SENTENCES: &[FixedSentence] = &[
1037 FixedSentence {
1038 sentence: "Platinum deposited this way outperformed organic-solvent materials in photocatalytic dye degradation.",
1039 source: "https://doi.org/10.3762/bjnano.10.71",
1040 reason: "published chemistry result, sourced in the next paragraph",
1041 done_when_prefix: false,
1042 pages: &["engineer/scholar/index.html"],
1043 },
1044 FixedSentence {
1045 sentence: "Ionic-liquid synthesis outperformed organic-solvent routes in photocatalytic methylene blue degradation.",
1046 source: "https://digitalcommons.wku.edu/theses/2101/",
1047 reason: "published chemistry result, sourced in the next paragraph",
1048 done_when_prefix: false,
1049 pages: &["engineer/scholar/index.html"],
1050 },
1051];
1052
1053/// Game title. It names a memorizer, not another project's system.
1054const TURING_GAME_SENTENCE: &str = "Game 2: Beat the memorizer";
1055
1056fn plain_sentence(s: &str) -> String {
1057 s.replace("&#39;", "'")
1058 .replace("&#x27;", "'")
1059 .replace("&apos;", "'")
1060 .split_whitespace()
1061 .collect::<Vec<_>>()
1062 .join(" ")
1063}
1064
1065/// A dist path, a `public/` path, and a directory path are one page.
1066fn normalize_page(path: &str) -> String {
1067 let path = path.trim().replace('\\', "/");
1068 let path = path.strip_prefix("./").unwrap_or(&path);
1069 let path = path.strip_prefix("public/").unwrap_or(path);
1070 let path = path.trim_start_matches('/');
1071 if path.is_empty() {
1072 return String::new();
1073 }
1074 if path.ends_with('/') {
1075 return format!("{path}index.html");
1076 }
1077 if !path.contains('.') {
1078 return format!("{path}/index.html");
1079 }
1080 path.to_string()
1081}
1082
1083fn page_is(page: &str, allowed: &str) -> bool {
1084 normalize_page(page) == normalize_page(allowed)
1085}
1086
1087/// `llms.txt` writes `- [Name](https://...): {sentence}`. Returns that sentence
1088/// only when the URL maps to `page`. A different page's entry does not match.
1089fn llms_catalogue_sentence<'a>(page: &str, prepared: &'a str) -> Option<&'a str> {
1090 let (target, body) = catalogue_parts(prepared)?;
1091 if page_is(page, &target) { Some(body) } else { None }
1092}
1093
1094/// The page an llms.txt catalogue line points at, and the sentence after it.
1095fn catalogue_parts(prepared: &str) -> Option<(String, &str)> {
1096 let rest = prepared.strip_prefix("- [")?;
1097 let marker = rest.find("](https://")?;
1098 let after = &rest[marker + 2..];
1099 let split = after.find("): ")?;
1100 let url = &after[..split];
1101 if !url.starts_with("https://") || url.chars().any(char::is_whitespace) {
1102 return None;
1103 }
1104 let target = map_aienos_page(url)?;
1105 Some((target, &after[split + 3..]))
1106}
1107
1108fn sentence_page(file_page: &str, prepared: &str) -> String {
1109 if let Some((target, _)) = catalogue_parts(prepared) {
1110 return target;
1111 }
1112 normalize_page(file_page)
1113}
1114
1115fn is_fixed_sentence(page: &str, s: &str) -> bool {
1116 let n = plain_sentence(s);
1117 if n == TURING_GAME_SENTENCE {
1118 return true;
1119 }
1120 let here = normalize_page(page);
1121 if let Some(body) = llms_catalogue_sentence(&here, &n) {
1122 if FIXED_SENTENCES.iter().any(|row| {
1123 body == row.sentence && row.pages.iter().any(|allowed| page_is(&here, allowed))
1124 }) {
1125 return true;
1126 }
1127 }
1128 FIXED_SENTENCES.iter().any(|row| {
1129 let bare = n == row.sentence
1130 || (row.done_when_prefix && n == format!("Done when: {}", row.sentence));
1131 bare && row.pages.iter().any(|allowed| page_is(&here, allowed))
1132 })
1133}
1134
1135/// `None` when the text is not a comparison, or is one honest sentence
1136/// with a real ISO date and a source link. Overclaims always return
1137/// "overclaim". A comparison with no date or no link in this same text
1138/// returns "unsourced comparison".
1139fn decode_nbsp(s: &str) -> String {
1140 let lower = s.to_ascii_lowercase();
1141 let mut out = String::with_capacity(s.len());
1142 let mut i = 0;
1143 while i < s.len() {
1144 let ch = s[i..].chars().next().unwrap();
1145 if ch == '\u{00a0}' {
1146 out.push(' ');
1147 i += ch.len_utf8();
1148 continue;
1149 }
1150 let rest = &lower[i..];
1151 let entity = ["&nbsp;", "&#160;", "&#xa0;", "&#x00a0;"]
1152 .into_iter()
1153 .find(|entity| rest.starts_with(entity));
1154 if let Some(entity) = entity {
1155 out.push(' ');
1156 i += entity.len();
1157 continue;
1158 }
1159 out.push(ch);
1160 i += ch.len_utf8();
1161 }
1162 out
1163}
1164
1165fn strip_tags_to_space(s: &str) -> String {
1166 if !s.contains('<') {
1167 return s.to_string();
1168 }
1169 let mut out = String::with_capacity(s.len());
1170 let mut rest = s;
1171 while let Some(start) = rest.find('<') {
1172 out.push_str(&rest[..start]);
1173 if let Some(end) = rest[start..].find('>') {
1174 out.push(' ');
1175 rest = &rest[start + end + 1..];
1176 } else {
1177 out.push_str(&rest[start..]);
1178 return out;
1179 }
1180 }
1181 out.push_str(rest);
1182 out
1183}
1184
1185/// NBSP and `&nbsp;` become spaces, inline tags become spaces, and whitespace collapses.
1186fn prepare_sentence(s: &str) -> String {
1187 decode_nbsp(&strip_tags_to_space(s))
1188 .split_whitespace()
1189 .collect::<Vec<_>>()
1190 .join(" ")
1191}
1192
1193/// "replacement for" then a CUDA token within four words. A period, semicolon,
1194/// colon, comma, parenthesis, em dash or en dash in that gap ends the search.
1195/// "not a replacement" and "isn't a replacement" are not the claim.
1196/// "replacement for the CUDA user stack" and "a replacement for CUDA" are
1197/// the same overclaim. CUDA++ is this project's GPU half.
1198fn replacement_for_cuda(lower: &str) -> bool {
1199 let phrase = "replacement for";
1200 let mut from = 0;
1201 while let Some(rel) = lower[from..].find(phrase) {
1202 let i = from + rel;
1203 let before_ok = i == 0 || !is_word_char(lower.as_bytes()[i - 1] as char);
1204 let after = i + phrase.len();
1205 let after_ok = after >= lower.len() || !is_word_char(lower.as_bytes()[after] as char);
1206 if before_ok && after_ok && !replacement_is_negated(lower, i) && cuda_within_four_words(&lower[after..]) {
1207 return true;
1208 }
1209 from = i + phrase.len().max(1);
1210 }
1211 false
1212}
1213
1214/// The word immediately before "replacement", skipping one "a", "an" or "the".
1215fn replacement_is_negated(lower: &str, phrase_at: usize) -> bool {
1216 let Some((start, end)) = previous_word_span(lower, phrase_at) else {
1217 return false;
1218 };
1219 let mut word = &lower[start..end];
1220 if matches!(word, "a" | "an" | "the") {
1221 let Some((start, end)) = previous_word_span(lower, start) else {
1222 return false;
1223 };
1224 word = &lower[start..end];
1225 }
1226 matches!(word, "not" | "isn't" | "isnt")
1227}
1228
1229fn previous_word_span(lower: &str, at: usize) -> Option<(usize, usize)> {
1230 let mut i = at;
1231 while i > 0 {
1232 let ch = lower[..i].chars().next_back()?;
1233 if negation_word_char(ch) {
1234 break;
1235 }
1236 i -= ch.len_utf8();
1237 }
1238 if i == 0 {
1239 return None;
1240 }
1241 let end = i;
1242 while i > 0 {
1243 let ch = lower[..i].chars().next_back()?;
1244 if !negation_word_char(ch) {
1245 break;
1246 }
1247 i -= ch.len_utf8();
1248 }
1249 Some((i, end))
1250}
1251
1252fn negation_word_char(c: char) -> bool {
1253 is_word_char(c) || c == '\''
1254}
1255
1256/// At most four words between "for" and the CUDA token. Zero words counts:
1257/// "replacement for CUDA" is the claim. A clause break stops the gap,
1258/// including an en dash.
1259fn cuda_within_four_words(tail: &str) -> bool {
1260 let mut words = 0u32;
1261 let mut i = 0;
1262 while i < tail.len() {
1263 let c = tail[i..].chars().next().unwrap();
1264 let clen = c.len_utf8();
1265 if c.is_whitespace() {
1266 i += clen;
1267 continue;
1268 }
1269 if matches!(c, '.' | ';' | ':' | ',' | '(' | ')') || c == '\u{2014}' || c == '\u{2013}' {
1270 return false;
1271 }
1272 if tail[i..].starts_with("cuda") {
1273 let after = i + "cuda".len();
1274 let before_ok = i == 0 || !is_word_char(tail[..i].chars().next_back().unwrap());
1275 let next = tail[after..].chars().next();
1276 let plus = tail[after..].starts_with("++");
1277 let after_ok = next.map(|ch| !is_word_char(ch)).unwrap_or(true);
1278 if before_ok && after_ok && !plus {
1279 return words <= 4;
1280 }
1281 }
1282 if is_word_char(c) {
1283 words += 1;
1284 if words > 4 {
1285 return false;
1286 }
1287 i += clen;
1288 while i < tail.len() {
1289 let n = tail[i..].chars().next().unwrap();
1290 if !is_word_char(n) {
1291 break;
1292 }
1293 i += n.len_utf8();
1294 }
1295 continue;
1296 }
1297 i += clen;
1298 }
1299 false
1300}
1301
1302/// "beating cuda" is an overclaim. "beating cuda++" is this project's GPU half, not that claim.
1303fn has_overclaim(lower: &str) -> bool {
1304 for w in OVERCLAIMS {
1305 if w == "beating cuda" {
1306 let mut from = 0;
1307 while let Some(at) = lower[from..].find(w) {
1308 let i = from + at;
1309 let before_ok = i == 0 || !is_word_char(lower[..i].chars().next_back().unwrap());
1310 let after = i + w.len();
1311 let plus = lower[after..].starts_with("++");
1312 let after_ok = after >= lower.len() || !is_word_char(lower[after..].chars().next().unwrap());
1313 if before_ok && after_ok && !plus {
1314 return true;
1315 }
1316 from = i + w.len();
1317 }
1318 continue;
1319 }
1320 if w == "replacement for cuda" {
1321 if replacement_for_cuda(lower) {
1322 return true;
1323 }
1324 continue;
1325 }
1326 if lower.contains(w) {
1327 return true;
1328 }
1329 }
1330 false
1331}
1332
1333pub fn comparison_problem(s: &str) -> Option<&'static str> {
1334 comparison_problem_on("", s)
1335}
1336
1337/// Same check as `comparison_problem`, on one page. An exact fixed sentence
1338/// is allowed only on a page named by that sentence. A llms.txt line uses the
1339/// page its catalogue URL maps to. Any other wording stays banned.
1340pub fn comparison_problem_on(page: &str, s: &str) -> Option<&'static str> {
1341 let prepared = prepare_sentence(s);
1342 let lower = prepared.to_ascii_lowercase();
1343 let page = sentence_page(page, &prepared);
1344 if is_owned_slower(&prepared) || is_fixed_sentence(&page, &prepared) {
1345 return None;
1346 }
1347 if has_overclaim(&lower) {
1348 return Some("overclaim");
1349 }
1350 if is_comparison_claim(&prepared) && !(has_real_iso_date(&prepared) && has_allowed_source(&prepared)) {
1351 return Some("unsourced comparison");
1352 }
1353 None
1354}
1355
1356fn href_in_tag(tag: &str) -> Option<&str> {
1357 let tag_l = tag.to_ascii_lowercase();
1358 for key in ["href=\"", "href='"] {
1359 if let Some(i) = tag_l.find(key) {
1360 let value = &tag[i + key.len()..];
1361 let quote = if key.ends_with('"') { '"' } else { '\'' };
1362 let end = value.find(quote)?;
1363 return Some(&value[..end]);
1364 }
1365 }
1366 None
1367}
1368
1369fn closes_block(tag_l: &str) -> bool {
1370 tag_l.starts_with("</p")
1371 || tag_l.starts_with("</li")
1372 || tag_l.starts_with("</h")
1373 || tag_l.starts_with("</div")
1374 || tag_l.starts_with("</tr")
1375 || tag_l.starts_with("</dd")
1376 || tag_l.starts_with("</dt")
1377 || tag_l.starts_with("</blockquote")
1378 || tag_l.starts_with("</section")
1379 || tag_l.starts_with("</article")
1380 || tag_l.starts_with("</nav")
1381}
1382
1383fn is_inline_join(tag_l: &str) -> bool {
1384 matches!(
1385 open_name(tag_l),
1386 Some(
1387 "a" | "abbr" | "b" | "bdi" | "bdo" | "br" | "cite" | "code" | "data" | "dfn" | "em" | "i"
1388 | "mark" | "q" | "s" | "small" | "span" | "strong" | "sub" | "sup" | "time" | "u"
1389 | "var" | "wbr"
1390 )
1391 )
1392}
1393
1394fn open_name(tag_l: &str) -> Option<&str> {
1395 let t = tag_l.strip_prefix('<')?;
1396 if t.starts_with('/') || t.starts_with('!') {
1397 return None;
1398 }
1399 let end = t.find(|c: char| !c.is_ascii_alphanumeric()).unwrap_or(t.len());
1400 if end == 0 {
1401 return None;
1402 }
1403 Some(&t[..end])
1404}
1405
1406/// Skip a balanced element. `rest` begins just after the opening tag.
1407fn skip_balanced<'a>(rest: &'a str, name: &str) -> &'a str {
1408 let lower = rest.to_ascii_lowercase();
1409 let open = format!("<{name}");
1410 let close = format!("</{name}");
1411 let mut depth = 1usize;
1412 let mut i = 0usize;
1413 while depth > 0 && i < lower.len() {
1414 let rel_open = lower[i..].find(&open);
1415 let rel_close = lower[i..].find(&close);
1416 match (rel_open, rel_close) {
1417 (Some(o), Some(c)) if o < c => {
1418 depth += 1;
1419 i += o + open.len();
1420 }
1421 (_, Some(c)) => {
1422 depth -= 1;
1423 i += c + close.len();
1424 if depth == 0 {
1425 let after = rest.get(i..).unwrap_or("");
1426 let gt = after.find('>').map(|n| n + 1).unwrap_or(0);
1427 return after.get(gt..).unwrap_or("");
1428 }
1429 }
1430 _ => return "",
1431 }
1432 }
1433 ""
1434}
1435
1436/// Ledger and roster classes. `data-verbatim` alone does not opt out.
1437const VERBATIM_CLASSES: &[&str] = &[
1438 "now-item",
1439 "now-note",
1440 "now-done",
1441 "now-queue-item",
1442 "now-tl-item",
1443 "now-tl-evidence",
1444 "now-model-role",
1445 "agents-verbatim",
1446];
1447
1448fn has_verbatim_class(tag: &str) -> bool {
1449 let lower = tag.to_ascii_lowercase();
1450 let Some(i) = lower.find("class=") else { return false };
1451 let rest = &tag[i + 6..];
1452 let Some(quote) = rest.chars().next() else { return false };
1453 if quote != '"' && quote != '\'' {
1454 return false;
1455 }
1456 let rest = &rest[1..];
1457 let end = rest.find(quote).unwrap_or(rest.len());
1458 rest[..end].split_whitespace().any(|c| VERBATIM_CLASSES.iter().any(|v| c.eq_ignore_ascii_case(v)))
1459}
1460
1461/// Program text in `pre` (and therefore `pre > code`) is not prose.
1462/// A bare inline `<code>` is prose. `data-verbatim` opts out only for the fixed class list.
1463fn skip_whole_element(tag: &str, tag_l: &str) -> bool {
1464 matches!(
1465 open_name(tag_l),
1466 Some("script" | "style" | "pre" | "textarea" | "kbd" | "samp")
1467 ) || has_verbatim_class(tag)
1468}
1469
1470/// Keep link targets, drop tags, and break on block ends so a date in one
1471/// element does not license a claim in the next. Script, style, comments,
1472/// program text (`pre`, so `pre > code`, plus `textarea`, `kbd`, `samp`), and a
1473/// fixed verbatim class are not page prose. Inline `code` is prose.
1474fn readable_text(text: &str) -> String {
1475 if !text.contains('<') {
1476 return text.to_string();
1477 }
1478 let mut out = String::with_capacity(text.len());
1479 let mut rest = text;
1480 while let Some(start) = rest.find('<') {
1481 out.push_str(&rest[..start]);
1482 rest = &rest[start..];
1483 if rest.starts_with("<!--") {
1484 rest = rest.find("-->").map(|end| &rest[end + 3..]).unwrap_or("");
1485 continue;
1486 }
1487 let Some(end) = rest.find('>') else {
1488 out.push_str(rest);
1489 return out;
1490 };
1491 let tag = &rest[..=end];
1492 let tag_l = tag.to_ascii_lowercase();
1493 if !tag_l.ends_with("/>") && skip_whole_element(tag, &tag_l) {
1494 if let Some(name) = open_name(&tag_l) {
1495 rest = skip_balanced(&rest[end + 1..], name);
1496 continue;
1497 }
1498 }
1499 if let Some(url) = href_in_tag(tag) {
1500 out.push(' ');
1501 out.push_str(url);
1502 out.push(' ');
1503 }
1504 if is_inline_join(&tag_l) {
1505 out.push(' ');
1506 }
1507 if closes_block(&tag_l) {
1508 out.push('\n');
1509 }
1510 rest = &rest[end + 1..];
1511 }
1512 out.push_str(rest);
1513 out
1514}
1515
1516fn is_closer(c: char) -> bool {
1517 matches!(c, ')' | ']' | '"' | '\'' | '\u{201d}' | '\u{2019}')
1518}
1519
1520/// A sentence ends at `.`, `!`, or `?` followed by whitespace, or at the
1521/// end of the text. A closing `)` or quote may sit between the mark and
1522/// the whitespace. The next sentence may start with a digit or a lowercase
1523/// letter. A mark with no whitespace after it stays inside the sentence,
1524/// so llama.cpp, URLs, and 21.95 stay whole.
1525fn split_sentences(text: &str) -> Vec<String> {
1526 let chars: Vec<char> = text.chars().collect();
1527 let mut out = Vec::new();
1528 let mut cur = String::new();
1529 let mut i = 0;
1530 while i < chars.len() {
1531 let c = chars[i];
1532 if matches!(c, '.' | '!' | '?') {
1533 let mut j = i + 1;
1534 while j < chars.len() && is_closer(chars[j]) {
1535 j += 1;
1536 }
1537 if j >= chars.len() || chars[j].is_whitespace() {
1538 for ch in chars.iter().take(j).skip(i) {
1539 cur.push(*ch);
1540 }
1541 let sentence = cur.trim().to_string();
1542 if !sentence.is_empty() {
1543 out.push(sentence);
1544 }
1545 cur.clear();
1546 i = j;
1547 while i < chars.len() && chars[i].is_whitespace() {
1548 i += 1;
1549 }
1550 continue;
1551 }
1552 }
1553 cur.push(c);
1554 i += 1;
1555 }
1556 let sentence = cur.trim().to_string();
1557 if !sentence.is_empty() {
1558 out.push(sentence);
1559 }
1560 out
1561}
1562
1563/// Sentence-sized check. A date or a link in another sentence does not
1564/// license a comparison in this one.
1565pub fn comparison_errors(text: &str) -> Vec<String> {
1566 comparison_errors_on("", text)
1567}
1568
1569fn comparison_errors_on(page: &str, text: &str) -> Vec<String> {
1570 let mut errors = Vec::new();
1571 // Block ends already become newlines in `readable_text`. A newline ends a
1572 // sentence so a claim in the next block does not inherit the previous line.
1573 for line in readable_text(text).split('\n') {
1574 for sentence in split_sentences(line) {
1575 if let Some(kind) = comparison_problem_on(page, &sentence) {
1576 errors.push(format!("{kind} in {sentence:?}"));
1577 }
1578 }
1579 }
1580 errors
1581}
1582
1583/// Published papers and receipts, by exact repo path. Live pages are not on
1584/// this list: `/omega/`, `omega.json`, and the `/engineer/` tree are scanned.
1585/// A path matches only when the whole string equals an entry.
1586pub const PROSE_EXEMPT_PATHS: &[&str] = &[
1587 "public/engineer/papers/the-continuation-test.md",
1588 "crates/site-builder/data/models.json",
1589 "public/research/aien-research-plan.md",
1590 "public/research/computing-machinery-and-understanding-emergence/index.html",
1591 "public/research/the-stapleton-doctrine/index.html",
1592];
1593
1594pub fn is_prose_exempt(path: &str) -> bool {
1595 let norm = path.replace('\\', "/");
1596 PROSE_EXEMPT_PATHS.contains(&norm.as_str())
1597}
1598
1599/// Same check as `comparison_errors`, except a path on `PROSE_EXEMPT_PATHS` is skipped.
1600pub fn comparison_errors_at(path: &str, text: &str) -> Vec<String> {
1601 if is_prose_exempt(path) {
1602 Vec::new()
1603 } else {
1604 comparison_errors_on(path, text)
1605 }
1606}
1607
1608fn section_is_exempt(rel: &str) -> bool {
1609 is_prose_exempt(&format!("public/{rel}")) || is_prose_exempt(rel)
1610}
1611
1612/// `https://www.aienos.com/now/` becomes `now/index.html`. Anything else is unmapped.
1613fn map_aienos_page(url: &str) -> Option<String> {
1614 let url = url.trim().trim_end_matches(|c: char| c == '.' || c == ')');
1615 let rest = url
1616 .strip_prefix("https://www.aienos.com")
1617 .or_else(|| url.strip_prefix("http://www.aienos.com"))
1618 .or_else(|| url.strip_prefix("https://aienos.com"))
1619 .or_else(|| url.strip_prefix("http://aienos.com"))?;
1620 let path = rest.split(['?', '#', ' ']).next().unwrap_or("");
1621 if !path.is_empty() && !path.starts_with('/') {
1622 return None;
1623 }
1624 let rel = path.trim_matches('/');
1625 if rel.is_empty() {
1626 Some("index.html".to_string())
1627 } else if rel.ends_with(".html") || rel.ends_with(".md") || rel.ends_with(".json") || rel.ends_with(".tsv") {
1628 Some(rel.to_string())
1629 } else {
1630 Some(format!("{rel}/index.html"))
1631 }
1632}
1633
1634fn norm_ws(s: &str) -> String {
1635 s.split_whitespace().collect::<Vec<_>>().join(" ").to_ascii_lowercase()
1636}
1637
1638/// Fields from the public ledger long enough to identify a row. A sentence that
1639/// contains one of these is that row, not a new claim on the page.
1640fn ledger_fields(ledger: &str) -> Vec<String> {
1641 let mut out = Vec::new();
1642 for line in ledger.lines() {
1643 for field in line.split('\t') {
1644 let n = norm_ws(field);
1645 if n.chars().count() >= 40 {
1646 out.push(n);
1647 }
1648 }
1649 }
1650 out
1651}
1652
1653fn is_ledger_excerpt(sentence: &str, fields: &[String]) -> bool {
1654 let s = norm_ws(sentence);
1655 let n = s.chars().count();
1656 if n < 40 {
1657 return false;
1658 }
1659 fields.iter().any(|field| s.contains(field.as_str()) || field.contains(s.as_str()))
1660}
1661
1662/// `llms-full.txt` is one file with one section per page. Each section is
1663/// checked under its own source path. An exempt paper, receipt or ledger
1664/// section is skipped. A sentence copied from the public ledger stays with
1665/// the ledger. A section with no mappable source fails closed. A second
1666/// `Source:` line stays on the first path and is an error. `Published:` is
1667/// skipped only when it is the header line directly after `Source:`. The
1668/// file as a whole is not exempt.
1669fn push_line_problems(problems: &mut Vec<String>, n: usize, label: &str, line: &str, fields: &[String]) {
1670 if is_ledger_excerpt(line, fields) {
1671 return;
1672 }
1673 for sentence in split_sentences(line) {
1674 if is_ledger_excerpt(&sentence, fields) {
1675 continue;
1676 }
1677 if let Some(kind) = comparison_problem_on(label, &sentence) {
1678 problems.push(format!("llms-full.txt:{n} ({label}): {kind} in {sentence:?}"));
1679 }
1680 }
1681}
1682
1683/// `Published: YYYY-MM-DD. Last changed: <timestamp>.` as `seo::llms_full` writes it.
1684/// The timestamp is `YYYY-MM-DDTHH:MM:SSZ` or the same clock with a numeric offset.
1685fn is_published_header(line: &str) -> bool {
1686 let Some(rest) = line.strip_prefix("Published: ") else {
1687 return false;
1688 };
1689 let Some((date, changed)) = rest.split_once(". Last changed: ") else {
1690 return false;
1691 };
1692 let Some(stamp) = changed.strip_suffix('.') else {
1693 return false;
1694 };
1695 is_exact_iso_date(date) && is_exact_timestamp(stamp)
1696}
1697
1698fn is_exact_iso_date(s: &str) -> bool {
1699 let b = s.as_bytes();
1700 if b.len() != 10 || b[4] != b'-' || b[7] != b'-' {
1701 return false;
1702 }
1703 if !b[..4].iter().all(u8::is_ascii_digit)
1704 || !b[5..7].iter().all(u8::is_ascii_digit)
1705 || !b[8..10].iter().all(u8::is_ascii_digit)
1706 {
1707 return false;
1708 }
1709 let Ok(year) = s[..4].parse::<i32>() else {
1710 return false;
1711 };
1712 let Ok(month) = s[5..7].parse::<u32>() else {
1713 return false;
1714 };
1715 let Ok(day) = s[8..10].parse::<u32>() else {
1716 return false;
1717 };
1718 is_real_date(year, month, day)
1719}
1720
1721fn is_exact_timestamp(s: &str) -> bool {
1722 let b = s.as_bytes();
1723 if b.len() != 20 && b.len() != 25 {
1724 return false;
1725 }
1726 if !is_exact_iso_date(&s[..10]) || b[10] != b'T' || !is_hh_mm_ss(&b[11..19]) {
1727 return false;
1728 }
1729 if b.len() == 20 {
1730 return b[19] == b'Z';
1731 }
1732 (b[19] == b'+' || b[19] == b'-')
1733 && b[22] == b':'
1734 && is_two_digits(&b[20..22], 23)
1735 && is_two_digits(&b[23..25], 59)
1736}
1737
1738fn is_hh_mm_ss(b: &[u8]) -> bool {
1739 b.len() == 8
1740 && b[2] == b':'
1741 && b[5] == b':'
1742 && is_two_digits(&b[0..2], 23)
1743 && is_two_digits(&b[3..5], 59)
1744 && is_two_digits(&b[6..8], 59)
1745}
1746
1747fn is_two_digits(b: &[u8], max: u32) -> bool {
1748 if b.len() != 2 || !b.iter().all(u8::is_ascii_digit) {
1749 return false;
1750 }
1751 let Ok(n) = std::str::from_utf8(b).unwrap_or("").parse::<u32>() else {
1752 return false;
1753 };
1754 n <= max
1755}
1756
1757pub fn llms_full_problems(text: &str, ledger: &str) -> Vec<String> {
1758 let fields = ledger_fields(ledger);
1759 let mut problems = Vec::new();
1760 // None: file banner, before the first section. Some(None): section not yet
1761 // mapped. Some(Some(path)): mapped page.
1762 let mut section: Option<Option<String>> = None;
1763 let mut exempt = false;
1764 let mut reported_unmapped = false;
1765 let mut section_line = 1usize;
1766 let mut in_fence = false;
1767 let mut saw_source = false;
1768 let mut expect_published = false;
1769 let mut prelude: Vec<(usize, String)> = Vec::new();
1770 let flush = |section: &mut Option<Option<String>>,
1771 reported_unmapped: bool,
1772 section_line: usize,
1773 prelude: &mut Vec<(usize, String)>,
1774 problems: &mut Vec<String>,
1775 fields: &[String]| {
1776 if let Some(None) = section {
1777 if !reported_unmapped && !prelude.is_empty() {
1778 problems.push(format!("llms-full.txt:{section_line}: unmapped section"));
1779 for (n, line) in prelude.iter() {
1780 push_line_problems(problems, *n, "unmapped", line, fields);
1781 }
1782 }
1783 *section = None;
1784 }
1785 prelude.clear();
1786 };
1787 for (idx, line) in text.lines().enumerate() {
1788 let n = idx + 1;
1789 // html_to_text emits pre and textarea as fenced blocks. The page check
1790 // skips that program text, so the section check skips the same blocks.
1791 // A "---" inside a fence is program text, not the next page.
1792 if in_fence {
1793 if line.trim() == "```" {
1794 in_fence = false;
1795 }
1796 continue;
1797 }
1798 if line.trim() == "```" {
1799 in_fence = true;
1800 continue;
1801 }
1802 if line == "---" {
1803 flush(&mut section, reported_unmapped, section_line, &mut prelude, &mut problems, &fields);
1804 section = Some(None);
1805 exempt = false;
1806 reported_unmapped = false;
1807 section_line = n;
1808 saw_source = false;
1809 expect_published = false;
1810 continue;
1811 }
1812 if let Some(rest) = line.strip_prefix("Source: ") {
1813 if saw_source {
1814 problems.push(format!("llms-full.txt:{n}: second Source in section"));
1815 if expect_published {
1816 expect_published = false;
1817 problems.push(format!("llms-full.txt:{n}: missing Published header"));
1818 }
1819 continue;
1820 }
1821 saw_source = true;
1822 expect_published = true;
1823 if section.is_none() {
1824 section_line = n;
1825 }
1826 match map_aienos_page(rest) {
1827 Some(path) => {
1828 exempt = section_is_exempt(&path);
1829 if exempt {
1830 prelude.clear();
1831 } else {
1832 for (pn, pline) in prelude.drain(..) {
1833 push_line_problems(&mut problems, pn, &path, &pline, &fields);
1834 }
1835 }
1836 section = Some(Some(path));
1837 }
1838 None => {
1839 problems.push(format!("llms-full.txt:{n}: unmapped section {rest}"));
1840 exempt = false;
1841 section = Some(None);
1842 reported_unmapped = true;
1843 for (pn, pline) in prelude.drain(..) {
1844 push_line_problems(&mut problems, pn, "unmapped", &pline, &fields);
1845 }
1846 }
1847 }
1848 continue;
1849 }
1850 if section.is_none() {
1851 for sentence in split_sentences(line) {
1852 if let Some(kind) = comparison_problem(&sentence) {
1853 problems.push(format!("llms-full.txt:{n}: {kind} in {sentence:?}"));
1854 }
1855 }
1856 continue;
1857 }
1858 if expect_published {
1859 expect_published = false;
1860 if is_published_header(line) {
1861 continue;
1862 }
1863 problems.push(format!("llms-full.txt:{n}: missing Published header"));
1864 }
1865 if line.is_empty() {
1866 continue;
1867 }
1868 if exempt {
1869 continue;
1870 }
1871 match &section {
1872 Some(Some(path)) => push_line_problems(&mut problems, n, path, line, &fields),
1873 Some(None) => {
1874 if reported_unmapped {
1875 push_line_problems(&mut problems, n, "unmapped", line, &fields);
1876 } else {
1877 prelude.push((n, line.to_string()));
1878 }
1879 }
1880 None => {}
1881 }
1882 }
1883 flush(&mut section, reported_unmapped, section_line, &mut prelude, &mut problems, &fields);
1884 problems
1885}
1886
1887#[derive(Debug, Clone, Deserialize)]
1888#[serde(deny_unknown_fields)]
1889pub struct Data {
1890 pub as_of: String,
1891 pub source: String,
1892 pub judging: String,
1893 pub ceilings: Vec<Ceiling>,
1894 pub machines: Vec<Machine>,
1895 pub speeds: Vec<Speed>,
1896}
1897
1898#[derive(Debug, Clone, Deserialize)]
1899#[serde(deny_unknown_fields)]
1900pub struct Ceiling {
1901 pub id: String,
1902 pub model: String,
1903 pub machine: String,
1904 pub tok_s: f64,
1905 pub how: String,
1906 pub link: String,
1907 pub receipt: String,
1908 pub branch: String,
1909 pub on_main: bool,
1910}
1911
1912#[derive(Debug, Clone, Deserialize)]
1913#[serde(deny_unknown_fields)]
1914pub struct Link {
1915 pub label: String,
1916 pub link: String,
1917}
1918
1919#[derive(Debug, Clone, Deserialize)]
1920#[serde(deny_unknown_fields)]
1921pub struct Machine {
1922 pub id: String,
1923 pub name: String,
1924 pub detail: String,
1925 pub role: String,
1926 pub today: String,
1927 pub evidence_date: String,
1928 pub evidence: String,
1929 pub link: String,
1930 pub branch: String,
1931 pub on_main: bool,
1932 pub more: Vec<Link>,
1933}
1934
1935#[derive(Debug, Clone, Deserialize)]
1936#[serde(deny_unknown_fields)]
1937pub struct Speed {
1938 pub id: String,
1939 pub what: String,
1940 pub model: String,
1941 pub machine: String,
1942 pub engine: String,
1943 pub value: String,
1944 pub detail: String,
1945 pub tok_s: Option<f64>,
1946 pub ceiling: String,
1947 pub previous: String,
1948 pub date: String,
1949 pub link: String,
1950 pub receipt: String,
1951 pub branch: String,
1952 pub on_main: bool,
1953 pub verdict: String,
1954 pub note: String,
1955}
1956
1957impl Data {
1958 pub fn ceiling(&self, id: &str) -> Option<&Ceiling> {
1959 if id.is_empty() {
1960 return None;
1961 }
1962 self.ceilings.iter().find(|c| c.id == id)
1963 }
1964}
1965
1966fn has_dash(s: &str) -> bool {
1967 s.contains('\u{2014}') || s.contains('\u{2013}')
1968}
1969
1970fn check_text(what: &str, s: &str, errors: &mut Vec<String>) {
1971 if has_dash(s) {
1972 errors.push(format!("{what}: em or en dash in {s:?}"));
1973 }
1974 for problem in comparison_errors(s) {
1975 errors.push(format!("{what}: {problem}"));
1976 }
1977}
1978
1979fn check_link(what: &str, link: &str, errors: &mut Vec<String>) {
1980 if !link.starts_with(super::boxlink::FORGE) && !crate::forge::valid_repo_link(link) {
1981 errors.push(format!("{what}: link must be a public https URL on the forge, got {link:?}"));
1982 }
1983}
1984
1985/// Parse and validate. Every error is listed, not just the first.
1986pub fn parse(raw: &str) -> Result<Data, String> {
1987 let d: Data = serde_json::from_str(raw).map_err(|e| format!("machines.json: {e}"))?;
1988 let mut errors = Vec::new();
1989 check_text("as_of", &d.as_of, &mut errors);
1990 check_text("source", &d.source, &mut errors);
1991 check_text("judging", &d.judging, &mut errors);
1992 if d.machines.is_empty() {
1993 errors.push("no machines".into());
1994 }
1995 if d.speeds.is_empty() {
1996 errors.push("no speeds".into());
1997 }
1998 for c in &d.ceilings {
1999 let what = format!("ceiling {}", c.id);
2000 check_link(&what, &c.link, &mut errors);
2001 for s in [&c.model, &c.machine, &c.how, &c.receipt, &c.branch] {
2002 check_text(&what, s, &mut errors);
2003 }
2004 if c.tok_s.is_nan() || c.tok_s <= 0.0 {
2005 errors.push(format!("{what}: ceiling must be positive"));
2006 }
2007 }
2008 for m in &d.machines {
2009 let what = format!("machine {}", m.id);
2010 check_link(&what, &m.link, &mut errors);
2011 for s in [&m.name, &m.detail, &m.role, &m.today, &m.evidence_date, &m.evidence, &m.branch] {
2012 check_text(&what, s, &mut errors);
2013 }
2014 if m.evidence_date.len() != 10 {
2015 errors.push(format!("{what}: evidence_date must be YYYY-MM-DD"));
2016 }
2017 for l in &m.more {
2018 // An extra with no forge copy is a plain label, never an outside link.
2019 if !l.link.is_empty() {
2020 check_link(&what, &l.link, &mut errors);
2021 }
2022 check_text(&what, &l.label, &mut errors);
2023 }
2024 }
2025 for s in &d.speeds {
2026 let what = format!("speed {}", s.id);
2027 check_link(&what, &s.link, &mut errors);
2028 for t in [
2029 &s.what, &s.model, &s.machine, &s.engine, &s.value, &s.detail, &s.previous, &s.date,
2030 &s.receipt, &s.branch, &s.verdict, &s.note,
2031 ] {
2032 check_text(&what, t, &mut errors);
2033 }
2034 if !s.ceiling.is_empty() && d.ceiling(&s.ceiling).is_none() {
2035 errors.push(format!("{what}: unknown ceiling {:?}", s.ceiling));
2036 }
2037 if !s.ceiling.is_empty() && s.tok_s.is_none() {
2038 errors.push(format!("{what}: a ceiling needs a numeric tok_s"));
2039 }
2040 if let (Some(t), Some(c)) = (s.tok_s, d.ceiling(&s.ceiling)) {
2041 if t > c.tok_s {
2042 errors.push(format!("{what}: {t} tok/s is above its ceiling {}", c.tok_s));
2043 }
2044 }
2045 if s.on_main && s.branch != "main" {
2046 errors.push(format!("{what}: on_main is true but branch is {:?}", s.branch));
2047 }
2048 }
2049 let ids: Vec<&str> = d.speeds.iter().map(|s| s.id.as_str()).collect();
2050 for (i, id) in ids.iter().enumerate() {
2051 if ids[..i].contains(id) {
2052 errors.push(format!("speed {id}: duplicate id"));
2053 }
2054 }
2055 if errors.is_empty() {
2056 Ok(d)
2057 } else {
2058 Err(errors.join("\n"))
2059 }
2060}
2061
2062static DATA: OnceLock<Data> = OnceLock::new();
2063
2064/// The validated data. A bad file stops the build.
2065pub fn data() -> &'static Data {
2066 DATA.get_or_init(|| parse(RAW).unwrap_or_else(|e| panic!("{e}")))
2067}
2068
2069/// "0.752" for 7.63 of 10.15.
2070pub fn fraction(tok_s: f64, ceiling: f64) -> String {
2071 format!("{:.3}", tok_s / ceiling)
2072}
2073
2074/// "22.0 to 22.5 tok/s" as a big number and a small unit (the last word);
2075/// a value with no space stays whole.
2076fn big_value(value: &str) -> Markup {
2077 let (n, unit) = value.rsplit_once(' ').unwrap_or((value, ""));
2078 html! {
2079 span class="mx-hero-value mono" { (n) @if !unit.is_empty() { " " span class="mx-unit" { (unit) } } }
2080 }
2081}
2082
2083fn where_badge(on_main: bool, branch: &str) -> Markup {
2084 html! {
2085 @if on_main {
2086 span class="mx-where mx-where-main" { "receipt on main" }
2087 } @else {
2088 span class="mx-where mx-where-branch" title=(format!("branch {branch}")) { "branch " (branch) }
2089 }
2090 }
2091}
2092
2093// ---------------------------------------------------------------- machines
2094
2095fn machine_card(m: &Machine) -> Markup {
2096 html! {
2097 article class="mx-card" id=(format!("machine-{}", m.id)) {
2098 header class="mx-card-head" {
2099 h3 class="mx-name" { (m.name) }
2100 p class="mx-detail" { (m.detail) }
2101 }
2102 p class="mx-role" { (m.role) }
2103 dl class="mx-facts" {
2104 dt { "Today" }
2105 dd { (m.today) }
2106 dt { "Last evidence" }
2107 dd {
2108 span class="mx-date mono" { (m.evidence_date) }
2109 " " (m.evidence)
2110 }
2111 }
2112 footer class="mx-card-foot" {
2113 (where_badge(m.on_main, &m.branch))
2114 @if !m.more.is_empty() {
2115 span class="mx-more" {
2116 @for (i, l) in m.more.iter().enumerate() {
2117 @if i > 0 { " · " }
2118 @if l.link.is_empty() {
2119 code { (l.label) }
2120 } @else {
2121 a href=(l.link) target="_blank" rel="noopener noreferrer" { (l.label) }
2122 (crate::forge::receipt_code(&l.link))
2123 }
2124 }
2125 }
2126 }
2127 }
2128 (foot(&m.link, Target::Evidence))
2129 }
2130 }
2131}
2132
2133/// The grid of machine cards, shared by the homepage and /machine/.
2134pub fn render_machine_cards(d: &Data) -> Markup {
2135 html! {
2136 div class="mx-grid" {
2137 @for m in &d.machines { (machine_card(m)) }
2138 }
2139 }
2140}
2141
2142/// Homepage section: one card per machine.
2143pub fn render_machines_section() -> Markup {
2144 let d = data();
2145 html! {
2146 section id="machines" class="mx-section" aria-labelledby="machines-title" {
2147 div class="container" {
2148 div class="mx-head" {
2149 p class="kicker" { "The machines" }
2150 h2 id="machines-title" class="mx-h2" { "Five machines, one project" }
2151 p class="mx-lead" {
2152 "Aien is built and judged on a DGX Spark, runs bare metal on an Intel iMac and a Raspberry Pi 5, passes every kernel gate in QEMU first, and is being built for a Windows PC with an RTX 5070. Each card says what runs on that machine today, when the last evidence landed, and where the receipt is."
2153 }
2154 }
2155 (render_machine_cards(d))
2156 p class="mx-stamp" {
2157 "Inventory date " span class="mono" { (d.as_of) } " is when this list was taken. It is not the date of each card. Each card carries its own evidence date. A machine without a public receipt is not on this list."
2158 }
2159 }
2160 }
2161 }
2162}
2163
2164/// The compact version for the top of /machine/: the same cards under a
2165/// shorter introduction, so the page names real hardware before the theory.
2166pub fn render_real_machines() -> Markup {
2167 let d = data();
2168 html! {
2169 section id="real-machines" class="narr-section mx-on-narr" aria-labelledby="real-machines-heading" {
2170 h2 id="real-machines-heading" { "The bodies of one machine" }
2171 p {
2172 "One machine, five physical bodies. Aien is one system whose work moves between them: a DGX Spark for development and judgment, an Intel iMac and a Raspberry Pi 5 that run the kernel bare metal, QEMU for every gate before hardware, and a Windows PC with an RTX 5070 as the next target. Each card says what runs on that body today, the last evidence for it, and where the receipt is. The loop below is what they are for."
2173 }
2174 (render_machine_cards(d))
2175 p class="mx-stamp" {
2176 "Inventory date " span class="mono" { (d.as_of) } " is when this list was taken. It is not the date of each card. Each card carries its own evidence date."
2177 }
2178 p class="narr-more" {
2179 a href="/#speed" { "The speeds measured on them, with receipts, are on the homepage." }
2180 }
2181 }
2182 }
2183}
2184
2185// ---------------------------------------------------------------- speeds
2186
2187fn speed_row(d: &Data, s: &Speed) -> Markup {
2188 let ceiling = d.ceiling(&s.ceiling);
2189 html! {
2190 tr class="mx-row" id=(format!("speed-{}", s.id)) {
2191 td class="mx-td-what" data-label="What" {
2192 span class="mx-what" { (s.what) }
2193 span class="mx-model" { (s.model) }
2194 }
2195 td class="mx-td-machine" data-label="Machine and engine" {
2196 (s.machine)
2197 span class="mx-sub" { (s.engine) }
2198 }
2199 td class="mx-td-value" data-label="Measured" {
2200 span class="mx-value mono" { (s.value) }
2201 @if !s.detail.is_empty() { span class="mx-sub" { (s.detail) } }
2202 @if !s.verdict.is_empty() { span class="mx-verdict" { (s.verdict) } }
2203 }
2204 td class="mx-td-ceiling" data-label="Ceiling" {
2205 @if let (Some(t), Some(c)) = (s.tok_s, ceiling) {
2206 span class="mono" { (fraction(t, c.tok_s)) }
2207 span class="mx-sub" {
2208 "of "
2209 a href=(c.link) target="_blank" rel="noopener noreferrer" { (format!("{:.2} tok/s", c.tok_s)) }
2210 }
2211 } @else {
2212 span class="mx-sub mx-none" { "none shown" }
2213 }
2214 }
2215 td class="mx-td-prev" data-label="My previous run" {
2216 @if s.previous.is_empty() {
2217 span class="mx-sub mx-none" { "first of its kind" }
2218 } @else {
2219 (s.previous)
2220 }
2221 }
2222 td class="mx-td-date mono" data-label="Date" { (s.date) }
2223 td class="mx-td-receipt" data-label="Receipt" {
2224 span class="mx-receipt" { (s.receipt) }
2225 (where_badge(s.on_main, &s.branch))
2226 @if !s.note.is_empty() { span class="mx-sub" { (s.note) } }
2227 (foot(&s.link, Target::Evidence))
2228 }
2229 }
2230 }
2231}
2232
2233/// Homepage section: the speed table, the 35B end to end first.
2234pub fn render_speeds_section() -> Markup {
2235 let d = data();
2236 let first = d.speeds.first().expect("at least one speed row");
2237 let first_ceiling = d.ceiling(&first.ceiling);
2238 html! {
2239 section id="speed" class="mx-section mx-speed" aria-labelledby="speed-title" {
2240 div class="container" {
2241 div class="mx-head" {
2242 p class="kicker" { "Speed, with receipts" }
2243 h2 id="speed-title" class="mx-h2" { "The retired 35B end to end, on a test server" }
2244 p class="mx-lead" {
2245 "Qwen3.6-35B-A3B, a mixture-of-experts with about 3B parameters active per token, answered through my own C GPU stack, on the Spark, until I retired it on 2026-11-06. Nothing serves a Qwen model now, so every number here is dated history. Numbers for the Omega LLM, my own model, will join them as its receipts land. The number below is end-to-end wall time from a test server running a branch build, prompt reading included. Chip time for the same model is decode only. The gap between chip time and this end-to-end time comes from prompt reading. The full table holds the 27B chip-time rows, the engine alone, the smaller Rig engine and the long-context cost, each labelled end to end or chip time, and every row links to the folder its number came from."
2246 }
2247 }
2248 div class="mx-hero" {
2249 div class="mx-hero-n" {
2250 (big_value(&first.value))
2251 span class="mx-hero-l" { (first.model) " · " (first.engine) " · " (first.machine) }
2252 }
2253 @if let (Some(t), Some(c)) = (first.tok_s, first_ceiling) {
2254 div class="mx-hero-c" {
2255 span class="mx-hero-value mono mx-hero-frac" { (fraction(t, c.tok_s)) }
2256 span class="mx-hero-l" {
2257 "of the " a href=(c.link) target="_blank" rel="noopener noreferrer" { (format!("{:.2} tok/s", c.tok_s)) " memory ceiling" }
2258 }
2259 }
2260 }
2261 @if !first.previous.is_empty() {
2262 div class="mx-hero-p mx-hero-prev" {
2263 (big_value(first.previous.split(',').next().unwrap_or("")))
2264 span class="mx-hero-l" { "my previous run" }
2265 }
2266 }
2267 a class="mx-hero-r" href=(first.link) target="_blank" rel="noopener noreferrer" {
2268 "Receipt: " (first.receipt) " " (where_badge(first.on_main, &first.branch))
2269 }
2270 }
2271 // One number leads; every other row stays one click away in a
2272 // native disclosure, so the section reads as one idea.
2273 details class="mx-receipts" {
2274 summary class="mx-receipts-summary" { "All " (d.speeds.len()) " speed receipts, ceilings and how they are judged" }
2275 div class="mx-table-wrap" {
2276 table class="mx-table" {
2277 thead {
2278 tr {
2279 th { "What" }
2280 th { "Machine and engine" }
2281 th { "Measured" }
2282 th { "Ceiling" }
2283 th { "My previous run" }
2284 th { "Date" }
2285 th { "Receipt" }
2286 }
2287 }
2288 tbody {
2289 @for s in &d.speeds { (speed_row(d, s)) }
2290 }
2291 }
2292 }
2293 p class="mx-judging" { (d.judging) }
2294 @for c in &d.ceilings {
2295 p class="mx-stamp" {
2296 "Ceiling for " (c.model) " on the " (c.machine) ": " span class="mono" { (format!("{:.2} tok/s", c.tok_s)) } ". " (c.how) " "
2297 a href=(c.link) target="_blank" rel="noopener noreferrer" { (c.receipt) }
2298 " " (where_badge(c.on_main, &c.branch))
2299 }
2300 }
2301 }
2302 }
2303 }
2304 }
2305}
2306
2307#[cfg(test)]
2308mod tests {
2309 use super::*;
2310
2311 /// A speed row whose receipt is chip time: a chip folder, milliseconds per
2312 /// token, or GPU time per token. End-to-end wall time and cold time to
2313 /// first token are not chip time.
2314 fn is_chip_time(s: &Speed) -> bool {
2315 let blob = format!("{} {} {}", s.receipt, s.detail, s.value).to_ascii_lowercase();
2316 blob.contains("chip") || blob.contains("ms per token") || blob.contains("gpu time")
2317 }
2318
2319 #[test]
2320 fn real_data_parses_and_validates() {
2321 let d = parse(RAW).expect("machines.json must validate");
2322 assert_eq!(d.machines.len(), 5, "five machines: Spark, iMac, Pi 5, QEMU, RTX 5070 PC");
2323 for want in ["Spark", "iMac", "Raspberry Pi 5", "QEMU", "RTX 5070"] {
2324 assert!(d.machines.iter().any(|m| m.name.contains(want)), "machine {want} missing");
2325 }
2326 assert!(d.speeds.first().unwrap().model.starts_with("Qwen3.6-35B-A3B"), "the 35B end to end comes first");
2327 let spark = d.machines.iter().find(|m| m.id == "spark").unwrap();
2328 assert_eq!(spark.evidence_date, "2026-11-06");
2329 assert_eq!(spark.branch, "main");
2330 assert!(spark.on_main);
2331 assert!(spark.link.contains("/aien-train/tree/0518c915"), "{}", spark.link);
2332 assert!(spark.today.contains("Omega LLM"), "{}", spark.today);
2333 assert!(spark.today.contains("not deployed"), "{}", spark.today);
2334 assert!(spark.today.contains("no model is served here today"), "{}", spark.today);
2335 assert!(spark.today.contains("retired on 2026-11-06"), "{}", spark.today);
2336 assert!(!spark.today.contains("bin-16b0e6f8"), "{}", spark.today);
2337 assert!(
2338 spark.more.iter().any(|l| l.link.ends_with("/evidence/qwen38-serve-fast-20261019") && l.label.starts_with("Retired 27B")),
2339 "the 27B live-server receipt stays as dated history"
2340 );
2341 assert!(d.speeds.first().unwrap().what.starts_with("End to end"));
2342 assert!(d.speeds.first().unwrap().what.contains("test server") && d.speeds.first().unwrap().what.contains("branch build"));
2343 assert!(d.speeds.first().unwrap().engine.contains("Omega"));
2344 assert!(d.judging.contains("prompt reading"));
2345 assert!(!d.judging.to_ascii_lowercase().contains("without the server"));
2346 for s in d.speeds.iter().filter(|s| is_chip_time(s)) {
2347 assert!(s.what.to_ascii_lowercase().contains("chip time"), "{}: chip-time row must say so ({})", s.id, s.what);
2348 }
2349 }
2350
2351 /// Problems where the inventory still presents a retired Qwen model as live.
2352 fn live_qwen_problems(d: &Data) -> Vec<String> {
2353 let mut out = Vec::new();
2354 for m in &d.machines {
2355 if m.today.to_ascii_lowercase().contains("serves qwen") {
2356 out.push(format!("{}: today claims a served Qwen model", m.id));
2357 }
2358 }
2359 for s in d.speeds.iter().filter(|s| s.what.to_ascii_lowercase().contains("live server")) {
2360 if !s.what.contains(&s.date) {
2361 out.push(format!("{}: live-server row without its date", s.id));
2362 }
2363 if !(s.note.contains("retired") && s.note.contains("2026-11-06")) {
2364 out.push(format!("{}: live-server row without the retirement note", s.id));
2365 }
2366 }
2367 out
2368 }
2369
2370 #[test]
2371 fn no_card_claims_a_live_qwen_model() {
2372 // Qwen3.6-35B-A3B and Qwen3.8-27B were retired on 2026-11-06 and nothing
2373 // serves them. Their receipts stay as dated history, never as today's state.
2374 assert_eq!(live_qwen_problems(data()), Vec::<String>::new());
2375 let speeds = render_speeds_section().into_string();
2376 assert!(speeds.contains("until I retired it on 2026-11-06"));
2377 assert!(!speeds.contains("answers through my own C GPU stack"));
2378 // Negative controls: each old claim, put back, is refused.
2379 let serves = RAW.replacen("Linux. Trains and runs the Omega LLM", "Linux. Serves Qwen3.8-27B. Trains and runs the Omega LLM", 1);
2380 let undated = RAW.replacen("\"Live server on 2026-10-19, chip time", "\"Live server, chip time", 1);
2381 let unnoted = RAW.replacen(" Dated history: Qwen3.8-27B is retired (2026-11-06), and no server runs it now.", "", 1);
2382 for (name, raw) in [("serves", &serves), ("undated", &undated), ("unnoted", &unnoted)] {
2383 assert_ne!(raw.as_str(), RAW, "{name}: the control must change the data");
2384 let bad = parse(raw).unwrap();
2385 assert_eq!(live_qwen_problems(&bad).len(), 1, "{name}: {:?}", live_qwen_problems(&bad));
2386 }
2387 }
2388
2389 #[test]
2390 fn every_row_has_a_public_link() {
2391 let d = data();
2392 for m in &d.machines {
2393 assert!(m.link.starts_with("https://interplane.io/drakestapleton/") || crate::forge::valid_repo_link(&m.link), "{}: {}", m.id, m.link);
2394 for l in &m.more {
2395 assert!(l.link.is_empty() || l.link.starts_with("https://interplane.io/drakestapleton/") || crate::forge::valid_repo_link(&l.link), "{}: {}", m.id, l.link);
2396 }
2397 }
2398 for s in &d.speeds {
2399 assert!(s.link.starts_with("https://interplane.io/drakestapleton/") || crate::forge::valid_repo_link(&s.link), "{}: {}", s.id, s.link);
2400 }
2401 for c in &d.ceilings {
2402 assert!(c.link.starts_with("https://interplane.io/drakestapleton/") || crate::forge::valid_repo_link(&c.link), "{}: {}", c.id, c.link);
2403 }
2404 }
2405
2406 #[test]
2407 fn fraction_matches_the_inventory() {
2408 assert_eq!(fraction(7.63, 10.15), "0.752");
2409 assert_eq!(fraction(7.657, 10.15), "0.754");
2410 }
2411
2412 #[test]
2413 fn rejects_missing_link_dashes_and_comparisons() {
2414 let no_link = RAW.replacen("\"link\": \"https://interplane.io/", "\"link\": \"", 1);
2415 assert!(parse(&no_link).unwrap_err().contains("public https URL"));
2416 let github = RAW.replacen("\"link\": \"https://interplane.io/drakestapleton/", "\"link\": \"https://github.com/aien-dev/", 1);
2417 assert!(parse(&github).unwrap_err().contains("on the forge"), "github.com is rejected");
2418 let dashed = RAW.replacen("\"what\": \"Live server", "\"what\": \"Live \u{2014} server", 1);
2419 assert!(parse(&dashed).unwrap_err().contains("em or en dash"));
2420 let compared = RAW.replacen("\"note\": \"Nothing has run on the 5070 yet.\"", "\"note\": \"2x faster than llama.cpp\"", 1);
2421 let err = parse(&compared).unwrap_err();
2422 assert!(err.contains("unsourced comparison"), "{err}");
2423 let honest = RAW.replacen(
2424 "\"note\": \"Nothing has run on the 5070 yet.\"",
2425 "\"note\": \"On 2026-10-21 this run was faster than llama.cpp's published 40 tok/s (https://interplane.io/drakestapleton/sovereign-intelligence).\"",
2426 1,
2427 );
2428 assert!(parse(&honest).is_ok(), "an honest dated sourced comparison is allowed");
2429 let over = RAW.replacen(
2430 "\"note\": \"Nothing has run on the 5070 yet.\"",
2431 "\"note\": \"A replacement for CUDA, dated 2026-10-21, receipt https://example.com/r.\"",
2432 1,
2433 );
2434 let err = parse(&over).unwrap_err();
2435 assert!(err.contains("overclaim"), "{err}");
2436 let neighbor = RAW.replacen(
2437 "\"note\": \"Nothing has run on the 5070 yet.\"",
2438 "\"note\": \"Measured on 2026-10-21 (https://example.com/bench). CUDA is slower than Omega.\"",
2439 1,
2440 );
2441 let err = parse(&neighbor).unwrap_err();
2442 assert!(err.contains("unsourced comparison"), "{err}");
2443 let bare = RAW.replacen(
2444 "\"note\": \"Nothing has run on the 5070 yet.\"",
2445 "\"note\": \"On 2026-10-21 this beats vLLM (receipt).\"",
2446 1,
2447 );
2448 let err = parse(&bare).unwrap_err();
2449 assert!(err.contains("unsourced comparison"), "{err}");
2450 let above = RAW.replacen("\"tok_s\": 7.63,", "\"tok_s\": 70.63,", 1);
2451 assert!(parse(&above).unwrap_err().contains("above its ceiling"));
2452 let extra = RAW.replacen("\"as_of\"", "\"surprise\": 1, \"as_of\"", 1);
2453 assert!(parse(&extra).is_err(), "unknown fields must be refused");
2454 }
2455
2456 #[test]
2457 fn sections_render_clean() {
2458 for page in [
2459 render_machines_section().into_string(),
2460 render_speeds_section().into_string(),
2461 render_real_machines().into_string(),
2462 ] {
2463 assert!(!page.contains('\u{2014}') && !page.contains('\u{2013}'), "dash on the page");
2464 let problems = comparison_errors(&page);
2465 assert!(problems.is_empty(), "comparison problem on the page: {problems:?}");
2466 }
2467 let speeds = render_speeds_section().into_string();
2468 assert!(speeds.contains("7.63 tok/s"));
2469 assert!(speeds.contains("0.752"));
2470 assert!(speeds.contains("10.15 tok/s"));
2471 assert!(speeds.contains("id=\"speed-27b-live\""));
2472 assert!(speeds.contains("id=\"speed-35b-e2e\""));
2473 assert!(speeds.contains("22.0 to 22.5"));
2474 assert!(speeds.contains("test server running a branch build"));
2475 assert!(speeds.contains("mx-where-main\">receipt on main"), "35B row badge");
2476 assert!(speeds.contains("comes from prompt reading"));
2477 assert!(!speeds.to_ascii_lowercase().contains("without the server"));
2478 assert!(!speeds.to_ascii_lowercase().contains("leaves out the server"));
2479 assert!(speeds.contains(&data().judging));
2480 let machines = render_machines_section().into_string();
2481 assert!(machines.contains("mx-where-main\">receipt on main"), "Spark badge");
2482 for id in ["machine-spark", "machine-imac", "machine-pi5", "machine-qemu", "machine-rig"] {
2483 assert!(machines.contains(&format!("id=\"{id}\"")), "{id} missing");
2484 }
2485 assert_eq!(machines.matches("class=\"box-link\"").count(), 5, "one evidence link per machine");
2486 assert_eq!(crate::components::boxlink::check_boxes(&machines), Ok(5), "every machine card links to GitHub");
2487 let rows = data().speeds.len();
2488 assert_eq!(crate::components::boxlink::check_boxes(&speeds), Ok(rows), "every speed row links to GitHub");
2489 }
2490
2491 #[test]
2492 fn honest_example_passes_the_page_check() {
2493 let page = "Lead 21.95 tok/s from https://example.com/bench.v2/time.jsonl stayed put. On 2026-10-21 this run was faster than llama.cpp's published 40 tok/s (https://interplane.io/drakestapleton/sovereign-intelligence).";
2494 let problems = comparison_errors(page);
2495 assert!(problems.is_empty(), "{problems:?}");
2496 let html = "<p>On 2026-10-21 this run was faster than llama.cpp's published 40 tok/s (<a href=\"https://interplane.io/drakestapleton/sovereign-intelligence\">bench</a>).</p>";
2497 let problems = comparison_errors(html);
2498 assert!(problems.is_empty(), "{problems:?}");
2499 let unrelated = comparison_errors("On 2026-10-21 this run was faster than llama.cpp's published 40 tok/s (https://example.com/bench).");
2500 assert!(
2501 unrelated.iter().any(|e| e.contains("unsourced comparison")),
2502 "an unrelated https link is not a source: {unrelated:?}"
2503 );
2504 }
2505
2506 #[test]
2507 fn unsourced_comparisons_fail_on_the_page() {
2508 let slower = comparison_errors("CUDA is slower than Omega");
2509 assert!(slower.iter().any(|e| e.contains("unsourced comparison")), "{slower:?}");
2510 let neighbor = comparison_errors(
2511 "Measured on 2026-10-21 (https://example.com/bench). CUDA is slower than Omega.",
2512 );
2513 assert!(
2514 neighbor.iter().any(|e| e.contains("unsourced comparison") && e.to_ascii_lowercase().contains("slower than")),
2515 "{neighbor:?}"
2516 );
2517 assert!(
2518 !neighbor.iter().any(|e| e.contains("Measured on")),
2519 "the dated sentence is not the failure: {neighbor:?}"
2520 );
2521 let bare = comparison_errors("On 2026-10-21 this beats vLLM (receipt).");
2522 assert!(bare.iter().any(|e| e.contains("unsourced comparison")), "{bare:?}");
2523 let published = comparison_errors("On 2026-10-21 this was faster than the published figure.");
2524 assert!(
2525 published.is_empty(),
2526 "faster than, with no outside system and no rival noun, is not a claim: {published:?}"
2527 );
2528 let competition = comparison_errors("On 2026-10-21 this was faster than the competition.");
2529 assert!(
2530 competition.iter().any(|e| e.contains("unsourced comparison")),
2531 "{competition:?}"
2532 );
2533 assert!(comparison_problem("Slower than I want.").is_none());
2534 assert!(comparison_problem("On 2026-02-31 this was faster than CUDA (https://example.com/r).").is_some());
2535 assert!(comparison_problem(
2536 "On 2026-10-21 this run was faster than llama.cpp's published 40 tok/s (https://example.com/bench)."
2537 ).is_some());
2538 // GitHub is never a source link, not even the other project's own repository.
2539 assert!(comparison_problem(
2540 "On 2026-10-21 this run was faster than llama.cpp's published 40 tok/s (https://github.com/ggml-org/llama.cpp)."
2541 ).is_some());
2542 assert!(comparison_problem(
2543 "On 2026-10-21 this was faster than vLLM (https://docs.vllm.ai/en/latest/)."
2544 ).is_none());
2545 }
2546
2547 #[test]
2548 fn a_sentence_ends_at_a_mark_then_whitespace_whatever_follows() {
2549 for mark in [".", "!", "?"] {
2550 let page = format!(
2551 "Measured on 2026-10-21 (https://example.com/bench){mark} vLLM is slower than Omega."
2552 );
2553 let problems = comparison_errors(&page);
2554 assert!(
2555 problems.iter().any(|e| e.contains("unsourced comparison") && e.contains("slower than")),
2556 "{mark}: {problems:?}"
2557 );
2558 assert!(
2559 !problems.iter().any(|e| e.contains("Measured on")),
2560 "the dated sentence is not the failure ({mark}): {problems:?}"
2561 );
2562 }
2563 let closer = "Measured on 2026-10-21 (https://example.com/bench.) vLLM is slower than Omega.";
2564 let problems = comparison_errors(closer);
2565 assert!(
2566 problems.iter().any(|e| e.contains("slower than") && !e.contains("Measured on")),
2567 "a closing paren between the mark and the space still ends the sentence: {problems:?}"
2568 );
2569 let quoted = "Measured on 2026-10-21 (https://example.com/bench).\" vLLM is slower than Omega.";
2570 let problems = comparison_errors(quoted);
2571 assert!(
2572 problems.iter().any(|e| e.contains("slower than")),
2573 "a closing quote between the mark and the space still ends the sentence: {problems:?}"
2574 );
2575 let digit = "Measured on 2026-10-21 (https://example.com/bench). 2x vLLM was the next sentence.";
2576 let problems = comparison_errors(digit);
2577 assert!(
2578 problems.iter().any(|e| e.contains("unsourced comparison") && e.contains("2x")),
2579 "a next sentence may start with a digit: {problems:?}"
2580 );
2581 assert!(!problems.iter().any(|e| e.contains("Measured on")), "{problems:?}");
2582 let whole = comparison_errors("Lead 21.95 tok/s from llama.cpp and https://example.com/bench.v2/time.jsonl stayed put.");
2583 assert!(whole.is_empty(), "no whitespace after the mark, so the token stays whole: {whole:?}");
2584 }
2585
2586 #[test]
2587 fn every_comparison_term_fails_without_a_date_and_link_and_passes_with_both() {
2588 let terms = [
2589 "beat vLLM",
2590 "beats vLLM",
2591 "beating vLLM",
2592 "beaten by vLLM",
2593 "outperforms vLLM",
2594 "outpaces vLLM",
2595 "outpaced vLLM",
2596 "surpasses vLLM",
2597 "exceeds vLLM",
2598 "exceeded vLLM",
2599 "rivals vLLM",
2600 "better than vLLM",
2601 "worse than vLLM",
2602 "faster than vLLM",
2603 "slower than vLLM",
2604 "on par with vLLM",
2605 "on a par with vLLM",
2606 "level with vLLM",
2607 "ahead of vLLM",
2608 "same speed as vLLM",
2609 "as fast as vLLM",
2610 "2x vLLM",
2611 "2× faster",
2612 "3 times vLLM",
2613 "20.3-fold vLLM",
2614 "a factor of 1.80",
2615 "twice vLLM",
2616 "double vLLM",
2617 "half vLLM",
2618 "12% faster",
2619 "the fastest vLLM",
2620 "the worst vLLM",
2621 "the slowest vLLM",
2622 "the quickest vLLM",
2623 "best vLLM",
2624 "equals vLLM",
2625 "ties vLLM",
2626 "parity with vLLM",
2627 "outdoes vLLM",
2628 "tops vLLM",
2629 "trails vLLM",
2630 "lags vLLM",
2631 "edges out vLLM",
2632 "quicker than vLLM",
2633 "cheaper than vLLM",
2634 "more efficient than vLLM",
2635 "Omega vs CUDA",
2636 "twice CUDA",
2637 "comparable to vLLM",
2638 "competitive with vLLM",
2639 "within 5% of vLLM",
2640 "vLLM vs Omega",
2641 ];
2642 for term in terms {
2643 let bare = format!("This run will {term}.");
2644 let problems = comparison_errors(&bare);
2645 assert!(
2646 problems.iter().any(|e| e.contains("unsourced comparison")),
2647 "{term} must fail: {problems:?}"
2648 );
2649 let honest = if term.contains(['.', '!', '?']) {
2650 format!("On 2026-10-21 (https://interplane.io/drakestapleton/sovereign-intelligence) this was {term}")
2651 } else {
2652 format!("On 2026-10-21 this was {term} (https://interplane.io/drakestapleton/sovereign-intelligence).")
2653 };
2654 let problems = comparison_errors(&honest);
2655 assert!(problems.is_empty(), "{term} with a real date and a link must pass: {problems:?}");
2656 }
2657 assert!(comparison_problem("The ratio was 1.8x.").is_none());
2658 assert!(comparison_problem("The note says (2x).").is_none());
2659 assert!(comparison_problem("The quickest walkthrough of what exists today.").is_none());
2660 assert!(comparison_problem("Omega vs CUDA.").is_some());
2661 assert!(comparison_problem("This ties CUDA.").is_some());
2662 assert!(comparison_problem_on("omega/index.html", "Omega's best format beats the best measured CUDA number at one conversation, with golden tokens identical to my host reference.").is_some());
2663 assert!(comparison_problem_on("omega/index.html", "Done when: Omega prefill beats the best measured CUDA number at 512 and 8k.").is_some());
2664 assert!(comparison_problem_on("omega/index.html", "Omega total words per second beats the best measured CUDA number at 8 and 32 conversations.").is_some());
2665 assert!(comparison_problem("Omega beats the best measured CUDA number.").is_some());
2666 assert!(comparison_problem("Game 2: Beat the memorizer").is_none());
2667 assert!(comparison_problem("Game 2: Beat CUDA").is_some());
2668 assert!(comparison_problem("The drive behind the grades.").is_none());
2669 assert!(comparison_problem("answers matching the shipped reference.").is_none());
2670 assert!(comparison_problem("This is not directly comparable to TOP500 scores.").is_none());
2671 assert!(comparison_problem("lowercase 0x and lowercase digits.").is_none());
2672 assert!(comparison_problem("P vs NP is open.").is_none());
2673 assert!(comparison_problem("The frame is 1920x1080 and the hex is 0xff.").is_none());
2674 let shouted = comparison_errors("BEATS vLLM. Faster Than the competition.");
2675 assert_eq!(shouted.len(), 2, "word forms are case-insensitive, one sentence each: {shouted:?}");
2676 assert!(comparison_problem("served_match is an identifier, not a claim.").is_none());
2677 assert!(comparison_errors("<style>/* beat the memorizer */</style><p>A note.</p>").is_empty());
2678 assert!(comparison_errors("<pre><code>files match SHA256SUMS. 3x physical.</code></pre>").is_empty());
2679 assert!(
2680 !comparison_errors("<code>2x vLLM</code>").is_empty(),
2681 "inline code is prose"
2682 );
2683 assert!(
2684 !comparison_errors("<p data-verbatim>The gb10 is 2x vLLM.</p>").is_empty(),
2685 "data-verbatim alone is not an opt-out"
2686 );
2687 assert!(comparison_errors("<p class=\"now-note\" data-verbatim>The gb10 is 2x vLLM.</p><p>A note.</p>").is_empty());
2688 assert!(comparison_errors("<p class=\"agents-verbatim\" data-verbatim>aien-serve-http vs vLLM vs llama.cpp</p>").is_empty());
2689 }
2690
2691 #[test]
2692 fn round5_sentences_pass_and_real_rivals_still_fail() {
2693 let pass = [
2694 "CUDA++, the GPU half of Omega, has its own page: /cudaplusplus/ CUDA++.",
2695 "What Omega is, in plain words, and its GPU half, CUDA++.",
2696 "CUDA++, its GPU half",
2697 "the GPU half of Omega and every step from program to chip",
2698 "CUDA++ is the GPU half of Omega, plus the motor.",
2699 "AR2 simulated analog provider with digital oracle parity",
2700 "CUDA++ is the GPU half of Omega, under Apache-2.0 with the LLVM exception, plus the motor, with no NVIDIA user-space software, and how it was built.",
2701 "Its GPU half is now its own open source project, CUDA++, plus the motor, with no NVIDIA software above the kernel driver.",
2702 "The prime-counting benchmark on the GB10 runs 20.3 times faster than its own frozen starting point.",
2703 "I earned it step by step, and today I love that AI helps other people climb faster than I could.",
2704 "20.3x",
2705 "Prime Drag Race native GPU sieve on GB10 at 19,701 passes per second, 20.3x its own frozen starting point of 971.",
2706 "CUDA++ is described as the GPU half of Omega.",
2707 "CUDA++ is the GPU half of Omega, now its own open source project under Apache-2.0 with the LLVM exception.",
2708 "It is the GPU half of Omega, plus the motor, on the NVIDIA GPUs people already own, with no NVIDIA user-space software.",
2709 "AEGIS treats that boundary like a house: watch the door, recognize unauthorized access, isolate sessions, and preserve forensic trails for incident teams.",
2710 "The bird's-eye map, whose axis begins 18 June 2026, labels a 4k standing prompt \"typed ~169\u{00d7}\" and notes that MobDev and Panel already exist.",
2711 "The cognitive faculty acted 137 times, the synthesis faculty 122 times.",
2712 "A heart beating does not mean the body is finished.",
2713 "The heart is beating.",
2714 "Then I watched one subsystem do it: a goal given, and a machine that continued with no hand inside the loop, promoting itself, cutting its own cost nearly in half, checking its work at the end.",
2715 "The heart beats.",
2716 "GPU half of Omega",
2717 "oracle parity",
2718 "forensic trails",
2719 "acted 137 times",
2720 "faster than I could",
2721 "typed ~169x",
2722 "typed ~169\u{00d7}",
2723 "20.3x its own frozen starting point",
2724 "faster than its own baseline",
2725 "faster than our own previous run",
2726 "2x faster than its own baseline",
2727 "parity with CUDA++",
2728 "twice CUDA++",
2729 "The GPU half of Omega, with no NVIDIA software.",
2730 "Claude Max 20x plan.",
2731 "Claude Max 20x planread 2026-10-30T14:45Z",
2732 ];
2733 for sentence in pass {
2734 assert!(
2735 comparison_problem(sentence).is_none(),
2736 "must pass: {sentence:?} -> {:?}",
2737 comparison_problem(sentence)
2738 );
2739 }
2740 let fail = [
2741 "2x faster than vLLM",
2742 "twice as fast as PyTorch",
2743 "parity with CUDA",
2744 "beats llama.cpp",
2745 "faster than the competition",
2746 "faster than its own baseline and vLLM",
2747 "2x faster",
2748 "40% cheaper",
2749 "half as fast",
2750 "3 times faster",
2751 "faster than NVIDIA",
2752 "twice NVIDIA",
2753 "Omega vs NVIDIA",
2754 "parity with NVIDIA",
2755 "the fastest NVIDIA card",
2756 "Omega vs CUDA",
2757 "20.3-fold vLLM",
2758 "2x vLLM",
2759 ];
2760 for sentence in fail {
2761 let problem = comparison_problem(sentence);
2762 assert!(
2763 problem.is_some(),
2764 "must fail: {sentence:?}"
2765 );
2766 }
2767 // The same-sentence source rule is unchanged. A one-word variant is not
2768 // on the exact list, so it still needs a real date and an allowlisted link.
2769 let variant = "Platinum deposited this way outperformed organic-solvent compounds in photocatalytic dye degradation.";
2770 assert_eq!(comparison_problem(variant), Some("unsourced comparison"));
2771 let sourced = format!(
2772 "{variant} Recorded 2019-04-02 (https://interplane.io/drakestapleton/sovereign-intelligence)."
2773 );
2774 assert!(comparison_problem(&sourced).is_none(), "a dated allowlisted link still covers a real comparison");
2775 let unrelated = format!("{variant} See https://doi.org/10.3762/bjnano.10.71.");
2776 assert!(comparison_problem(&unrelated).is_some(), "doi.org is not an allowlisted source host");
2777 }
2778
2779 #[test]
2780 fn fixed_sentences_match_exactly_and_carry_a_source() {
2781 for row in FIXED_SENTENCES {
2782 assert!(!row.source.is_empty() && row.source.starts_with("https://"), "{}", row.sentence);
2783 assert!(!row.reason.is_empty(), "{}", row.sentence);
2784 assert!(!row.pages.is_empty(), "{}", row.sentence);
2785 assert!(
2786 comparison_problem_on(row.pages[0], row.sentence).is_none(),
2787 "{}",
2788 row.sentence
2789 );
2790 assert!(
2791 comparison_problem_on("index.html", row.sentence).is_some(),
2792 "the allowance stays on its own page: {}",
2793 row.sentence
2794 );
2795 }
2796 let chemistry: Vec<_> = FIXED_SENTENCES
2797 .iter()
2798 .filter(|row| row.reason == "published chemistry result, sourced in the next paragraph")
2799 .collect();
2800 assert_eq!(chemistry.len(), 2);
2801 for row in &chemistry {
2802 assert_eq!(row.reason, "published chemistry result, sourced in the next paragraph");
2803 let changed = row.sentence.replacen("outperformed", "surpassed", 1);
2804 assert_ne!(changed, row.sentence);
2805 assert_eq!(comparison_problem(&changed), Some("unsourced comparison"), "{changed}");
2806 let prefixed = format!("Done when: {}", row.sentence);
2807 assert!(comparison_problem(&prefixed).is_some(), "the chemistry sentence has no Done when prefix");
2808 }
2809 assert_eq!(
2810 chemistry[0].source,
2811 "https://doi.org/10.3762/bjnano.10.71"
2812 );
2813 assert_eq!(
2814 chemistry[1].source,
2815 "https://digitalcommons.wku.edu/theses/2101/"
2816 );
2817 let scholar = crate::components::engineer::pages()
2818 .into_iter()
2819 .find(|page| page.path == "/engineer/scholar/")
2820 .expect("scholar page");
2821 for row in chemistry {
2822 let at = scholar.body_html.find(row.sentence).unwrap_or_else(|| panic!("missing {}", row.sentence));
2823 let following = &scholar.body_html[at + row.sentence.len()..];
2824 let window = following.chars().take(800).collect::<String>();
2825 assert!(
2826 window.contains(row.source),
2827 "{} is not in the paragraph after {}",
2828 row.source,
2829 row.sentence
2830 );
2831 }
2832 assert!(comparison_errors_at("engineer/scholar/index.html", &scholar.body_html).is_empty());
2833 }
2834
2835 #[test]
2836 fn removed_cuda_bar_sentences_and_tie_variants_fail() {
2837 let bars = [
2838 "Omega's best format beats the best measured CUDA number at one conversation, with golden tokens identical to my host reference.",
2839 "Omega prefill beats the best measured CUDA number at 512 and 8k.",
2840 "Omega total words per second beats the best measured CUDA number at 8 and 32 conversations.",
2841 ];
2842 for bar in bars {
2843 assert!(comparison_problem_on("omega/index.html", bar).is_some(), "{bar}");
2844 assert!(comparison_problem_on("index.html", bar).is_some(), "{bar} is an omega sentence");
2845 let tied = bar.replacen("beats", "matches", 1);
2846 assert_ne!(tied, bar);
2847 assert_eq!(comparison_problem(&tied), Some("unsourced comparison"), "{tied}");
2848 }
2849 assert_eq!(
2850 comparison_problem("Omega prefill matches the best measured CUDA number at 512 and 8k."),
2851 Some("unsourced comparison")
2852 );
2853 }
2854
2855 #[test]
2856 fn arch_review_examples_fail() {
2857 let fail = [
2858 "beats the incumbent",
2859 "faster than the leading GPU stack",
2860 "Nvidia's stack is 3x slower",
2861 "NVIDIA trails Omega",
2862 "reaches NVIDIA parity",
2863 "Omega versus vLLM",
2864 "compared with vLLM",
2865 "matches vLLM",
2866 "tied with vLLM",
2867 "llama.cpp: 1.8x",
2868 "speedup over vLLM: 2x",
2869 "faster&nbsp;than CUDA",
2870 "faster\u{00a0}than CUDA",
2871 "faster<br>than CUDA",
2872 "faster<em>than</em> CUDA",
2873 "faster<span>than</span> CUDA",
2874 "equal to vLLM",
2875 "on par with vLLM",
2876 "matching vLLM",
2877 "match vLLM",
2878 "matched vLLM",
2879 "ties vLLM",
2880 "tie vLLM",
2881 "tied vLLM",
2882 "equal vLLM",
2883 "equaled vLLM",
2884 "compared to vLLM",
2885 "relative to vLLM",
2886 "ahead of vLLM",
2887 "beats the leader",
2888 "faster than the market leader",
2889 "beats the GPU stacks",
2890 "faster than the field",
2891 "beats everyone else",
2892 "faster than existing tools",
2893 "beats Ollama",
2894 "faster than ONNX Runtime",
2895 "beats MLX",
2896 "faster than ROCm",
2897 "beats Groq",
2898 "faster than TensorRT",
2899 "beats SGLang",
2900 ];
2901 for sentence in fail {
2902 assert!(
2903 comparison_problem(sentence).is_some(),
2904 "must fail: {sentence:?} -> {:?}",
2905 comparison_problem(sentence)
2906 );
2907 }
2908 assert!(comparison_errors("faster<br>than CUDA").iter().any(|e| e.contains("faster than CUDA")));
2909 assert_eq!(comparison_problem("beating CUDA"), Some("overclaim"));
2910 assert_eq!(comparison_problem("beating CUDA today"), Some("overclaim"));
2911 assert_eq!(comparison_problem("replacement for the CUDA user stack"), Some("overclaim"));
2912 assert_eq!(comparison_problem("a replacement for CUDA"), Some("overclaim"));
2913 assert_eq!(
2914 comparison_problem("a clean-room replacement for the CUDA user stack"),
2915 Some("overclaim")
2916 );
2917 assert!(
2918 comparison_problem("a replacement for CUDA++").is_none(),
2919 "a replacement for CUDA++ is this project's GPU half, not the replacement-for-CUDA overclaim: {:?}",
2920 comparison_problem("a replacement for CUDA++")
2921 );
2922 assert_eq!(
2923 comparison_problem("a replacement for one two three four CUDA"),
2924 Some("overclaim"),
2925 "four words between replacement for and CUDA still fail"
2926 );
2927 assert!(
2928 comparison_problem("a replacement for one two three four five CUDA").is_none(),
2929 "five words is past the gap: {:?}",
2930 comparison_problem("a replacement for one two three four five CUDA")
2931 );
2932 for sentence in [
2933 "a replacement for the stack, CUDA is named later",
2934 "a replacement for the stack; CUDA stays",
2935 "a replacement for the stack: CUDA stays",
2936 "a replacement for the stack. CUDA stays",
2937 "a replacement for the stack \u{2014} CUDA stays",
2938 "a replacement for the stack \u{2013} CUDA stays",
2939 "a replacement for (CUDA)",
2940 "not a replacement for CUDA",
2941 "isn't a replacement for CUDA",
2942 ] {
2943 assert!(
2944 comparison_problem(sentence).is_none(),
2945 "gap, clause break, or negation must pass: {sentence:?} -> {:?}",
2946 comparison_problem(sentence)
2947 );
2948 }
2949 assert_eq!(
2950 comparison_problem("This is not really a replacement for CUDA"),
2951 Some("overclaim"),
2952 "a not that is not the word before replacement still fails"
2953 );
2954 for sentence in [
2955 "not only a replacement for CUDA",
2956 "not just a replacement for CUDA",
2957 "no longer just a replacement for CUDA",
2958 ] {
2959 assert_eq!(
2960 comparison_problem(sentence),
2961 Some("overclaim"),
2962 "a negation that does not cover the claim still fails: {sentence}"
2963 );
2964 }
2965 assert_eq!(
2966 comparison_problem("aien-serve-http equalled vLLM."),
2967 Some("unsourced comparison")
2968 );
2969 assert_eq!(comparison_problem("Omega rivaled vLLM."), Some("unsourced comparison"));
2970 assert_eq!(comparison_problem("Omega rivalled vLLM."), Some("unsourced comparison"));
2971 assert_eq!(comparison_problem("Omega rivals vLLM."), Some("unsourced comparison"));
2972 assert_eq!(
2973 comparison_problem("aien-serve-http matched vLLM and llama.cpp on Qwen3.6-35B-A3B."),
2974 Some("unsourced comparison")
2975 );
2976 assert_eq!(
2977 comparison_problem("Omega prefill matched the best measured CUDA number"),
2978 Some("unsourced comparison")
2979 );
2980 assert!(
2981 comparison_problem("The total equals 4.").is_none(),
2982 "equals with no rival is not a tie: {:?}",
2983 comparison_problem("The total equals 4.")
2984 );
2985 assert!(
2986 comparison_problem("The notes matched.").is_none(),
2987 "matched with no rival is not a tie: {:?}",
2988 comparison_problem("The notes matched.")
2989 );
2990 assert!(
2991 comparison_problem("convert once ahead of time and store").is_none(),
2992 "ahead of time is an idiom: {:?}",
2993 comparison_problem("convert once ahead of time and store")
2994 );
2995 assert_eq!(
2996 comparison_problem("Omega is ahead of NVIDIA."),
2997 Some("unsourced comparison"),
2998 "ahead of a rival is still a comparison"
2999 );
3000 assert!(
3001 comparison_problem("Session-limit cutoff 2026-10-19 ~19:3x CDT killed 9 Claude agents.").is_none(),
3002 "a clock token is not a multiplier: {:?}",
3003 comparison_problem("Session-limit cutoff 2026-10-19 ~19:3x CDT killed 9 Claude agents.")
3004 );
3005 assert!(
3006 comparison_problem("Noted at ~19:30 CDT on 2026-10-19.").is_none(),
3007 "a timestamp is not a multiplier: {:?}",
3008 comparison_problem("Noted at ~19:30 CDT on 2026-10-19.")
3009 );
3010 assert_eq!(
3011 comparison_problem("On 2026-10-19 at ~19:30 CDT the run was 3x faster than vLLM."),
3012 Some("unsourced comparison"),
3013 "a real multiplier beside a timestamp still fails"
3014 );
3015 assert!(
3016 comparison_problem("That grip holds back every rival chipmaker.").is_none(),
3017 "holds back plus a rival noun is not a comparison: {:?}",
3018 comparison_problem("That grip holds back every rival chipmaker.")
3019 );
3020 assert!(
3021 comparison_problem("holds back every rival chipmaker, every independent builder, and every person who wants intelligence running on hardware they own.").is_none(),
3022 "the call-to-humanity sentence is not a comparison: {:?}",
3023 comparison_problem("holds back every rival chipmaker, every independent builder, and every person who wants intelligence running on hardware they own.")
3024 );
3025 assert_eq!(
3026 comparison_problem("Omega is faster than every rival chipmaker."),
3027 Some("unsourced comparison"),
3028 "a rival noun with a real comparative still fails"
3029 );
3030 assert_eq!(
3031 comparison_problem("This rivals vLLM."),
3032 Some("unsourced comparison"),
3033 "the verb rivals is still a comparison"
3034 );
3035 assert!(
3036 comparison_problem("beating CUDA++").is_none(),
3037 "beating CUDA++ is this project's GPU half, not the beating-CUDA overclaim: {:?}",
3038 comparison_problem("beating CUDA++")
3039 );
3040 for sentence in [
3041 "The GPU half of Omega, with no NVIDIA software.",
3042 "parity with CUDA++",
3043 "twice CUDA++",
3044 "answers matching the shipped reference.",
3045 "Understanding versus search.",
3046 "How hard was it compared with verifying it?",
3047 "A paper projects average investment equal to 3.63% of U.S. GDP per year.",
3048 "Claude Max 20x plan.",
3049 ] {
3050 assert!(comparison_problem(sentence).is_none(), "must pass: {sentence:?} -> {:?}", comparison_problem(sentence));
3051 }
3052 }
3053
3054 #[test]
3055 fn llms_full_is_checked_section_by_section() {
3056 let ledger = "id\titem\nL1\tCUDA++ developer experience includes a D-bar that beats CUDA in the written plan for the driver work\n";
3057 let doc = "\
3058# Sovereign Intelligence
3059
3060The site in one file.
3061
3062---
3063
3064# A Call to Humanity
3065
3066Source: https://www.aienos.com/call-to-humanity/
3067
3068This beats vLLM with no date.
3069
3070---
3071
3072# Now
3073
3074Source: https://www.aienos.com/now/
3075
3076CUDA++ developer experience includes a D-bar that beats CUDA in the written plan for the driver work
3077The now page itself is faster than vLLM.
3078
3079---
3080
3081# Agents
3082
3083Source: https://www.aienos.com/agents/
3084
3085Same-Spark end-to-end head-to-head: aien-serve-http vs vLLM vs llama.cpp.
3086
3087---
3088
3089# Nowhere
3090
3091Source: https://example.com/not-a-page
3092
3093Omega beats CUDA.
3094
3095---
3096
3097# Reference
3098
3099Source: https://www.aienos.com/omega/reference/
3100
3101```
3102note collatz: exceeding it traps 4
3103---
3104```
3105
3106The reference page itself is faster than CUDA.
3107";
3108 let problems = llms_full_problems(doc, ledger);
3109 let joined = problems.join("\n");
3110 assert!(
3111 joined.contains("call-to-humanity/index.html") && joined.contains("beats vLLM"),
3112 "call-to-humanity is a live page and must be scanned: {joined}"
3113 );
3114 assert!(!joined.contains("D-bar that beats CUDA"), "a ledger excerpt is not a new page claim: {joined}");
3115 assert!(joined.contains("now/index.html") && joined.contains("faster than vLLM"), "the now page's own sentence still fails: {joined}");
3116 assert!(joined.contains("agents/index.html") && joined.contains("vs vLLM"), "a live page section still fails: {joined}");
3117 assert!(joined.contains("unmapped"), "an unmapped source fails closed: {joined}");
3118 assert!(!joined.contains("exceeding it traps"), "program text in a fence is not page prose: {joined}");
3119 assert!(
3120 joined.contains("omega/reference/index.html") && joined.contains("faster than CUDA"),
3121 "prose after a fence is still checked: {joined}"
3122 );
3123 assert!(!is_prose_exempt("llms-full.txt"), "the aggregate file is not itself exempt");
3124 assert!(!is_prose_exempt("public/llms-full.txt"));
3125 assert!(
3126 joined.contains("missing Published header"),
3127 "a section with no header line still reports it: {joined}"
3128 );
3129 }
3130
3131 #[test]
3132 fn llms_full_published_header_and_second_source_fail_closed() {
3133 let missing = "\
3134---
3135
3136# Call
3137
3138Source: https://www.aienos.com/call-to-humanity/
3139
3140This beats vLLM.
3141";
3142 let missing_problems = llms_full_problems(missing, "").join("\n");
3143 assert!(
3144 missing_problems.contains("missing Published header"),
3145 "{missing_problems}"
3146 );
3147 assert!(
3148 missing_problems.contains("call-to-humanity/index.html") && missing_problems.contains("beats vLLM"),
3149 "the body is still scanned: {missing_problems}"
3150 );
3151
3152 let doubled = "\
3153---
3154
3155# Now
3156
3157Source: https://www.aienos.com/now/
3158Published: 2026-10-16. Last changed: 2026-10-16T16:29:47Z.
3159
3160Source: https://www.aienos.com/agents/
3161
3162Omega beats CUDA.
3163";
3164 let doubled_problems = llms_full_problems(doubled, "").join("\n");
3165 assert!(doubled_problems.contains("second Source"), "{doubled_problems}");
3166 assert!(
3167 !doubled_problems.contains("missing Published"),
3168 "a real header directly after Source is not an error: {doubled_problems}"
3169 );
3170 assert!(
3171 doubled_problems.contains("now/index.html") && doubled_problems.contains("beats CUDA"),
3172 "{doubled_problems}"
3173 );
3174 assert!(
3175 !doubled_problems.contains("agents/index.html"),
3176 "a second Source does not move the section: {doubled_problems}"
3177 );
3178
3179 let offset = "\
3180---
3181
3182# Now
3183
3184Source: https://www.aienos.com/now/
3185Published: 2026-09-23. Last changed: 2026-10-30T16:17:50+00:00.
3186
3187Published: the paper is a replacement for CUDA.
3188";
3189 let offset_problems = llms_full_problems(offset, "").join("\n");
3190 assert!(
3191 !offset_problems.contains("missing Published"),
3192 "a numeric offset header is the real format: {offset_problems}"
3193 );
3194 assert!(
3195 offset_problems.contains("now/index.html") && offset_problems.contains("overclaim"),
3196 "a later Published line is prose: {offset_problems}"
3197 );
3198
3199 let fake = "\
3200---
3201
3202# Now
3203
3204Source: https://www.aienos.com/now/
3205Published: yesterday.
3206";
3207 let fake_problems = llms_full_problems(fake, "").join("\n");
3208 assert!(
3209 fake_problems.contains("missing Published header"),
3210 "{fake_problems}"
3211 );
3212 }
3213
3214 #[test]
3215 fn removed_planned_head_to_head_and_results_are_refused() {
3216 const PLANNED: &str = "Same-Spark end-to-end head-to-head: aien-serve-http vs vLLM vs llama.cpp, Qwen3.6-35B-A3B (bar P0).";
3217 assert!(!FIXED_SENTENCES.iter().any(|row| row.sentence == PLANNED));
3218 const DESCRIPTION: &str = "End-to-end Omega measurements on my DGX Spark, with the model, prompts, output length, dates and receipts recorded (bar P0).";
3219 let raw = include_str!("../../../../public/data/agent-repos.json");
3220 let line = raw.lines().position(|l| l.contains(DESCRIPTION)).expect("Omega measurement description") + 1;
3221 assert_eq!(line, 197);
3222 assert!(comparison_errors_at("agents/index.html", DESCRIPTION).is_empty());
3223 let omega: serde_json::Value = serde_json::from_str(include_str!("../../data/omega.json")).expect("omega.json");
3224 let p0 = omega["performance"]["bar"]
3225 .as_array()
3226 .expect("bar")
3227 .iter()
3228 .find(|bar| bar["id"] == "P0")
3229 .expect("bar P0");
3230 assert_eq!(p0["status"], "MISSING");
3231 assert!(p0["receipt"].is_null());
3232 assert!(comparison_problem_on("agents/index.html", PLANNED).is_some());
3233 assert!(comparison_problem_on("omega/index.html", PLANNED).is_some());
3234 assert!(comparison_problem(&format!("Done when: {PLANNED}")).is_some());
3235 for phrase in ["beats vLLM", "is 2x faster than vLLM"] {
3236 let changed = PLANNED.replacen("vs vLLM", phrase, 1);
3237 assert_ne!(changed, PLANNED);
3238 assert_eq!(comparison_problem(&changed), Some("unsourced comparison"));
3239 }
3240 assert_eq!(comparison_problem("aien-serve-http beats vLLM"), Some("unsourced comparison"));
3241 }
3242
3243 #[test]
3244 fn call_to_humanity_has_no_comparison_allowances() {
3245 assert!(FIXED_SENTENCES.iter().all(|row| !row.pages.contains(&"call-to-humanity/index.html")));
3246 let summary = "An open letter: what I built on one NVIDIA GB10, what was measured, and how to check it, built in the open, with public receipts.";
3247 let working = "This letter is how I am starting: the GPU software I wrote for the NVIDIA GB10, built in the open, with receipts anyone on Earth can check.";
3248 let gb10 = "What exists today is CUDA++, the GPU machine-code toolchain and runtime I wrote for the GB10.";
3249 let seo = include_str!("../seo.rs");
3250 let seo_line = seo.lines()
3251 .find(|line| line.contains("path: \"/call-to-humanity/\""))
3252 .expect("seo.rs has a PageInfo for /call-to-humanity/");
3253 assert!(seo_line.contains(summary), "the page summary stays in the catalogue");
3254 let html = include_str!("../../../../public/call-to-humanity/index.html");
3255 for sentence in [summary, working, gb10] {
3256 assert!(html.contains(sentence), "the page carries the neutral sentence: {sentence}");
3257 assert!(comparison_problem_on("call-to-humanity/index.html", sentence).is_none());
3258 assert!(comparison_problem_on("omega/index.html", sentence).is_none());
3259 }
3260 let catalogue = format!("- [A Call to Humanity](https://www.aienos.com/call-to-humanity/): {summary} DOI 10.5281/zenodo.23614947.");
3261 assert!(comparison_errors_at("llms.txt", &catalogue).is_empty());
3262 assert!(comparison_errors_at("public/call-to-humanity/index.html", html).is_empty());
3263 let sectioned = format!(
3264 "---\n\n# Call\n\nSource: https://www.aienos.com/call-to-humanity/\nPublished: 2026-10-24. Last changed: 2026-10-16T16:29:47Z.\n\n{working}\n"
3265 );
3266 assert!(llms_full_problems(&sectioned, "").is_empty());
3267 let retired = [
3268 "An open letter on breaking the CUDA stranglehold on the hardware market: a clean-room replacement for the CUDA user stack, built in the open, with public receipts.",
3269 "I intend to break it, and this letter is how I am starting: a working replacement for the CUDA user software layer, built in the open, with receipts anyone on Earth can check.",
3270 "What exists today is a clean-room replacement for the CUDA user stack on the GB10, with no nvcc, no libcuda, and no cuBLAS at run time.",
3271 ];
3272 for sentence in retired {
3273 assert!(!html.contains(sentence), "the retired comparison is absent: {sentence}");
3274 for path in ["call-to-humanity/index.html", "public/call-to-humanity/index.html", "omega/index.html"] {
3275 assert_eq!(comparison_problem_on(path, sentence), Some("overclaim"), "{path}: {sentence}");
3276 assert!(comparison_problem_on(path, &format!("Done when: {sentence}")).is_some());
3277 }
3278 let wrapped = format!("- [A Call to Humanity](https://www.aienos.com/call-to-humanity/): {sentence}");
3279 assert!(comparison_errors_at("llms.txt", &wrapped).iter().any(|e| e.contains("overclaim")));
3280 let sectioned = format!(
3281 "---\n\n# Call\n\nSource: https://www.aienos.com/call-to-humanity/\nPublished: 2026-10-24. Last changed: 2026-10-16T16:29:47Z.\n\n{sentence}\n"
3282 );
3283 let problems = llms_full_problems(&sectioned, "").join("\n");
3284 assert!(problems.contains("call-to-humanity/index.html") && problems.contains("overclaim"));
3285 let changed = sentence.replacen("replacement", "partial replacement", 1);
3286 assert_ne!(changed, sentence);
3287 assert_eq!(comparison_problem(&changed), Some("overclaim"));
3288 }
3289 assert_eq!(comparison_problem("a replacement for CUDA"), Some("overclaim"));
3290 assert_eq!(comparison_problem("The lab page is a replacement for CUDA."), Some("overclaim"));
3291 assert!(comparison_problem("I only compare my work with other systems when I can show a dated receipt.").is_none());
3292 }
3293
3294 #[test]
3295 fn engineer_json_unsourced_comparison_fails_the_build() {
3296 let raw = include_str!("../../../../public/data/engineer.json");
3297 let line = raw
3298 .lines()
3299 .position(|l| l.contains("Platinum deposited this way outperformed"))
3300 .expect("chemistry sentence")
3301 + 1;
3302 assert_eq!(line, 91, "body_html holds the sentences; line 89 is the description");
3303 assert!(!raw.lines().nth(88).unwrap().contains("Platinum deposited"));
3304 let needle = "Platinum deposited this way outperformed organic-solvent materials in photocatalytic dye degradation.";
3305 let doctored = raw.replacen(needle, &format!("{needle} This new line outperforms vLLM."), 1);
3306 assert_ne!(doctored, raw);
3307 let value: serde_json::Value = serde_json::from_str(&doctored).expect("doctored engineer.json still parses");
3308 let body = value["pages"]
3309 .as_array()
3310 .expect("pages")
3311 .iter()
3312 .find_map(|page| {
3313 let body = page["body_html"].as_str()?;
3314 body.contains("This new line outperforms vLLM.").then(|| body.to_string())
3315 })
3316 .expect("the injected sentence is in engineer.json");
3317 let problems = comparison_errors(&body);
3318 assert!(
3319 problems.iter().any(|e| e.contains("unsourced comparison") && e.contains("outperforms vLLM")),
3320 "an unsourced comparison added to engineer.json fails the check the build runs: {problems:?}"
3321 );
3322 let clean: serde_json::Value = serde_json::from_str(raw).expect("engineer.json");
3323 let clean_body = clean["pages"]
3324 .as_array()
3325 .unwrap()
3326 .iter()
3327 .find_map(|page| {
3328 let body = page["body_html"].as_str()?;
3329 body.contains(needle).then_some(body)
3330 })
3331 .unwrap();
3332 assert!(
3333 comparison_errors_at("engineer/scholar/index.html", clean_body).is_empty(),
3334 "{:?}",
3335 comparison_errors_at("engineer/scholar/index.html", clean_body)
3336 );
3337 }
3338
3339 #[test]
3340 fn published_papers_are_exempt_by_exact_path() {
3341 let papers = [
3342 "public/engineer/papers/the-continuation-test.md",
3343 "crates/site-builder/data/models.json",
3344 "public/research/aien-research-plan.md",
3345 "public/research/computing-machinery-and-understanding-emergence/index.html",
3346 "public/research/the-stapleton-doctrine/index.html",
3347 ];
3348 let claim = "This beats vLLM with no date.";
3349 for path in papers {
3350 assert!(is_prose_exempt(path), "{path} missing from the fixed list");
3351 assert!(comparison_errors_at(path, claim).is_empty(), "{path} was scanned");
3352 assert!(!is_prose_exempt(&format!("/tmp/{path}")), "{path} must not match by ending");
3353 assert!(!is_prose_exempt(&format!("dist/{path}")), "{path} must not match by ending");
3354 }
3355 for live in [
3356 "public/call-to-humanity/index.html",
3357 "public/research/index.html",
3358 "omega/index.html",
3359 "dist/omega/index.html",
3360 "public/omega/index.html",
3361 "crates/site-builder/data/omega.json",
3362 "omega.json",
3363 "public/data/engineer.json",
3364 "/engineer/",
3365 "engineer/index.html",
3366 "public/engineer/index.html",
3367 "dist/engineer/index.html",
3368 ] {
3369 assert!(!is_prose_exempt(live), "{live} is a live page and must be scanned");
3370 assert!(!comparison_errors_at(live, claim).is_empty(), "{live} was skipped");
3371 }
3372 assert_eq!(PROSE_EXEMPT_PATHS, papers);
3373 }
3374
3375 #[test]
3376 fn omega_and_every_other_page_use_the_shared_check() {
3377 let omega = crate::components::omega::render_omega_page().into_string();
3378 assert!(!is_prose_exempt("omega/index.html"));
3379 let problems = comparison_errors("This beats vLLM.");
3380 assert!(!problems.is_empty());
3381 let mut bad = Vec::new();
3382 for problem in comparison_errors_at("omega/index.html", &omega) {
3383 bad.push(format!("omega/index.html: {problem}"));
3384 }
3385 let planted = "Measured on 2026-10-21 (https://example.com/bench). vLLM is slower than Omega.";
3386 let problems = comparison_errors(planted);
3387 assert!(
3388 problems.iter().any(|e| e.contains("unsourced comparison") && e.contains("slower than")),
3389 "the same function still refuses a planted sentence: {problems:?}"
3390 );
3391
3392 for page in crate::components::engineer::pages() {
3393 assert!(!is_prose_exempt(&page.path), "engineer page {} must be scanned", page.path);
3394 assert!(
3395 !comparison_errors_at(&page.path, "This beats vLLM.").is_empty(),
3396 "{} must not be skipped",
3397 page.path
3398 );
3399 }
3400
3401 let facts: crate::facts::Facts = serde_json::from_str(include_str!("../../../../facts.json")).expect("facts");
3402 let engineer_pages = crate::components::engineer::pages();
3403 for page in &engineer_pages {
3404 let html = crate::components::engineer::render(page, &engineer_pages, &facts).into_string();
3405 for problem in comparison_errors_at(&page.path, &html) {
3406 bad.push(format!("{}: {problem}", page.path));
3407 }
3408 }
3409
3410 let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
3411 let mut files = Vec::new();
3412 collect_html(&root.join("public"), &mut files);
3413 collect_html(&root.join("crates/site-builder/templates"), &mut files);
3414 collect_named(&root.join("om"), "main.html", &mut files);
3415 assert!(files.len() > 20, "expected the shipped pages, found {}", files.len());
3416 for path in &files {
3417 let text = std::fs::read_to_string(path).unwrap_or_else(|e| panic!("read {}: {e}", path.display()));
3418 let rel = path.strip_prefix(&root).unwrap_or(path);
3419 let rel = rel.to_string_lossy().replace('\\', "/");
3420 let problems = comparison_errors_at(&rel, &text);
3421 if rel == "public/call-to-humanity/index.html" {
3422 assert!(!is_prose_exempt(&rel), "call-to-humanity is a live page");
3423 assert!(
3424 problems.is_empty(),
3425 "the three allowed sentences are exact; nothing else on the page is a hit: {problems:?}"
3426 );
3427 continue;
3428 }
3429 if !problems.is_empty() {
3430 bad.push(format!(
3431 "{}: {}",
3432 path.display(),
3433 problems.iter().map(|e| clip(e, 400)).collect::<Vec<_>>().join(" | ")
3434 ));
3435 }
3436 }
3437 assert!(bad.is_empty(), "pages failed the shared check:\n{}", bad.join("\n"));
3438 assert!(
3439 files.iter().any(|p| p.ends_with("om/alpha-page/main.html")),
3440 "the generated alpha page is scanned, not skipped"
3441 );
3442 }
3443
3444 fn clip(s: &str, n: usize) -> String {
3445 s.chars().take(n).collect()
3446 }
3447
3448 fn collect_html(dir: &std::path::Path, out: &mut Vec<std::path::PathBuf>) {
3449 let rd = std::fs::read_dir(dir).unwrap_or_else(|e| panic!("unreadable directory {}: {e}", dir.display()));
3450 for entry in rd {
3451 let entry = entry.unwrap_or_else(|e| panic!("unreadable directory entry in {}: {e}", dir.display()));
3452 let path = entry.path();
3453 if path.is_dir() {
3454 collect_html(&path, out);
3455 } else if path.extension().and_then(|e| e.to_str()) == Some("html") {
3456 out.push(path);
3457 }
3458 }
3459 }
3460
3461 fn collect_named(dir: &std::path::Path, name: &str, out: &mut Vec<std::path::PathBuf>) {
3462 let rd = std::fs::read_dir(dir).unwrap_or_else(|e| panic!("unreadable directory {}: {e}", dir.display()));
3463 for entry in rd {
3464 let entry = entry.unwrap_or_else(|e| panic!("unreadable directory entry in {}: {e}", dir.display()));
3465 let path = entry.path();
3466 if path.is_dir() {
3467 if path.file_name().and_then(|n| n.to_str()) == Some("vendor") {
3468 continue;
3469 }
3470 collect_named(&path, name, out);
3471 } else if path.file_name().and_then(|n| n.to_str()) == Some(name) {
3472 out.push(path);
3473 }
3474 }
3475 }
3476}