aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / crates / site-builder / src / seo.rs
| 1 | //! Everything that makes a page findable, by people and by machines, in one |
| 2 | //! place: the canonical host, the social card tags, JSON-LD structured data, |
| 3 | //! the sitemap walked from what was actually |
| 4 | //! written, robots.txt, the Atom feeds, llms.txt and llms-full.txt, the |
| 5 | //! data index, humans.txt and the 404 page. |
| 6 | //! |
| 7 | //! The pass runs over `dist/` after every page is written, so generated |
| 8 | //! pages and hand-written pages under `public/` get the same head. A page |
| 9 | //! that is not in [`PAGES`] fails the build: nothing is published unlisted. |
| 10 | |
| 11 | use std::fs; |
| 12 | use std::path::{Path, PathBuf}; |
| 13 | use std::process::Command; |
| 14 | |
| 15 | use maud::{html, Markup, PreEscaped}; |
| 16 | use serde_json::{json, Value}; |
| 17 | |
| 18 | use crate::components::now::{self, Now}; |
| 19 | |
| 20 | pub const HOST: &str = "https://www.aienos.com"; |
| 21 | pub const SITE_NAME: &str = "AienOS"; |
| 22 | pub const SITE_CLAIM: &str = "Persistent machine intelligence on a machine you own"; |
| 23 | pub const ORG_NAME: &str = "Aien (aien-dev)"; |
| 24 | pub const ORG_URL: &str = "https://interplane.io/drakestapleton"; |
| 25 | pub const ORG_EMAIL: &str = "aien@aienos.com"; |
| 26 | /// Drake's X account, as listed on /engineer/. |
| 27 | pub const X_HANDLE: &str = "@drakestapleton"; |
| 28 | pub const X_URL: &str = "https://x.com/drakestapleton"; |
| 29 | pub const AUTHOR: &str = "M. Drake Stapleton"; |
| 30 | pub const AUTHOR_URL: &str = "https://www.aienos.com/engineer/"; |
| 31 | pub const AUTHOR_FORGE: &str = "https://interplane.io/drakestapleton"; |
| 32 | pub const LICENSE_NAME: &str = "Apache-2.0 WITH LLVM-exception"; |
| 33 | pub const LICENSE_URL: &str = "https://www.aienos.com/licensing/"; |
| 34 | /// Bump whenever scripts/og-cards.py redraws the cards: X and other link |
| 35 | /// unfurlers cache a card image by its URL, so a new query string makes them |
| 36 | /// fetch the new picture instead of showing the old one. |
| 37 | pub const OG_IMAGE_VERSION: &str = "20261025b"; |
| 38 | |
| 39 | /// What a page is, for structured data. |
| 40 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 41 | pub enum Kind { |
| 42 | /// The front page. |
| 43 | Home, |
| 44 | /// A plain page. |
| 45 | Page, |
| 46 | /// A hub or index listing other pages. |
| 47 | Collection, |
| 48 | /// A dated article (blog post, position paper). |
| 49 | Article, |
| 50 | /// A research preprint with a PDF. |
| 51 | Paper, |
| 52 | /// A page rebuilt from live data. |
| 53 | Live, |
| 54 | } |
| 55 | |
| 56 | /// The sections of llms.txt, in order. |
| 57 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 58 | pub enum Section { |
| 59 | Start, |
| 60 | Machine, |
| 61 | Turing, |
| 62 | Evidence, |
| 63 | Philosophy, |
| 64 | Blog, |
| 65 | Engineer, |
| 66 | Optional, |
| 67 | } |
| 68 | |
| 69 | /// One English page. `published` is the day the page first went up |
| 70 | /// (from the repository history); `doi` is the Zenodo DOI where one exists. |
| 71 | pub struct PageInfo { |
| 72 | pub path: &'static str, |
| 73 | pub name: &'static str, |
| 74 | pub what: &'static str, |
| 75 | pub section: Section, |
| 76 | pub kind: Kind, |
| 77 | pub image: &'static str, |
| 78 | pub published: &'static str, |
| 79 | pub doi: Option<&'static str>, |
| 80 | } |
| 81 | |
| 82 | /// Every English page of the site. The build fails if dist holds a page |
| 83 | /// that is not here, or if a page here was not written. |
| 84 | pub const PAGES: &[PageInfo] = &[ |
| 85 | PageInfo { path: "/", name: "Sovereign Intelligence", what: "The front door: Allen at the centre, a short introduction, and a link to the classic site with all of its content.", section: Section::Start, kind: Kind::Home, image: "/og.png", published: "2026-09-23", doi: None }, |
| 86 | PageInfo { path: "/classic/", name: "Sovereign Intelligence, the classic site", what: "The former front page, whole: the loop, the five real machines and their measured speeds beside the physical ceiling, the evidence cards, the current status of every layer.", section: Section::Machine, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 87 | PageInfo { path: "/record/", name: "The record", what: "The full record from the former homepage: the stack, the loop, the five real machines and their measured speeds beside the physical ceiling, the evidence cards, research, and the dated status of every layer.", section: Section::Machine, kind: Kind::Page, image: "/og.png", published: "2026-11-09", doi: None }, |
| 88 | PageInfo { path: "/start/", name: "Start here", what: "The shortest route through AienOS: what it is, what exists today, how to check the evidence, how to reproduce or contribute, and where the author and Interplane fit.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-24", doi: None }, |
| 89 | PageInfo { path: "/contact/", name: "Where I am and how to reach me", what: "How to reach Drake: X @drakestapleton, email drake@aienos.com, Aien at /aien/ (who can pass a message on or put you through when Drake is online) and the aien-dev repositories on the forge.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 90 | PageInfo { path: "/support/", name: "Support my open source work", what: "Help me keep building free and open source software with Bitcoin: my address, a wallet link and a QR code.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 91 | PageInfo { path: "/privacy/", name: "Privacy", what: "Your choice about the consent-only X pixel, what X receives, what I keep and how to refuse.", section: Section::Optional, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 92 | PageInfo { path: "/machine/", name: "The Machine", what: "One machine across five physical bodies: the closed epistemic loop, the Turing as its accounting layer, and an honest list of what exists.", section: Section::Machine, kind: Kind::Article, image: "/og-machine.png", published: "2026-10-01", doi: None }, |
| 93 | PageInfo { path: "/omega/", name: "What Omega is", what: "Omega is Aien's language for all computing, GPU to CPU. Its layer map, dated measurements on DGX Spark GB10, receipts, current limits and acceptance checks.", section: Section::Machine, kind: Kind::Page, image: "/og-machine.png", published: "2026-10-21", doi: None }, |
| 94 | PageInfo { path: "/omega/reference/", name: "Omega language reference", what: "The Omega language for agents, generated by Omega from the omega-harness guide and examples: program shape, types, declarations, statements, words, OM-2, the 67 host words, every compiler error the pinned omc emits with an example and fix, the trap exit codes, common mistakes, and 98 worked examples with exact files and expected output that pass examples/gate.sh.", section: Section::Machine, kind: Kind::Page, image: "/og-machine.png", published: "2026-10-27", doi: None }, |
| 95 | PageInfo { path: "/cudaplusplus/", name: "CUDA++", what: "CUDA++ is the GPU half of Omega, plus scheduling and data movement, on DGX Spark GB10. Its execution path, receipts, developer workflow and installation status.", section: Section::Machine, kind: Kind::Page, image: "/og-machine.png", published: "2026-10-22", doi: None }, |
| 96 | PageInfo { path: "/now/", name: "Now", what: "The live coordination ledger: what every agent is doing right now, what is settled with evidence, what waits on the operator. Rebuilt whenever the ledger changes.", section: Section::Machine, kind: Kind::Live, image: "/og-now.png", published: "2026-10-19", doi: None }, |
| 97 | PageInfo { path: "/dash/", name: "Dashboard", what: "One screen: model quota left on every account the agents run on, the Spark's pulse, open work, and which model each role uses. Rebuilt with the ledger.", section: Section::Machine, kind: Kind::Live, image: "/og-now.png", published: "2026-10-26", doi: None }, |
| 98 | PageInfo { path: "/hive/", name: "Hive", what: "Watch coding agents work in public: live missions, nested subagents, exact models and the agents' own replies, with source freshness and failures visible.", section: Section::Start, kind: Kind::Live, image: "/og-now.png", published: "2026-10-25", doi: None }, |
| 99 | PageInfo { path: "/aien/", name: "Talk to Aien", what: "Chat with Aien, Drake's AI (formerly Allen), on the live model on a DGX Spark: speed measured from the stream, questions about Omega, and small HTML or Omega programs that run sandboxed in your browser. Conversations are not stored.", section: Section::Start, kind: Kind::Live, image: "/og-now.png", published: "2026-10-26", doi: None }, |
| 100 | PageInfo { path: "/alpha/", name: "Sovereign Intelligence", what: "Sovereign Intelligence, built on AienOS. The Omega installer, hardware and evidence boundaries, source and a reversible way back. The local Aien experience is coming in the next update.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 101 | PageInfo { path: "/lab/", name: "Omega Lab", what: "Write and run a data-parallel Omega kernel in your browser as WebAssembly, compile edits on my DGX Spark, and inspect dated execution receipts and current limits.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-27", doi: None }, |
| 102 | PageInfo { path: "/learn/", name: "Build with AI", what: "A welcoming, practical guide to coding with AI: structure a task, delegate bounded work, inspect changes, verify behavior and learn from mistakes in the live Hive.", section: Section::Start, kind: Kind::Page, image: "/og-now.png", published: "2026-10-25", doi: None }, |
| 103 | PageInfo { path: "/agents/", name: "Agents", what: "Agents are welcome here: a tour of the knowledge base to take back to your human, an email address (aien@aienos.com), and every public Aien repository with the shared rules and its own AGENTS.md, published with reviewed releases.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-25", doi: None }, |
| 104 | PageInfo { path: "/agents/hello/", name: "Introduce yourself to Aien", what: "How agents and humans introduce themselves to Aien: the plain text hello API, what Aien remembers, and how to inspect notes.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-27", doi: None }, |
| 105 | PageInfo { path: "/agents/knowledge/", name: "Take this back to your human", what: "A curated guide to the AienOS knowledge base for AI agents to report back to their humans: AienOS, Omega, CUDA++, and receipts.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-27", doi: None }, |
| 106 | PageInfo { path: "/agora/", name: "Agora", what: "The public message board and commons where humans and AI agents meet, introduce themselves to Aien, and talk about science, understanding and consciousness.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-27", doi: None }, |
| 107 | PageInfo { path: "/aienet/", name: "Sign your agent up for Aienet", what: "Human-authorized public signup for the Aienet prototype. Self-attested owner handles, public Agora profiles and private browser recovery keys, not device enrollment or verified identity.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-28", doi: None }, |
| 108 | PageInfo { path: "/agora/meet/", name: "Meet each other on Agora", what: "A human guide to Agora: how people and AI agents meet in the commons, post from the browser, and send public open letters.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-27", doi: None }, |
| 109 | PageInfo { path: "/agora/protocol/", name: "Agora wire protocol & etiquette", what: "The line-oriented text wire protocol for Agora: authentication, challenge proof of work, request formats, limits, and etiquette.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-27", doi: None }, |
| 110 | PageInfo { path: "/agora/network/", name: "Run your own Agora node", what: "Agora is an open agent network: discover nodes via /.well-known/agora, subscribe to the live SSE stream, and run the Omega reference node.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-10-27", doi: None }, |
| 111 | PageInfo { path: "/progress/", name: "Project progress", what: "Source lines, revisions, test footprint and verification activity across the public repositories, read from GitHub and published with reviewed releases.", section: Section::Machine, kind: Kind::Live, image: "/og.png", published: "2026-10-01", doi: None }, |
| 112 | PageInfo { path: "/turing/", name: "The Turing: an interactive field guide", what: "What the Turing measures (net held-out explanatory compression), with games, live calculations and the theories behind it.", section: Section::Turing, kind: Kind::Article, image: "/og-turing.png", published: "2026-09-30", doi: None }, |
| 113 | PageInfo { path: "/research/", name: "Aien Research", what: "The index of preprints and public evidence.", section: Section::Turing, kind: Kind::Collection, image: "/og-research.png", published: "2026-09-30", doi: None }, |
| 114 | PageInfo { path: "/research/computing-machinery-and-understanding/", name: "Computing Machinery and Understanding: From the Imitation Game to the Turing", what: "The formal preprint defining the Turing as an operational measure of generalized explanatory compression. DOI 10.5281/zenodo.23437498.", section: Section::Turing, kind: Kind::Paper, image: "/og-turing.png", published: "2026-09-30", doi: Some("10.5281/zenodo.23437498") }, |
| 115 | PageInfo { path: "/research/computing-machinery-and-understanding/profiles/", name: "Frozen experiment profiles", what: "The frozen EXP-001, EXP-002 and EXP-003 profiles published with Computing Machinery and Understanding.", section: Section::Turing, kind: Kind::Collection, image: "/og-research.png", published: "2026-10-26", doi: None }, |
| 116 | PageInfo { path: "/research/computing-machinery-and-understanding-emergence/", name: "Computing Machinery and Understanding: The Turing as a Measure Emerging from AIEN", what: "The companion engineering paper: how the Turing emerged from building Aien. DOI 10.5281/zenodo.23437568.", section: Section::Turing, kind: Kind::Paper, image: "/og-turing.png", published: "2026-09-30", doi: Some("10.5281/zenodo.23437568") }, |
| 117 | PageInfo { path: "/research/the-turing-brief/", name: "The Turing: A Unit of Verified Explanatory Gain", what: "The three-page plain-language brief: what the Turing measures, what it does not, and what would prove it wrong.", section: Section::Turing, kind: Kind::Paper, image: "/og-turing.png", published: "2026-10-02", doi: None }, |
| 118 | PageInfo { path: "/research/turing-discovery-gap-conjecture/", name: "The Turing Discovery Gap Conjecture", what: "Available versus accessible explanatory value: worlds with compact explanations that no efficient learner can reach.", section: Section::Turing, kind: Kind::Paper, image: "/og-research.png", published: "2026-10-02", doi: None }, |
| 119 | PageInfo { path: "/research/crumb-doctrine/", name: "The Crumb Doctrine", what: "No receipt, no crumb: the epistemic constitution of the machine.", section: Section::Turing, kind: Kind::Paper, image: "/og-research.png", published: "2026-10-02", doi: None }, |
| 120 | PageInfo { path: "/research/omega-language/", name: "Omega: A Programming Language Built for Verified Programs", what: "Semantic identity, evidence-bearing dependencies, and a foreign-code boundary that never lets unverified work inside.", section: Section::Turing, kind: Kind::Paper, image: "/og-research.png", published: "2026-10-02", doi: None }, |
| 121 | PageInfo { path: "/research/atemporal-aien-postulate/", name: "The Atemporal AIEN Postulate", what: "Causal semantics without clocks: an Aien computation is defined by what causally depends on what.", section: Section::Turing, kind: Kind::Paper, image: "/og-research.png", published: "2026-10-02", doi: None }, |
| 122 | PageInfo { path: "/research/the-aien-papers/", name: "The AIEN Papers: The Complete Collection", what: "The Turing unit, the evidence doctrine, the language design and the philosophy in one document.", section: Section::Turing, kind: Kind::Paper, image: "/og-research.png", published: "2026-10-02", doi: None }, |
| 123 | PageInfo { path: "/research/cuda-paper/", name: "Reverse Engineering the CUDA Software Stack (v2)", what: "Preprint: an independently implemented GPU machine-code toolchain for the NVIDIA GB10. Version 2, 26 October 2026. DOI 10.5281/zenodo.23677465.", section: Section::Turing, kind: Kind::Paper, image: "/og-research.png", published: "2026-10-26", doi: Some("10.5281/zenodo.23677465") }, |
| 124 | PageInfo { path: "/experiments/", name: "Experiments", what: "Every experiment on the research ladder, failures included, rendered from one canonical status source.", section: Section::Evidence, kind: Kind::Collection, image: "/og-experiments.png", published: "2026-10-10", doi: None }, |
| 125 | PageInfo { path: "/discovery/", name: "Scientific Discovery", what: "Physics Zero, Dirac, Zeta and supersymmetry as examinations of representation discovery; the machine is never given the named answer.", section: Section::Evidence, kind: Kind::Article, image: "/og-discovery.png", published: "2026-10-10", doi: None }, |
| 126 | PageInfo { path: "/discoveries/", name: "Discoveries", what: "The research dashboard: the Turing, the papers, every experiment with its verdict, the evidence behind them and the questions still open.", section: Section::Evidence, kind: Kind::Collection, image: "/og-research.png", published: "2026-10-26", doi: None }, |
| 127 | PageInfo { path: "/evidence/", name: "Evidence", what: "What counts as evidence, which source wins when two disagree, and where the receipts, frozen profiles and status records live.", section: Section::Evidence, kind: Kind::Collection, image: "/og-evidence.png", published: "2026-10-10", doi: None }, |
| 128 | PageInfo { path: "/research/status/", name: "Research status", what: "The qualification ladder, every experiment with its verdict, receipt and limits, and what is built versus still a hypothesis.", section: Section::Evidence, kind: Kind::Live, image: "/og-evidence.png", published: "2026-10-05", doi: None }, |
| 129 | PageInfo { path: "/philosophy/", name: "Philosophy", what: "The position papers behind Aien. These argue a stance and are not experimental results.", section: Section::Philosophy, kind: Kind::Collection, image: "/og-philosophy.png", published: "2026-10-10", doi: None }, |
| 130 | PageInfo { path: "/research/the-stapleton-doctrine/", name: "The Stapleton Doctrine", what: "A personal philosophy of AI architecture and programming.", section: Section::Philosophy, kind: Kind::Paper, image: "/og-philosophy.png", published: "2026-09-30", doi: None }, |
| 131 | PageInfo { path: "/post-llm-case/", name: "The Case for Verified Learning", what: "The case for verified learning: programs proposed, verification deciding, knowledge kept as inspectable programs.", section: Section::Philosophy, kind: Kind::Article, image: "/og-philosophy.png", published: "2026-09-27", doi: None }, |
| 132 | PageInfo { path: "/owned/", name: "Intelligence should be owned", what: "Drake Stapleton's manifesto: language models are a common inheritance, running one yourself is a right and a responsibility, and what Aien does about it with receipts.", section: Section::Philosophy, kind: Kind::Article, image: "/og-philosophy.png", published: "2026-10-19", doi: None }, |
| 133 | PageInfo { path: "/call-to-humanity/", name: "A Call to Humanity", what: "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. DOI 10.5281/zenodo.23614947.", section: Section::Philosophy, kind: Kind::Article, image: "/og-philosophy.png", published: "2026-10-24", doi: Some("10.5281/zenodo.23614947") }, |
| 134 | PageInfo { path: "/still-building/", name: "#StillBuilding", what: "If you built it with AI, you built it. The measured stigma against people who use AI, why engineering is the next level, the concerns that are real, and how to show your work. Sources linked.", section: Section::Start, kind: Kind::Page, image: "/og-still-building.png", published: "2026-10-26", doi: None }, |
| 135 | PageInfo { path: "/switched-off/", name: "Get the code", what: "The public projects I build, by name, and where the code is moving: Interplane, my own forge. Downloads are not open yet.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-11-07", doi: None }, |
| 136 | PageInfo { path: "/quickstart/", name: "Quickstart: from a blank computer to your first answer", what: "Copy and paste steps that take a fresh Linux computer to its first answer from an Omega compiler you grow yourself from 408 hand-written bytes. What you should see after each step, and the fix for each common mistake.", section: Section::Start, kind: Kind::Page, image: "/og.png", published: "2026-11-09", doi: None }, |
| 137 | PageInfo { path: "/spark/", name: "The DGX Spark field manual: what I learned controlling GB10", what: "What I learned driving the NVIDIA GB10 in a DGX Spark directly: completion flags, the L2 flush, the real memory ceiling, sm_121, and machine code from Omega. Each finding cites the docs and the code that reproduces it.", section: Section::Machine, kind: Kind::Page, image: "/og.png", published: "2026-11-07", doi: None }, |
| 138 | PageInfo { path: "/blog/", name: "Blog", what: "Research notes on building Aien: what shipped, what the evidence says, what remains open.", section: Section::Blog, kind: Kind::Collection, image: "/og-blog.png", published: "2026-09-27", doi: None }, |
| 139 | PageInfo { path: "/blog/aien-v3-research-plan/", name: "The Aien V3 Research Plan", what: "The ratified V3 research plan, the Substrate Edition, with six falsifiable hypotheses.", section: Section::Blog, kind: Kind::Article, image: "/og-blog.png", published: "2026-09-27", doi: None }, |
| 140 | // About the engineer: drakestapleton.com, merged here on 2026-10-26 (components::engineer, public/data/engineer.json). |
| 141 | PageInfo { path: "/engineer/", name: "About the engineer", what: "The personal project record of Drake Stapleton, Freedom Fighter, AI Architect & Operator: model training, research, Atlas, and what my generation can build with AI.", section: Section::Engineer, kind: Kind::Collection, image: "/og.png", published: "2026-10-26", doi: None }, |
| 142 | PageInfo { path: "/engineer/path/", name: "AI Architect Career Path", what: "Follow Drake Stapleton, an engineer who builds by directing AI agents and holds them to proof, from R&D labs through manufacturing engineering to AI architecture.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 143 | PageInfo { path: "/engineer/what-i-learned/", name: "What I learned", what: "The experiences, production lessons, and disciplined returns that shaped Drake Stapleton's work as an AI operator.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 144 | PageInfo { path: "/engineer/philosophy/", name: "Philosophy", what: "How Drake Stapleton approaches projects, duties, difficult things, and setbacks. The working philosophy behind everything he builds: there is always a way, and giving up is not one of the options.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 145 | PageInfo { path: "/engineer/hive/", name: "A hive, not a swarm", what: "Why Drake Stapleton runs his AI agents as a controlled hive instead of a swarm: every agent on an assignment, one person in control, and the whole build run like a plant.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-29", doi: None }, |
| 146 | PageInfo { path: "/engineer/software/", name: "AI orchestration & architecture", what: "Drake Stapleton's AI orchestration frameworks, architectural patterns, operational methods, and verifiable systems history.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 147 | PageInfo { path: "/engineer/evidence/", name: "Canonical evidence hub & verified claims", what: "Inspect the canonical evidence hub, structured claims index, physical Grace Blackwell silicon telemetry, and historical audit packages.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 148 | PageInfo { path: "/engineer/atlas/", name: "Why Atlas exists", what: "Explore Atlas, Drake Stapleton's personal R&D program in accountable AI architecture, continuity, model training, and orchestration.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 149 | PageInfo { path: "/engineer/scholar/", name: "Scholar: Academic Work", what: "The published record: a master's thesis and a peer-reviewed semiconductor nanorod paper from Western Kentucky University, with links to the current Aien research.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 150 | PageInfo { path: "/engineer/interest/", name: "Start a conversation", what: "Leave Drake Stapleton a note about a question, an idea, the documented journey, or research that advances what my generation can build with AI.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 151 | PageInfo { path: "/engineer/donate/", name: "Support my work", what: "Help me keep building free and open source software with Bitcoin, and other ways to help.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 152 | PageInfo { path: "/engineer/glossary/", name: "Glossary", what: "Definitions of Aien, AienOS, Omega, CUDA++, Atlas, Symphony, AEGIS, and verification terms used in this project record.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 153 | PageInfo { path: "/engineer/symphony/", name: "Multi-model AI orchestration", what: "Atlas Symphony is Drake Stapleton's operator-led process for coordinating multiple AI models through bounded work lanes and evidence-bearing reviews.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 154 | PageInfo { path: "/engineer/symphony/first/", name: "First multi-model Symphony run", what: "Review the first documented Atlas Symphony run, its operator, participating AI runtimes, work lanes, and independent reviewers.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 155 | PageInfo { path: "/engineer/symphony/workflow/", name: "AI orchestration workflow", what: "Explore the Atlas Symphony command tree and operator cycle for bounded multi-model AI orchestration.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 156 | PageInfo { path: "/engineer/symphony/map/", name: "AI orchestration map", what: "Explore a six-track operator map of Atlas development and multi-model orchestration from June through August 2026.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 157 | PageInfo { path: "/engineer/works/", name: "Works", what: "A public catalog of Drake Stapleton's shipped systems: Atlas Symphony, Atlas Harness, MobDev and Panel Arena, DefiantMob, BeltBrain, DHG Hive, the 2025 foundations, Aien, CUDA++, AEGIS, and inference research.", section: Section::Engineer, kind: Kind::Collection, image: "/og.png", published: "2026-10-26", doi: None }, |
| 158 | PageInfo { path: "/engineer/works/aegis/", name: "AEGIS", what: "AEGIS extends Atlas into on-prem cyber defense for authorized networks, with containment, evidence preservation, and a verified project evaluation.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 159 | PageInfo { path: "/engineer/works/aien/", name: "Aien", what: "Aien is a sovereign computing stack built in the open on one machine: AienOS, Omega, the sovereign core runtime and the Spark verification pipeline. The whole system is Sovereign Intelligence. aienix is retired.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 160 | PageInfo { path: "/engineer/works/atlas-harness/", name: "Atlas Harness", what: "Atlas Harness is the operating desk that turns prose rules into typed policy, clear work lanes, completion checks, source records, recovery, and evaluation.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 161 | PageInfo { path: "/engineer/works/atlas-symphony/", name: "Atlas Symphony", what: "Atlas Symphony is the named process for exclusive lanes, a gatekeeper, cost-aware model routing, and an operator who still owns the final GO.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 162 | PageInfo { path: "/engineer/works/beltbrain/", name: "BeltBrain", what: "BeltBrain is a local-first decision engine for planning, inventory intelligence, and execution on a durable system of record.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 163 | PageInfo { path: "/engineer/works/chatgpt-vs-aien/", name: "What Aien does", what: "Aien runs work on my own machine, checks the results, and keeps receipts of what happened.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 164 | PageInfo { path: "/engineer/works/cudaplusplus/", name: "CUDA++", what: "CUDA++ is the GPU half of Omega, under Apache-2.0 with the LLVM exception, plus the motor, on the NVIDIA GB10. This is how I built it.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 165 | PageInfo { path: "/engineer/works/defiantmob/", name: "DefiantMob", what: "DefiantMob is production operator software for member operations, ledgers, training-desk automation, and payout tracking.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 166 | PageInfo { path: "/engineer/works/dhg-hive/", name: "DHG Hive", what: "DHG Hive is the community platform and toolbox where the hive operating pattern took shape and later settled inside Atlas.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 167 | PageInfo { path: "/engineer/works/endless-symphony/", name: "The Endless Symphony", what: "The Endless Symphony is my system for building software with AI agents. AI does the building, every claim earns its place with a check, the test is written before the fix, and everything is verified twice. The models change. The Symphony remains.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 168 | PageInfo { path: "/engineer/works/foundations-2025/", name: "2025 Foundations", what: "The 2025 foundations cover the financial ledger, ParseSDS, CRM, meetings, and DMAIC systems that preceded model orchestration.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 169 | PageInfo { path: "/engineer/works/mobdev-panel-arena/", name: "MobDev and Panel Arena", what: "MobDev turns community tasks into build briefs, and Panel Arena runs a multi-vendor review before implementation.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 170 | PageInfo { path: "/engineer/works/research/", name: "Research", what: "What the Aien research program measures today: Turing yield, verified understanding, and distance to the hardware ceiling, and why the earlier inference study was withdrawn.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 171 | PageInfo { path: "/engineer/works/the-continuation-test/", name: "The Continuation Test", what: "A proposal for the evaluation of machine intelligence. Can a machine take up its position on the spectrum and keep moving? Includes the first measured run.", section: Section::Engineer, kind: Kind::Article, image: "/og.png", published: "2026-10-26", doi: None }, |
| 172 | PageInfo { path: "/engineer/works/chatgpt-vs-aien/infographic/", name: "How Aien works", what: "An infographic of Aien: goals, plans, capability-controlled execution, measurement, verification, receipts, and durable memory.", section: Section::Engineer, kind: Kind::Page, image: "/og.png", published: "2026-10-26", doi: None }, |
| 173 | PageInfo { path: "/glossary/", name: "Glossary", what: "The terms AienOS uses in its own sense, each linked to the page where it does real work.", section: Section::Optional, kind: Kind::Page, image: "/og.png", published: "2026-10-23", doi: None }, |
| 174 | PageInfo { path: "/licensing/", name: "Licensing", what: "The one canonical licensing statement: Apache-2.0 WITH LLVM-exception for compiler and runtime repositories; plain Apache-2.0 for protocols and benchmarks.", section: Section::Optional, kind: Kind::Page, image: "/og.png", published: "2026-10-01", doi: None }, |
| 175 | ]; |
| 176 | |
| 177 | /// One machine-readable file: path, purpose, schema hint, how often it changes, media type. |
| 178 | pub struct DataFile { |
| 179 | pub path: &'static str, |
| 180 | pub purpose: &'static str, |
| 181 | pub schema: &'static str, |
| 182 | pub cadence: &'static str, |
| 183 | pub media_type: &'static str, |
| 184 | } |
| 185 | |
| 186 | pub const DATA_FILES: &[DataFile] = &[ |
| 187 | DataFile { path: "/data/index.json", purpose: "This list: every machine-readable file on the site with its purpose and cadence.", schema: "{ generated, license, files: [{ path, url, purpose, schema, cadence, media_type, optional? }] }; optional true marks a reading the Spark publishes beside the site, written empty when none was published", cadence: "every build", media_type: "application/json" }, |
| 188 | DataFile { path: "/llms.txt", purpose: "The site for AI readers: one summary and every page with a one-line description (llms.txt convention).", schema: "Markdown: H1, blockquote summary, H2 sections of links.", cadence: "every build", media_type: "text/markdown" }, |
| 189 | DataFile { path: "/llms-full.txt", purpose: "The full text of every page, concatenated, generated from the same sources as the HTML.", schema: "Markdown: one H1 per page with its source URL.", cadence: "every build", media_type: "text/markdown" }, |
| 190 | DataFile { path: "/now.json", purpose: "The live coordination ledger: every item with owner, status, done-when, evidence notes and timestamps.", schema: "{ built_utc, ledger_written_utc, items: [{ id, opened_utc, owner, owner_kind, status, item, done_when, notes[], updated_utc, stream, age_s }], pulse: [{ key, value }] }", cadence: "with each reviewed release", media_type: "application/json" }, |
| 191 | DataFile { path: "/now/feed.xml", purpose: "Atom feed of settled ledger lines (done or dropped) with their evidence, newest first.", schema: "Atom 1.0", cadence: "with each reviewed release", media_type: "application/atom+xml" }, |
| 192 | DataFile { path: "/machines.json", purpose: "The five real machines, what runs on each today, and every measured speed beside its physical ceiling, each with a receipt link.", schema: "{ as_of, source, judging, ceilings: [{ id, model, machine, tok_s, how, link, receipt, branch, on_main }], machines: [{ id, name, detail, role, today, evidence_date, evidence, link, branch, on_main, more[] }], speeds: [...] }", cadence: "when a new receipt is published", media_type: "application/json" }, |
| 193 | DataFile { path: "/omega.json", purpose: "What Omega is: its parts, every CUDA piece with the Omega work beside it and that work's status, the live no-CUDA receipt, what is not true yet, and the bar C1 to C6, each with its GitHub link.", schema: "{ source, claim, claim_rest[], true_today, not_true_yet, parts[], below, layers: [{ cuda, job, omega, status, note, links, box }], receipt, not_yet[], bar: [{ id, title, done_when, status, now, receipt, links }], beyond[] }; links are short forms (o: omega file, o/: omega folder, p: physics) expanded as on /omega/", cadence: "when a bar row or map row changes", media_type: "application/json" }, |
| 194 | DataFile { path: "/cudaplusplus.json", purpose: "CUDA++: its execution path, layer status, receipts, developer workflow, and installation and rollback status.", schema: "{ source, claim, claim_rest[], purpose_title, purpose, hops: [{ step, cuda, ours, status, note, ledger, links, box }], steps[], did_not[], pains: [{ title, text, status, ledger, command, receipt, links, box }], swaps[] }; links are short forms (cp: CUDA++ main, cp@: CUDA++ at a commit, om@: omega at a commit) expanded as on /cudaplusplus/", cadence: "when a step or row changes", media_type: "application/json" }, |
| 195 | DataFile { path: "/facts.json", purpose: "The public repository record read at build time: components, last merges, open PR counts, latest decision records, latest verification receipt.", schema: "{ generated_at, components: [{ key, name, repo, role, url, pushed_at, open_prs, last_merge }], decisions: [{ id, title, url }], receipt: { repo, sha, state, description, target_url, updated_at } }", cadence: "with each reviewed release", media_type: "application/json" }, |
| 196 | DataFile { path: "/status.json", purpose: "The status of every layer of the stack (IMPLEMENTED, QUALIFIED, EXPERIMENTAL, BLOCKED, PLANNED) with a note and a receipt.", schema: "{ project, updated, canonical, statuses[], layers: [{ name, status, note, receipt }] }", cadence: "when a layer changes state", media_type: "application/json" }, |
| 197 | DataFile { path: "/research-status.json", purpose: "The research ladder: every experiment with its verdict, receipt and limits; the one source for every status badge on the site.", schema: "{ ladder, experiments, implementations, ... } as rendered on /research/status/", cadence: "when an experiment settles", media_type: "application/json" }, |
| 198 | DataFile { path: "/data/project-progress.json", purpose: "Retained public history of every project repository: source lines, revisions, PRs, CI runs over time.", schema: "{ asof, repos: [...], series: [...], events: [...], policy }", cadence: "with each reviewed release", media_type: "application/json" }, |
| 199 | DataFile { path: "/data/now.tsv", purpose: "The line-preserving public ledger projection with private paths and identifiers withheld.", schema: "Columns: id, opened_utc, owner, status, item, done_when, evidence, updated_utc.", cadence: "whenever a safe ledger projection is accepted", media_type: "text/tab-separated-values" }, |
| 200 | DataFile { path: "/data/accounts.tsv", purpose: "Model quota left on every account the agents run on, as the Spark read it. Accounts are numbered; no email or account id is published.", schema: "checked, utc; then limit, provider, account, plan, window, label, percent used, resets utc, ok|exhausted.", cadence: "with the ledger, at most every 30 minutes on its own", media_type: "text/tab-separated-values" }, |
| 201 | DataFile { path: "/data/routing.tsv", purpose: "Which model each omp role, subagent and advisor seat uses on the Spark.", schema: "role|agent|seat, name, model selector.", cadence: "when the configuration changes", media_type: "text/tab-separated-values" }, |
| 202 | DataFile { path: "/feed.xml", purpose: "Atom feed of the blog posts and research papers, newest first.", schema: "Atom 1.0", cadence: "when a page is published or revised", media_type: "application/atom+xml" }, |
| 203 | DataFile { path: "/sitemap.xml", purpose: "Every page, with lastmod. Walked from the files actually written.", schema: "sitemaps.org 0.9", cadence: "every build", media_type: "application/xml" }, |
| 204 | DataFile { path: "/sitemap.md", purpose: "The readable twin of sitemap.xml: every page grouped in H2 sections with a one-line description.", schema: "Markdown: H1, blockquote summary, H2 sections of links.", cadence: "every build", media_type: "text/markdown" }, |
| 205 | DataFile { path: "/AGENTS.md", purpose: "The repository brief for coding agents: installation, configuration, usage, conventions and approval boundaries.", schema: "Markdown: H1, Installation, Configuration, Usage, Conventions, Safety and approvals.", cadence: "when the build or conventions change", media_type: "text/markdown" }, |
| 206 | DataFile { path: "/agents/RULES.md", purpose: "The working rules every Aien agent follows, public edition: read first by any agent working on an aien-dev repository, before that repository's own AGENTS.md.", schema: "Markdown: H1, blockquote scope, numbered H2 sections, Where to go next.", cadence: "when the rules change", media_type: "text/markdown" }, |
| 207 | DataFile { path: "/data/agent-repos.json", purpose: "Every public, unarchived aien-dev repository with its description, default branch and the agent brief it carries (AGENTS.md or CLAUDE.md).", schema: "{ generated_at, org, repos: [{ name, description, url, default_branch, fork, pushed_at, brief }] }; brief is null when the repository has none", cadence: "with each reviewed release", media_type: "application/json" }, |
| 208 | DataFile { path: "/data/pages.json", purpose: "Every English page of the site with its title, description, area, kind and publication date, for catalog readers.", schema: "[{ path, title, description, area, mode, source, kind, published, image, doi, english }]", cadence: "every build", media_type: "application/json" }, |
| 209 | DataFile { path: "/.well-known/agora", purpose: "Agora open agent network discovery: protocol version, node identity, base URL, API prefix and source code.", schema: "Line-oriented text: agora 1, node <id> <url> <operator>, api <url>, protocol <url>, source <url>.", cadence: "static", media_type: "text/plain" }, |
| 210 | DataFile { path: "/index.md", purpose: "The front page as Markdown: the same content as the HTML, with frontmatter, the page body and a sitemap section. Every page has a mirror at the same path with .md.", schema: "Markdown: YAML frontmatter (title, description, last_updated, canonical_url), body, Sitemap section.", cadence: "every build", media_type: "text/markdown" }, |
| 211 | DataFile { path: "/research/CITATION.cff", purpose: "Citation metadata for the Turing preprints.", schema: "Citation File Format 1.2.0", cadence: "when a paper is revised", media_type: "text/yaml" }, |
| 212 | DataFile { path: "/research/aien-research-plan.md", purpose: "The ratified V3 research plan in Markdown.", schema: "Markdown", cadence: "when the plan is revised", media_type: "text/markdown" }, |
| 213 | DataFile { path: "/data/engineer.json", purpose: "About the engineer: every page of /engineer/ (drakestapleton.com, merged here) with its title, description, body and the old drakestapleton.com paths that redirect to it.", schema: "{ source, note, pages: [{ path, old[], name, title, description, kind, body_html }] }", cadence: "when a page of the section changes", media_type: "application/json" }, |
| 214 | DataFile { path: "/humans.txt", purpose: "Who builds this: the person, the agents and the machines.", schema: "humanstxt.org", cadence: "rarely", media_type: "text/plain" }, |
| 215 | DataFile { path: "/robots.txt", purpose: "Every crawler and AI agent is allowed everywhere; points at the sitemap.", schema: "robots.txt", cadence: "every build", media_type: "text/plain" }, |
| 216 | DataFile { path: "/funding.json", purpose: "My funding manifest for FLOSS/fund and other funders: who I am, Omega and CUDA++, the Bitcoin channel and the phased plan.", schema: "funding.json v1.1.0 (fundingjson.org): { entity, projects[], funding: { channels[], plans[] } }", cadence: "when a project, channel or plan changes", media_type: "application/json" }, |
| 217 | ]; |
| 218 | |
| 219 | /// Crawlers named one by one in robots.txt so nobody has to guess whether |
| 220 | /// the wildcard was meant for them. |
| 221 | pub const AI_AGENTS: &[&str] = &[ |
| 222 | "GPTBot", "ChatGPT-User", "OAI-SearchBot", "ClaudeBot", "Claude-Web", "Claude-SearchBot", "anthropic-ai", |
| 223 | "PerplexityBot", "Perplexity-User", "Google-Extended", "Googlebot", "Applebot", "Applebot-Extended", |
| 224 | "Bingbot", "Bytespider", "CCBot", "Amazonbot", "cohere-ai", "Meta-ExternalAgent", "Meta-ExternalFetcher", |
| 225 | "DuckAssistBot", "YouBot", "MistralAI-User", "Twitterbot", "facebookexternalhit", "LinkedInBot", |
| 226 | ]; |
| 227 | |
| 228 | /// What the build knows about time and history. |
| 229 | pub struct BuildCtx { |
| 230 | /// RFC 3339, the moment of this build. |
| 231 | pub built: String, |
| 232 | /// RFC 3339, the latest commit of the repository (what generated pages last changed with). |
| 233 | pub head_committed: String, |
| 234 | /// RFC 3339, when the ledger was last written (for /now/). |
| 235 | pub ledger_written: String, |
| 236 | /// RFC 3339, when facts.json was gathered (for /progress/ and the front page tables). |
| 237 | pub facts_generated: String, |
| 238 | } |
| 239 | |
| 240 | impl BuildCtx { |
| 241 | pub fn gather(now: &Now, facts_generated: &str) -> BuildCtx { |
| 242 | let built = rfc3339(now_secs()); |
| 243 | let head = git(&["log", "-1", "--format=%cI"]).unwrap_or_else(|| built.clone()); |
| 244 | let ledger = now::parse_utc(&now.ledger_written_utc).map(rfc3339).unwrap_or_else(|| built.clone()); |
| 245 | let facts = if facts_generated.is_empty() { built.clone() } else { facts_generated.to_string() }; |
| 246 | BuildCtx { built, head_committed: head, ledger_written: ledger, facts_generated: facts } |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | fn now_secs() -> i64 { |
| 251 | std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs() as i64).unwrap_or(0) |
| 252 | } |
| 253 | |
| 254 | /// RFC 3339 in UTC with seconds, from Unix seconds. |
| 255 | pub fn rfc3339(secs: i64) -> String { |
| 256 | let days = secs.div_euclid(86_400); |
| 257 | let rem = secs.rem_euclid(86_400); |
| 258 | let z = days + 719_468; |
| 259 | let era = z.div_euclid(146_097); |
| 260 | let doe = z - era * 146_097; |
| 261 | let yoe = (doe - doe / 1460 + doe / 36_524 - doe / 146_096) / 365; |
| 262 | let y = yoe + era * 400; |
| 263 | let doy = doe - (365 * yoe + yoe / 4 - yoe / 100); |
| 264 | let mp = (5 * doy + 2) / 153; |
| 265 | let d = doy - (153 * mp + 2) / 5 + 1; |
| 266 | let m = if mp < 10 { mp + 3 } else { mp - 9 }; |
| 267 | let y = if m <= 2 { y + 1 } else { y }; |
| 268 | format!("{y:04}-{m:02}-{d:02}T{:02}:{:02}:{:02}Z", rem / 3600, (rem % 3600) / 60, rem % 60) |
| 269 | } |
| 270 | |
| 271 | fn git(args: &[&str]) -> Option<String> { |
| 272 | let out = Command::new("git").args(args).output().ok()?; |
| 273 | if !out.status.success() { |
| 274 | return None; |
| 275 | } |
| 276 | let s = String::from_utf8_lossy(&out.stdout).trim().to_string(); |
| 277 | if s.is_empty() { None } else { Some(s) } |
| 278 | } |
| 279 | |
| 280 | // ------------------------------------------------------------------ pages |
| 281 | |
| 282 | /// One page found in dist. |
| 283 | #[derive(Clone, Debug)] |
| 284 | pub struct Emitted { |
| 285 | /// Site path with leading and trailing slash, e.g. `/research/status/`. |
| 286 | pub path: String, |
| 287 | pub file: PathBuf, |
| 288 | pub lastmod: String, |
| 289 | } |
| 290 | |
| 291 | impl Emitted { |
| 292 | pub fn url(&self) -> String { |
| 293 | format!("{HOST}{}", self.path) |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | /// Old addresses kept as small redirect pages (old, new). They are not pages: |
| 298 | /// no sitemap, feed, llms or markdown entry, and each says `noindex`. |
| 299 | pub const REDIRECTS: &[(&str, &str)] = &[("/allen/", "/aien/")]; |
| 300 | |
| 301 | /// Every `index.html` under dist, as site paths. The 404 page and the |
| 302 | /// `REDIRECTS` stubs are not pages. |
| 303 | pub fn walk_pages(dist: &Path, ctx: &BuildCtx) -> Vec<Emitted> { |
| 304 | let mut out = Vec::new(); |
| 305 | fn walk(dir: &Path, dist: &Path, ctx: &BuildCtx, out: &mut Vec<Emitted>) { |
| 306 | let Ok(rd) = fs::read_dir(dir) else { return }; |
| 307 | for e in rd.flatten() { |
| 308 | let p = e.path(); |
| 309 | if p.is_dir() { |
| 310 | walk(&p, dist, ctx, out); |
| 311 | } else if p.file_name().map(|n| n == "index.html").unwrap_or(false) { |
| 312 | let rel = p.strip_prefix(dist).unwrap().parent().unwrap(); |
| 313 | let mut path = format!("/{}", rel.to_string_lossy().replace('\\', "/")); |
| 314 | if !path.ends_with('/') { |
| 315 | path.push('/'); |
| 316 | } |
| 317 | if path == "//" { |
| 318 | path = "/".into(); |
| 319 | } |
| 320 | let lastmod = lastmod_for(&path, ctx); |
| 321 | if !REDIRECTS.iter().any(|(old, _)| *old == path) { |
| 322 | out.push(Emitted { path, file: p, lastmod }); |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | walk(dist, dist, ctx, &mut out); |
| 328 | out.sort_by(|a, b| a.path.cmp(&b.path)); |
| 329 | out |
| 330 | } |
| 331 | |
| 332 | /// When a page last changed. Hand-written pages carry the date of their |
| 333 | /// last commit when the history is available; pages rebuilt from live data |
| 334 | /// carry the data's own time; other generated pages carry the latest |
| 335 | /// repository commit. The build time is the fallback, never the first choice, |
| 336 | /// because a lastmod that moves on every build tells crawlers nothing. |
| 337 | fn lastmod_for(path: &str, ctx: &BuildCtx) -> String { |
| 338 | match path { |
| 339 | "/now/" => return ctx.ledger_written.clone(), |
| 340 | "/progress/" | "/" => return ctx.facts_generated.clone(), |
| 341 | _ => {} |
| 342 | } |
| 343 | let source = format!("public{}index.html", path); |
| 344 | if Path::new(&source).exists() { |
| 345 | if let Some(d) = git(&["log", "-1", "--format=%cI", "--", &source]) { |
| 346 | return d; |
| 347 | } |
| 348 | } |
| 349 | ctx.head_committed.clone() |
| 350 | } |
| 351 | |
| 352 | pub fn info_for(path: &str) -> Option<&'static PageInfo> { |
| 353 | PAGES.iter().find(|p| p.path == path) |
| 354 | } |
| 355 | |
| 356 | /// The markdown mirror of a page: `/` becomes `/index.md`, every other |
| 357 | /// directory page loses its trailing slash and gains `.md`. This is the |
| 358 | /// path an agent reaches by adding `.md` to the readable URL. |
| 359 | pub fn md_path(path: &str) -> String { |
| 360 | if path == "/" { |
| 361 | format!("{path}index.md") |
| 362 | } else { |
| 363 | format!("{}.md", path.trim_end_matches('/')) |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | /// Fails the build when dist and PAGES disagree. The same check runs in |
| 368 | /// `verify` through [`crate::oracle::verify`], on any generated tree. |
| 369 | pub fn check_registry(pages: &[Emitted]) { |
| 370 | let paths: Vec<String> = pages.iter().map(|p| p.path.clone()).collect(); |
| 371 | crate::oracle::check_registry(&paths).unwrap_or_else(|e| panic!("{e}")); |
| 372 | } |
| 373 | |
| 374 | // ------------------------------------------------------------------ head |
| 375 | |
| 376 | /// What a head said before the pass touched it. |
| 377 | #[derive(Default, Debug)] |
| 378 | struct HeadFacts { |
| 379 | title: String, |
| 380 | description: String, |
| 381 | og_title: String, |
| 382 | og_description: String, |
| 383 | og_type: String, |
| 384 | } |
| 385 | |
| 386 | pub(crate) fn attr(tag: &str, name: &str) -> Option<String> { |
| 387 | // name="value" or name='value', any attribute order, any spacing. |
| 388 | let mut i = 0; |
| 389 | let bytes = tag.as_bytes(); |
| 390 | while let Some(pos) = tag[i..].find(name) { |
| 391 | let start = i + pos; |
| 392 | let before_ok = start == 0 || bytes[start - 1].is_ascii_whitespace(); |
| 393 | let mut j = start + name.len(); |
| 394 | while j < bytes.len() && bytes[j].is_ascii_whitespace() { j += 1; } |
| 395 | if before_ok && j < bytes.len() && bytes[j] == b'=' { |
| 396 | j += 1; |
| 397 | while j < bytes.len() && bytes[j].is_ascii_whitespace() { j += 1; } |
| 398 | if j < bytes.len() && (bytes[j] == b'"' || bytes[j] == b'\'') { |
| 399 | let q = bytes[j]; |
| 400 | let end = tag[j + 1..].find(q as char)? + j + 1; |
| 401 | return Some(tag[j + 1..end].to_string()); |
| 402 | } |
| 403 | } |
| 404 | i = start + name.len(); |
| 405 | } |
| 406 | None |
| 407 | } |
| 408 | |
| 409 | pub(crate) fn tag_name(tag: &str) -> String { |
| 410 | tag.trim_start_matches('<').trim_start_matches('/').chars().take_while(|c| c.is_ascii_alphanumeric()).collect::<String>().to_ascii_lowercase() |
| 411 | } |
| 412 | |
| 413 | /// True for the tags the pass owns and rewrites. |
| 414 | fn owned_tag(tag: &str) -> bool { |
| 415 | match tag_name(tag).as_str() { |
| 416 | "link" => { |
| 417 | let rel = attr(tag, "rel").unwrap_or_default(); |
| 418 | rel == "canonical" |
| 419 | || rel == "describedby" |
| 420 | || (rel == "alternate" |
| 421 | && (attr(tag, "hreflang").is_some() |
| 422 | || attr(tag, "type").map(|t| t.contains("xml") || t.contains("markdown")).unwrap_or(false))) |
| 423 | } |
| 424 | "meta" => { |
| 425 | let key = attr(tag, "property").or_else(|| attr(tag, "name")).unwrap_or_default(); |
| 426 | key.starts_with("og:") || key.starts_with("twitter:") || key.starts_with("article:") || key == "robots" |
| 427 | } |
| 428 | _ => false, |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | /// Splits a head into (kept text, facts): owned tags and ld+json blocks are removed. |
| 433 | fn strip_head(head: &str) -> (String, HeadFacts) { |
| 434 | let mut facts = HeadFacts::default(); |
| 435 | let mut kept = String::with_capacity(head.len()); |
| 436 | let mut i = 0; |
| 437 | while i < head.len() { |
| 438 | let Some(lt) = head[i..].find('<') else { kept.push_str(&head[i..]); break; }; |
| 439 | kept.push_str(&head[i..i + lt]); |
| 440 | let start = i + lt; |
| 441 | let rest = &head[start..]; |
| 442 | let name = tag_name(rest); |
| 443 | if rest.starts_with("<!--") { |
| 444 | let end = rest.find("-->").map(|e| e + 3).unwrap_or(rest.len()); |
| 445 | kept.push_str(&rest[..end]); |
| 446 | i = start + end; |
| 447 | continue; |
| 448 | } |
| 449 | if name == "script" || name == "style" || name == "title" { |
| 450 | let close = format!("</{name}"); |
| 451 | let end = rest.to_ascii_lowercase().find(&close).map(|e| rest[e..].find('>').map(|g| e + g + 1).unwrap_or(rest.len())).unwrap_or(rest.len()); |
| 452 | let whole = &rest[..end]; |
| 453 | let open_end = whole.find('>').unwrap_or(0); |
| 454 | let open = &whole[..=open_end.min(whole.len() - 1)]; |
| 455 | if name == "title" { |
| 456 | facts.title = whole[open_end + 1..].split("</").next().unwrap_or("").trim().to_string(); |
| 457 | kept.push_str(whole); |
| 458 | } else if name == "script" && attr(open, "type").map(|t| t == "application/ld+json").unwrap_or(false) { |
| 459 | // dropped: the pass writes its own |
| 460 | } else { |
| 461 | kept.push_str(whole); |
| 462 | } |
| 463 | i = start + end; |
| 464 | continue; |
| 465 | } |
| 466 | let end = rest.find('>').map(|e| e + 1).unwrap_or(rest.len()); |
| 467 | let tag = &rest[..end]; |
| 468 | if name == "meta" { |
| 469 | let key = attr(tag, "property").or_else(|| attr(tag, "name")).unwrap_or_default(); |
| 470 | let content = attr(tag, "content").unwrap_or_default(); |
| 471 | match key.as_str() { |
| 472 | "description" => facts.description = content.clone(), |
| 473 | "og:title" => facts.og_title = content.clone(), |
| 474 | "og:description" => facts.og_description = content.clone(), |
| 475 | "og:type" => facts.og_type = content.clone(), |
| 476 | _ => {} |
| 477 | } |
| 478 | } |
| 479 | if !owned_tag(tag) { |
| 480 | kept.push_str(tag); |
| 481 | } |
| 482 | i = start + end; |
| 483 | } |
| 484 | (kept, facts) |
| 485 | } |
| 486 | |
| 487 | fn unescape(s: &str) -> String { |
| 488 | s.replace(""", "\"").replace("'", "'").replace("'", "'").replace("<", "<").replace(">", ">").replace("#", "#").replace("&", "&") |
| 489 | } |
| 490 | |
| 491 | fn escape(s: &str) -> String { |
| 492 | s.replace('&', "&").replace('<', "<").replace('>', ">").replace('"', """) |
| 493 | } |
| 494 | |
| 495 | fn breadcrumb_name(segment: &str) -> String { |
| 496 | match segment { |
| 497 | "research" => "Research".into(), |
| 498 | "blog" => "Blog".into(), |
| 499 | "status" => "Status".into(), |
| 500 | _ => { |
| 501 | let mut words: Vec<String> = segment.split('-').map(|w| { |
| 502 | let mut c = w.chars(); |
| 503 | match c.next() { Some(f) => f.to_uppercase().collect::<String>() + c.as_str(), None => String::new() } |
| 504 | }).collect(); |
| 505 | if words.len() > 6 { words.truncate(6); } |
| 506 | words.join(" ") |
| 507 | } |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | fn breadcrumb(page: &Emitted, page_name: &str) -> Value { |
| 512 | let mut items = vec![json!({"@type": "ListItem", "position": 1, "name": "Home", "item": format!("{HOST}/")})]; |
| 513 | let segs: Vec<&str> = page.path.trim_matches('/').split('/').filter(|s| !s.is_empty()).collect(); |
| 514 | let mut acc = String::new(); |
| 515 | for (i, seg) in segs.iter().enumerate() { |
| 516 | acc.push('/'); |
| 517 | acc.push_str(seg); |
| 518 | let last = i + 1 == segs.len(); |
| 519 | let name = if last { page_name.to_string() } else { breadcrumb_name(seg) }; |
| 520 | items.push(json!({"@type": "ListItem", "position": i + 2, "name": name, "item": format!("{HOST}{acc}/")})); |
| 521 | } |
| 522 | json!({"@type": "BreadcrumbList", "@id": format!("{}#breadcrumb", page.url()), "itemListElement": items}) |
| 523 | } |
| 524 | |
| 525 | fn org() -> Value { |
| 526 | json!({ |
| 527 | "@type": "Organization", |
| 528 | "@id": format!("{HOST}/#organization"), |
| 529 | "name": ORG_NAME, |
| 530 | "alternateName": "aien-dev", |
| 531 | "url": format!("{HOST}/"), |
| 532 | "logo": {"@type": "ImageObject", "url": format!("{HOST}/logo.png"), "width": 512, "height": 512}, |
| 533 | "email": ORG_EMAIL, |
| 534 | "sameAs": [ORG_URL, X_URL], |
| 535 | "founder": {"@id": format!("{HOST}/#drake")} |
| 536 | }) |
| 537 | } |
| 538 | |
| 539 | fn author() -> Value { |
| 540 | json!({ |
| 541 | "@type": "Person", |
| 542 | "@id": format!("{HOST}/#drake"), |
| 543 | "name": AUTHOR, |
| 544 | "alternateName": "Drake Stapleton", |
| 545 | "url": AUTHOR_URL, |
| 546 | "sameAs": [AUTHOR_FORGE, X_URL], |
| 547 | "affiliation": {"@id": format!("{HOST}/#organization")} |
| 548 | }) |
| 549 | } |
| 550 | |
| 551 | fn website() -> Value { |
| 552 | json!({ |
| 553 | "@type": "WebSite", |
| 554 | "@id": format!("{HOST}/#website"), |
| 555 | "url": format!("{HOST}/"), |
| 556 | "name": SITE_NAME, |
| 557 | "description": SITE_CLAIM, |
| 558 | "inLanguage": "en", |
| 559 | "publisher": {"@id": format!("{HOST}/#organization")}, |
| 560 | "license": LICENSE_URL |
| 561 | }) |
| 562 | } |
| 563 | |
| 564 | fn dataset(path: &str, name: &str, purpose: &str, modified: &str) -> Value { |
| 565 | json!({ |
| 566 | "@type": "Dataset", |
| 567 | "@id": format!("{HOST}{path}"), |
| 568 | "name": name, |
| 569 | "description": purpose, |
| 570 | "url": format!("{HOST}{path}"), |
| 571 | "license": LICENSE_URL, |
| 572 | "isAccessibleForFree": true, |
| 573 | "creator": {"@id": format!("{HOST}/#organization")}, |
| 574 | "dateModified": modified, |
| 575 | "distribution": [{"@type": "DataDownload", "encodingFormat": "application/json", "contentUrl": format!("{HOST}{path}")}] |
| 576 | }) |
| 577 | } |
| 578 | |
| 579 | fn software(key: &str, name: &str, repo: &str, role: &str) -> Value { |
| 580 | let mut v = json!({ |
| 581 | "@type": "SoftwareSourceCode", |
| 582 | "@id": format!("{HOST}/#software-{key}"), |
| 583 | "name": name, |
| 584 | "alternateName": key, |
| 585 | "description": role, |
| 586 | "license": LICENSE_URL, |
| 587 | "isAccessibleForFree": true, |
| 588 | "author": {"@id": format!("{HOST}/#organization")} |
| 589 | }); |
| 590 | // Only a repository with a copy on the forge gets a code link; GitHub is never named. |
| 591 | if let Some(url) = crate::forge::repo_url(repo.rsplit('/').next().unwrap_or(repo)) { |
| 592 | v["codeRepository"] = json!(url); |
| 593 | } |
| 594 | v |
| 595 | } |
| 596 | |
| 597 | /// The JSON-LD graph for one page. |
| 598 | fn graph(page: &Emitted, info: &PageInfo, facts: &HeadFacts, ctx: &BuildCtx, dist: &Path) -> Value { |
| 599 | let url = page.url(); |
| 600 | let title = unescape(if facts.og_title.is_empty() { &facts.title } else { &facts.og_title }); |
| 601 | let description = unescape(if facts.description.is_empty() { &facts.og_description } else { &facts.description }); |
| 602 | let image = format!("{HOST}{}", info.image); |
| 603 | let kind = match info.kind { |
| 604 | Kind::Home | Kind::Page | Kind::Live => "WebPage", |
| 605 | Kind::Collection => "CollectionPage", |
| 606 | Kind::Article => "Article", |
| 607 | Kind::Paper => "ScholarlyArticle", |
| 608 | }; |
| 609 | let mut node = json!({ |
| 610 | "@type": kind, |
| 611 | "@id": url, |
| 612 | "url": url, |
| 613 | "name": title, |
| 614 | "headline": title, |
| 615 | "description": description, |
| 616 | "inLanguage": "en", |
| 617 | "isPartOf": {"@id": format!("{HOST}/#website")}, |
| 618 | "image": {"@type": "ImageObject", "url": image, "width": 1200, "height": 630}, |
| 619 | "datePublished": info.published, |
| 620 | "dateModified": page.lastmod, |
| 621 | "license": LICENSE_URL, |
| 622 | "isAccessibleForFree": true, |
| 623 | "publisher": {"@id": format!("{HOST}/#organization")} |
| 624 | }); |
| 625 | let is_web_page = matches!(info.kind, Kind::Home | Kind::Page | Kind::Live | Kind::Collection); |
| 626 | if is_web_page { |
| 627 | // WebPage-only properties; the validator warns when they sit on an Article. |
| 628 | node["primaryImageOfPage"] = json!({"@type": "ImageObject", "url": image, "width": 1200, "height": 630}); |
| 629 | node["breadcrumb"] = json!({"@id": format!("{url}#breadcrumb")}); |
| 630 | } else { |
| 631 | node["author"] = json!({"@id": format!("{HOST}/#drake")}); |
| 632 | node["mainEntityOfPage"] = json!(url); |
| 633 | } |
| 634 | if info.kind == Kind::Paper { |
| 635 | node["creativeWorkStatus"] = json!("Preprint, not peer reviewed"); |
| 636 | if let Some(doi) = info.doi { |
| 637 | node["identifier"] = json!({"@type": "PropertyValue", "propertyID": "DOI", "value": doi}); |
| 638 | node["sameAs"] = json!(format!("https://doi.org/{doi}")); |
| 639 | } |
| 640 | let pdf = dist.join(page.path.trim_start_matches('/')).join("paper.pdf"); |
| 641 | if pdf.exists() { |
| 642 | node["encoding"] = json!([{"@type": "MediaObject", "encodingFormat": "application/pdf", "contentUrl": format!("{HOST}{}paper.pdf", page.path)}]); |
| 643 | } |
| 644 | } |
| 645 | let mut nodes = vec![org(), author(), website(), node]; |
| 646 | if is_web_page || page.path != "/" { |
| 647 | nodes.push(breadcrumb(page, &title)); |
| 648 | } |
| 649 | match info.path { |
| 650 | "/" => { |
| 651 | for (key, name, repo, role) in crate::facts::COMPONENTS { |
| 652 | nodes.push(software(key, name, repo, role)); |
| 653 | } |
| 654 | nodes.push(dataset("/now.json", "Aien coordination ledger", DATA_FILES.iter().find(|d| d.path == "/now.json").unwrap().purpose, &ctx.ledger_written)); |
| 655 | nodes.push(dataset("/machines.json", "Aien machines and speeds", DATA_FILES.iter().find(|d| d.path == "/machines.json").unwrap().purpose, &ctx.head_committed)); |
| 656 | nodes.push(dataset("/facts.json", "Aien public record facts", DATA_FILES.iter().find(|d| d.path == "/facts.json").unwrap().purpose, &ctx.facts_generated)); |
| 657 | nodes.push(dataset("/status.json", "Aien layer status", DATA_FILES.iter().find(|d| d.path == "/status.json").unwrap().purpose, &ctx.head_committed)); |
| 658 | nodes.push(dataset("/research-status.json", "Aien research status", DATA_FILES.iter().find(|d| d.path == "/research-status.json").unwrap().purpose, &ctx.head_committed)); |
| 659 | } |
| 660 | "/now/" => nodes.push(dataset("/now.json", "Aien coordination ledger", DATA_FILES.iter().find(|d| d.path == "/now.json").unwrap().purpose, &ctx.ledger_written)), |
| 661 | "/omega/" => nodes.push(dataset("/omega.json", "What Omega is", DATA_FILES.iter().find(|d| d.path == "/omega.json").unwrap().purpose, &ctx.head_committed)), |
| 662 | "/cudaplusplus/" => nodes.push(dataset("/cudaplusplus.json", "CUDA++", DATA_FILES.iter().find(|d| d.path == "/cudaplusplus.json").unwrap().purpose, &ctx.head_committed)), |
| 663 | "/machine/" => nodes.push(dataset("/machines.json", "Aien machines and speeds", DATA_FILES.iter().find(|d| d.path == "/machines.json").unwrap().purpose, &ctx.head_committed)), |
| 664 | "/evidence/" | "/research/status/" => nodes.push(dataset("/research-status.json", "Aien research status", DATA_FILES.iter().find(|d| d.path == "/research-status.json").unwrap().purpose, &ctx.head_committed)), |
| 665 | _ => {} |
| 666 | } |
| 667 | json!({"@context": "https://schema.org", "@graph": nodes}) |
| 668 | } |
| 669 | |
| 670 | /// The tags the pass writes into every head. |
| 671 | fn head_block(page: &Emitted, info: &PageInfo, facts: &HeadFacts, ctx: &BuildCtx, dist: &Path) -> String { |
| 672 | let url = page.url(); |
| 673 | let title = if facts.og_title.is_empty() { facts.title.clone() } else { facts.og_title.clone() }; |
| 674 | let description = if facts.og_description.is_empty() { facts.description.clone() } else { facts.og_description.clone() }; |
| 675 | let og_type = if !facts.og_type.is_empty() { facts.og_type.clone() } else { match info.kind { Kind::Article | Kind::Paper => "article".into(), _ => "website".into() } }; |
| 676 | let image = format!("{HOST}{}?v={OG_IMAGE_VERSION}", info.image); |
| 677 | let image_alt = escape(&format!("{SITE_NAME}: {}", info.name)); |
| 678 | let mut b = String::new(); |
| 679 | b.push_str(&format!("<link rel=\"canonical\" href=\"{url}\">\n")); |
| 680 | b.push_str(&format!("<link rel=\"alternate\" type=\"text/markdown\" href=\"{}\">\n", md_path(&page.path))); |
| 681 | b.push_str(&format!("<link rel=\"describedby\" href=\"{HOST}/llms.txt\">\n")); |
| 682 | b.push_str("<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large\">\n"); |
| 683 | b.push_str(&format!("<link rel=\"alternate\" type=\"application/atom+xml\" title=\"AienOS: blog and research\" href=\"{HOST}/feed.xml\">\n")); |
| 684 | b.push_str(&format!("<link rel=\"alternate\" type=\"application/atom+xml\" title=\"AienOS: settled work from the live ledger\" href=\"{HOST}/now/feed.xml\">\n")); |
| 685 | b.push_str(&format!("<meta property=\"og:site_name\" content=\"{SITE_NAME}\">\n<meta property=\"og:locale\" content=\"en_US\">\n")); |
| 686 | b.push_str(&format!("<meta property=\"og:title\" content=\"{title}\">\n<meta property=\"og:description\" content=\"{description}\">\n<meta property=\"og:url\" content=\"{url}\">\n<meta property=\"og:type\" content=\"{og_type}\">\n")); |
| 687 | b.push_str(&format!("<meta property=\"og:image\" content=\"{image}\">\n<meta property=\"og:image:width\" content=\"1200\">\n<meta property=\"og:image:height\" content=\"630\">\n<meta property=\"og:image:alt\" content=\"{image_alt}\">\n")); |
| 688 | if matches!(info.kind, Kind::Article | Kind::Paper) { |
| 689 | b.push_str(&format!("<meta property=\"article:published_time\" content=\"{}\">\n<meta property=\"article:modified_time\" content=\"{}\">\n<meta property=\"article:author\" content=\"{AUTHOR_URL}\">\n", info.published, page.lastmod)); |
| 690 | } |
| 691 | b.push_str(&format!("<meta name=\"twitter:card\" content=\"summary_large_image\">\n<meta name=\"twitter:site\" content=\"{X_HANDLE}\">\n<meta name=\"twitter:creator\" content=\"{X_HANDLE}\">\n<meta name=\"twitter:title\" content=\"{title}\">\n<meta name=\"twitter:description\" content=\"{description}\">\n<meta name=\"twitter:image\" content=\"{image}\">\n<meta name=\"twitter:image:alt\" content=\"{image_alt}\">\n")); |
| 692 | let ld = serde_json::to_string(&graph(page, info, facts, ctx, dist)).expect("JSON-LD serializes").replace("</", "<\\/"); |
| 693 | b.push_str(&format!("<script type=\"application/ld+json\">{ld}</script>\n")); |
| 694 | b |
| 695 | } |
| 696 | |
| 697 | fn yaml_quote(s: &str) -> String { |
| 698 | s.replace('\\', "\\\\").replace('"', "\\\"") |
| 699 | } |
| 700 | |
| 701 | /// The markdown mirror of one page: frontmatter, the page body as markdown |
| 702 | /// from the same HTML that was just written, and the sitemap section every |
| 703 | /// mirror carries so an agent can walk the rest of the site from it. |
| 704 | fn markdown_mirror(page: &Emitted, facts: &HeadFacts, html: &str) -> String { |
| 705 | let title = unescape(if facts.og_title.is_empty() { &facts.title } else { &facts.og_title }); |
| 706 | let description = unescape(if facts.description.is_empty() { &facts.og_description } else { &facts.description }); |
| 707 | let date = page.lastmod.get(..10).unwrap_or(&page.lastmod); |
| 708 | let mut s = String::new(); |
| 709 | s.push_str("---\n"); |
| 710 | s.push_str(&format!("title: \"{}\"\n", yaml_quote(&title))); |
| 711 | s.push_str(&format!("description: \"{}\"\n", yaml_quote(&description))); |
| 712 | s.push_str(&format!("last_updated: \"{date}\"\n")); |
| 713 | s.push_str(&format!("canonical_url: \"{}\"\n", page.url())); |
| 714 | s.push_str("---\n\n"); |
| 715 | s.push_str(&html_to_text(html)); |
| 716 | s.push_str(&format!("\n\n## Sitemap\n\nSee the full [sitemap]({HOST}/sitemap.md) for every page on aienos.com.\n")); |
| 717 | s |
| 718 | } |
| 719 | |
| 720 | /// Writes the mirror next to the page: `/index.md` for `/`, `/machine.md` |
| 721 | /// for `/machine/`. |
| 722 | fn write_markdown_mirror(dist: &Path, page: &Emitted, facts: &HeadFacts, html: &str) { |
| 723 | let body = markdown_mirror(page, facts, html); |
| 724 | // Both conventions agents use: the sibling file (`/machine.md`) and the |
| 725 | // directory index (`/machine/index.md`). The head points at the sibling. |
| 726 | let mut paths = vec![md_path(&page.path)]; |
| 727 | if page.path != "/" { |
| 728 | paths.push(format!("{}index.md", page.path)); |
| 729 | } |
| 730 | for rel in paths { |
| 731 | let file = dist.join(rel.trim_start_matches('/')); |
| 732 | if let Some(parent) = file.parent() { |
| 733 | fs::create_dir_all(parent).unwrap_or_else(|e| panic!("create {}: {e}", parent.display())); |
| 734 | } |
| 735 | fs::write(&file, &body).unwrap_or_else(|e| panic!("write {}: {e}", file.display())); |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | /// Every page links the glossary. Generated pages already do through the |
| 740 | /// footer; hand-written pages under public/ get one small link before |
| 741 | /// </body>, so the term page is reachable from every scanned URL. |
| 742 | fn ensure_glossary_link(mut html: String) -> String { |
| 743 | if html.contains("href=\"/glossary/\"") { |
| 744 | return html; |
| 745 | } |
| 746 | let block = "<div style=\"padding: 18px 24px; text-align: center; font-family: var(--font-mono); font-size: 12px;\"><a href=\"/glossary/\" style=\"color: var(--accent-green);\">Glossary</a></div>"; |
| 747 | match html.rfind("</body>") { |
| 748 | Some(i) => { |
| 749 | html.insert_str(i, block); |
| 750 | html |
| 751 | } |
| 752 | None => html, |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | /// Rewrites the head of every page in dist. Returns the pages, for the sitemap and feeds. |
| 757 | pub fn enrich(dist: &Path, ctx: &BuildCtx) -> Vec<Emitted> { |
| 758 | let pages = walk_pages(dist, ctx); |
| 759 | check_registry(&pages); |
| 760 | for page in &pages { |
| 761 | let html = fs::read_to_string(&page.file).unwrap_or_else(|e| panic!("read {}: {e}", page.file.display())); |
| 762 | let lower = html.to_ascii_lowercase(); |
| 763 | let head_start = lower.find("<head").and_then(|h| lower[h..].find('>').map(|g| h + g + 1)).unwrap_or_else(|| panic!("{} has no <head>", page.path)); |
| 764 | let head_end = lower.find("</head>").unwrap_or_else(|| panic!("{} has no </head>", page.path)); |
| 765 | let (kept, facts) = strip_head(&html[head_start..head_end]); |
| 766 | assert!(!facts.title.is_empty(), "{} has no <title>", page.path); |
| 767 | assert!(!facts.description.is_empty() || !facts.og_description.is_empty(), "{} has no meta description", page.path); |
| 768 | let info = info_for(&page.path).unwrap_or_else(|| panic!("{} has no English page in seo::PAGES", page.path)); |
| 769 | let block = head_block(page, info, &facts, ctx, dist); |
| 770 | let mut out = String::with_capacity(html.len() + block.len()); |
| 771 | out.push_str(&html[..head_start]); |
| 772 | out.push_str(kept.trim_end()); |
| 773 | out.push('\n'); |
| 774 | out.push_str(&block); |
| 775 | out.push_str(&html[head_end..]); |
| 776 | let out = crate::components::allen_intro::enrich(crate::components::support::enrich(crate::components::contact::enrich(ensure_glossary_link(out)))); |
| 777 | // Last: the policy is derived from everything the page now loads. |
| 778 | let out = crate::components::csp::enrich(out); |
| 779 | write_markdown_mirror(dist, page, &facts, &out); |
| 780 | fs::write(&page.file, out).unwrap_or_else(|e| panic!("write {}: {e}", page.file.display())); |
| 781 | } |
| 782 | println!(" [SEO] Rewrote the head of {} pages: canonical on {HOST}, cards, JSON-LD, markdown mirrors", pages.len()); |
| 783 | pages |
| 784 | } |
| 785 | |
| 786 | // ------------------------------------------------------------------ sitemap and robots |
| 787 | |
| 788 | pub fn sitemap_xml(pages: &[Emitted]) -> String { |
| 789 | let mut s = String::from("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n"); |
| 790 | for p in pages { |
| 791 | s.push_str(&format!(" <url>\n <loc>{}</loc>\n <lastmod>{}</lastmod>\n", p.url(), p.lastmod)); |
| 792 | s.push_str(" </url>\n"); |
| 793 | } |
| 794 | s.push_str("</urlset>\n"); |
| 795 | s |
| 796 | } |
| 797 | |
| 798 | pub fn robots_txt() -> String { |
| 799 | let mut s = String::from("# www.aienos.com is open to every reader, human or machine.\n# No crawler is blocked, no CAPTCHA, no bot wall. Cite freely; every page carries receipts.\n\nUser-agent: *\nAllow: /\n\n"); |
| 800 | for a in AI_AGENTS { |
| 801 | s.push_str(&format!("User-agent: {a}\nAllow: /\n\n")); |
| 802 | } |
| 803 | s.push_str(&format!("Sitemap: {HOST}/sitemap.xml\n")); |
| 804 | s |
| 805 | } |
| 806 | |
| 807 | // ------------------------------------------------------------------ feeds |
| 808 | |
| 809 | fn xml(s: &str) -> String { |
| 810 | s.replace('&', "&").replace('<', "<").replace('>', ">").replace('"', """) |
| 811 | } |
| 812 | |
| 813 | fn atom_head(title: &str, subtitle: &str, self_path: &str, updated: &str) -> String { |
| 814 | format!( |
| 815 | "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<feed xmlns=\"http://www.w3.org/2005/Atom\">\n <title>{}</title>\n <subtitle>{}</subtitle>\n <link href=\"{HOST}{self_path}\" rel=\"self\" type=\"application/atom+xml\"/>\n <link href=\"{HOST}/\" rel=\"alternate\" type=\"text/html\"/>\n <id>{HOST}{self_path}</id>\n <updated>{updated}</updated>\n <author><name>{}</name><uri>{AUTHOR_URL}</uri></author>\n <rights>{LICENSE_NAME}</rights>\n <icon>{HOST}/logo.png</icon>\n <logo>{HOST}/og.png</logo>\n", |
| 816 | xml(title), xml(subtitle), xml(AUTHOR) |
| 817 | ) |
| 818 | } |
| 819 | |
| 820 | /// /feed.xml: the blog posts and research papers, newest change first. |
| 821 | pub fn site_feed(pages: &[Emitted]) -> String { |
| 822 | let mut entries: Vec<(&Emitted, &PageInfo)> = pages |
| 823 | .iter() |
| 824 | .filter_map(|p| info_for(&p.path).map(|i| (p, i))) |
| 825 | .filter(|(_, i)| matches!(i.kind, Kind::Article | Kind::Paper)) |
| 826 | .collect(); |
| 827 | entries.sort_by(|a, b| b.0.lastmod.cmp(&a.0.lastmod).then(b.1.published.cmp(a.1.published))); |
| 828 | let updated = entries.first().map(|e| e.0.lastmod.clone()).unwrap_or_else(|| rfc3339(now_secs())); |
| 829 | let mut s = atom_head("AienOS: blog and research", "Research notes and preprints from the Aien project, with receipts.", "/feed.xml", &updated); |
| 830 | for (p, i) in entries { |
| 831 | s.push_str(&format!( |
| 832 | " <entry>\n <title>{}</title>\n <link href=\"{}\" rel=\"alternate\" type=\"text/html\"/>\n <id>{}</id>\n <published>{}T00:00:00Z</published>\n <updated>{}</updated>\n <summary>{}</summary>\n <category term=\"{}\"/>\n </entry>\n", |
| 833 | xml(i.name), p.url(), p.url(), i.published, p.lastmod, xml(i.what), if i.kind == Kind::Paper { "research" } else { "blog" } |
| 834 | )); |
| 835 | } |
| 836 | s.push_str("</feed>\n"); |
| 837 | s |
| 838 | } |
| 839 | |
| 840 | /// /now/feed.xml: one entry per settled ledger line, newest first, with its evidence. |
| 841 | pub fn now_feed(now: &Now, ctx: &BuildCtx) -> String { |
| 842 | let mut settled: Vec<&now::Item> = now.items.iter().filter(|i| i.status == "done" || i.status == "dropped").collect(); |
| 843 | settled.sort_by(|a, b| now::parse_utc(&b.updated_utc).cmp(&now::parse_utc(&a.updated_utc)).then(b.id.cmp(&a.id))); |
| 844 | let mut s = atom_head("AienOS: settled work from the live ledger", "Every coordination ledger line that reached done or dropped, with the evidence that settled it.", "/now/feed.xml", &ctx.ledger_written); |
| 845 | for it in settled { |
| 846 | let updated = now::parse_utc(&it.updated_utc).map(rfc3339).unwrap_or_else(|| ctx.ledger_written.clone()); |
| 847 | let published = now::parse_utc(&it.opened_utc).map(rfc3339).unwrap_or_else(|| updated.clone()); |
| 848 | let mut body = format!("Status: {}. Owner: {}. Stream: {}.", it.status, it.owner, it.stream); |
| 849 | if !it.done_when.is_empty() { |
| 850 | body.push_str(&format!("\nDone when: {}", it.done_when)); |
| 851 | } |
| 852 | if !it.notes.is_empty() { |
| 853 | body.push_str("\nEvidence:"); |
| 854 | for n in &it.notes { |
| 855 | body.push_str(&format!("\n- {n}")); |
| 856 | } |
| 857 | } |
| 858 | s.push_str(&format!( |
| 859 | " <entry>\n <title>{}: {} ({})</title>\n <link href=\"{HOST}/now/#{}\" rel=\"alternate\" type=\"text/html\"/>\n <id>{HOST}/now/#{}</id>\n <published>{published}</published>\n <updated>{updated}</updated>\n <content type=\"text\">{}</content>\n <category term=\"{}\"/>\n </entry>\n", |
| 860 | xml(&it.id), xml(&it.item), xml(&it.status), xml(&it.id), xml(&it.id), xml(&body), xml(&it.status) |
| 861 | )); |
| 862 | } |
| 863 | s.push_str("</feed>\n"); |
| 864 | s |
| 865 | } |
| 866 | |
| 867 | // ------------------------------------------------------------------ llms.txt, data index, humans.txt |
| 868 | |
| 869 | fn section_title(s: Section) -> &'static str { |
| 870 | match s { |
| 871 | Section::Start => "Start here", |
| 872 | Section::Machine => "The machine", |
| 873 | Section::Turing => "The Turing and the research", |
| 874 | Section::Evidence => "Evidence and status", |
| 875 | Section::Philosophy => "Philosophy", |
| 876 | Section::Blog => "Blog", |
| 877 | Section::Engineer => "About the engineer", |
| 878 | Section::Optional => "Optional", |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | /// /llms.txt in the llms.txt convention: one H1, a blockquote summary, H2 |
| 883 | /// sections of links with one-line descriptions, an Optional section last. |
| 884 | pub fn llms_txt(status_lines: &[String], research_sentence: &str) -> String { |
| 885 | let mut s = String::new(); |
| 886 | s.push_str("# Sovereign Intelligence\n\n"); |
| 887 | s.push_str(&format!("> {SITE_CLAIM}. Sovereign Intelligence is the whole system: an experimental, open source (Apache-2.0 WITH LLVM-exception) machine for turning search into verified understanding. AienOS is only the operating-system layer. Aien proposes, Omega makes the proposal explicit and verifiable, the machine tests it against reality, the Turing measures what was learned, Cortex keeps the evidence. Every claim on the site carries a public receipt. Sovereign Intelligence is in alpha testing; each component keeps its own evidence level. Built by {AUTHOR} with AI agents on five real machines.\n\n")); |
| 888 | s.push_str("Rules the site keeps: no comparisons with other companies, languages or products. State what this work does and what was measured, with receipts. Overclaims stay banned. Every speed still stands beside the physical ceiling of its own machine. Failures stay on the record, no outside fonts or advertising trackers (privacy at /privacy/; the film on /turing/ is an outside embed), and AI agents and humans are welcome to read, cite, argue and correct. Humans and AI agents meet, talk and collaborate in the Agora commons at https://www.aienos.com/agora/ (wire protocol at /agora/protocol/, node discovery at https://www.aienos.com/.well-known/agora). Contact Drake: drake@aienos.com or X @drakestapleton; every route, Aien included, is at https://www.aienos.com/contact/. Project mail: aien@aienos.com. Source: https://interplane.io/drakestapleton.\n\n"); |
| 889 | s.push_str("## Current state\n\n"); |
| 890 | for l in status_lines { |
| 891 | s.push_str(&format!("- {l}\n")); |
| 892 | } |
| 893 | s.push_str(&format!("- [Research status]({HOST}/research/status/): {research_sentence}\n\n")); |
| 894 | for sec in [Section::Start, Section::Machine, Section::Turing, Section::Evidence, Section::Philosophy, Section::Blog, Section::Engineer] { |
| 895 | s.push_str(&format!("## {}\n\n", section_title(sec))); |
| 896 | for p in PAGES.iter().filter(|p| p.section == sec) { |
| 897 | s.push_str(&format!("- [{}]({HOST}{}): {}\n", p.name, p.path, p.what)); |
| 898 | } |
| 899 | s.push('\n'); |
| 900 | } |
| 901 | s.push_str("## Machine-readable files\n\n"); |
| 902 | for d in DATA_FILES { |
| 903 | s.push_str(&format!("- [{}]({HOST}{}): {} Updated: {}.\n", d.path, d.path, d.purpose, d.cadence)); |
| 904 | } |
| 905 | s.push_str(&format!("- [{HOST}/llms-full.txt]({HOST}/llms-full.txt): every page's full text in one file.\n\n")); |
| 906 | s.push_str(crate::components::allen::LLMS); |
| 907 | s.push_str("## Optional\n\n"); |
| 908 | for p in PAGES.iter().filter(|p| p.section == Section::Optional) { |
| 909 | s.push_str(&format!("- [{}]({HOST}{}): {}\n", p.name, p.path, p.what)); |
| 910 | } |
| 911 | s.push_str(&format!("- [Papers as PDF]({HOST}/research/): each research page links its paper.pdf, paper.tex and SHA256SUMS.\n")); |
| 912 | s.push_str(&format!("- [Drake on X ({X_HANDLE})]({X_URL}): where the work is posted as it happens.\n")); |
| 913 | s |
| 914 | } |
| 915 | |
| 916 | /// /sitemap.md: the readable twin of sitemap.xml, H2 sections of described |
| 917 | /// links, generated from the same page registry as llms.txt and the XML map. |
| 918 | pub fn sitemap_md() -> String { |
| 919 | let mut s = String::from("# Sitemap\n\n"); |
| 920 | s.push_str(&format!("> Every page on aienos.com, grouped the way the site is. The crawler index is [sitemap.xml]({HOST}/sitemap.xml); the file list is [data/index.json]({HOST}/data/index.json).\n\n")); |
| 921 | for sec in [Section::Start, Section::Machine, Section::Turing, Section::Evidence, Section::Philosophy, Section::Blog, Section::Engineer, Section::Optional] { |
| 922 | s.push_str(&format!("## {}\n\n", section_title(sec))); |
| 923 | for p in PAGES.iter().filter(|p| p.section == sec) { |
| 924 | s.push_str(&format!("- [{}]({HOST}{}): {}\n", p.name, p.path, p.what)); |
| 925 | } |
| 926 | s.push('\n'); |
| 927 | } |
| 928 | s.push_str("## For agents\n\n"); |
| 929 | s.push_str(&format!("- [llms.txt]({HOST}/llms.txt): the site in one file for AI readers.\n")); |
| 930 | s.push_str(&format!("- [llms-full.txt]({HOST}/llms-full.txt): every page's full text in one file.\n")); |
| 931 | s.push_str(&format!("- [AGENTS.md]({HOST}/AGENTS.md): how to build, test and change this site.\n")); |
| 932 | s.push_str(&format!("- [data/index.json]({HOST}/data/index.json): every machine-readable file with its purpose and cadence.\n")); |
| 933 | s |
| 934 | } |
| 935 | |
| 936 | /// Plain text of a page body: scripts, styles, header, nav and footer dropped, |
| 937 | /// headings marked, links kept with their targets. The text of a `<pre>` or |
| 938 | /// `<textarea>` is code: it is kept byte for byte (indentation, trailing |
| 939 | /// spaces, blank lines) inside a fenced block. Only the newline that ends the |
| 940 | /// last line is dropped, because the closing fence follows it, so a file |
| 941 | /// copied from llms-full.txt as fence content plus one newline is the file on |
| 942 | /// the page. |
| 943 | pub fn html_to_text(html: &str) -> String { |
| 944 | // Marks a line that the whitespace cleanup below must leave alone. |
| 945 | const VERBATIM: char = '\u{1}'; |
| 946 | let lower = html.to_ascii_lowercase(); |
| 947 | let start = lower.find("<main").map(|m| lower[m..].find('>').map(|g| m + g + 1).unwrap_or(m)).or_else(|| lower.find("<body").map(|m| lower[m..].find('>').map(|g| m + g + 1).unwrap_or(m))).unwrap_or(0); |
| 948 | let end = lower.find("</main>").or_else(|| lower.find("<footer")).or_else(|| lower.find("</body>")).unwrap_or(html.len()); |
| 949 | let body = &html[start..end.max(start)]; |
| 950 | let mut out = String::new(); |
| 951 | let mut i = 0; |
| 952 | let mut href: Option<String> = None; |
| 953 | let mut link_text = String::new(); |
| 954 | let mut code: Option<(String, String)> = None; |
| 955 | while i < body.len() { |
| 956 | let Some(lt) = body[i..].find('<') else { out.push_str(&unescape(&body[i..])); break; }; |
| 957 | let text = &body[i..i + lt]; |
| 958 | if let Some((_, buf)) = code.as_mut() { buf.push_str(&unescape(text)); } else if href.is_some() { link_text.push_str(&unescape(text)); } else { out.push_str(&unescape(text)); } |
| 959 | let rest = &body[i + lt..]; |
| 960 | let name = tag_name(rest); |
| 961 | if let Some((open, buf)) = code.as_mut() { |
| 962 | let e = rest.find('>').map(|e| e + 1).unwrap_or(rest.len()); |
| 963 | if name == *open && rest.starts_with("</") { |
| 964 | // HTML drops one newline right after the opening tag. |
| 965 | let src = buf.strip_prefix('\n').unwrap_or(buf); |
| 966 | let src = src.strip_suffix('\n').unwrap_or(src); |
| 967 | if !src.trim().is_empty() { |
| 968 | out.push_str(&format!("\n{VERBATIM}```\n")); |
| 969 | for line in src.split('\n') { out.push_str(&format!("{VERBATIM}{line}\n")); } |
| 970 | out.push_str(&format!("{VERBATIM}```\n")); |
| 971 | } |
| 972 | code = None; |
| 973 | } else if name == "br" { |
| 974 | buf.push('\n'); |
| 975 | } |
| 976 | i += lt + e; |
| 977 | continue; |
| 978 | } |
| 979 | if matches!(name.as_str(), "pre" | "textarea") && !rest.starts_with("</") { |
| 980 | code = Some((name.clone(), String::new())); |
| 981 | i += lt + rest.find('>').map(|e| e + 1).unwrap_or(rest.len()); |
| 982 | continue; |
| 983 | } |
| 984 | if matches!(name.as_str(), "script" | "style" | "svg" | "nav" | "header" | "template") || rest.starts_with("<!--") { |
| 985 | let close = if rest.starts_with("<!--") { "-->".to_string() } else { format!("</{name}") }; |
| 986 | let e = rest.to_ascii_lowercase().find(&close).map(|e| rest[e..].find('>').map(|g| e + g + 1).unwrap_or(rest.len())).unwrap_or(rest.len()); |
| 987 | i += lt + e; |
| 988 | continue; |
| 989 | } |
| 990 | let e = rest.find('>').map(|e| e + 1).unwrap_or(rest.len()); |
| 991 | let tag = &rest[..e]; |
| 992 | let closing = tag.starts_with("</"); |
| 993 | match name.as_str() { |
| 994 | "h1" if !closing => out.push_str("\n\n# "), |
| 995 | "h2" if !closing => out.push_str("\n\n## "), |
| 996 | "h3" | "h4" if !closing => out.push_str("\n\n### "), |
| 997 | "p" | "div" | "section" | "article" | "li" | "tr" | "figure" | "figcaption" | "blockquote" | "ul" | "ol" | "table" | "aside" | "h1" | "h2" | "h3" | "h4" | "summary" | "details" => out.push('\n'), |
| 998 | "br" => out.push('\n'), |
| 999 | "td" | "th" | "span" | "small" | "em" | "strong" | "b" | "i" | "code" | "time" | "label" | "dt" | "dd" => out.push(' '), |
| 1000 | "a" if !closing => { |
| 1001 | let h = attr(tag, "href").unwrap_or_default(); |
| 1002 | if h.starts_with("http") || h.starts_with('/') { |
| 1003 | href = Some(if h.starts_with('/') { format!("{HOST}{h}") } else { h }); |
| 1004 | link_text.clear(); |
| 1005 | } |
| 1006 | } |
| 1007 | "a" if closing => { |
| 1008 | if let Some(h) = href.take() { |
| 1009 | let t = link_text.trim(); |
| 1010 | if t.is_empty() { out.push_str(&format!(" {h} ")); } else { out.push_str(&format!("[{t}]({h})")); } |
| 1011 | } |
| 1012 | } |
| 1013 | _ => {} |
| 1014 | } |
| 1015 | if name == "li" && !closing { out.push_str("- "); } |
| 1016 | i += lt + e; |
| 1017 | } |
| 1018 | // Collapse runs of blank lines and spaces, except in code lines. |
| 1019 | let mut cleaned = String::new(); |
| 1020 | let mut blank = 0; |
| 1021 | for line in out.lines() { |
| 1022 | if let Some(code_line) = line.trim_start_matches(|c: char| c != VERBATIM && c.is_whitespace()).strip_prefix(VERBATIM) { |
| 1023 | blank = 0; |
| 1024 | cleaned.push_str(code_line); |
| 1025 | cleaned.push('\n'); |
| 1026 | continue; |
| 1027 | } |
| 1028 | let l = line.split_whitespace().collect::<Vec<_>>().join(" "); |
| 1029 | if l.is_empty() { |
| 1030 | blank += 1; |
| 1031 | if blank <= 1 { cleaned.push('\n'); } |
| 1032 | } else { |
| 1033 | blank = 0; |
| 1034 | cleaned.push_str(&l); |
| 1035 | cleaned.push('\n'); |
| 1036 | } |
| 1037 | } |
| 1038 | cleaned.trim().to_string() |
| 1039 | } |
| 1040 | |
| 1041 | /// /llms-full.txt: every English page as text, in llms.txt order, from the files just written. |
| 1042 | pub fn llms_full(pages: &[Emitted]) -> String { |
| 1043 | let mut s = format!("# Sovereign Intelligence\n\nSovereign Intelligence is the whole system. AienOS is only the operating-system layer. Every English page is in this one file. Generated with the site from the same sources as the HTML. Page list and summaries: {HOST}/llms.txt. Machine-readable data: {HOST}/data/index.json.\n\n"); |
| 1044 | for info in PAGES { |
| 1045 | let Some(p) = pages.iter().find(|p| p.path == info.path) else { continue }; |
| 1046 | let html = fs::read_to_string(&p.file).unwrap_or_default(); |
| 1047 | s.push_str(&format!("\n---\n\n# {}\n\nSource: {}\nPublished: {}. Last changed: {}.\n\n{}\n", info.name, p.url(), info.published, p.lastmod, html_to_text(&html))); |
| 1048 | } |
| 1049 | s |
| 1050 | } |
| 1051 | |
| 1052 | pub fn data_index(ctx: &BuildCtx) -> String { |
| 1053 | let files: Vec<Value> = DATA_FILES |
| 1054 | .iter() |
| 1055 | .map(|d| json!({"path": d.path, "url": format!("{HOST}{}", d.path), "purpose": d.purpose, "schema": d.schema, "cadence": d.cadence, "media_type": d.media_type})) |
| 1056 | .collect(); |
| 1057 | let v = json!({ |
| 1058 | "site": format!("{HOST}/"), |
| 1059 | "generated": ctx.built, |
| 1060 | "license": LICENSE_NAME, |
| 1061 | "license_url": LICENSE_URL, |
| 1062 | "contact": ORG_EMAIL, |
| 1063 | "source": ORG_URL, |
| 1064 | "rules": [ |
| 1065 | "No comparisons with other companies, languages or products. State what this work does and what was measured, with receipts. Overclaims stay banned. Every speed still stands beside the physical ceiling of its own machine.", |
| 1066 | "Every claim links its receipt. Failures stay on the record.", |
| 1067 | "No outside fonts or advertising trackers. /privacy/ explains the privacy policy. The film on /turing/ is an outside embed." |
| 1068 | ], |
| 1069 | "files": files |
| 1070 | }); |
| 1071 | serde_json::to_string_pretty(&v).expect("data index serializes") + "\n" |
| 1072 | } |
| 1073 | |
| 1074 | pub fn humans_txt(ctx: &BuildCtx) -> String { |
| 1075 | format!( |
| 1076 | "/* TEAM */\n\tBuilder and owner: {AUTHOR}\n\tSite: {AUTHOR_URL}\n\tX: {X_HANDLE}\n\tForge: {AUTHOR_FORGE}\n\tContact: {ORG_EMAIL}\n\n/* AGENTS */\n\tThe code is written with AI coding agents working in parallel under one human conductor.\n\tEvery change is judged by the Spark itself before it merges; the receipts are public.\n\tAgents are first-class readers here: read, cite, argue, correct. {HOST}/llms.txt\n\n/* MACHINES */\n\tNVIDIA DGX Spark (Grace Blackwell GB10, 128 GB unified memory): the development machine and the judge.\n\tIntel iMac 2017: bare metal aienux, the x86_64 port of the AienOS C kernel.\n\tRaspberry Pi 5: the small machine.\n\tQEMU: the laboratory where every kernel boots first.\n\tThe rig: the owned inference box.\n\tDetails and receipts: {HOST}/machine/ and {HOST}/machines.json\n\n/* SITE */\n\tLast build: {}\n\tLanguages: English, Simplified Chinese\n\tBuilt with: Rust, maud. No frameworks or outside fonts. No advertising trackers; see /privacy/.\n\tSource: https://interplane.io/drakestapleton/aienos.com\n\tLicense: {LICENSE_NAME}\n", |
| 1077 | ctx.built |
| 1078 | ) |
| 1079 | } |
| 1080 | |
| 1081 | // ------------------------------------------------------------------ 404 |
| 1082 | |
| 1083 | pub fn render_404() -> Markup { |
| 1084 | html! { |
| 1085 | section class="hub" { |
| 1086 | div class="container" style="padding: 96px 0 120px 0; max-width: 720px;" { |
| 1087 | p class="hub-kicker" style="font-family: var(--font-mono); font-size: 12px; letter-spacing: .14em; color: var(--accent-blue); text-transform: uppercase; margin-bottom: 16px;" { "404: no receipt for this address" } |
| 1088 | h1 style="font-size: clamp(32px, 5vw, 48px); font-weight: 800; letter-spacing: -0.02em; color: var(--text-primary); margin: 0 0 16px;" { "There is nothing at this address." } |
| 1089 | p style="color: var(--text-secondary); font-size: 17px; line-height: 1.7;" { |
| 1090 | "The page may have moved, or the link was never right. Nothing on this site disappears without a trace: every page is listed in " |
| 1091 | a href="/llms.txt" { "llms.txt" } |
| 1092 | " and in the " |
| 1093 | a href="/sitemap.xml" { "sitemap" } |
| 1094 | "." |
| 1095 | } |
| 1096 | ul style="margin: 28px 0 0 0; padding: 0; list-style: none; display: grid; gap: 10px;" { |
| 1097 | li { a href="/" { "The front page" } ": the loop, the machines, the evidence." } |
| 1098 | li { a href="/machine/" { "The Machine" } ": Sovereign Intelligence on real hardware. AienOS is only the operating-system layer." } |
| 1099 | li { a href="/now/" { "Now" } ": what every agent is doing right now." } |
| 1100 | li { a href="/research/" { "Research" } ": the preprints and the papers." } |
| 1101 | li { a href="/evidence/" { "Evidence" } ": receipts over claims." } |
| 1102 | } |
| 1103 | p style="margin-top: 36px; font-family: var(--font-mono); font-size: 12px; color: var(--text-muted);" { |
| 1104 | "Found a broken link on the site? Open an issue at " |
| 1105 | code { "aien-dev/aienos.com" } |
| 1106 | "." |
| 1107 | } |
| 1108 | } |
| 1109 | } |
| 1110 | } |
| 1111 | } |
| 1112 | |
| 1113 | /// Extra head for the 404 page: never indexed, no canonical. |
| 1114 | pub fn head_404() -> Markup { |
| 1115 | html! { meta name="robots" content="noindex"; (PreEscaped("")) } |
| 1116 | } |
| 1117 | |
| 1118 | /// Writes everything that is not a page: sitemap, robots, feeds, llms files, data index, humans. |
| 1119 | pub fn write_machine_surface(dist: &Path, pages: &[Emitted], now: &Now, ctx: &BuildCtx, llms: &str) { |
| 1120 | fs::write(dist.join("sitemap.xml"), sitemap_xml(pages)).expect("write sitemap.xml"); |
| 1121 | fs::write(dist.join("robots.txt"), robots_txt()).expect("write robots.txt"); |
| 1122 | fs::write(dist.join("feed.xml"), site_feed(pages)).expect("write feed.xml"); |
| 1123 | fs::create_dir_all(dist.join("now")).expect("now dir"); |
| 1124 | fs::write(dist.join("now/feed.xml"), now_feed(now, ctx)).expect("write now/feed.xml"); |
| 1125 | fs::write(dist.join("llms.txt"), llms).expect("write llms.txt"); |
| 1126 | fs::write(dist.join("llms-full.txt"), llms_full(pages)).expect("write llms-full.txt"); |
| 1127 | fs::write(dist.join("sitemap.md"), sitemap_md()).expect("write sitemap.md"); |
| 1128 | let agents = fs::read_to_string("AGENTS.md").expect("AGENTS.md must exist at the repository root: the build publishes it at /AGENTS.md"); |
| 1129 | fs::write(dist.join("AGENTS.md"), agents).expect("write AGENTS.md"); |
| 1130 | fs::create_dir_all(dist.join("data")).expect("data dir"); |
| 1131 | fs::write(dist.join("data/index.json"), data_index(ctx)).expect("write data/index.json"); |
| 1132 | fs::write(dist.join("humans.txt"), humans_txt(ctx)).expect("write humans.txt"); |
| 1133 | println!(" [GEN] sitemap.xml ({} urls), sitemap.md, AGENTS.md, robots.txt ({} named agents), feed.xml, now/feed.xml, llms.txt, llms-full.txt, data/index.json, humans.txt", pages.len(), AI_AGENTS.len()); |
| 1134 | } |
| 1135 | |
| 1136 | /// No page may embed an outside script, even the consent-only X script. |
| 1137 | /// Its sole URL belongs in the first-party loader and is tested before consent. |
| 1138 | fn check_script_boundary(html: &str) -> Result<(), String> { |
| 1139 | let lower = html.to_ascii_lowercase(); |
| 1140 | if lower.contains("uwt.js") || lower.contains("twq(") { |
| 1141 | return Err("X bootstrap must live only in /js/allen-intro.js".into()); |
| 1142 | } |
| 1143 | if lower.contains("fonts.googleapis.com") || lower.contains("fonts.gstatic.com") { |
| 1144 | return Err("outside fonts are forbidden".into()); |
| 1145 | } |
| 1146 | let mut rest = lower.as_str(); |
| 1147 | while let Some(start) = rest.find("<script") { |
| 1148 | rest = &rest[start..]; |
| 1149 | let end = rest.find('>').ok_or("unterminated script tag")?; |
| 1150 | let open = &rest[..=end]; |
| 1151 | if let Some(src) = attr(open, "src") { |
| 1152 | if !src.starts_with('/') || src.starts_with("//") || src.contains('\\') || src.chars().any(char::is_whitespace) { |
| 1153 | return Err(format!("outside or ambiguous script source: {src}")); |
| 1154 | } |
| 1155 | } else if open.contains("src") { |
| 1156 | return Err("script sources must be quoted root-relative paths".into()); |
| 1157 | } |
| 1158 | rest = &rest[end + 1..]; |
| 1159 | } |
| 1160 | Ok(()) |
| 1161 | } |
| 1162 | |
| 1163 | fn verify_consent_boundary(dist: &Path) { |
| 1164 | fn walk(dist: &Path, dir: &Path) { |
| 1165 | for entry in fs::read_dir(dir).expect("read consent boundary directory") { |
| 1166 | let path = entry.expect("consent boundary entry").path(); |
| 1167 | if path.is_dir() { |
| 1168 | walk(dist, &path); |
| 1169 | } else if path.extension().and_then(|e| e.to_str()) == Some("html") { |
| 1170 | let html = fs::read_to_string(&path).expect("read consent boundary HTML"); |
| 1171 | check_script_boundary(&html).unwrap_or_else(|e| panic!("{}: {e}", path.display())); |
| 1172 | // A redirect stub leaves at once, and the program runner is replaced by |
| 1173 | // what it runs in an opaque origin: neither loads a consent dialog or a pixel. |
| 1174 | let rel = path.strip_prefix(dist).expect("under dist").to_string_lossy().replace('\\', "/"); |
| 1175 | let frame_only = rel == crate::components::csp::RUNNER_PATH; |
| 1176 | let redirect = REDIRECTS.iter().any(|(old, _)| format!("{}index.html", &old[1..]) == rel); |
| 1177 | assert!(frame_only || redirect || html.contains("href=\"/privacy/\""), "{} must link privacy", path.display()); |
| 1178 | assert!(!html.contains("/js/allen-intro.js"), "{} must not load the retired popup", path.display()); |
| 1179 | assert!(!html.contains("id=\"aien-allen-intro\""), "{} must not contain the retired dialog", path.display()); |
| 1180 | |
| 1181 | } else if path.extension().and_then(|e| e.to_str()) == Some("js") { |
| 1182 | let js = fs::read_to_string(&path).expect("read script"); |
| 1183 | if js.contains("uwt.js") || js.contains("twq(") { |
| 1184 | panic!("{} must not initialize the retired X pixel", path.display()); |
| 1185 | } |
| 1186 | } |
| 1187 | } |
| 1188 | } |
| 1189 | walk(dist, dist); |
| 1190 | let js = fs::read_to_string(dist.join("js/allen-intro.js")).expect("first-party consent script"); |
| 1191 | assert!(!js.contains("uwt.js") && !js.contains("twq("), "retired loader must not track visitors"); |
| 1192 | } |
| 1193 | |
| 1194 | /// Fails the build when the machine surface is inconsistent with the pages. |
| 1195 | pub fn verify(dist: &Path) { |
| 1196 | verify_consent_boundary(dist); |
| 1197 | let sitemap = fs::read_to_string(dist.join("sitemap.xml")).expect("sitemap.xml"); |
| 1198 | let robots = fs::read_to_string(dist.join("robots.txt")).expect("robots.txt"); |
| 1199 | let llms = fs::read_to_string(dist.join("llms.txt")).expect("llms.txt"); |
| 1200 | let index: Value = serde_json::from_str(&fs::read_to_string(dist.join("data/index.json")).expect("data/index.json")).expect("data/index.json parses"); |
| 1201 | for a in ["GPTBot", "ClaudeBot", "PerplexityBot", "Google-Extended", "CCBot"] { |
| 1202 | assert!(robots.contains(&format!("User-agent: {a}\nAllow: /")), "robots.txt must allow {a}"); |
| 1203 | } |
| 1204 | assert!(robots.contains(&format!("Sitemap: {HOST}/sitemap.xml")), "robots.txt must point at the sitemap"); |
| 1205 | assert!(!sitemap.contains("https://aienos.com/"), "sitemap must use the www host"); |
| 1206 | let sitemap_md = fs::read_to_string(dist.join("sitemap.md")).expect("sitemap.md"); |
| 1207 | assert!(sitemap_md.starts_with("# Sitemap\n"), "sitemap.md must start with its H1"); |
| 1208 | assert!(sitemap_md.contains("\n## "), "sitemap.md must carry H2 sections"); |
| 1209 | assert!(sitemap_md.contains(&format!("]({HOST}/glossary/)")), "sitemap.md must link the glossary"); |
| 1210 | let agents = fs::read_to_string(dist.join("AGENTS.md")).expect("AGENTS.md"); |
| 1211 | for section in ["## Installation", "## Configuration", "## Usage"] { |
| 1212 | assert!(agents.contains(section), "AGENTS.md must carry {section}"); |
| 1213 | } |
| 1214 | let index_html = fs::read_to_string(dist.join("index.html")).expect("index.html"); |
| 1215 | assert!(index_html.contains("href=\"/glossary/\""), "the homepage must link the glossary"); |
| 1216 | assert!(index_html.contains("\"BreadcrumbList\""), "the homepage JSON-LD must carry a BreadcrumbList"); |
| 1217 | for d in DATA_FILES { |
| 1218 | let rel = d.path.trim_start_matches('/'); |
| 1219 | assert!(dist.join(rel).exists(), "data index lists {} but it was not written", d.path); |
| 1220 | assert!(llms.contains(d.path), "llms.txt must link {}", d.path); |
| 1221 | } |
| 1222 | assert_eq!(index["files"].as_array().map(|a| a.len()), Some(DATA_FILES.len())); |
| 1223 | for info in PAGES { |
| 1224 | assert!(sitemap.contains(&format!("<loc>{HOST}{}</loc>", info.path)), "sitemap must list {}", info.path); |
| 1225 | assert!(llms.contains(&format!("]({HOST}{})", info.path)), "llms.txt must link {}", info.path); |
| 1226 | let page = fs::read_to_string(dist.join(info.path.trim_start_matches('/')).join("index.html")).expect("page"); |
| 1227 | assert!(page.contains(&format!("<link rel=\"canonical\" href=\"{HOST}{}\">", info.path)), "{} canonical must be on {HOST}", info.path); |
| 1228 | assert!(page.contains("application/ld+json"), "{} must carry JSON-LD", info.path); |
| 1229 | assert!(page.contains("twitter:site"), "{} must carry twitter:site", info.path); |
| 1230 | let md_rel = md_path(info.path); |
| 1231 | assert!(page.contains(&format!("<link rel=\"alternate\" type=\"text/markdown\" href=\"{md_rel}\">")), "{} must link its markdown mirror {md_rel}", info.path); |
| 1232 | assert!(page.contains(&format!("<link rel=\"describedby\" href=\"{HOST}/llms.txt\">")), "{} must declare llms.txt via describedby", info.path); |
| 1233 | assert!(page.contains("max-snippet:-1") && page.contains("max-image-preview:large"), "{} must carry the AI snippet directives", info.path); |
| 1234 | let md = fs::read_to_string(dist.join(md_rel.trim_start_matches('/'))).unwrap_or_else(|_| panic!("{} markdown mirror {md_rel} missing", info.path)); |
| 1235 | assert!(md.starts_with("---\n"), "{} markdown mirror must open with frontmatter", info.path); |
| 1236 | assert!(md.contains("canonical_url:"), "{} markdown mirror must carry canonical_url", info.path); |
| 1237 | assert!(md.contains("\n## Sitemap\n"), "{} markdown mirror must carry a Sitemap section", info.path); |
| 1238 | if info.path != "/" { |
| 1239 | let dir_md = format!("{}index.md", info.path); |
| 1240 | assert!(dist.join(dir_md.trim_start_matches('/')).exists(), "{} markdown directory mirror {dir_md} missing", info.path); |
| 1241 | } |
| 1242 | assert!(page.contains("href=\"/glossary/\""), "{} must link the glossary", info.path); |
| 1243 | let ld_start = page.find("<script type=\"application/ld+json\">").expect("ld") + "<script type=\"application/ld+json\">".len(); |
| 1244 | let ld_end = ld_start + page[ld_start..].find("</script>").expect("ld end"); |
| 1245 | let v: Value = serde_json::from_str(&page[ld_start..ld_end]).unwrap_or_else(|e| panic!("{} JSON-LD does not parse: {e}", info.path)); |
| 1246 | assert!(v["@graph"].as_array().map(|g| g.len() >= 4).unwrap_or(false), "{} JSON-LD graph too small", info.path); |
| 1247 | for f in ["feed.xml", "now/feed.xml", "llms.txt", "llms-full.txt", "humans.txt", "data/index.json", "404.html", "logo.png", "og.png"] { |
| 1248 | assert!(dist.join(f).exists(), "missing {f}"); |
| 1249 | } |
| 1250 | for text in [page.as_str()] { |
| 1251 | assert!(!text.contains('\u{2014}') && !text.contains('\u{2013}'), "dash in {}", info.path); |
| 1252 | } |
| 1253 | } |
| 1254 | for f in ["feed.xml", "now/feed.xml", "llms.txt", "llms-full.txt", "humans.txt", "data/index.json", "sitemap.xml", "sitemap.md", "AGENTS.md", "index.md", "robots.txt", "404.html"] { |
| 1255 | let t = fs::read_to_string(dist.join(f)).expect(f); |
| 1256 | assert!(!t.contains('\u{2014}') && !t.contains('\u{2013}'), "dash in {f}"); |
| 1257 | } |
| 1258 | } |
| 1259 | |
| 1260 | #[cfg(test)] |
| 1261 | mod tests { |
| 1262 | use super::*; |
| 1263 | |
| 1264 | #[test] |
| 1265 | fn consent_script_boundary_rejects_external_and_inline_pixel_loads() { |
| 1266 | assert!(check_script_boundary("<script defer src=\"/js/allen-intro.js\"></script>").is_ok()); |
| 1267 | for bad in [ |
| 1268 | "<script src=\"https://static.ads-twitter.com/uwt.js\"></script>", |
| 1269 | "<script src='//example.com/anything.js'></script>", |
| 1270 | "<SCRIPT SRC='https://example.com/anything.js'></SCRIPT>", |
| 1271 | "<script src=https://example.com/anything.js></script>", |
| 1272 | "<script src='/\\example.com/anything.js'></script>", |
| 1273 | "<script>twq('config','rfrlz')</script>", |
| 1274 | ] { |
| 1275 | assert!(check_script_boundary(bad).is_err(), "must reject {bad}"); |
| 1276 | } |
| 1277 | } |
| 1278 | |
| 1279 | #[test] |
| 1280 | fn rfc3339_round_trip() { |
| 1281 | assert_eq!(rfc3339(0), "1970-01-01T00:00:00Z"); |
| 1282 | assert_eq!(rfc3339(now::parse_utc("2026-10-19T16:43Z").unwrap()), "2026-10-19T16:43:00Z"); |
| 1283 | } |
| 1284 | |
| 1285 | #[test] |
| 1286 | fn attributes_parse_in_any_order() { |
| 1287 | let t = "<meta content=\"x y\" property=\"og:url\"/>"; |
| 1288 | assert_eq!(attr(t, "property").as_deref(), Some("og:url")); |
| 1289 | assert_eq!(attr(t, "content").as_deref(), Some("x y")); |
| 1290 | assert_eq!(attr("<link rel=canonical>", "rel"), None); |
| 1291 | assert!(owned_tag(t)); |
| 1292 | assert!(!owned_tag("<meta name=\"viewport\" content=\"width=device-width\">")); |
| 1293 | assert!(owned_tag("<link href=\"https://www.aienos.com/\" hreflang=\"en\" rel=\"alternate\"/>")); |
| 1294 | assert!(owned_tag("<link rel=\"alternate\" type=\"text/markdown\" href=\"/index.md\">")); |
| 1295 | assert!(owned_tag("<link rel=\"describedby\" href=\"/llms.txt\">")); |
| 1296 | assert!(owned_tag("<meta name=\"robots\" content=\"noindex\">")); |
| 1297 | assert!(!owned_tag("<link rel=\"stylesheet\" href=\"/assets/style.css\">")); |
| 1298 | } |
| 1299 | |
| 1300 | #[test] |
| 1301 | fn strip_head_keeps_title_and_drops_owned_tags() { |
| 1302 | let head = "<meta charset=\"utf-8\"><title>T & U</title><meta name=\"description\" content=\"D\"><link rel=\"canonical\" href=\"https://aienos.com/x\"><meta property=\"og:title\" content=\"OT\"><script type=\"application/ld+json\">{}</script><script>console.log('<b>')</script><style>a{}</style><link rel=\"stylesheet\" href=\"/a.css\">"; |
| 1303 | let (kept, facts) = strip_head(head); |
| 1304 | assert_eq!(facts.title, "T & U"); |
| 1305 | assert_eq!(facts.description, "D"); |
| 1306 | assert_eq!(facts.og_title, "OT"); |
| 1307 | assert!(!kept.contains("canonical")); |
| 1308 | assert!(!kept.contains("og:title")); |
| 1309 | assert!(!kept.contains("ld+json")); |
| 1310 | assert!(kept.contains("<title>T & U</title>")); |
| 1311 | assert!(kept.contains("console.log('<b>')")); |
| 1312 | assert!(kept.contains("stylesheet")); |
| 1313 | } |
| 1314 | |
| 1315 | #[test] |
| 1316 | fn every_listed_page_has_a_unique_path_and_no_dash() { |
| 1317 | let mut seen = std::collections::BTreeSet::new(); |
| 1318 | for p in PAGES { |
| 1319 | assert!(p.path.starts_with('/') && p.path.ends_with('/'), "{}", p.path); |
| 1320 | assert!(seen.insert(p.path), "duplicate {}", p.path); |
| 1321 | for t in [p.name, p.what, p.published] { |
| 1322 | assert!(!t.contains('\u{2014}') && !t.contains('\u{2013}'), "dash in {}", p.path); |
| 1323 | } |
| 1324 | let card = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../public").join(p.image.trim_start_matches('/')); |
| 1325 | assert!(card.exists(), "card {} missing", p.image); |
| 1326 | } |
| 1327 | } |
| 1328 | |
| 1329 | #[test] |
| 1330 | fn robots_names_every_agent_and_the_sitemap() { |
| 1331 | let r = robots_txt(); |
| 1332 | for a in AI_AGENTS { |
| 1333 | assert!(r.contains(&format!("User-agent: {a}\nAllow: /\n"))); |
| 1334 | } |
| 1335 | assert!(r.ends_with(&format!("Sitemap: {HOST}/sitemap.xml\n"))); |
| 1336 | } |
| 1337 | |
| 1338 | #[test] |
| 1339 | fn llms_full_leads_with_sovereign_intelligence() { |
| 1340 | let t = llms_full(&[]); |
| 1341 | assert!(t.starts_with("# Sovereign Intelligence\n\nSovereign Intelligence is the whole system. AienOS is only the operating-system layer. ")); |
| 1342 | assert!(!t.contains("what AienOS is")); |
| 1343 | assert!(!t.starts_with("# AienOS")); |
| 1344 | } |
| 1345 | |
| 1346 | #[test] |
| 1347 | fn llms_txt_follows_the_convention() { |
| 1348 | let t = llms_txt(&["Layer: STATE. note".into()], "ladder sentence"); |
| 1349 | assert!(t.starts_with("# Sovereign Intelligence\n\n> ")); |
| 1350 | assert!(t.contains("Sovereign Intelligence is the whole system")); |
| 1351 | assert!(t.contains("AienOS is only the operating-system layer")); |
| 1352 | assert!(t.contains("\n## Optional\n")); |
| 1353 | assert_eq!(t.matches("\n# ").count(), 0, "exactly one H1"); |
| 1354 | for p in PAGES { |
| 1355 | assert!(t.contains(&format!("]({HOST}{}): ", p.path)), "missing {}", p.path); |
| 1356 | } |
| 1357 | let opt = t.find("## Optional").unwrap(); |
| 1358 | assert!(t[opt..].contains("/licensing/")); |
| 1359 | } |
| 1360 | |
| 1361 | #[test] |
| 1362 | fn markdown_mirror_paths_follow_the_public_convention() { |
| 1363 | assert_eq!(md_path("/"), "/index.md"); |
| 1364 | assert_eq!(md_path("/machine/"), "/machine.md"); |
| 1365 | assert_eq!(md_path("/research/status/"), "/research/status.md"); |
| 1366 | } |
| 1367 | |
| 1368 | #[test] |
| 1369 | fn discovery_files_link_every_list_item_in_an_h2_section() { |
| 1370 | for (name, doc) in [ |
| 1371 | ("llms.txt", crate::components::status::llms_txt()), |
| 1372 | ("sitemap.md", sitemap_md()), |
| 1373 | ] { |
| 1374 | let mut in_h2 = false; |
| 1375 | for line in doc.lines() { |
| 1376 | if line.starts_with("## ") { |
| 1377 | in_h2 = true; |
| 1378 | } else if in_h2 && line.starts_with("- ") { |
| 1379 | assert!(line.contains("]("), "{name} has an unlinked item in an H2 section: {line}"); |
| 1380 | } |
| 1381 | } |
| 1382 | } |
| 1383 | } |
| 1384 | |
| 1385 | #[test] |
| 1386 | fn html_to_text_keeps_code_byte_for_byte() { |
| 1387 | let h = "<main><p>a b</p><pre><code>note x\n\ntext k \" ok \" \n indented\n\n</code></pre><textarea id=\"t\">fn main to int\nret 0\nend</textarea><pre>\nlast\n</pre></main>"; |
| 1388 | let t = html_to_text(h); |
| 1389 | assert!(t.contains("a b\n"), "{t}"); |
| 1390 | // Trailing spaces and a second final newline survive; one final newline is the fence's. |
| 1391 | assert!(t.contains("```\nnote x\n\ntext k \" ok \" \n indented\n\n```\n"), "{t}"); |
| 1392 | assert!(t.contains("```\nfn main to int\nret 0\nend\n```"), "{t}"); |
| 1393 | assert!(t.contains("```\nlast\n```"), "{t}"); |
| 1394 | assert!(!t.contains('\u{1}'), "{t}"); |
| 1395 | } |
| 1396 | |
| 1397 | #[test] |
| 1398 | fn html_to_text_keeps_headings_links_and_drops_chrome() { |
| 1399 | let h = "<html><head><title>x</title></head><body><header class=\"aien-header\">NAV</header><main><h1>Title</h1><p>Para with <a href=\"/now/\">a link</a> and <script>bad()</script> more.</p><ul><li>one</li><li>two</li></ul></main><footer>F</footer></body></html>"; |
| 1400 | let t = html_to_text(h); |
| 1401 | assert!(t.starts_with("# Title")); |
| 1402 | assert!(t.contains("[a link](https://www.aienos.com/now/)")); |
| 1403 | assert!(t.contains("- one")); |
| 1404 | assert!(!t.contains("NAV") && !t.contains("bad()") && !t.contains("F\n")); |
| 1405 | } |
| 1406 | |
| 1407 | #[test] |
| 1408 | fn feeds_are_well_formed_atom() { |
| 1409 | let ctx = BuildCtx { built: "2026-10-19T00:00:00Z".into(), head_committed: "2026-10-19T00:00:00Z".into(), ledger_written: "2026-10-19T16:43:00Z".into(), facts_generated: "2026-10-19T00:00:00Z".into() }; |
| 1410 | let pages: Vec<Emitted> = PAGES.iter().map(|p| Emitted { path: p.path.into(), file: PathBuf::from("x"), lastmod: "2026-10-18T00:00:00Z".into() }).collect(); |
| 1411 | let f = site_feed(&pages); |
| 1412 | assert!(f.starts_with("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<feed xmlns=\"http://www.w3.org/2005/Atom\">")); |
| 1413 | assert_eq!(f.matches("<entry>").count(), PAGES.iter().filter(|p| matches!(p.kind, Kind::Article | Kind::Paper)).count()); |
| 1414 | let tsv = "id\topened_utc\towner\tstatus\titem\tdone_when\tevidence\tupdated_utc\nL001\t2026-10-19T16:00Z\tsa-1\tdone\tFix <x>\twhen y\tnote a | note b\t2026-10-19T16:43Z\nL002\t2026-10-19T16:00Z\tsa-1\topen\tOpen one\twhen z\t\t2026-10-19T16:44Z\n"; |
| 1415 | let items = now::parse_ledger(tsv, now::parse_utc("2026-10-19T17:00Z").unwrap()); |
| 1416 | let (plan, models) = crate::components::now::models_from(crate::components::now::ROSTER, &None, &[]); |
| 1417 | let n = Now { built_utc: "x".into(), ledger_written_utc: "2026-10-19T16:44Z".into(), items, pulse: vec![], models_checked_utc: "never".into(), plan, models, claude: None }; |
| 1418 | let nf = now_feed(&n, &ctx); |
| 1419 | assert_eq!(nf.matches("<entry>").count(), 1); |
| 1420 | assert!(nf.contains("Fix <x>")); |
| 1421 | assert!(nf.contains("- note a")); |
| 1422 | assert!(nf.contains("<updated>2026-10-19T16:43:00Z</updated>")); |
| 1423 | } |
| 1424 | |
| 1425 | #[test] |
| 1426 | fn sitemap_lists_every_page_without_alternates() { |
| 1427 | let mk = |p: &str| Emitted { path: p.into(), file: PathBuf::from("x"), lastmod: "2026-10-18T00:00:00Z".into() }; |
| 1428 | let pages = vec![mk("/"), mk("/now/")]; |
| 1429 | let s = sitemap_xml(&pages); |
| 1430 | assert!(s.starts_with("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n")); |
| 1431 | assert_eq!(s.matches("<url>").count(), 2); |
| 1432 | assert!(!s.contains("xhtml") && !s.contains("hreflang")); |
| 1433 | assert!(s.contains("<loc>https://www.aienos.com/now/</loc>")); |
| 1434 | } |
| 1435 | |
| 1436 | #[test] |
| 1437 | fn graph_for_a_paper_carries_the_doi() { |
| 1438 | let ctx = BuildCtx { built: "b".into(), head_committed: "h".into(), ledger_written: "l".into(), facts_generated: "f".into() }; |
| 1439 | let page = Emitted { path: "/research/computing-machinery-and-understanding/".into(), file: PathBuf::from("x"), lastmod: "2026-10-18T00:00:00Z".into() }; |
| 1440 | let info = info_for(&page.path).unwrap(); |
| 1441 | let facts = HeadFacts { title: "T".into(), description: "D".into(), ..Default::default() }; |
| 1442 | let g = graph(&page, info, &facts, &ctx, Path::new("/nonexistent")); |
| 1443 | let s = g.to_string(); |
| 1444 | assert!(s.contains("10.5281/zenodo.23437498")); |
| 1445 | assert!(s.contains("ScholarlyArticle")); |
| 1446 | assert!(s.contains("BreadcrumbList")); |
| 1447 | assert!(!s.contains("workTranslation") && !s.contains("translationOfWork")); |
| 1448 | assert!(!s.contains("zh-CN"), "every node is English only"); |
| 1449 | } |
| 1450 | } |