aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / crates / site-builder / src / components / lab.rs
| 1 | //! /lab/: seeded Omega owns the page structure, the browser client and its run worker |
| 2 | //! (om/lab-page/lab.om and client.om, regenerated by om/lab-page/check.sh). |
| 3 | use maud::{html, Markup, PreEscaped}; |
| 4 | pub const TITLE: &str = "Omega Lab: write a kernel, run it in one click | AienOS"; |
| 5 | pub const DESCRIPTION: &str = "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."; |
| 6 | pub const URL: &str = "https://www.aienos.com/lab/"; |
| 7 | pub const PAGE: &str = include_str!("../../../../om/lab-page/main.html"); |
| 8 | pub fn render_lab_page() -> Markup { html! { (PreEscaped(PAGE)) } } |
| 9 | pub fn render_lab_entry() -> Markup { |
| 10 | html! { |
| 11 | a href="/lab/" style="display:block;padding:18px 24px;text-align:center;background:var(--bg-base);border-bottom:1px solid var(--border-subtle);color:var(--text-primary);" { |
| 12 | strong style="color:var(--accent-green);font-family:var(--font-mono);" { "OMEGA LAB" } |
| 13 | " · Write a kernel, run it in your browser in one click. Nothing to install. " |
| 14 | span style="text-decoration:underline;text-underline-offset:4px;" { "Open the lab →" } |
| 15 | } |
| 16 | } |
| 17 | } |
| 18 | #[cfg(test)] |
| 19 | mod tests { |
| 20 | use super::*; |
| 21 | use sha2::{Digest, Sha256}; |
| 22 | #[test] |
| 23 | fn lab_generated_artifacts_match_hashes() { |
| 24 | for (bytes, receipt) in [ |
| 25 | (PAGE.as_bytes(), include_str!("../../../../om/lab-page/main.html.sha256")), |
| 26 | (include_bytes!("../../../../public/js/lab.js").as_slice(), include_str!("../../../../om/lab-page/lab.js.sha256")), |
| 27 | (include_bytes!("../../../../public/js/lab-worker.js").as_slice(), include_str!("../../../../om/lab-page/lab-worker.js.sha256")), |
| 28 | ] { |
| 29 | assert_eq!(format!("{:x}", Sha256::digest(bytes)), receipt.split_whitespace().next().expect("digest")); |
| 30 | } |
| 31 | let published = include_str!("../../../../om/lab-page/published.sha256"); |
| 32 | for (bytes, name) in [ |
| 33 | (include_bytes!("../../../../public/lab/axpy.wasm").as_slice(), "axpy.wasm"), |
| 34 | (include_bytes!("../../../../public/lab/record.tsv").as_slice(), "record.tsv"), |
| 35 | ] { |
| 36 | let line = published.lines().find(|l| l.ends_with(name)).expect(name); |
| 37 | assert_eq!(format!("{:x}", Sha256::digest(bytes)), line.split_whitespace().next().expect("digest")); |
| 38 | } |
| 39 | } |
| 40 | #[test] |
| 41 | fn lab_keeps_its_evidence_boundaries() { |
| 42 | for text in ["NOT_RUN", "Take it home: not open yet.", "id=\"lab-src\"", "ret add mul a x y", "fn axpy", "PASS"] { |
| 43 | assert!(PAGE.contains(text), "missing {text}"); |
| 44 | } |
| 45 | for gone in ["radicle", "rad:z", "rad clone", "/rad/"] { |
| 46 | assert!(!PAGE.to_ascii_lowercase().contains(gone), "Radicle pointer: {gone}"); |
| 47 | } |
| 48 | assert!(!PAGE.contains("<script"), "no inline script"); |
| 49 | for removed in ["CUDA C", "nvcc", "JavaScript", "THE HONEST RACE"] { |
| 50 | assert!(!PAGE.contains(removed), "removed comparison: {removed}"); |
| 51 | } |
| 52 | for (i, _) in PAGE.match_indices(" on") { |
| 53 | let rest: String = PAGE[i + 3..].chars().take_while(|c| c.is_ascii_alphabetic()).collect(); |
| 54 | assert!(!PAGE[i + 3 + rest.len()..].starts_with('='), "inline handler on{rest}"); |
| 55 | } |
| 56 | assert!(!PAGE.contains("curl"), "installs go through GitHub only"); |
| 57 | let js = include_str!("../../../../public/js/lab.js"); |
| 58 | let css = include_str!("../../../../public/assets/lab.css"); |
| 59 | for text in [PAGE, js, css] { |
| 60 | assert!(!text.contains('\u{2014}') && !text.contains('\u{2013}'), "no em or en dash"); |
| 61 | } |
| 62 | for word in PAGE.split(|c: char| !c.is_ascii_alphabetic()) { |
| 63 | assert!(!["we", "our", "ours", "ourselves"].contains(&word.to_ascii_lowercase().as_str()), "plural first person: {word}"); |
| 64 | } |
| 65 | assert!(css.contains("prefers-reduced-motion:no-preference")); |
| 66 | assert!(!css.contains("http"), "no external assets"); |
| 67 | assert!(css.match_indices('#').all(|(i, _)| css[i + 1..].starts_with("lab-")), "palette tokens only, no hex colors"); |
| 68 | } |
| 69 | } |