aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / crates / site-builder / src / main.rs
| 1 | mod collector; |
| 2 | mod components; |
| 3 | mod facts; |
| 4 | mod forge; |
| 5 | mod ledger_public; |
| 6 | mod oracle; |
| 7 | mod layouts; |
| 8 | mod seo; |
| 9 | |
| 10 | use std::fs; |
| 11 | use std::io::Write; |
| 12 | use std::path::{Path, PathBuf}; |
| 13 | use std::time::Instant; |
| 14 | |
| 15 | use layouts::base::{render_base_layout, render_page_layout}; |
| 16 | use maud::{html, DOCTYPE}; |
| 17 | |
| 18 | fn copy_dir_all(src: &Path, dst: &Path) -> std::io::Result<()> { |
| 19 | if !src.exists() { |
| 20 | return Ok(()); |
| 21 | } |
| 22 | fs::create_dir_all(dst)?; |
| 23 | for entry in fs::read_dir(src)? { |
| 24 | let entry = entry?; |
| 25 | let ty = entry.file_type()?; |
| 26 | let from = entry.path(); |
| 27 | if entry.file_name() == ".crumb" || entry.file_name() == ".crumb.local" { continue; } |
| 28 | let to = dst.join(entry.file_name()); |
| 29 | if ty.is_dir() { |
| 30 | copy_dir_all(&from, &to)?; |
| 31 | } else { |
| 32 | fs::copy(&from, &to)?; |
| 33 | } |
| 34 | } |
| 35 | Ok(()) |
| 36 | } |
| 37 | |
| 38 | fn render_aienet_document() -> maud::Markup { |
| 39 | render_page_layout( |
| 40 | "Sign your agent up for Aienet | AienOS", |
| 41 | "Human-authorized public agent signup for the Aienet prototype, using Agora profiles.", |
| 42 | "https://www.aienos.com/aienet/", |
| 43 | "website", |
| 44 | html! { |
| 45 | link rel="stylesheet" href="/assets/agora.css"; |
| 46 | @if components::agora::AIENET_HELLO_FORM { script src="/js/aienet.js" defer {} } |
| 47 | }, |
| 48 | components::agora::render_aienet_page(), |
| 49 | ) |
| 50 | } |
| 51 | |
| 52 | fn build_pure_rust_site(dist: &Path, facts_path: &Path) { |
| 53 | if let Ok(ledger) = fs::read_to_string("public/data/now.tsv") { |
| 54 | ledger_public::check_public(&ledger).expect("refusing to build with an unprojected public ledger"); |
| 55 | } else if Path::new("public/data/now.tsv").exists() { |
| 56 | panic!("refusing unreadable public ledger"); |
| 57 | } |
| 58 | let facts = facts::Facts::load(facts_path) |
| 59 | .unwrap_or_else(|e| panic!("Cannot build without facts: {e}. Run `site-builder facts {}` first.", facts_path.display())); |
| 60 | println!(" [FACTS] Using facts gathered at {} from {}", facts.generated_at, facts_path.display()); |
| 61 | println!(" [BUILD] Compiling pure Rust Maud static site into: {}", dist.display()); |
| 62 | fs::create_dir_all(dist.join("assets")).expect("Failed to create assets dir"); |
| 63 | fs::create_dir_all(dist.join("js")).expect("Failed to create js dir"); |
| 64 | |
| 65 | // Copy public assets |
| 66 | let public_dir = Path::new("public"); |
| 67 | if public_dir.exists() { |
| 68 | for entry in fs::read_dir(public_dir).expect("Failed to read public dir") { |
| 69 | let entry = entry.expect("Valid entry"); |
| 70 | let path = entry.path(); |
| 71 | let name = entry.file_name(); |
| 72 | if name == ".crumb" || name == ".crumb.local" { continue; } |
| 73 | let dest = dist.join(&name); |
| 74 | if path.is_dir() { |
| 75 | copy_dir_all(&path, &dest).expect("Failed to copy public subfolder"); |
| 76 | } else { |
| 77 | fs::copy(&path, &dest).expect("Failed to copy public file"); |
| 78 | } |
| 79 | } |
| 80 | println!(" [ASSETS] Synced public/ assets into {}", dist.display()); |
| 81 | } |
| 82 | |
| 83 | // Canonical project state for machines: rendered from the same |
| 84 | // source as the homepage status section (components::status), so |
| 85 | // the page, the JSON, and llms.txt can never drift apart. |
| 86 | fs::write( |
| 87 | dist.join("status.json"), |
| 88 | components::status::status_json(), |
| 89 | ) |
| 90 | .expect("Failed to write status.json"); |
| 91 | // The machines and speeds data, published next to the page that renders it. |
| 92 | fs::write(dist.join("machines.json"), components::machines::RAW) |
| 93 | .expect("Failed to write machines.json"); |
| 94 | println!(" [STATE] Wrote status.json from the canonical layer states"); |
| 95 | |
| 96 | // Render landing page in Maud |
| 97 | let page_content = html! { |
| 98 | (components::alpha::render_alpha_entry()) |
| 99 | (components::lab::render_lab_entry()) |
| 100 | (components::home_loop::render_home_loop()) |
| 101 | (components::story::render_story()) |
| 102 | (components::machines::render_machines_section()) |
| 103 | (components::machines::render_speeds_section()) |
| 104 | (components::evidence::render_evidence()) |
| 105 | (components::matrix::render_matrix()) |
| 106 | (components::research::render_research()) |
| 107 | (components::terminal::render_terminal()) |
| 108 | (components::status::render_status(&facts)) |
| 109 | (components::follow::render_follow()) |
| 110 | }; |
| 111 | |
| 112 | let full_document = render_base_layout(page_content); |
| 113 | let output_file = dist.join("index.html"); |
| 114 | fs::write(&output_file, full_document.into_string()).expect("Failed to write index.html"); |
| 115 | println!(" [PAGE] Emitted / (index.html)"); |
| 116 | fs::copy(facts_path, dist.join("facts.json")).expect("Failed to copy facts.json"); |
| 117 | println!(" [FACTS] Published /facts.json"); |
| 118 | |
| 119 | // /start/: the newcomer route through the project. It carries no status |
| 120 | // figures of its own; it links to the canonical implementation list, |
| 121 | // evidence record and release record, and names the cross-project |
| 122 | // boundaries. |
| 123 | let start_page = render_page_layout( |
| 124 | components::start::TITLE, |
| 125 | components::start::DESCRIPTION, |
| 126 | components::start::URL, |
| 127 | "website", |
| 128 | html! {}, |
| 129 | components::start::render_start_page(), |
| 130 | ); |
| 131 | fs::create_dir_all(dist.join("start")).expect("Failed to create start dir"); |
| 132 | fs::write(dist.join("start/index.html"), start_page.into_string()) |
| 133 | .expect("Failed to write start/index.html"); |
| 134 | println!(" [PAGE] Emitted /start/ (index.html)"); |
| 135 | |
| 136 | // Public project measurements, collected before compilation in CI. |
| 137 | let progress = render_page_layout( |
| 138 | "Project progress | AienOS", |
| 139 | "Explore the retained Aien project history: codebase growth, revisions, test footprint and verification activity, read from public GitHub sources and published with reviewed releases.", |
| 140 | "https://www.aienos.com/progress/", "website", |
| 141 | html! { |
| 142 | link rel="stylesheet" href="/assets/progress.css"; |
| 143 | script defer src="/vendor/d3-7.9.0.min.js" {} |
| 144 | script defer src="/js/project-progress.js" {} |
| 145 | }, components::progress::render_progress_page(), |
| 146 | ); |
| 147 | fs::create_dir_all(dist.join("progress")).expect("Create progress directory"); |
| 148 | fs::write(dist.join("progress/index.html"), progress.into_string()).expect("Write progress page"); |
| 149 | |
| 150 | // Blog index page |
| 151 | let blog_index = render_page_layout( |
| 152 | "Blog | AienOS", |
| 153 | "Research notes on building Aien V2: what shipped, what the evidence says, and what remains an open question.", |
| 154 | "https://www.aienos.com/blog/", |
| 155 | "website", |
| 156 | html! {}, |
| 157 | components::blog::render_blog_index(), |
| 158 | ); |
| 159 | let blog_index_dir = dist.join("blog"); |
| 160 | fs::create_dir_all(&blog_index_dir).expect("Failed to create blog dir"); |
| 161 | fs::write(blog_index_dir.join("index.html"), blog_index.into_string()) |
| 162 | .expect("Failed to write blog index.html"); |
| 163 | println!(" [PAGE] Emitted /blog (index.html)"); |
| 164 | |
| 165 | // First post: the AIEN V3 research plan |
| 166 | let blog_post = render_page_layout( |
| 167 | &format!("{} | AienOS Blog", components::blog::POST_TITLE), |
| 168 | components::blog::POST_DESCRIPTION, |
| 169 | &format!("https://www.aienos.com/blog/{}/", components::blog::POST_SLUG), |
| 170 | "article", |
| 171 | html! {}, |
| 172 | components::blog::render_blog_post(), |
| 173 | ); |
| 174 | let post_dir = blog_index_dir.join(components::blog::POST_SLUG); |
| 175 | fs::create_dir_all(&post_dir).expect("Failed to create post dir"); |
| 176 | fs::write(post_dir.join("index.html"), blog_post.into_string()) |
| 177 | .expect("Failed to write post index.html"); |
| 178 | println!(" [PAGE] Emitted /blog/{} (index.html)", components::blog::POST_SLUG); |
| 179 | |
| 180 | // Research status: ladder, experiment cards, and implementation list, |
| 181 | // all rendered from data/research_status.json. The data file itself is |
| 182 | // published next to it so machines read the same source. |
| 183 | let research_status = render_page_layout( |
| 184 | "Research status | AienOS", |
| 185 | "Where the Aien research stands: the qualification ladder, every experiment with its verdict, receipt and limits, and what is built versus still a hypothesis.", |
| 186 | "https://www.aienos.com/research/status/", |
| 187 | "website", |
| 188 | html! {}, |
| 189 | components::research_status::render_research_status_page(), |
| 190 | ); |
| 191 | let research_status_dir = dist.join("research/status"); |
| 192 | fs::create_dir_all(&research_status_dir).expect("Failed to create research/status dir"); |
| 193 | fs::write(research_status_dir.join("index.html"), research_status.into_string()) |
| 194 | .expect("Failed to write research/status/index.html"); |
| 195 | fs::write(dist.join("research-status.json"), components::research_status::RAW) |
| 196 | .expect("Failed to write research-status.json"); |
| 197 | println!(" [PAGE] Emitted /research/status (index.html) and /research-status.json"); |
| 198 | |
| 199 | // /now/: the live coordination ledger, laid into public/data/now.tsv by |
| 200 | // the pages workflow from the data/now branch (components::now). |
| 201 | let now = components::now::load(); |
| 202 | let now_page = render_page_layout( |
| 203 | components::now::TITLE, |
| 204 | components::now::DESCRIPTION, |
| 205 | components::now::URL, |
| 206 | "website", |
| 207 | html! { link rel="stylesheet" href="/assets/now.css"; }, |
| 208 | components::now::render_now_page(&now), |
| 209 | ); |
| 210 | fs::create_dir_all(dist.join("now")).expect("Failed to create now dir"); |
| 211 | fs::write(dist.join("now/index.html"), now_page.into_string()).expect("Failed to write now/index.html"); |
| 212 | fs::write(dist.join("now.json"), components::now::to_json(&now)).expect("Failed to write now.json"); |
| 213 | println!(" [PAGE] Emitted /now/ ({} ledger lines) and /now.json", now.items.len()); |
| 214 | // /dash/: the one-screen dashboard, from accounts.tsv and routing.tsv on data/now. |
| 215 | let dash = components::dash::load(); |
| 216 | let dash_page = render_page_layout( |
| 217 | components::dash::TITLE, |
| 218 | components::dash::DESCRIPTION, |
| 219 | components::dash::URL, |
| 220 | "website", |
| 221 | html! { link rel="stylesheet" href="/assets/dash.css"; }, |
| 222 | components::dash::render_dash_page(&dash, &now), |
| 223 | ); |
| 224 | fs::create_dir_all(dist.join("dash")).expect("Failed to create dash dir"); |
| 225 | fs::write(dist.join("dash/index.html"), dash_page.into_string()).expect("Failed to write dash/index.html"); |
| 226 | println!(" [PAGE] Emitted /dash/ ({} quota accounts)", dash.quota.accounts.len()); |
| 227 | let hive_page = render_page_layout( |
| 228 | components::hive::TITLE, |
| 229 | components::hive::DESCRIPTION, |
| 230 | components::hive::URL, |
| 231 | "website", |
| 232 | html! { |
| 233 | link rel="stylesheet" href="/assets/hive.css"; |
| 234 | script defer src="/js/hive.js" {} |
| 235 | }, |
| 236 | components::hive::render_hive_page(), |
| 237 | ); |
| 238 | fs::create_dir_all(dist.join("hive")).expect("Create Hive directory"); |
| 239 | fs::write(dist.join("hive/index.html"), hive_page.into_string()).expect("Write Hive page"); |
| 240 | let allen_page = render_page_layout( |
| 241 | components::allen::TITLE, |
| 242 | components::allen::DESCRIPTION, |
| 243 | components::allen::URL, |
| 244 | "website", |
| 245 | html! { |
| 246 | link rel="stylesheet" href="/assets/allen.css"; |
| 247 | link rel="stylesheet" href="/assets/allen-panes.css"; |
| 248 | script defer src="/js/allen.js" {} |
| 249 | script defer src="/js/allen-scene.js" {} |
| 250 | script defer src="/js/allen-audio.js" {} |
| 251 | script defer src="/js/allen-panes.js" {} |
| 252 | script defer src="/js/aien-universe.js" {} |
| 253 | }, |
| 254 | components::allen::render_allen_page(), |
| 255 | ); |
| 256 | fs::create_dir_all(dist.join("aien")).expect("Create Aien directory"); |
| 257 | fs::write(dist.join("aien/index.html"), allen_page.into_string()).expect("Write Aien page"); |
| 258 | // Programs Aien writes run in this document, never in a srcdoc frame, which |
| 259 | // would inherit the page policy (components::csp). A direct visitor sees |
| 260 | // the shared header and footer and a pointer back to /aien/. |
| 261 | let run_page = html! { |
| 262 | (DOCTYPE) |
| 263 | html lang="en" { |
| 264 | head { |
| 265 | meta charset="utf-8"; |
| 266 | meta name="viewport" content="width=device-width, initial-scale=1"; |
| 267 | title { "Program runner | AienOS" } |
| 268 | meta name="description" content="Runs a program Aien wrote, sandboxed, inside the Aien page."; |
| 269 | meta name="robots" content="noindex"; |
| 270 | link rel="icon" type="image/svg+xml" href="/favicon.svg"; |
| 271 | link rel="stylesheet" href="/assets/style.css"; |
| 272 | link rel="stylesheet" href="/assets/site-nav.css"; |
| 273 | link rel="stylesheet" href="/assets/turing-look.css"; |
| 274 | script src=(components::csp::RUNNER_SCRIPT) {} |
| 275 | } |
| 276 | body { |
| 277 | div id="root" style="min-height: 100vh; display: flex; flex-direction: column;" { |
| 278 | (components::navbar::render_navbar()) |
| 279 | main id="main-content" style="flex: 1;" { |
| 280 | section class="container" { |
| 281 | p { "This document runs programs Aien writes, inside a sandboxed frame on " a href="/aien/" { "aienos.com/aien/" } "." } |
| 282 | } |
| 283 | } |
| 284 | (components::footer::render_footer()) |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | }; |
| 289 | fs::write(dist.join(components::csp::RUNNER_PATH), components::csp::enrich(run_page.into_string())).expect("Write the program runner"); |
| 290 | // Old addresses (seo::REDIRECTS) forward visitors, with any ?query and #hash, |
| 291 | // to the new one; /js/redirect.js reads the target from data-to. |
| 292 | for (old, new) in seo::REDIRECTS { |
| 293 | let page = render_page_layout( |
| 294 | &format!("Moved to {new} | AienOS"), |
| 295 | &format!("This page moved to {new}."), |
| 296 | &format!("https://www.aienos.com{new}"), |
| 297 | "website", |
| 298 | html! { |
| 299 | meta name="robots" content="noindex"; |
| 300 | meta http-equiv="refresh" content=(format!("0; url={new}")); |
| 301 | script src="/js/redirect.js" data-to=(new) {} |
| 302 | }, |
| 303 | html! { |
| 304 | section class="container" { |
| 305 | p { "This page moved to " a href=(new) { "aienos.com" (new) } "." } |
| 306 | } |
| 307 | }, |
| 308 | ); |
| 309 | let dir = dist.join(old.trim_matches('/')); |
| 310 | fs::create_dir_all(&dir).expect("Create redirect directory"); |
| 311 | fs::write(dir.join("index.html"), components::csp::enrich(page.into_string())).expect("Write redirect page"); |
| 312 | } |
| 313 | let alpha_page = render_page_layout( |
| 314 | components::alpha::TITLE, |
| 315 | components::alpha::DESCRIPTION, |
| 316 | components::alpha::URL, |
| 317 | "website", |
| 318 | html! { |
| 319 | link rel="stylesheet" href="/assets/alpha.css"; |
| 320 | script defer src="/js/alpha.js" {} |
| 321 | }, |
| 322 | components::alpha::render_alpha_page(), |
| 323 | ); |
| 324 | fs::create_dir_all(dist.join("alpha")).expect("Create Alpha directory"); |
| 325 | fs::write(dist.join("alpha/index.html"), alpha_page.into_string()).expect("Write Alpha page"); |
| 326 | let lab_page = render_page_layout( |
| 327 | components::lab::TITLE, |
| 328 | components::lab::DESCRIPTION, |
| 329 | components::lab::URL, |
| 330 | "website", |
| 331 | html! { |
| 332 | link rel="stylesheet" href="/assets/lab.css"; |
| 333 | script defer src="/js/lab.js" {} |
| 334 | }, |
| 335 | components::lab::render_lab_page(), |
| 336 | ); |
| 337 | fs::create_dir_all(dist.join("lab")).expect("Create Lab directory"); |
| 338 | fs::write(dist.join("lab/index.html"), lab_page.into_string()).expect("Write Lab page"); |
| 339 | let learn_page = render_page_layout( |
| 340 | components::learn::TITLE, |
| 341 | components::learn::DESCRIPTION, |
| 342 | components::learn::URL, |
| 343 | "website", |
| 344 | html! { link rel="stylesheet" href="/assets/learn.css"; }, |
| 345 | components::learn::render_learn_page(), |
| 346 | ); |
| 347 | fs::create_dir_all(dist.join("learn")).expect("Create learning directory"); |
| 348 | fs::write(dist.join("learn/index.html"), learn_page.into_string()).expect("Write learning page"); |
| 349 | // /engineer/: About the engineer, drakestapleton.com merged into this site. |
| 350 | components::engineer::emit(dist, &facts); |
| 351 | // /agents/: every public repository with its agent instructions, from |
| 352 | // public/data/agent-repos.json (refreshed by `site-builder agents`). |
| 353 | let agent_repos = components::agents::Repos::load(Path::new(components::agents::DATA_PATH)) |
| 354 | .unwrap_or_else(|e| panic!("agents: {e}")); |
| 355 | let agents_page = render_page_layout( |
| 356 | components::agents::TITLE, |
| 357 | components::agents::DESCRIPTION, |
| 358 | components::agents::URL, |
| 359 | "website", |
| 360 | html! {}, |
| 361 | components::agents::render_agents_page(&agent_repos), |
| 362 | ); |
| 363 | fs::create_dir_all(dist.join("agents")).expect("Failed to create agents dir"); |
| 364 | fs::write(dist.join("agents/index.html"), agents_page.into_string()).expect("Failed to write agents/index.html"); |
| 365 | println!(" [PAGE] Emitted /agents/ ({} repositories)", agent_repos.listed().len()); |
| 366 | let agents_hello_page = render_page_layout( |
| 367 | components::agents_hello::TITLE, |
| 368 | components::agents_hello::DESCRIPTION, |
| 369 | components::agents_hello::URL, |
| 370 | "website", |
| 371 | html! {}, |
| 372 | components::agents_hello::render_agents_hello_page(), |
| 373 | ); |
| 374 | fs::create_dir_all(dist.join("agents/hello")).expect("Failed to create agents/hello dir"); |
| 375 | fs::write(dist.join("agents/hello/index.html"), agents_hello_page.into_string()).expect("Failed to write agents/hello/index.html"); |
| 376 | println!(" [PAGE] Emitted /agents/hello/"); |
| 377 | |
| 378 | let agents_knowledge_page = render_page_layout( |
| 379 | components::agents_knowledge::TITLE, |
| 380 | components::agents_knowledge::DESCRIPTION, |
| 381 | components::agents_knowledge::URL, |
| 382 | "website", |
| 383 | html! {}, |
| 384 | components::agents_knowledge::render_agents_knowledge_page(), |
| 385 | ); |
| 386 | fs::create_dir_all(dist.join("agents/knowledge")).expect("Failed to create agents/knowledge dir"); |
| 387 | fs::write(dist.join("agents/knowledge/index.html"), agents_knowledge_page.into_string()).expect("Failed to write agents/knowledge/index.html"); |
| 388 | println!(" [PAGE] Emitted /agents/knowledge/"); |
| 389 | |
| 390 | let agora_page = render_page_layout( |
| 391 | components::agora::TITLE, |
| 392 | components::agora::DESCRIPTION, |
| 393 | components::agora::URL, |
| 394 | "website", |
| 395 | html! { |
| 396 | link rel="stylesheet" href="/assets/agora.css"; |
| 397 | script defer src="/js/agora.js" {} |
| 398 | }, |
| 399 | components::agora::render_agora_page(), |
| 400 | ); |
| 401 | fs::create_dir_all(dist.join("agora")).expect("Failed to create agora dir"); |
| 402 | fs::write(dist.join("agora/index.html"), agora_page.into_string()).expect("Failed to write agora/index.html"); |
| 403 | println!(" [PAGE] Emitted /agora/"); |
| 404 | |
| 405 | let aienet_page = render_aienet_document(); |
| 406 | fs::create_dir_all(dist.join("aienet")).expect("Failed to create aienet dir"); |
| 407 | fs::write(dist.join("aienet/index.html"), aienet_page.into_string()).expect("Failed to write aienet/index.html"); |
| 408 | println!(" [PAGE] Emitted /aienet/"); |
| 409 | |
| 410 | let agora_meet_page = render_page_layout( |
| 411 | components::agora_meet::TITLE, |
| 412 | components::agora_meet::DESCRIPTION, |
| 413 | components::agora_meet::URL, |
| 414 | "website", |
| 415 | html! {}, |
| 416 | components::agora_meet::render_agora_meet_page(), |
| 417 | ); |
| 418 | fs::create_dir_all(dist.join("agora/meet")).expect("Failed to create agora/meet dir"); |
| 419 | fs::write(dist.join("agora/meet/index.html"), agora_meet_page.into_string()).expect("Failed to write agora/meet/index.html"); |
| 420 | println!(" [PAGE] Emitted /agora/meet/"); |
| 421 | |
| 422 | let agora_protocol_page = render_page_layout( |
| 423 | components::agora_protocol::TITLE, |
| 424 | components::agora_protocol::DESCRIPTION, |
| 425 | components::agora_protocol::URL, |
| 426 | "website", |
| 427 | html! {}, |
| 428 | components::agora_protocol::render_agora_protocol_page(), |
| 429 | ); |
| 430 | fs::create_dir_all(dist.join("agora/protocol")).expect("Failed to create agora/protocol dir"); |
| 431 | fs::write(dist.join("agora/protocol/index.html"), agora_protocol_page.into_string()).expect("Failed to write agora/protocol/index.html"); |
| 432 | println!(" [PAGE] Emitted /agora/protocol/"); |
| 433 | |
| 434 | let agora_network_page = render_page_layout( |
| 435 | components::agora_network::TITLE, |
| 436 | components::agora_network::DESCRIPTION, |
| 437 | components::agora_network::URL, |
| 438 | "website", |
| 439 | html! {}, |
| 440 | components::agora_network::render_agora_network_page(), |
| 441 | ); |
| 442 | fs::create_dir_all(dist.join("agora/network")).expect("Failed to create agora/network dir"); |
| 443 | fs::write(dist.join("agora/network/index.html"), agora_network_page.into_string()).expect("Failed to write agora/network/index.html"); |
| 444 | println!(" [PAGE] Emitted /agora/network/"); |
| 445 | // /omega/: what Omega is, from data/omega.json (the omega repository's |
| 446 | // docs/OMEGA.md), published next to it as /omega.json. |
| 447 | let omega_page = render_page_layout( |
| 448 | components::omega::TITLE, |
| 449 | components::omega::DESCRIPTION, |
| 450 | components::omega::URL, |
| 451 | "website", |
| 452 | html! { link rel="stylesheet" href="/assets/omega.css"; }, |
| 453 | components::omega::render_omega_page(), |
| 454 | ); |
| 455 | fs::create_dir_all(dist.join("omega")).expect("Failed to create omega dir"); |
| 456 | fs::write(dist.join("omega/index.html"), omega_page.into_string()).expect("Failed to write omega/index.html"); |
| 457 | fs::write(dist.join("omega.json"), components::omega::RAW).expect("Failed to write omega.json"); |
| 458 | println!(" [PAGE] Emitted /omega/ and /omega.json"); |
| 459 | // /omega/reference/: the agent-facing language reference, written by |
| 460 | // seeded Omega (om/omega-reference/page.om, gated by its check.sh). |
| 461 | let omega_ref_page = render_page_layout( |
| 462 | components::omega_reference::TITLE, |
| 463 | components::omega_reference::DESCRIPTION, |
| 464 | components::omega_reference::URL, |
| 465 | "website", |
| 466 | html! { link rel="stylesheet" href="/assets/omega.css"; }, |
| 467 | components::omega_reference::render_omega_reference_page(), |
| 468 | ); |
| 469 | fs::create_dir_all(dist.join("omega/reference")).expect("Failed to create omega/reference dir"); |
| 470 | fs::write(dist.join("omega/reference/index.html"), omega_ref_page.into_string()).expect("Failed to write omega/reference/index.html"); |
| 471 | println!(" [PAGE] Emitted /omega/reference/"); |
| 472 | |
| 473 | // /cudaplusplus/: CUDA++, the GPU half of Omega, from |
| 474 | // data/cudaplusplus.json, published next to it as /cudaplusplus.json. |
| 475 | let cudapp_page = render_page_layout( |
| 476 | components::cudaplusplus::TITLE, |
| 477 | components::cudaplusplus::DESCRIPTION, |
| 478 | components::cudaplusplus::URL, |
| 479 | "website", |
| 480 | html! { link rel="stylesheet" href="/assets/omega.css"; link rel="stylesheet" href="/assets/cudaplusplus.css"; }, |
| 481 | components::cudaplusplus::render_cudaplusplus_page(), |
| 482 | ); |
| 483 | fs::create_dir_all(dist.join("cudaplusplus")).expect("Failed to create cudaplusplus dir"); |
| 484 | fs::write(dist.join("cudaplusplus/index.html"), cudapp_page.into_string()).expect("Failed to write cudaplusplus/index.html"); |
| 485 | fs::write(dist.join("cudaplusplus.json"), components::cudaplusplus::RAW).expect("Failed to write cudaplusplus.json"); |
| 486 | println!(" [PAGE] Emitted /cudaplusplus/ and /cudaplusplus.json"); |
| 487 | |
| 488 | // Research narrative pages (NARR-RESEARCH): The Machine and Scientific Discovery |
| 489 | for (slug, title, description, url, body) in [ |
| 490 | ( |
| 491 | "machine", |
| 492 | components::machine::TITLE, |
| 493 | components::machine::DESCRIPTION, |
| 494 | components::machine::URL, |
| 495 | components::machine::render_machine(), |
| 496 | ), |
| 497 | ( |
| 498 | "discovery", |
| 499 | components::discovery::TITLE, |
| 500 | components::discovery::DESCRIPTION, |
| 501 | components::discovery::URL, |
| 502 | components::discovery::render_discovery(), |
| 503 | ), |
| 504 | ( |
| 505 | "owned", |
| 506 | components::owned::TITLE, |
| 507 | components::owned::DESCRIPTION, |
| 508 | components::owned::URL, |
| 509 | components::owned::render_owned(), |
| 510 | ), |
| 511 | ] { |
| 512 | let page = render_page_layout(title, description, url, "article", html! {}, body); |
| 513 | let page_dir = dist.join(slug); |
| 514 | fs::create_dir_all(&page_dir).expect("Failed to create narrative page dir"); |
| 515 | fs::write(page_dir.join("index.html"), page.into_string()) |
| 516 | .expect("Failed to write narrative page index.html"); |
| 517 | println!(" [PAGE] Emitted /{}/ (index.html)", slug); |
| 518 | } |
| 519 | |
| 520 | // Glossary: the terms of the project, each linked to where it is used. |
| 521 | let glossary = render_page_layout( |
| 522 | components::glossary::TITLE, |
| 523 | components::glossary::DESCRIPTION, |
| 524 | components::glossary::URL, |
| 525 | "website", |
| 526 | html! {}, |
| 527 | components::glossary::render_glossary(), |
| 528 | ); |
| 529 | fs::create_dir_all(dist.join("glossary")).expect("Failed to create glossary dir"); |
| 530 | fs::write(dist.join("glossary/index.html"), glossary.into_string()) |
| 531 | .expect("Failed to write glossary/index.html"); |
| 532 | println!(" [PAGE] Emitted /glossary/ (index.html)"); |
| 533 | |
| 534 | let privacy = render_page_layout( |
| 535 | "Privacy & saying hello to Aien | AienOS", |
| 536 | "Privacy, operational logs and the separate choices for talking to Aien. No advertising trackers.", |
| 537 | "https://www.aienos.com/privacy/", |
| 538 | "website", |
| 539 | html! {}, |
| 540 | components::allen_intro::render_privacy(), |
| 541 | ); |
| 542 | fs::create_dir_all(dist.join("privacy")).expect("Create privacy directory"); |
| 543 | fs::write(dist.join("privacy/index.html"), privacy.into_string()).expect("Write privacy page"); |
| 544 | |
| 545 | // Where I am and how to reach me: X, email, Allen and the forge. |
| 546 | let contact = render_page_layout( |
| 547 | components::contact::TITLE, |
| 548 | components::contact::DESCRIPTION, |
| 549 | components::contact::URL, |
| 550 | "website", |
| 551 | html! {}, |
| 552 | components::contact::render_contact(), |
| 553 | ); |
| 554 | fs::create_dir_all(dist.join("contact")).expect("Create contact directory"); |
| 555 | fs::write(dist.join("contact/index.html"), contact.into_string()).expect("Write contact page"); |
| 556 | |
| 557 | let support = render_page_layout( |
| 558 | components::support::TITLE, |
| 559 | components::support::DESCRIPTION, |
| 560 | components::support::URL, |
| 561 | "website", |
| 562 | html! {}, |
| 563 | components::support::render_page(), |
| 564 | ); |
| 565 | fs::create_dir_all(dist.join("support")).expect("Create support directory"); |
| 566 | fs::write(dist.join("support/index.html"), support.into_string()).expect("Write support page"); |
| 567 | |
| 568 | let still_building = render_page_layout( |
| 569 | components::still_building::TITLE, |
| 570 | components::still_building::DESCRIPTION, |
| 571 | components::still_building::URL, |
| 572 | "website", |
| 573 | html! { link rel="stylesheet" href="/assets/still-building.css"; }, |
| 574 | components::still_building::render_page(), |
| 575 | ); |
| 576 | fs::create_dir_all(dist.join("still-building")).expect("Create still-building directory"); |
| 577 | fs::write(dist.join("still-building/index.html"), still_building.into_string()).expect("Write still-building page"); |
| 578 | println!(" [PAGE] Emitted /contact/ (index.html)"); |
| 579 | |
| 580 | // Section hubs: /experiments/, /evidence/, /philosophy/ (NARR-NAV) |
| 581 | components::hubs::emit_hub_pages(dist); |
| 582 | |
| 583 | // The 404 page, served by SiteHub on my own hardware for any address that has no file. |
| 584 | let not_found = render_page_layout( |
| 585 | "Page not found | AienOS", |
| 586 | "There is nothing at this address. Every page of AienOS is listed in llms.txt and the sitemap; the front page, the machine and the research are one link away.", |
| 587 | "", |
| 588 | "website", |
| 589 | seo::head_404(), |
| 590 | seo::render_404(), |
| 591 | ); |
| 592 | fs::write(dist.join("404.html"), components::csp::enrich(components::allen_intro::enrich(components::support::enrich(not_found.into_string())))).expect("Failed to write 404.html"); |
| 593 | |
| 594 | // Every page written above (generated or copied from public/) gets the same |
| 595 | // head: www canonical, cards, feeds, JSON-LD. Then the machine |
| 596 | // surface is written from the pages that actually exist. |
| 597 | let ctx = seo::BuildCtx::gather(&now, &facts.generated_at); |
| 598 | let pages = seo::enrich(dist, &ctx); |
| 599 | seo::write_machine_surface(dist, &pages, &now, &ctx, &components::status::llms_txt()); |
| 600 | } |
| 601 | |
| 602 | fn comparison_page_key(dist: &Path, path: &Path) -> String { |
| 603 | let rel = path.strip_prefix(dist).unwrap_or(path); |
| 604 | let rel = rel.to_string_lossy().replace('\\', "/"); |
| 605 | let source = format!("public/{rel}"); |
| 606 | if components::machines::is_prose_exempt(&source) { |
| 607 | source |
| 608 | } else { |
| 609 | rel |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | fn is_scanned_comparison_file(path: &Path) -> bool { |
| 614 | let name = path.file_name().and_then(|n| n.to_str()).unwrap_or(""); |
| 615 | path.extension().and_then(|e| e.to_str()) == Some("html") |
| 616 | || name == "llms.txt" |
| 617 | || name == "llms-full.txt" |
| 618 | } |
| 619 | |
| 620 | fn collect_comparison_pages(dist: &Path, dir: &Path, bad: &mut Vec<(PathBuf, String)>) -> Result<(), String> { |
| 621 | let rd = match fs::read_dir(dir) { |
| 622 | Ok(rd) => rd, |
| 623 | Err(e) => { |
| 624 | let msg = format!("unreadable directory {}: {e}", dir.display()); |
| 625 | eprintln!("{msg}"); |
| 626 | return Err(msg); |
| 627 | } |
| 628 | }; |
| 629 | for entry in rd { |
| 630 | let entry = match entry { |
| 631 | Ok(entry) => entry, |
| 632 | Err(e) => { |
| 633 | let msg = format!("unreadable directory entry in {}: {e}", dir.display()); |
| 634 | eprintln!("{msg}"); |
| 635 | return Err(msg); |
| 636 | } |
| 637 | }; |
| 638 | let path = entry.path(); |
| 639 | if path.is_dir() { |
| 640 | collect_comparison_pages(dist, &path, bad)?; |
| 641 | } else if is_scanned_comparison_file(&path) { |
| 642 | let content = match fs::read_to_string(&path) { |
| 643 | Ok(content) => content, |
| 644 | Err(e) => { |
| 645 | let msg = format!("unreadable file {}: {e}", path.display()); |
| 646 | eprintln!("{msg}"); |
| 647 | return Err(msg); |
| 648 | } |
| 649 | }; |
| 650 | if path.file_name().and_then(|n| n.to_str()) == Some("llms-full.txt") { |
| 651 | let ledger = fs::read_to_string(dist.join("data/now.tsv")).unwrap_or_default(); |
| 652 | for problem in components::machines::llms_full_problems(&content, &ledger) { |
| 653 | bad.push((path.clone(), problem)); |
| 654 | } |
| 655 | } else { |
| 656 | let key = comparison_page_key(dist, &path); |
| 657 | for problem in components::machines::comparison_errors_at(&key, &content) { |
| 658 | bad.push((path.clone(), problem)); |
| 659 | } |
| 660 | } |
| 661 | } |
| 662 | } |
| 663 | Ok(()) |
| 664 | } |
| 665 | |
| 666 | fn verify_site(dist: &Path) { |
| 667 | let index_file = dist.join("index.html"); |
| 668 | let ledger_path = dist.join("data/now.tsv"); |
| 669 | if ledger_path.exists() { |
| 670 | let ledger = fs::read_to_string(&ledger_path).expect("unreadable published ledger"); |
| 671 | ledger_public::check_public(&ledger).expect("refusing unprojected published ledger"); |
| 672 | } |
| 673 | assert!(index_file.exists(), "Required index.html missing in {}", dist.display()); |
| 674 | // No translated copy, the registry both ways, every head, the six |
| 675 | // destinations on every page, the root's Allen door and classic links |
| 676 | // (oracle::check_root), every script and stylesheet resolving inside |
| 677 | // dist, and every published data file: gates that hold on any tree. |
| 678 | oracle::verify(dist); |
| 679 | |
| 680 | // The root is Allen's native front door (the approved redesign); the |
| 681 | // former front page lives whole at /classic/ and is checked below. |
| 682 | let root = fs::read_to_string(&index_file).expect("Failed to read index.html"); |
| 683 | assert!(!root.contains("fonts.googleapis.com"), "Outside font loaded in index.html"); |
| 684 | assert!(!root.contains('\u{2014}') && !root.contains('\u{2013}'), "Forbidden dash in index.html"); |
| 685 | |
| 686 | let classic_file = dist.join("classic/index.html"); |
| 687 | let content = fs::read_to_string(&classic_file).expect("Failed to read classic/index.html, the former front page"); |
| 688 | |
| 689 | // The former front page, now /classic/: every invariant it carried. |
| 690 | assert!(content.contains("<div id=\"root\""), "Missing #root element in classic/index.html"); |
| 691 | assert!(content.contains("<main id=\"main-content\""), "Missing main container in classic/index.html"); |
| 692 | assert!(content.contains("id=\"terminal-output\""), "Missing interactive terminal output in classic/index.html"); |
| 693 | assert!(content.contains("id=\"follow\""), "Missing follow section in classic/index.html"); |
| 694 | assert!(content.contains("href=\"/now/\""), "Missing the Now link in the classic follow section"); |
| 695 | assert!(content.contains("id=\"receipt\""), "Missing verification receipt in classic/index.html"); |
| 696 | assert!(content.contains("id=\"live\""), "Missing live components block in classic/index.html"); |
| 697 | assert!(!content.contains("fonts.googleapis.com"), "Outside font loaded in classic/index.html"); |
| 698 | assert!(dist.join("facts.json").exists(), "Missing facts.json"); |
| 699 | |
| 700 | // Homepage top (NARR-HOME): literal phrases, so a wording change in the |
| 701 | // component cannot pass by accident. |
| 702 | for phrase in [ |
| 703 | "AienOS is an owned experimental machine for turning search into verified understanding.", |
| 704 | "Weights suggest. Programs explain. Verification decides. Evidence teaches. The Turing keeps score.", |
| 705 | "Did it learn anything?", |
| 706 | "What did it cost to learn?", |
| 707 | "Did what it learned make future discovery easier?", |
| 708 | ] { |
| 709 | assert!(content.contains(phrase), "Missing former homepage phrase in classic/index.html: {phrase}"); |
| 710 | } |
| 711 | assert!(content.contains("<ol class=\"loop-stages\""), "Missing loop stage list in classic/index.html"); |
| 712 | |
| 713 | // The machines and the speeds (components::machines): five machines, |
| 714 | // the 35B end to end first, every number beside its receipt. An honest |
| 715 | // dated sourced comparison may appear. Overclaims and unsourced |
| 716 | // comparisons may not. |
| 717 | assert!(content.contains("id=\"machines\""), "Missing machines section in classic/index.html"); |
| 718 | assert!(content.contains("id=\"speed\""), "Missing speed section in classic/index.html"); |
| 719 | for id in ["machine-spark", "machine-imac", "machine-pi5", "machine-qemu", "machine-rig", "speed-35b-e2e", "speed-27b-live"] { |
| 720 | assert!(content.contains(&format!("id=\"{id}\"")), "Missing {id} in classic/index.html"); |
| 721 | } |
| 722 | assert!(content.contains("22.0 to 22.5"), "Missing the 35B end-to-end speed in classic/index.html"); |
| 723 | assert!(content.contains("7.63"), "Missing the 27B chip-time row in classic/index.html"); |
| 724 | { |
| 725 | let problems = components::machines::comparison_errors(&content); |
| 726 | assert!(problems.is_empty(), "Unsourced comparison or overclaim on the classic front page: {problems:?}"); |
| 727 | } |
| 728 | { |
| 729 | let mut bad = Vec::new(); |
| 730 | collect_comparison_pages(dist, dist, &mut bad).expect("comparison scan refused an unreadable directory"); |
| 731 | assert!( |
| 732 | bad.is_empty(), |
| 733 | "Unsourced comparison or overclaim. Every page uses machines::comparison_errors:\n{}", |
| 734 | bad.iter().take(40).map(|(p, e)| format!("{}: {}", p.display(), e.chars().take(300).collect::<String>())).collect::<Vec<_>>().join("\n") |
| 735 | ); |
| 736 | } |
| 737 | assert!(dist.join("assets/machines.css").exists(), "Missing assets/machines.css"); |
| 738 | assert!(dist.join("machines.json").exists(), "Missing machines.json"); |
| 739 | |
| 740 | // Verify asset output |
| 741 | assert!(dist.join("assets/style.css").exists(), "Missing assets/style.css"); |
| 742 | assert!(dist.join("js/terminal.js").exists(), "Missing js/terminal.js"); |
| 743 | |
| 744 | // A stray or missing brace silently nests every later rule inside an |
| 745 | // earlier one (this left the footer unstyled), so refuse unbalanced CSS. |
| 746 | let css = fs::read_to_string(dist.join("assets/style.css")).expect("read assets/style.css"); |
| 747 | let mut depth: i64 = 0; |
| 748 | for ch in css.chars() { |
| 749 | match ch { |
| 750 | '{' => depth += 1, |
| 751 | '}' => depth -= 1, |
| 752 | _ => {} |
| 753 | } |
| 754 | assert!(depth >= 0, "assets/style.css has an unmatched closing brace"); |
| 755 | } |
| 756 | assert_eq!(depth, 0, "assets/style.css has an unclosed rule; later rules would be nested"); |
| 757 | for class in ["aien-footer", "aien-footer-row", "aien-footer-brand", "aien-footer-links", "aien-footer-legal"] { |
| 758 | assert!(css.contains(&format!(".{class}")), "assets/style.css missing footer rule .{class}"); |
| 759 | } |
| 760 | |
| 761 | // Verify Unslop standard |
| 762 | assert!(!content.contains('\u{2014}'), "Forbidden em dash detected in classic/index.html"); |
| 763 | assert!(!content.contains('\u{2013}'), "Forbidden en dash detected in classic/index.html"); |
| 764 | |
| 765 | assert!(dist.join("progress/index.html").exists(), "Missing progress page"); |
| 766 | assert!(dist.join("data/project-progress.json").exists(), "Missing progress dataset"); |
| 767 | assert!(!dist.join("data/.crumb.local").exists(), "Local coordination must not be published"); |
| 768 | |
| 769 | // Verify sitemap and robots |
| 770 | assert!(dist.join("sitemap.xml").exists(), "Missing sitemap.xml"); |
| 771 | assert!(dist.join("robots.txt").exists(), "Missing robots.txt"); |
| 772 | // The whole machine surface: canonical host, JSON-LD, feeds, llms files, data index. |
| 773 | seo::verify(dist); |
| 774 | |
| 775 | // Verify blog pages |
| 776 | let blog_index = dist.join("blog/index.html"); |
| 777 | assert!(blog_index.exists(), "Missing blog/index.html"); |
| 778 | let blog_post = dist.join("blog/aien-v3-research-plan/index.html"); |
| 779 | assert!(blog_post.exists(), "Missing blog/aien-v3-research-plan/index.html"); |
| 780 | let research_status = dist.join("research/status/index.html"); |
| 781 | assert!(research_status.exists(), "Missing research/status/index.html"); |
| 782 | let now_page = dist.join("now/index.html"); |
| 783 | assert!(now_page.exists(), "Missing now/index.html"); |
| 784 | assert!(dist.join("now.json").exists(), "Missing now.json"); |
| 785 | assert!(dist.join("assets/now.css").exists(), "Missing assets/now.css"); |
| 786 | assert!(dist.join("research-status.json").exists(), "Missing research-status.json"); |
| 787 | // /omega/ (components::omega): says what Omega is first, carries the |
| 788 | // CUDA map, the live receipt and the bar, and is linked from the nav |
| 789 | // and from the front page wherever Omega is named. |
| 790 | let omega_page = dist.join("omega/index.html"); |
| 791 | assert!(omega_page.exists(), "Missing omega/index.html"); |
| 792 | assert!(dist.join("omega.json").exists(), "Missing omega.json"); |
| 793 | assert!(dist.join("assets/omega.css").exists(), "Missing assets/omega.css"); |
| 794 | { |
| 795 | let o = fs::read_to_string(&omega_page).expect("read omega page"); |
| 796 | for phrase in [ |
| 797 | "Omega is Aien's language for all computing, GPU to CPU.", |
| 798 | "Omega does not yet cover every GPU layer above the kernel driver", |
| 799 | "id=\"seed-birth\"", |
| 800 | "id=\"cuda-map\"", |
| 801 | "id=\"today\"", |
| 802 | "id=\"not-yet\"", |
| 803 | "id=\"bar\"", |
| 804 | "evidence/WHAT-OMEGA-IS-20261021/live-serve-no-cuda.txt", |
| 805 | ] { |
| 806 | assert!(o.contains(phrase) || o.contains(&phrase.replace("'", "'")), "Missing on /omega/: {phrase}"); |
| 807 | } |
| 808 | assert!(content.contains("href=\"/omega/\""), "The classic front page must link /omega/ where it names Omega"); |
| 809 | assert!(content.contains("href=\"/omega/#seed-birth\""), "The classic front page must link the seed walkthrough"); |
| 810 | assert!(o.contains("href=\"/omega/reference/\""), "/omega/ must link /omega/reference/"); |
| 811 | } |
| 812 | // /omega/reference/ (components::omega_reference): every vendored example |
| 813 | // file is in llms-full.txt byte for byte, so an agent can copy and gate it. |
| 814 | let omega_ref = dist.join("omega/reference/index.html"); |
| 815 | { |
| 816 | let r = fs::read_to_string(&omega_ref).expect("Missing omega/reference/index.html"); |
| 817 | assert!(r.contains(&components::boxlink::project_markup(components::omega_reference::PAGE)), "/omega/reference/ must carry the whole retained body with only owned navigation hrefs projected"); |
| 818 | components::omega_reference::verify_llms_full(dist); |
| 819 | } |
| 820 | // /cudaplusplus/ (components::cudaplusplus): CUDA++ with the plus |
| 821 | // signs, its four sections, linked from the nav, the front page and /omega/. |
| 822 | let cudapp_page = dist.join("cudaplusplus/index.html"); |
| 823 | assert!(cudapp_page.exists(), "Missing cudaplusplus/index.html"); |
| 824 | assert!(dist.join("cudaplusplus.json").exists(), "Missing cudaplusplus.json"); |
| 825 | assert!(dist.join("assets/cudaplusplus.css").exists(), "Missing assets/cudaplusplus.css"); |
| 826 | { |
| 827 | let c = fs::read_to_string(&cudapp_page).expect("read cudaplusplus page"); |
| 828 | for phrase in [ |
| 829 | "CUDA++ is the GPU half of Omega", |
| 830 | "Useful work on a machine I own.", |
| 831 | "id=\"path\"", |
| 832 | "id=\"how\"", |
| 833 | "id=\"pain-points\"", |
| 834 | "id=\"swap\"", |
| 835 | "https://interplane.io/drakestapleton/CUDApp", |
| 836 | ] { |
| 837 | assert!(c.contains(phrase), "Missing on /cudaplusplus/: {phrase}"); |
| 838 | } |
| 839 | assert!(content.contains("href=\"/cudaplusplus/\""), "The classic front page must link /cudaplusplus/"); |
| 840 | let o = fs::read_to_string(&omega_page).expect("read omega page"); |
| 841 | assert!(o.contains("href=\"/cudaplusplus/\""), "/omega/ must link /cudaplusplus/"); |
| 842 | } |
| 843 | for page in [&blog_index, &blog_post, &research_status, &now_page, &omega_page, &omega_ref, &cudapp_page] { |
| 844 | let page_content = fs::read_to_string(page) |
| 845 | .unwrap_or_else(|_| panic!("Failed to read {}", page.display())); |
| 846 | assert!( |
| 847 | !page_content.contains('\u{2014}'), |
| 848 | "Forbidden em dash detected in {}", |
| 849 | page.display() |
| 850 | ); |
| 851 | assert!( |
| 852 | !page_content.contains('\u{2013}'), |
| 853 | "Forbidden en dash detected in {}", |
| 854 | page.display() |
| 855 | ); |
| 856 | assert!( |
| 857 | page_content.contains("og:title"), |
| 858 | "Missing og:title in {}", |
| 859 | page.display() |
| 860 | ); |
| 861 | } |
| 862 | |
| 863 | // Section hubs exist, carry their required phrase and the six-section |
| 864 | // nav, and contain no em or en dash. |
| 865 | components::hubs::verify_hub_pages(dist); |
| 866 | |
| 867 | // Verify research narrative pages (NARR-RESEARCH) |
| 868 | for slug in ["machine", "discovery"] { |
| 869 | let page = dist.join(slug).join("index.html"); |
| 870 | assert!(page.exists(), "Missing {}", page.display()); |
| 871 | let page_content = fs::read_to_string(&page) |
| 872 | .unwrap_or_else(|_| panic!("Failed to read {}", page.display())); |
| 873 | assert!(!page_content.contains('\u{2014}'), "Forbidden em dash detected in {}", page.display()); |
| 874 | assert!(!page_content.contains('\u{2013}'), "Forbidden en dash detected in {}", page.display()); |
| 875 | assert!(page_content.contains("og:title"), "Missing og:title in {}", page.display()); |
| 876 | assert!(page_content.contains("rs-badge"), "Missing data-driven status badges in {}", page.display()); |
| 877 | assert!(!page_content.contains("status-badge"), "Old hand-kept status badge markup in {}", page.display()); |
| 878 | } |
| 879 | // /owned/ is a position page: no status badges, the thesis and signature present, no dashes. |
| 880 | let owned = fs::read_to_string(dist.join("owned/index.html")).expect("Missing owned/index.html"); |
| 881 | assert!(owned.contains(components::owned::THESIS), "Missing thesis in owned/index.html"); |
| 882 | assert!(owned.contains(components::owned::SIGNATURE_LINE), "Missing signature in owned/index.html"); |
| 883 | assert!(owned.contains("og:title"), "Missing og:title in owned/index.html"); |
| 884 | assert!(!owned.contains('\u{2014}') && !owned.contains('\u{2013}'), "Forbidden dash in owned/index.html"); |
| 885 | assert!(!owned.contains("rs-badge"), "Status badge on the position page owned/index.html"); |
| 886 | let machine = fs::read_to_string(dist.join("machine/index.html")).expect("Failed to read machine page"); |
| 887 | assert!(machine.contains(components::narrative::SLOGAN), "Missing slogan in machine/index.html"); |
| 888 | assert!(machine.contains(components::narrative::TURING_FORMULA), "Missing Turing formula in machine/index.html"); |
| 889 | assert!(machine.contains("id=\"real-machines\""), "Missing real-machines section in machine/index.html"); |
| 890 | assert!(machine.find("id=\"real-machines\"") < machine.find("id=\"loop\""), "Real machines must come before the loop in machine/index.html"); |
| 891 | assert!(machine.contains("id=\"research-ladder\""), "Missing research-ladder section in machine/index.html"); |
| 892 | assert!(machine.contains("class=\"rs-ladder\""), "Missing research ladder markup in machine/index.html"); |
| 893 | assert!(machine.contains("class=\"rs-impl\""), "Missing implementation list in machine/index.html"); |
| 894 | |
| 895 | // The newcomer route must reach the canonical status, evidence, |
| 896 | // reproduction and cross-project surfaces. |
| 897 | let start = fs::read_to_string(dist.join("start/index.html")).expect("Failed to read start/index.html"); |
| 898 | for needle in [ |
| 899 | "/machine/#today", |
| 900 | "/research/status/#implementation", |
| 901 | "/evidence/", |
| 902 | "/AGENTS.md", |
| 903 | "/engineer/", |
| 904 | "https://interplane.io/", |
| 905 | ] { |
| 906 | assert!(start.contains(needle), "/start/ is missing {needle}"); |
| 907 | } |
| 908 | |
| 909 | // Every box on every generated page links to its evidence on the forge |
| 910 | // (components::boxlink). A page listed here with a floor below it must |
| 911 | // carry at least that many boxes, so a component that stops rendering |
| 912 | // its cards is caught as well as one that renders them without a link. |
| 913 | let mut boxes_total = 0; |
| 914 | for (page, floor) in GENERATED_PAGES { |
| 915 | let path = dist.join(page); |
| 916 | let html = fs::read_to_string(&path).unwrap_or_else(|_| panic!("Failed to read {}", path.display())); |
| 917 | let n = components::boxlink::check_boxes(&html).unwrap_or_else(|e| panic!("/{page}: {e}")); |
| 918 | assert!(n >= *floor, "/{page}: expected at least {floor} boxes, found {n}"); |
| 919 | boxes_total += n; |
| 920 | } |
| 921 | assert!( |
| 922 | fs::read_to_string(dist.join("assets/turing-look.css")).expect("read turing-look.css").contains(".box-link::after"), |
| 923 | "assets/turing-look.css must stretch .box-link over its box" |
| 924 | ); |
| 925 | // About the engineer: every page written, filled and self-contained. |
| 926 | components::engineer::verify(dist); |
| 927 | // Drake writes alone: no we, us, our, ours or ourselves in rendered copy. |
| 928 | components::voice::verify_singular_voice(dist); |
| 929 | // Ledger rows keep their historical wording; withdrawn phrases carry the 2026-11-07 note on every /now/ surface. |
| 930 | components::now::verify_withdrawn_notes(dist); |
| 931 | // Published only with reviewed releases: no page claims an hourly or GitHub refresh. |
| 932 | components::voice::verify_no_refresh_claims(dist); |
| 933 | // Project, product and vendor names spelled one way: AienOS, Aien, GitHub, NVIDIA. |
| 934 | components::names::verify_canonical_names(dist); |
| 935 | // Every page shows the X contact button in its header and the contact line in its footer. |
| 936 | components::contact::verify(dist); |
| 937 | // Every page carries its Content-Security-Policy and needs no inline script. |
| 938 | components::csp::verify(dist); |
| 939 | |
| 940 | println!("------------------------------------------------------------"); |
| 941 | println!(" Verified index.html ({} bytes) and classic/index.html ({} bytes)", root.len(), content.len()); |
| 942 | println!(" Every box links to the forge: {boxes_total} boxes across {} pages", GENERATED_PAGES.len()); |
| 943 | println!(" Integrity & Unslop Invariants: PASS"); |
| 944 | } |
| 945 | |
| 946 | /// Every page this builder generates, with the least number of boxes it |
| 947 | /// must carry. /now/ has no floor because the ledger may be absent. |
| 948 | const GENERATED_PAGES: &[(&str, usize)] = &[ |
| 949 | ("index.html", 0), |
| 950 | ("classic/index.html", 30), |
| 951 | ("discoveries/index.html", 0), |
| 952 | ("aien/index.html", 0), |
| 953 | ("alpha/index.html", 0), |
| 954 | ("research/computing-machinery-and-understanding/profiles/index.html", 0), |
| 955 | ("support/index.html", 0), |
| 956 | ("still-building/index.html", 0), |
| 957 | ("start/index.html", 0), |
| 958 | ("privacy/index.html", 0), |
| 959 | ("contact/index.html", 0), |
| 960 | ("machine/index.html", 15), |
| 961 | ("discovery/index.html", 0), |
| 962 | ("experiments/index.html", 15), |
| 963 | ("evidence/index.html", 7), |
| 964 | ("philosophy/index.html", 4), |
| 965 | ("owned/index.html", 7), |
| 966 | ("research/status/index.html", 40), |
| 967 | ("now/index.html", 0), |
| 968 | ("dash/index.html", 0), |
| 969 | ("hive/index.html", 0), |
| 970 | ("aien/index.html", 0), |
| 971 | ("alpha/index.html", 0), |
| 972 | ("lab/index.html", 0), |
| 973 | ("learn/index.html", 0), |
| 974 | ("omega/index.html", 30), |
| 975 | ("omega/reference/index.html", 0), |
| 976 | ("cudaplusplus/index.html", 12), |
| 977 | ("progress/index.html", 0), |
| 978 | ("agents/index.html", 10), |
| 979 | ("blog/index.html", 2), |
| 980 | ("blog/aien-v3-research-plan/index.html", 0), |
| 981 | ]; |
| 982 | |
| 983 | fn main() { |
| 984 | let start = Instant::now(); |
| 985 | let first_arg = std::env::args().nth(1).unwrap_or_else(|| "build".to_string()); |
| 986 | if first_arg == "ledger-project" || first_arg == "ledger-check" { |
| 987 | let path = std::env::args().nth(2).filter(|_| std::env::args().nth(3).is_none()) |
| 988 | .unwrap_or_else(|| { eprintln!("{first_arg}: expected one TSV path"); std::process::exit(2) }); |
| 989 | let input = fs::read_to_string(&path).unwrap_or_else(|_| { |
| 990 | eprintln!("{first_arg}: unreadable ledger"); |
| 991 | std::process::exit(1); |
| 992 | }); |
| 993 | let result = if first_arg == "ledger-project" { |
| 994 | ledger_public::project(&input) |
| 995 | } else { |
| 996 | ledger_public::check_public(&input).map(|()| String::new()) |
| 997 | }; |
| 998 | let output = result.unwrap_or_else(|e| { |
| 999 | eprintln!("{first_arg}: {e}"); |
| 1000 | std::process::exit(1); |
| 1001 | }); |
| 1002 | if first_arg == "ledger-project" { |
| 1003 | std::io::stdout().write_all(output.as_bytes()).expect("cannot write projected ledger"); |
| 1004 | } |
| 1005 | return; |
| 1006 | } |
| 1007 | |
| 1008 | // `facts [facts.json]`: read the public GitHub record and write the facts file. Read-only, |
| 1009 | // needs `gh`. Run by the workflow before every build so the page never goes stale by hand. |
| 1010 | if first_arg == "facts" { |
| 1011 | let out = std::env::args().nth(2).unwrap_or_else(|| "facts.json".to_string()); |
| 1012 | let gathered = facts::gather().unwrap_or_else(|e| { |
| 1013 | eprintln!("facts: {e}"); |
| 1014 | std::process::exit(1); |
| 1015 | }); |
| 1016 | gathered.save(Path::new(&out)).unwrap_or_else(|e| { |
| 1017 | eprintln!("facts: cannot write {out}: {e}"); |
| 1018 | std::process::exit(1); |
| 1019 | }); |
| 1020 | println!( |
| 1021 | " [FACTS] {out}: {} components, {} decisions, receipt {} for {} ({:.2?})", |
| 1022 | gathered.components.len(), |
| 1023 | gathered.decisions.len(), |
| 1024 | gathered.receipt.state, |
| 1025 | &gathered.receipt.sha[..gathered.receipt.sha.len().min(12)], |
| 1026 | start.elapsed() |
| 1027 | ); |
| 1028 | return; |
| 1029 | } |
| 1030 | |
| 1031 | // `agents [out.json]`: read every public repository of the organization and |
| 1032 | // the agent brief it carries (AGENTS.md or CLAUDE.md). Read-only, needs `gh`. |
| 1033 | if first_arg == "agents" { |
| 1034 | let out = std::env::args().nth(2).unwrap_or_else(|| components::agents::DATA_PATH.to_string()); |
| 1035 | let gathered = components::agents::gather().unwrap_or_else(|e| { |
| 1036 | eprintln!("agents: {e}"); |
| 1037 | std::process::exit(1); |
| 1038 | }); |
| 1039 | gathered.save(Path::new(&out)).unwrap_or_else(|e| { |
| 1040 | eprintln!("agents: cannot write {out}: {e}"); |
| 1041 | std::process::exit(1); |
| 1042 | }); |
| 1043 | println!( |
| 1044 | " [AGENTS] {out}: {} public repositories, {} with a brief ({:.2?})", |
| 1045 | gathered.repos.len(), |
| 1046 | gathered.repos.iter().filter(|r| r.brief.is_some()).count(), |
| 1047 | start.elapsed() |
| 1048 | ); |
| 1049 | return; |
| 1050 | } |
| 1051 | |
| 1052 | // `progress`: the collector read every public project repository from the local Radicle |
| 1053 | // storage (git history plus patches through `rad cob`). Radicle was removed on 2026-11-14, |
| 1054 | // so the command refuses and the committed public/data/project-progress.json (as of |
| 1055 | // 2026-11-10) stays as the last collection. A new source is a separate change. |
| 1056 | if first_arg == "progress" { |
| 1057 | eprintln!("progress: stopped. The collector read the Radicle storage, which was removed on 2026-11-14; the committed dataset stays as it is."); |
| 1058 | std::process::exit(2); |
| 1059 | } |
| 1060 | |
| 1061 | let (mode, target_dir) = if first_arg == "build" || first_arg == "verify" { |
| 1062 | (first_arg, std::env::args().nth(2).unwrap_or_else(|| "dist-rust".to_string())) |
| 1063 | } else { |
| 1064 | ("verify".to_string(), first_arg) |
| 1065 | }; |
| 1066 | let facts_file = std::env::args().nth(3).unwrap_or_else(|| "facts.json".to_string()); |
| 1067 | |
| 1068 | let dist = Path::new(&target_dir); |
| 1069 | |
| 1070 | println!("============================================================"); |
| 1071 | println!(" AienOS Native Static Site Builder & Integrity Verifier "); |
| 1072 | println!(" Engine: Pure Rust & Maud | Target: {}", dist.display()); |
| 1073 | println!(" Mode: {}", mode); |
| 1074 | println!("============================================================"); |
| 1075 | |
| 1076 | if mode == "build" { |
| 1077 | build_pure_rust_site(dist, Path::new(&facts_file)); |
| 1078 | verify_site(dist); |
| 1079 | } else { |
| 1080 | if !dist.exists() { |
| 1081 | eprintln!("Error: Target directory '{}' does not exist.", dist.display()); |
| 1082 | std::process::exit(1); |
| 1083 | } |
| 1084 | verify_site(dist); |
| 1085 | } |
| 1086 | |
| 1087 | let elapsed = start.elapsed(); |
| 1088 | println!(" Build and Verification Completed in: {:.2?}", elapsed); |
| 1089 | println!("============================================================"); |
| 1090 | } |
| 1091 | |
| 1092 | #[cfg(test)] |
| 1093 | mod tests { |
| 1094 | use super::*; |
| 1095 | |
| 1096 | #[test] |
| 1097 | fn test_unslop_punctuation_invariants() { |
| 1098 | let sample = "AienOS: The GPU-Native Neural Operating Environment."; |
| 1099 | assert!(!sample.contains('\u{2014}'), "Must not contain em dash"); |
| 1100 | assert!(!sample.contains('\u{2013}'), "Must not contain en dash"); |
| 1101 | } |
| 1102 | |
| 1103 | #[test] |
| 1104 | fn turing_sliders_have_accessible_names() { |
| 1105 | let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../.."); |
| 1106 | for rel in ["public/turing/index.html"] { |
| 1107 | let page = fs::read_to_string(root.join(rel)).unwrap_or_else(|_| panic!("cannot read {rel}")); |
| 1108 | for id in ["r-gain", "r-cost", "r-base"] { |
| 1109 | assert!(page.contains(&format!("for=\"{id}\"")), "{rel}: no label for {id}"); |
| 1110 | let pos = page.find(&format!("id=\"{id}\"")).unwrap_or_else(|| panic!("{rel}: missing id {id}")); |
| 1111 | let tag_start = page[..pos].rfind("<input").unwrap_or_else(|| panic!("{rel}: {id} is not an input")); |
| 1112 | let tag_end = page[tag_start..].find('>').unwrap_or(0) + tag_start; |
| 1113 | let tag = &page[tag_start..=tag_end]; |
| 1114 | assert!(tag.contains("aria-label="), "{rel}: input {id} has no accessible name"); |
| 1115 | } |
| 1116 | assert!(!page.contains("<output"), "{rel}: <output> inside a label is invalid"); |
| 1117 | } |
| 1118 | } |
| 1119 | |
| 1120 | /// `uses: owner/action@<40 hex> # vX.Y.Z`: a moving tag lets whoever controls |
| 1121 | /// the action change what runs in this repository's CI. |
| 1122 | fn unpinned_uses(text: &str) -> Vec<String> { |
| 1123 | text.lines() |
| 1124 | .filter_map(|l| l.trim_start().trim_start_matches("- ").strip_prefix("uses:")) |
| 1125 | .map(str::trim) |
| 1126 | .filter(|u| { |
| 1127 | let Some((spec, comment)) = u.split_once(" # v") else { return true }; |
| 1128 | let Some((_, sha)) = spec.split_once('@') else { return true }; |
| 1129 | sha.len() != 40 || !sha.bytes().all(|b| b.is_ascii_hexdigit() && !b.is_ascii_uppercase()) || comment.trim().is_empty() |
| 1130 | }) |
| 1131 | .map(str::to_string) |
| 1132 | .collect() |
| 1133 | } |
| 1134 | |
| 1135 | #[test] |
| 1136 | fn workflow_actions_are_pinned_to_commit_shas() { |
| 1137 | let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../.github/workflows"); |
| 1138 | let mut seen = 0; |
| 1139 | for entry in fs::read_dir(&dir).expect("workflows directory") { |
| 1140 | let path = entry.unwrap().path(); |
| 1141 | if !matches!(path.extension().and_then(|e| e.to_str()), Some("yml" | "yaml")) { |
| 1142 | continue; |
| 1143 | } |
| 1144 | let text = fs::read_to_string(&path).unwrap(); |
| 1145 | seen += text.lines().filter(|l| l.trim_start().trim_start_matches("- ").starts_with("uses:")).count(); |
| 1146 | let bad = unpinned_uses(&text); |
| 1147 | assert!(bad.is_empty(), "{}: unpinned actions {bad:?}", path.display()); |
| 1148 | } |
| 1149 | assert!(seen > 0, "no uses: lines found; the scan is not reading the workflows"); |
| 1150 | // Negative controls: a moving tag, a short sha and a missing version comment are refused. |
| 1151 | assert_eq!(unpinned_uses(" - uses: actions/checkout@v4").len(), 1); |
| 1152 | assert_eq!(unpinned_uses(" uses: actions/checkout@11d5960a # v4.4.0").len(), 1); |
| 1153 | assert_eq!(unpinned_uses(" - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262").len(), 1); |
| 1154 | assert!(unpinned_uses(" - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0").is_empty()); |
| 1155 | } |
| 1156 | |
| 1157 | /// The document `main` writes for /aienet/, head included, before the shared SEO pass. |
| 1158 | #[test] |
| 1159 | fn aienet_built_page_has_no_script_or_api_while_form_is_paused() { |
| 1160 | if components::agora::AIENET_HELLO_FORM { return; } |
| 1161 | let page = render_aienet_document().into_string(); |
| 1162 | assert!(page.contains("<!DOCTYPE html>")); |
| 1163 | assert!(page.contains("<head>")); |
| 1164 | assert!(page.contains("href=\"/assets/agora.css\"")); |
| 1165 | assert!(page.contains("src=\"/js/turing-look.js\"")); |
| 1166 | assert!(page.contains("id=\"aienet-paused\"")); |
| 1167 | assert!(page.contains("class=\"hub-card\" inert>")); |
| 1168 | assert!(page.contains("type=\"submit\" disabled>")); |
| 1169 | assert!(page.contains("id=\"aienet-recheck\" type=\"button\" disabled>")); |
| 1170 | assert!(!page.contains("aienet.js"), "full /aienet/ page still loads aienet.js"); |
| 1171 | assert!(!page.contains("/agora/api/"), "full /aienet/ page still names /agora/api/"); |
| 1172 | } |
| 1173 | |
| 1174 | #[test] |
| 1175 | fn unreadable_directory_fails_the_comparison_scan() { |
| 1176 | let missing = std::env::temp_dir().join(format!("aienos-unreadable-{}", std::process::id())); |
| 1177 | let _ = fs::remove_dir_all(&missing); |
| 1178 | let err = collect_comparison_pages(&missing, &missing, &mut Vec::new()) |
| 1179 | .expect_err("a missing directory is unreadable"); |
| 1180 | assert!(err.contains("unreadable directory"), "{err}"); |
| 1181 | } |
| 1182 | |
| 1183 | #[test] |
| 1184 | fn llms_txt_and_llms_full_are_scanned() { |
| 1185 | let dir = std::env::temp_dir().join(format!("aienos-llms-scan-{}", std::process::id())); |
| 1186 | let _ = fs::remove_dir_all(&dir); |
| 1187 | fs::create_dir_all(&dir).unwrap(); |
| 1188 | fs::write(dir.join("llms.txt"), "Omega beats vLLM.\n").unwrap(); |
| 1189 | fs::write(dir.join("llms-full.txt"), "Omega matches vLLM.\n").unwrap(); |
| 1190 | fs::write(dir.join("notes.txt"), "Omega beats vLLM.\n").unwrap(); |
| 1191 | fs::write(dir.join("ok.html"), "<p>A quiet page.</p>\n").unwrap(); |
| 1192 | let mut bad = Vec::new(); |
| 1193 | collect_comparison_pages(&dir, &dir, &mut bad).expect("readable scan"); |
| 1194 | let joined = bad.iter().map(|(p, e)| format!("{} {e}", p.display())).collect::<Vec<_>>().join("\n"); |
| 1195 | assert!(joined.contains("llms.txt") && joined.contains("beats vLLM"), "{joined}"); |
| 1196 | assert!(joined.contains("llms-full.txt") && joined.contains("matches vLLM"), "{joined}"); |
| 1197 | assert!(!joined.contains("notes.txt"), "{joined}"); |
| 1198 | assert!(!joined.contains("ok.html"), "{joined}"); |
| 1199 | let _ = fs::remove_dir_all(&dir); |
| 1200 | } |
| 1201 | |
| 1202 | #[test] |
| 1203 | fn test_layout_rendering() { |
| 1204 | let markup = render_base_layout(html! { p { "Test" } }); |
| 1205 | let s = markup.into_string(); |
| 1206 | assert!(s.contains("<!DOCTYPE html>")); |
| 1207 | assert!(s.contains("<div id=\"root\"")); |
| 1208 | assert!(s.contains("AienOS")); |
| 1209 | } |
| 1210 | } |