aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / crates / site-builder / src / components / now.rs
| 1 | //! /now/: what the people and agents of AIEN are doing right now. |
| 2 | //! |
| 3 | //! The one private source is the coordination ledger, a tab separated file the |
| 4 | //! coordinator and agents write to on the Spark (`~/handoffs/LEDGER.tsv`). |
| 5 | //! The publisher projects it into a line-preserving, privacy-screened TSV |
| 6 | //! before pushing `data/now`. Pages refuses an unprojected input before |
| 7 | //! copying it into `public/data/now.tsv`; this module renders that public |
| 8 | //! projection as the page and `/now.json`. Redaction changes private text, |
| 9 | //! never the row count or source line links. |
| 10 | //! |
| 11 | //! Columns, in order: id, opened_utc, owner, status, item, done_when, |
| 12 | //! evidence, updated_utc. `evidence` carries the running notes, newest |
| 13 | //! last, separated by ` | `. |
| 14 | |
| 15 | use std::fs; |
| 16 | use std::path::Path; |
| 17 | use std::time::{SystemTime, UNIX_EPOCH}; |
| 18 | |
| 19 | use maud::{html, Markup}; |
| 20 | use serde::{Deserialize, Serialize}; |
| 21 | |
| 22 | use super::boxlink::{foot_labelled, Target}; |
| 23 | |
| 24 | pub const TITLE: &str = "Now | AienOS"; |
| 25 | pub const DESCRIPTION: &str = "The live coordination ledger of Aien: what every agent is doing right now, what is settled with evidence, and what waits on an operator decision."; |
| 26 | pub const URL: &str = "https://www.aienos.com/now/"; |
| 27 | |
| 28 | /// Where the pages workflow lays the published ledger before a build. |
| 29 | pub const LEDGER_PATH: &str = "public/data/now.tsv"; |
| 30 | /// Where the pages workflow lays the machine pulse (optional). |
| 31 | pub const PULSE_PATH: &str = "public/data/now-pulse.tsv"; |
| 32 | /// The published ledger on the forge; `#L<n>` names one line of it. |
| 33 | pub const LEDGER_URL: &str = "https://interplane.io/drakestapleton/aienos.com/blob/main/public/data/now.tsv"; |
| 34 | |
| 35 | /// Where the pages workflow lays the Spark's reading of Drake's Claude plan. |
| 36 | pub const USAGE_PATH: &str = "public/data/claude-usage.tsv"; |
| 37 | /// The reading is not committed anywhere a visitor can open, so the usage |
| 38 | /// card links the source that reads and renders it. |
| 39 | pub const USAGE_SOURCE: &str = "crates/site-builder/src/components/now.rs"; |
| 40 | /// Where a visitor joins in: the Open Humanity repository, for agents |
| 41 | /// working on their own plans and Sparks qualifying the same gates. It has |
| 42 | /// no Radicle copy yet, so the page names it in plain text. |
| 43 | pub const HUMANITY: &str = "open-humanity"; |
| 44 | |
| 45 | /// One limit of the Claude plan: how much of it is used, and when it resets. |
| 46 | #[derive(Debug, Clone, Serialize)] |
| 47 | pub struct UsageLimit { |
| 48 | pub label: String, |
| 49 | pub used_pct: u32, |
| 50 | pub resets_utc: String, |
| 51 | } |
| 52 | |
| 53 | /// The Spark's reading of Drake's Claude plan meter. The publisher writes |
| 54 | /// `checked`, `plan` and `limit` rows (kind, percent used, reset time, |
| 55 | /// model scope); it publishes percentages only, never the login. |
| 56 | #[derive(Debug, Clone, Serialize)] |
| 57 | pub struct Usage { |
| 58 | pub checked_utc: String, |
| 59 | pub plan: String, |
| 60 | pub limits: Vec<UsageLimit>, |
| 61 | } |
| 62 | |
| 63 | /// Plain words and a safe character set for a scope the meter names. |
| 64 | fn usage_words(s: &str) -> String { |
| 65 | s.chars().filter(|c| c.is_ascii_alphanumeric() || *c == ' ' || *c == '.').take(40).collect::<String>().trim().to_string() |
| 66 | } |
| 67 | |
| 68 | pub fn parse_usage(tsv: &str) -> Option<Usage> { |
| 69 | let mut checked = None; |
| 70 | let mut plan = String::new(); |
| 71 | let mut limits = Vec::new(); |
| 72 | for line in tsv.lines() { |
| 73 | let f: Vec<&str> = line.split('\t').collect(); |
| 74 | match f.as_slice() { |
| 75 | ["checked", t, ..] => checked = parse_utc(t).map(fmt_utc), |
| 76 | ["plan", p, ..] => plan = usage_words(p), |
| 77 | ["limit", kind, pct, resets, rest @ ..] => { |
| 78 | let Ok(used) = pct.trim().parse::<f64>() else { continue }; |
| 79 | let scope = rest.first().map(|s| usage_words(s)).unwrap_or_default(); |
| 80 | let label = match (*kind, scope.is_empty()) { |
| 81 | ("session", _) => "This five-hour session".to_string(), |
| 82 | ("weekly_all", _) => "This week, all models".to_string(), |
| 83 | ("weekly_scoped", false) => format!("This week, {scope} only"), |
| 84 | _ => continue, |
| 85 | }; |
| 86 | let resets_utc = parse_utc(resets).map(fmt_utc).unwrap_or_default(); |
| 87 | limits.push(UsageLimit { label, used_pct: used.round().clamp(0.0, 100.0) as u32, resets_utc }); |
| 88 | } |
| 89 | _ => {} |
| 90 | } |
| 91 | } |
| 92 | let checked_utc = checked?; |
| 93 | if limits.is_empty() { |
| 94 | return None; |
| 95 | } |
| 96 | Some(Usage { checked_utc, plan: if plan.is_empty() { "Claude".into() } else { plan }, limits }) |
| 97 | } |
| 98 | |
| 99 | #[derive(Debug, Clone, Serialize)] |
| 100 | pub struct Item { |
| 101 | pub id: String, |
| 102 | /// The 1-based line of now.tsv this item was read from (the header is line 1). |
| 103 | pub line: usize, |
| 104 | pub opened_utc: String, |
| 105 | pub owner: String, |
| 106 | pub owner_kind: &'static str, |
| 107 | pub status: String, |
| 108 | pub item: String, |
| 109 | pub done_when: String, |
| 110 | pub notes: Vec<String>, |
| 111 | pub updated_utc: String, |
| 112 | pub stream: &'static str, |
| 113 | /// Seconds since the last write to this line, at build time. |
| 114 | pub age_s: i64, |
| 115 | } |
| 116 | |
| 117 | |
| 118 | /// Where the pages workflow lays the Spark's model check (optional). |
| 119 | /// Lines: `checked<TAB>utc`, then one `model<TAB>served id` per model that |
| 120 | /// answered the Spark's local check. No ports, no addresses. |
| 121 | pub const MODELS_PATH: &str = "public/data/models.tsv"; |
| 122 | /// Which models the plan names, their roles and their measured figures. |
| 123 | pub const ROSTER: &str = include_str!("../../data/models.json"); |
| 124 | |
| 125 | #[derive(Debug, Clone, Deserialize)] |
| 126 | struct Roster { |
| 127 | plan: Link, |
| 128 | models: Vec<ModelEntry>, |
| 129 | } |
| 130 | |
| 131 | #[derive(Debug, Clone, Serialize, Deserialize)] |
| 132 | pub struct Link { |
| 133 | pub label: String, |
| 134 | pub url: String, |
| 135 | } |
| 136 | |
| 137 | #[derive(Debug, Clone, Serialize, Deserialize)] |
| 138 | pub struct Figure { |
| 139 | pub label: String, |
| 140 | pub value: String, |
| 141 | pub receipt: String, |
| 142 | } |
| 143 | |
| 144 | #[derive(Debug, Clone, Deserialize)] |
| 145 | struct ModelEntry { |
| 146 | key: String, |
| 147 | name: String, |
| 148 | /// Lowercase text a served id must contain to count as this model. |
| 149 | served_match: Option<String>, |
| 150 | /// What the card says when no served id matches: not-answering, planned, |
| 151 | /// not-trained or retired. |
| 152 | absent: String, |
| 153 | track: String, |
| 154 | role: String, |
| 155 | plan_ledger: Option<String>, |
| 156 | source: Option<Link>, |
| 157 | figures: Vec<Figure>, |
| 158 | } |
| 159 | |
| 160 | /// One model as the page shows it, after the Spark's check. |
| 161 | #[derive(Debug, Clone, Serialize)] |
| 162 | pub struct Model { |
| 163 | pub key: String, |
| 164 | pub name: String, |
| 165 | /// answering, not-answering, planned, not-trained, retired or unknown. |
| 166 | pub state: String, |
| 167 | pub served_as: Option<String>, |
| 168 | pub track: String, |
| 169 | pub role: String, |
| 170 | pub plan_ledger: Option<String>, |
| 171 | pub source: Option<Link>, |
| 172 | pub figures: Vec<Figure>, |
| 173 | } |
| 174 | |
| 175 | /// The check: when the Spark last looked, and which served ids answered. |
| 176 | pub fn parse_models_check(tsv: &str) -> (Option<String>, Vec<String>) { |
| 177 | let mut checked = None; |
| 178 | let mut ids = Vec::new(); |
| 179 | for (k, v) in tsv.lines().filter_map(|l| l.split_once('\t')) { |
| 180 | match k.trim() { |
| 181 | "checked" if parse_utc(v).is_some() => checked = Some(v.trim().to_string()), |
| 182 | "model" if !v.trim().is_empty() => ids.push(clean(v)), |
| 183 | _ => {} |
| 184 | } |
| 185 | } |
| 186 | (checked, ids) |
| 187 | } |
| 188 | |
| 189 | /// Join the roster with the check. With no check at all, a model that |
| 190 | /// can be served reads as unknown, never as answering or down. |
| 191 | pub fn models_from(roster_json: &str, checked: &Option<String>, ids: &[String]) -> (Link, Vec<Model>) { |
| 192 | let roster: Roster = serde_json::from_str(roster_json).expect("data/models.json must parse"); |
| 193 | let models = roster |
| 194 | .models |
| 195 | .into_iter() |
| 196 | .map(|m| { |
| 197 | let served_as = m |
| 198 | .served_match |
| 199 | .as_deref() |
| 200 | .and_then(|pat| ids.iter().find(|id| id.to_ascii_lowercase().contains(pat)).cloned()); |
| 201 | let state = match (&served_as, &m.served_match, checked) { |
| 202 | (Some(_), _, _) => "answering".to_string(), |
| 203 | (None, Some(_), None) if m.absent == "not-answering" => "unknown".to_string(), |
| 204 | _ => m.absent.clone(), |
| 205 | }; |
| 206 | Model { |
| 207 | key: m.key, |
| 208 | name: m.name, |
| 209 | state, |
| 210 | served_as, |
| 211 | track: m.track, |
| 212 | role: m.role, |
| 213 | plan_ledger: m.plan_ledger, |
| 214 | source: m.source, |
| 215 | figures: m.figures, |
| 216 | } |
| 217 | }) |
| 218 | .collect(); |
| 219 | (roster.plan, models) |
| 220 | } |
| 221 | #[derive(Debug, Clone, Serialize)] |
| 222 | pub struct Pulse { |
| 223 | pub key: String, |
| 224 | pub value: String, |
| 225 | } |
| 226 | |
| 227 | #[derive(Debug, Clone, Serialize)] |
| 228 | pub struct Now { |
| 229 | pub built_utc: String, |
| 230 | pub ledger_written_utc: String, |
| 231 | pub items: Vec<Item>, |
| 232 | pub pulse: Vec<Pulse>, |
| 233 | /// When the Spark last checked its model servers, or "never". |
| 234 | pub models_checked_utc: String, |
| 235 | pub plan: Link, |
| 236 | pub models: Vec<Model>, |
| 237 | /// The last reading of Drake's Claude plan, if the Spark has published one. |
| 238 | pub claude: Option<Usage>, |
| 239 | } |
| 240 | |
| 241 | /// The streams, in display order. Classification is by the item's wording |
| 242 | /// and owner, the same words the coordinator uses when opening a line. |
| 243 | pub const STREAMS: [&str; 8] = [ |
| 244 | "Engine speed", |
| 245 | "Alpha release", |
| 246 | "AIEN Rig", |
| 247 | "AienOS on the iMac", |
| 248 | "Research", |
| 249 | "Public record", |
| 250 | "PR desk", |
| 251 | "Infrastructure", |
| 252 | ]; |
| 253 | |
| 254 | fn classify(item: &str, owner: &str) -> &'static str { |
| 255 | let t = item.to_ascii_lowercase(); |
| 256 | if t.starts_with("research") || t.contains("symposium") || t.contains("#583") || t.contains("#584") || t.contains("inventory for site") { |
| 257 | "Research" |
| 258 | } else if t.starts_with("agent:") || t.contains("cascade") || t.contains("decode") || t.contains("tok/s") || t.contains("flashnext") || t.contains("omega#") { |
| 259 | "Engine speed" |
| 260 | } else if t.starts_with("rig") { |
| 261 | "AIEN Rig" |
| 262 | } else if t.contains("aienos.com") || t.contains("org profile") || t.contains("readme") || t.contains("dashboard") { |
| 263 | "Public record" |
| 264 | } else if t.contains("alpha") || t.contains("install") || t.contains("serve-27b") || t.contains("27b server") { |
| 265 | "Alpha release" |
| 266 | } else if t.contains("imac") || t.contains("horizon") || t.contains("allen") || t.contains("aienos") || t.contains("bundle") { |
| 267 | "AienOS on the iMac" |
| 268 | } else if owner == "desk" || t.starts_with("merge") || t.starts_with("queue") || t.contains("label") || t.contains("squash") { |
| 269 | "PR desk" |
| 270 | } else { |
| 271 | "Infrastructure" |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | fn owner_kind(owner: &str) -> &'static str { |
| 276 | match owner { |
| 277 | "drake" => "operator", |
| 278 | "desk" => "desk", |
| 279 | "coordinator" => "coordinator", |
| 280 | "unassigned" => "unassigned", |
| 281 | _ => "agent", |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | /// Em and en dashes never reach the page, whatever an agent typed. |
| 286 | fn clean(s: &str) -> String { |
| 287 | s.replace(['\u{2014}', '\u{2013}'], "-").trim().to_string() |
| 288 | } |
| 289 | |
| 290 | /// "2026-10-19T16:43Z" or "2026-10-19T16:43:07Z" to seconds since the epoch. |
| 291 | /// Anything else gives None and the age reads as unknown. |
| 292 | pub fn parse_utc(s: &str) -> Option<i64> { |
| 293 | let s = s.trim().trim_end_matches('Z'); |
| 294 | let (date, time) = s.split_once('T')?; |
| 295 | let mut d = date.split('-'); |
| 296 | let y: i64 = d.next()?.parse().ok()?; |
| 297 | let m: i64 = d.next()?.parse().ok()?; |
| 298 | let day: i64 = d.next()?.parse().ok()?; |
| 299 | let mut t = time.split(':'); |
| 300 | let hh: i64 = t.next()?.parse().ok()?; |
| 301 | let mm: i64 = t.next()?.parse().ok()?; |
| 302 | let ss: i64 = t.next().map(|x| x.parse().unwrap_or(0)).unwrap_or(0); |
| 303 | // Days from civil, Howard Hinnant's algorithm. |
| 304 | let (y2, m2) = if m <= 2 { (y - 1, m + 9) } else { (y, m - 3) }; |
| 305 | let era = y2.div_euclid(400); |
| 306 | let yoe = y2 - era * 400; |
| 307 | let doy = (153 * m2 + 2) / 5 + day - 1; |
| 308 | let doe = yoe * 365 + yoe / 4 - yoe / 100 + doy; |
| 309 | let days = era * 146_097 + doe - 719_468; |
| 310 | Some(days * 86_400 + hh * 3_600 + mm * 60 + ss) |
| 311 | } |
| 312 | |
| 313 | pub fn fmt_utc(secs: i64) -> String { |
| 314 | // Civil from days, the inverse of the above. |
| 315 | let days = secs.div_euclid(86_400); |
| 316 | let rem = secs.rem_euclid(86_400); |
| 317 | let z = days + 719_468; |
| 318 | let era = z.div_euclid(146_097); |
| 319 | let doe = z - era * 146_097; |
| 320 | let yoe = (doe - doe / 1460 + doe / 36_524 - doe / 146_096) / 365; |
| 321 | let y = yoe + era * 400; |
| 322 | let doy = doe - (365 * yoe + yoe / 4 - yoe / 100); |
| 323 | let mp = (5 * doy + 2) / 153; |
| 324 | let d = doy - (153 * mp + 2) / 5 + 1; |
| 325 | let m = if mp < 10 { mp + 3 } else { mp - 9 }; |
| 326 | let y = if m <= 2 { y + 1 } else { y }; |
| 327 | format!("{y:04}-{m:02}-{d:02}T{:02}:{:02}Z", rem / 3600, (rem % 3600) / 60) |
| 328 | } |
| 329 | |
| 330 | fn now_secs() -> i64 { |
| 331 | SystemTime::now().duration_since(UNIX_EPOCH).map(|d| d.as_secs() as i64).unwrap_or(0) |
| 332 | } |
| 333 | |
| 334 | pub fn age_words(age_s: i64) -> String { |
| 335 | if age_s < 0 { |
| 336 | return "age unknown".into(); |
| 337 | } |
| 338 | let m = age_s / 60; |
| 339 | if m < 1 { |
| 340 | "just now".into() |
| 341 | } else if m < 60 { |
| 342 | format!("{m} min ago") |
| 343 | } else if m < 60 * 36 { |
| 344 | let h = m / 60; |
| 345 | if h == 1 { "1 hour ago".into() } else { format!("{h} hours ago") } |
| 346 | } else { |
| 347 | let d = m / 1440; |
| 348 | if d == 1 { "1 day ago".into() } else { format!("{d} days ago") } |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | /// How warm a line is: written within the last half hour, the last two |
| 353 | /// hours, today, or older. The page colours by this, never by opinion. |
| 354 | pub fn warmth(age_s: i64) -> &'static str { |
| 355 | if age_s < 0 { |
| 356 | "cold" |
| 357 | } else if age_s < 30 * 60 { |
| 358 | "hot" |
| 359 | } else if age_s < 2 * 3600 { |
| 360 | "warm" |
| 361 | } else if age_s < 24 * 3600 { |
| 362 | "cool" |
| 363 | } else { |
| 364 | "cold" |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | pub fn parse_ledger(tsv: &str, at: i64) -> Vec<Item> { |
| 369 | let mut out = Vec::new(); |
| 370 | for (n, line) in tsv.lines().enumerate() { |
| 371 | if n == 0 && line.starts_with("id\t") { |
| 372 | continue; |
| 373 | } |
| 374 | if line.trim().is_empty() { |
| 375 | continue; |
| 376 | } |
| 377 | let f: Vec<&str> = line.split('\t').collect(); |
| 378 | if f.len() < 5 { |
| 379 | continue; |
| 380 | } |
| 381 | let get = |i: usize| f.get(i).map(|s| clean(s)).unwrap_or_default(); |
| 382 | let owner = get(2); |
| 383 | let item = get(4); |
| 384 | let updated = get(7); |
| 385 | let age_s = parse_utc(&updated).or_else(|| parse_utc(&get(1))).map(|t| at - t).unwrap_or(-1); |
| 386 | let notes: Vec<String> = get(6) |
| 387 | .split(" | ") |
| 388 | .map(|s| s.trim().to_string()) |
| 389 | .filter(|s| !s.is_empty()) |
| 390 | .collect(); |
| 391 | out.push(Item { |
| 392 | id: get(0), |
| 393 | line: n + 1, |
| 394 | opened_utc: get(1), |
| 395 | owner_kind: owner_kind(&owner), |
| 396 | stream: classify(&item, &owner), |
| 397 | owner, |
| 398 | status: get(3).to_ascii_lowercase(), |
| 399 | item, |
| 400 | done_when: get(5), |
| 401 | notes, |
| 402 | updated_utc: updated, |
| 403 | age_s, |
| 404 | }); |
| 405 | } |
| 406 | out |
| 407 | } |
| 408 | |
| 409 | fn parse_pulse(tsv: &str) -> Vec<Pulse> { |
| 410 | tsv.lines() |
| 411 | .filter_map(|l| l.split_once('\t')) |
| 412 | .map(|(k, v)| Pulse { key: clean(k), value: clean(v) }) |
| 413 | .collect() |
| 414 | } |
| 415 | |
| 416 | /// Load from the laid-in files. A missing ledger is not an error: the page |
| 417 | /// then says plainly that nothing has been published yet. |
| 418 | pub fn load() -> Now { |
| 419 | let at = now_secs(); |
| 420 | let tsv = fs::read_to_string(Path::new(LEDGER_PATH)).unwrap_or_default(); |
| 421 | let pulse = fs::read_to_string(Path::new(PULSE_PATH)).map(|s| parse_pulse(&s)).unwrap_or_default(); |
| 422 | let items = parse_ledger(&tsv, at); |
| 423 | let written = items |
| 424 | .iter() |
| 425 | .filter_map(|i| parse_utc(&i.updated_utc)) |
| 426 | .max() |
| 427 | .map(fmt_utc) |
| 428 | .unwrap_or_else(|| "never".into()); |
| 429 | let (checked, ids) = fs::read_to_string(Path::new(MODELS_PATH)).map(|s| parse_models_check(&s)).unwrap_or_default(); |
| 430 | let (plan, models) = models_from(ROSTER, &checked, &ids); |
| 431 | let models_checked_utc = checked.unwrap_or_else(|| "never".into()); |
| 432 | let claude = fs::read_to_string(Path::new(USAGE_PATH)).ok().and_then(|s| parse_usage(&s)); |
| 433 | Now { built_utc: fmt_utc(at), ledger_written_utc: written, items, pulse, models_checked_utc, plan, models, claude } |
| 434 | } |
| 435 | |
| 436 | pub fn to_json(now: &Now) -> String { |
| 437 | serde_json::to_string_pretty(now).unwrap_or_else(|_| "{}".into()) |
| 438 | } |
| 439 | |
| 440 | // ---------------------------------------------------------------- rendering |
| 441 | |
| 442 | fn owner_label(it: &Item) -> String { |
| 443 | match it.owner_kind { |
| 444 | "operator" => "Drake".into(), |
| 445 | "desk" => "PR desk".into(), |
| 446 | "coordinator" => "Coordinator".into(), |
| 447 | "unassigned" => "Unassigned".into(), |
| 448 | _ => { |
| 449 | // Keeper, and the retired Renda workers (renda, renda1, renda2), read as Keeper. |
| 450 | if let Some(n) = it.owner.strip_prefix("keeper").or_else(|| it.owner.strip_prefix("renda")).filter(|n| n.chars().all(|c| c.is_ascii_digit())) { |
| 451 | return if n.is_empty() { "Keeper".into() } else { format!("Keeper {n}") }; |
| 452 | } |
| 453 | // sa-3-dfa217d1 reads as "agent dfa217"; anything else stays as written. |
| 454 | let parts: Vec<&str> = it.owner.split('-').collect(); |
| 455 | if parts.len() >= 3 && parts[0] == "sa" { |
| 456 | format!("agent {}", &parts[2][..parts[2].len().min(6)]) |
| 457 | } else { |
| 458 | format!("agent {}", it.owner) |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | /// Keeper, the merge desk, was called Renda until 2026-10-24 (Drake). The page |
| 465 | /// shows the new name in ledger prose; the ledger on the forge keeps every line as |
| 466 | /// written. Paths, file names and identifiers that contain the old name (a |
| 467 | /// slash, dot, underscore or letter next to it) stay as they are so they still |
| 468 | /// point at real things: `renda1` reads Keeper's `keeper1`, `~/renda-queue/` stays. |
| 469 | pub fn keeper_name(s: &str) -> String { |
| 470 | let b = s.as_bytes(); |
| 471 | let mut out = String::with_capacity(s.len()); |
| 472 | let mut i = 0; |
| 473 | while i < s.len() { |
| 474 | let hit = i + 5 <= b.len() && b[i..i + 5].eq_ignore_ascii_case(b"renda"); |
| 475 | // A capital R after a lowercase letter, or before a capital, is a word |
| 476 | // boundary an agent squashed ("soleRenda", "RendaL708"), not an identifier. |
| 477 | let capital = b[i] == b'R'; |
| 478 | let before_ok = i == 0 || { |
| 479 | let p = b[i - 1]; |
| 480 | !(p.is_ascii_uppercase() || p.is_ascii_digit() || b"/._~-".contains(&p)) && (!p.is_ascii_lowercase() || capital) |
| 481 | }; |
| 482 | let after_ok = i + 5 >= b.len() || { |
| 483 | let n = b[i + 5]; |
| 484 | let then = b.get(i + 6).copied(); |
| 485 | match n { |
| 486 | b'/' | b'_' => false, |
| 487 | b'.' => !then.is_some_and(|t| t.is_ascii_alphanumeric()), |
| 488 | _ if n.is_ascii_lowercase() => false, |
| 489 | _ if n.is_ascii_uppercase() => capital, |
| 490 | _ => true, |
| 491 | } |
| 492 | }; |
| 493 | if hit && before_ok && after_ok { |
| 494 | let word = &s[i..i + 5]; |
| 495 | out.push_str(if word == "RENDA" { |
| 496 | "KEEPER" |
| 497 | } else if word.starts_with('R') { |
| 498 | "Keeper" |
| 499 | } else { |
| 500 | "keeper" |
| 501 | }); |
| 502 | i += 5; |
| 503 | } else { |
| 504 | let c = s[i..].chars().next().unwrap(); |
| 505 | out.push(c); |
| 506 | i += c.len_utf8(); |
| 507 | } |
| 508 | } |
| 509 | out |
| 510 | } |
| 511 | |
| 512 | fn last_note(it: &Item) -> Option<&String> { |
| 513 | it.notes.last() |
| 514 | } |
| 515 | |
| 516 | /// Phrases withdrawn from the public record on 2026-11-07. Ledger rows stay |
| 517 | /// byte-identical; a row that still carries one is shown with a note. |
| 518 | pub const WITHDRAWN_PHRASES: [&str; 6] = |
| 519 | ["drop-in", "first ever", "replaced cuda", "faster than cuda", "no nvidia software", "works on any nvidia gpu"]; |
| 520 | pub const WITHDRAWN_NOTE: &str = |
| 521 | "Wording withdrawn 2026-11-07: this phrase is not a supported claim; see the hardware scope."; |
| 522 | |
| 523 | /// True when the shown text of a line (item, latest note, done-when) holds a withdrawn phrase. |
| 524 | fn withdrawn(it: &Item) -> bool { |
| 525 | let shown = [Some(&it.item), last_note(it), Some(&it.done_when)]; |
| 526 | shown.into_iter().flatten().any(|t| { |
| 527 | let t = t.to_ascii_lowercase(); |
| 528 | WITHDRAWN_PHRASES.iter().any(|p| t.contains(p)) |
| 529 | }) |
| 530 | } |
| 531 | |
| 532 | /// Every ledger box on a rendered /now/ page whose text holds a withdrawn |
| 533 | /// phrase but not the withdrawal note. Text before the first box counts too. |
| 534 | pub fn unannotated_withdrawn(page: &str) -> Vec<String> { |
| 535 | const STARTS: [&str; 3] = ["<article class=\"now-card", "<li class=\"now-queue-row", "<li class=\"now-tl "]; |
| 536 | let mut cuts: Vec<usize> = STARTS.iter().flat_map(|s| page.match_indices(s).map(|(i, _)| i)).collect(); |
| 537 | cuts.push(0); |
| 538 | cuts.push(page.len()); |
| 539 | cuts.sort_unstable(); |
| 540 | cuts.dedup(); |
| 541 | let mut bad = Vec::new(); |
| 542 | for w in cuts.windows(2) { |
| 543 | let chunk = &page[w[0]..w[1]]; |
| 544 | let lower = chunk.to_ascii_lowercase(); |
| 545 | for p in WITHDRAWN_PHRASES { |
| 546 | if lower.contains(p) && !chunk.contains(WITHDRAWN_NOTE) { |
| 547 | bad.push(format!("{p:?} without the withdrawal note in {:?}", &chunk[..chunk.len().min(200)])); |
| 548 | } |
| 549 | } |
| 550 | } |
| 551 | bad |
| 552 | } |
| 553 | |
| 554 | /// The same rule on a generated text copy of /now/ (now.md, now/index.md and the |
| 555 | /// /now/ section of llms-full.txt): after each withdrawn phrase the note comes |
| 556 | /// before the box ends, at its "[Ledger line " link or at the next "- L<digit>" row. |
| 557 | pub fn unannotated_withdrawn_text(text: &str) -> Vec<String> { |
| 558 | let lower = text.to_ascii_lowercase(); |
| 559 | let mut bad = Vec::new(); |
| 560 | for p in WITHDRAWN_PHRASES { |
| 561 | for (i, _) in lower.match_indices(p) { |
| 562 | let rest = &text[i..]; |
| 563 | let foot = rest.find("[Ledger line "); |
| 564 | let row = rest.match_indices("\n- L").find(|(k, m)| rest[k + m.len()..].starts_with(|c: char| c.is_ascii_digit())).map(|(k, _)| k); |
| 565 | let end = [foot, row].into_iter().flatten().min().unwrap_or(rest.len()); |
| 566 | if !rest[..end].contains(WITHDRAWN_NOTE) { |
| 567 | let from = text[..i].char_indices().rev().nth(80).map_or(0, |(k, _)| k); |
| 568 | bad.push(format!("{p:?} without the withdrawal note near {:?}", &text[from..(i + p.len())])); |
| 569 | } |
| 570 | } |
| 571 | } |
| 572 | bad |
| 573 | } |
| 574 | |
| 575 | /// The /now/ section of llms-full.txt, from its Source line to the next page. |
| 576 | pub fn llms_now_section(full: &str) -> Option<&str> { |
| 577 | let start = full.find("\nSource: https://www.aienos.com/now/\n")?; |
| 578 | let rest = &full[start..]; |
| 579 | Some(&rest[..rest[1..].find("\n---\n\n# ").map_or(rest.len(), |e| e + 1)]) |
| 580 | } |
| 581 | |
| 582 | /// Every built /now/ surface (HTML, markdown twins, llms-full.txt) notes withdrawn wording. |
| 583 | pub fn verify_withdrawn_notes(dist: &std::path::Path) { |
| 584 | let mut out = Vec::new(); |
| 585 | for rel in crate::components::voice::LEDGER_PAGES { |
| 586 | let body = std::fs::read_to_string(dist.join(rel)).unwrap_or_else(|_| panic!("read {rel}")); |
| 587 | let bad = if rel.ends_with(".html") { |
| 588 | unannotated_withdrawn(&body) |
| 589 | } else if *rel == "llms-full.txt" { |
| 590 | match llms_now_section(&body) { |
| 591 | Some(s) => unannotated_withdrawn_text(s), |
| 592 | None => vec!["no /now/ section".into()], |
| 593 | } |
| 594 | } else { |
| 595 | unannotated_withdrawn_text(&body) |
| 596 | }; |
| 597 | out.extend(bad.into_iter().map(|b| format!("{rel}: {b}"))); |
| 598 | } |
| 599 | assert!(out.is_empty(), "Withdrawn wording without the note:\n{}", out.join("\n")); |
| 600 | println!(" [NOW] withdrawn wording carries the note on {} ledger surfaces", crate::components::voice::LEDGER_PAGES.len()); |
| 601 | } |
| 602 | |
| 603 | /// /now/ rendered from `tsv` at `at`, with no model check. |
| 604 | #[cfg(test)] |
| 605 | pub(crate) fn render_ledger(tsv: &str, at: i64) -> String { |
| 606 | let (plan, models) = models_from(ROSTER, &None, &[]); |
| 607 | let now = Now { built_utc: fmt_utc(at), ledger_written_utc: fmt_utc(at), items: parse_ledger(tsv, at), pulse: vec![], models_checked_utc: "never".into(), plan, models, claude: None }; |
| 608 | render_now_page(&now).into_string() |
| 609 | } |
| 610 | |
| 611 | /// The item's own line of the published ledger. |
| 612 | fn line_url(it: &Item) -> String { |
| 613 | format!("{LEDGER_URL}#L{}", it.line) |
| 614 | } |
| 615 | |
| 616 | fn line_foot(it: &Item) -> Markup { |
| 617 | foot_labelled(&line_url(it), &format!("Ledger line {} on the forge", it.line), Target::Evidence) |
| 618 | } |
| 619 | |
| 620 | /// The repository a bare `branch@sha` in a note belongs to when the note |
| 621 | /// names none: the stream's home. Streams with no one home get None and |
| 622 | /// such a reference stays plain text. |
| 623 | fn default_repo(stream: &str) -> Option<&'static str> { |
| 624 | match stream { |
| 625 | "Engine speed" | "Research" => Some("omega-mv"), |
| 626 | "Alpha release" => Some("aien-sovereign-core-mv"), |
| 627 | "AIEN Rig" => Some("aien-rig"), |
| 628 | "AienOS on the iMac" => Some("aienux"), |
| 629 | "Public record" => Some("aienos.com"), |
| 630 | _ => None, |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | /// A note with its references turned into links (see `linkify`). |
| 635 | fn note_markup(note: &str, stream: &str) -> Markup { |
| 636 | let segs = linkify(note, default_repo(stream)); |
| 637 | html! { |
| 638 | @for seg in &segs { |
| 639 | @if let Some(href) = &seg.href { |
| 640 | a class="now-ref" href=(href) target="_blank" rel="noopener noreferrer" { (seg.text) } |
| 641 | (crate::forge::receipt_code(href)) |
| 642 | } @else { |
| 643 | (keeper_name(&seg.text)) |
| 644 | } |
| 645 | } |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | // ---------------------------------------------------------------- linkify |
| 650 | |
| 651 | /// A run of note text, linked or plain. |
| 652 | #[derive(Debug, Clone, PartialEq, Eq)] |
| 653 | pub struct Seg { |
| 654 | pub text: String, |
| 655 | pub href: Option<String>, |
| 656 | } |
| 657 | |
| 658 | /// Short repository names the ledger uses, and the GitHub name of each. |
| 659 | /// `aienos` and `aienos-mv` are the kernel's former names: ledger lines |
| 660 | /// written before the rename mean the kernel, now `aienux`. |
| 661 | const REPOS: [(&str, &str); 20] = [ |
| 662 | ("omega", "omega-mv"), |
| 663 | ("omega-mv", "omega-mv"), |
| 664 | ("sc", "aien-sovereign-core-mv"), |
| 665 | ("aien-sovereign-core", "aien-sovereign-core-mv"), |
| 666 | ("aien-sovereign-core-mv", "aien-sovereign-core-mv"), |
| 667 | ("aienux", "aienux"), |
| 668 | ("aienos", "aienux"), |
| 669 | ("aienos-mv", "aienux"), |
| 670 | ("arch", "aien-architecture-mv"), |
| 671 | ("aien-architecture", "aien-architecture-mv"), |
| 672 | ("aien-architecture-mv", "aien-architecture-mv"), |
| 673 | ("physics", "physics-mv"), |
| 674 | ("physics-mv", "physics-mv"), |
| 675 | ("aien-protocols", "aien-protocols-mv"), |
| 676 | ("aien-protocols-mv", "aien-protocols-mv"), |
| 677 | ("benchmarks", "benchmarks-mv"), |
| 678 | ("benchmarks-mv", "benchmarks-mv"), |
| 679 | ("aien-rig", "aien-rig"), |
| 680 | ("aienos.com", "aienos.com"), |
| 681 | (".github", ".github"), |
| 682 | ]; |
| 683 | |
| 684 | fn repo_name(short: &str) -> Option<&'static str> { |
| 685 | REPOS.iter().find(|(s, _)| *s == short).map(|(_, full)| *full) |
| 686 | } |
| 687 | |
| 688 | fn is_sha(s: &str) -> bool { |
| 689 | (7..=40).contains(&s.len()) && s.chars().all(|c| c.is_ascii_hexdigit() && !c.is_ascii_uppercase()) |
| 690 | } |
| 691 | |
| 692 | fn is_branch(s: &str) -> bool { |
| 693 | !s.is_empty() |
| 694 | && !s.starts_with('/') |
| 695 | && !s.ends_with('/') |
| 696 | && s.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || matches!(c, '/' | '.' | '_' | '-')) |
| 697 | } |
| 698 | |
| 699 | fn is_token_char(c: char) -> bool { |
| 700 | c.is_ascii_alphanumeric() || matches!(c, '.' | '_' | '/' | '@' | '#' | '-') |
| 701 | } |
| 702 | |
| 703 | /// What one token refers to, if anything. |
| 704 | enum Ref { |
| 705 | Issue, |
| 706 | Commit { branch: String, sha: String }, |
| 707 | Evidence(String), |
| 708 | Repo(&'static str), |
| 709 | Url, |
| 710 | } |
| 711 | |
| 712 | fn classify_token(tok: &str) -> Option<Ref> { |
| 713 | if tok.starts_with("https://") || tok.starts_with("http://") { |
| 714 | return Some(Ref::Url); |
| 715 | } |
| 716 | if let Some((repo, n)) = tok.rsplit_once('#') { |
| 717 | let repo = repo.strip_prefix("aien-dev/").unwrap_or(repo); |
| 718 | if !n.is_empty() && n.chars().all(|c| c.is_ascii_digit()) { |
| 719 | if repo_name(repo).is_some() { |
| 720 | return Some(Ref::Issue); |
| 721 | } |
| 722 | } |
| 723 | return None; |
| 724 | } |
| 725 | if let Some((branch, sha)) = tok.split_once('@') { |
| 726 | if is_branch(branch) && is_sha(sha) { |
| 727 | return Some(Ref::Commit { branch: branch.to_string(), sha: sha.to_string() }); |
| 728 | } |
| 729 | return None; |
| 730 | } |
| 731 | if let Some(rest) = tok.strip_prefix("evidence/") { |
| 732 | if !rest.is_empty() && !rest.contains("..") { |
| 733 | return Some(Ref::Evidence(tok.to_string())); |
| 734 | } |
| 735 | return None; |
| 736 | } |
| 737 | repo_name(tok).map(Ref::Repo) |
| 738 | } |
| 739 | |
| 740 | /// Turns the references in a ledger note into links and leaves everything |
| 741 | /// else as it was: |
| 742 | /// - `aien-dev/<repo>#<n>` and `<repo>#<n>` go to the issue or pull request |
| 743 | /// (GitHub serves either at /issues/<n>); |
| 744 | /// - `<branch>@<sha>` goes to that commit in the repository named earlier |
| 745 | /// earlier in the note, else the stream's home repository, else stays |
| 746 | /// text; a repository named in one clause does not carry past the `;` |
| 747 | /// that ends it (later commits stay text until a repository is named); |
| 748 | /// - `evidence/<path>` goes to that folder on the branch of the first |
| 749 | /// `branch@sha` in the note (the agent's own branch leads a note; a |
| 750 | /// branch in parentheses is a dependency), else stays text; |
| 751 | /// - a bare https URL links to itself. |
| 752 | /// Trailing punctuation stays outside the link. Anything that does not |
| 753 | /// match exactly (an upstream model name with a revision, a mail address, |
| 754 | /// `task#3`) is left alone. |
| 755 | pub fn linkify(note: &str, default_repo: Option<&str>) -> Vec<Seg> { |
| 756 | // Tokens: maximal runs of token characters, with position. |
| 757 | let mut tokens: Vec<(usize, usize)> = Vec::new(); |
| 758 | let mut start: Option<usize> = None; |
| 759 | for (i, c) in note.char_indices() { |
| 760 | match (is_token_char(c), start) { |
| 761 | (true, None) => start = Some(i), |
| 762 | (false, Some(s)) => { |
| 763 | tokens.push((s, i)); |
| 764 | start = None; |
| 765 | } |
| 766 | _ => {} |
| 767 | } |
| 768 | } |
| 769 | if let Some(s) = start { |
| 770 | tokens.push((s, note.len())); |
| 771 | } |
| 772 | // A URL runs to the next space, not just the next non-token character. |
| 773 | let mut toks: Vec<(usize, usize)> = Vec::new(); |
| 774 | let mut skip_until = 0; |
| 775 | for &(s, e) in &tokens { |
| 776 | if s < skip_until { |
| 777 | continue; |
| 778 | } |
| 779 | if note[s..].starts_with("https://") || note[s..].starts_with("http://") { |
| 780 | let end = note[s..].find(|c: char| c.is_whitespace() || c == ')' || c == '"' || c == '>').map(|k| s + k).unwrap_or(note.len()); |
| 781 | toks.push((s, end)); |
| 782 | skip_until = end; |
| 783 | } else { |
| 784 | toks.push((s, e)); |
| 785 | } |
| 786 | } |
| 787 | // Strip trailing punctuation off each token. |
| 788 | let toks: Vec<(usize, usize)> = toks |
| 789 | .into_iter() |
| 790 | .map(|(s, e)| { |
| 791 | let t = ¬e[s..e]; |
| 792 | let trimmed = t.trim_end_matches(['.', ',', ';', ':']); |
| 793 | (s, s + trimmed.len()) |
| 794 | }) |
| 795 | .filter(|(s, e)| e > s) |
| 796 | .collect(); |
| 797 | |
| 798 | // First pass: every branch@sha with the repository it resolves to. |
| 799 | let mut last_repo: Option<&str> = default_repo; |
| 800 | let mut commits: Vec<(usize, String, String)> = Vec::new(); // (pos, repo, branch) |
| 801 | let mut refs: Vec<Option<(String, usize, usize)>> = Vec::new(); // (href, s, e) |
| 802 | let mut prev_end = 0; |
| 803 | for &(s, e) in &toks { |
| 804 | // A repository named in an earlier clause does not carry past `;`. |
| 805 | if note[prev_end..s].contains(';') && last_repo != default_repo { |
| 806 | last_repo = None; |
| 807 | } |
| 808 | prev_end = e; |
| 809 | let tok = ¬e[s..e]; |
| 810 | match classify_token(tok) { |
| 811 | Some(Ref::Repo(r)) => { |
| 812 | last_repo = Some(r); |
| 813 | refs.push(None); |
| 814 | } |
| 815 | // Issues and pull requests have no forge page: plain text. |
| 816 | Some(Ref::Issue) => refs.push(None), |
| 817 | Some(Ref::Commit { branch, sha }) => match last_repo { |
| 818 | Some(r) => { |
| 819 | commits.push((s, r.to_string(), branch)); |
| 820 | refs.push(crate::forge::repo_url(r).map(|u| (format!("{u}/commit/{sha}"), s, e))); |
| 821 | } |
| 822 | None => refs.push(None), |
| 823 | }, |
| 824 | Some(Ref::Url) if tok.contains("github.com") => refs.push(None), |
| 825 | Some(Ref::Url) => refs.push(Some((tok.to_string(), s, e))), |
| 826 | Some(Ref::Evidence(_)) | None => refs.push(None), |
| 827 | } |
| 828 | } |
| 829 | // Second pass: evidence paths resolve against the note's first branch. |
| 830 | for (k, &(s, e)) in toks.iter().enumerate() { |
| 831 | let tok = ¬e[s..e]; |
| 832 | if let Some(Ref::Evidence(path)) = classify_token(tok) { |
| 833 | if let Some((_, repo, branch)) = commits.first() { |
| 834 | if let Some(u) = crate::forge::repo_url(repo) { |
| 835 | let dir = path.ends_with('/') || !path.rsplit('/').next().unwrap_or("").contains('.'); |
| 836 | let path = path.trim_end_matches('/'); |
| 837 | refs[k] = Some((format!("{u}/{}/{branch}/{path}", if dir { "tree" } else { "blob" }), s, e)); |
| 838 | } |
| 839 | } |
| 840 | } |
| 841 | } |
| 842 | // Emit. |
| 843 | let mut out: Vec<Seg> = Vec::new(); |
| 844 | let mut cursor = 0; |
| 845 | for r in refs.into_iter().flatten() { |
| 846 | let (href, s, e) = r; |
| 847 | if s > cursor { |
| 848 | out.push(Seg { text: note[cursor..s].to_string(), href: None }); |
| 849 | } |
| 850 | out.push(Seg { text: note[s..e].to_string(), href: Some(href) }); |
| 851 | cursor = e; |
| 852 | } |
| 853 | if cursor < note.len() { |
| 854 | out.push(Seg { text: note[cursor..].to_string(), href: None }); |
| 855 | } |
| 856 | out |
| 857 | } |
| 858 | |
| 859 | fn card(it: &Item) -> Markup { |
| 860 | let w = warmth(it.age_s); |
| 861 | html! { |
| 862 | article class=(format!("now-card now-{w} now-k-{}", it.owner_kind)) id=(it.id) { |
| 863 | header class="now-card-top" { |
| 864 | span class="now-id" { (it.id) } |
| 865 | (owner_chip(it)) |
| 866 | span class="now-age" title=(it.updated_utc) { |
| 867 | span class="now-dot" aria-hidden="true" {} |
| 868 | (age_words(it.age_s)) |
| 869 | } |
| 870 | } |
| 871 | h3 class="now-item" data-verbatim { (keeper_name(&it.item)) } |
| 872 | @if let Some(n) = last_note(it) { |
| 873 | p class="now-note" data-verbatim { (note_markup(n, it.stream)) } |
| 874 | } |
| 875 | @if !it.done_when.is_empty() { |
| 876 | p class="now-done" data-verbatim { span class="now-done-k" { "done when" } " " (keeper_name(&it.done_when)) } |
| 877 | } |
| 878 | @if withdrawn(it) { p class="now-withdrawn" { (WITHDRAWN_NOTE) } } |
| 879 | (line_foot(it)) |
| 880 | } |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | /// A line counts as current when it was written in the last day. Current |
| 885 | /// lines are shown open; older ones are folded, still in the HTML. |
| 886 | const CURRENT_S: i64 = 24 * 3600; |
| 887 | |
| 888 | fn is_current(it: &Item) -> bool { |
| 889 | it.age_s >= 0 && it.age_s < CURRENT_S |
| 890 | } |
| 891 | |
| 892 | /// One folded line: id, item, its latest note, owner, age, ledger link. |
| 893 | fn row(it: &Item) -> Markup { |
| 894 | html! { |
| 895 | li class="now-queue-row now-row" id=(it.id) { |
| 896 | span class="now-id" { (it.id) } |
| 897 | span class="now-queue-item" data-verbatim { |
| 898 | (keeper_name(&it.item)) |
| 899 | @if let Some(n) = last_note(it) { |
| 900 | span class="now-row-note" { (note_markup(n, it.stream)) } |
| 901 | } |
| 902 | @if !it.done_when.is_empty() { |
| 903 | span class="now-row-done" { "done when " (keeper_name(&it.done_when)) } |
| 904 | } |
| 905 | } |
| 906 | @if withdrawn(it) { span class="now-withdrawn" { (WITHDRAWN_NOTE) } } |
| 907 | span class="now-row-meta" { |
| 908 | (owner_chip(it)) |
| 909 | span class="now-row-age" title=(it.updated_utc) { (age_words(it.age_s)) } |
| 910 | } |
| 911 | (line_foot(it)) |
| 912 | } |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | /// A closed `details` block. Its rows stay in the page for every reader |
| 917 | /// and crawler; a visitor opens it with one click, and a link to a line |
| 918 | /// inside opens it in the browser. |
| 919 | fn fold(id: &str, title: &str, items: &[&Item]) -> Markup { |
| 920 | let newest = items.iter().filter(|i| i.age_s >= 0).map(|i| i.age_s).min(); |
| 921 | html! { |
| 922 | details class="now-fold" id=(id) { |
| 923 | summary class="now-fold-sum" { |
| 924 | span class="now-fold-name" { (title) } |
| 925 | span class="now-fold-n" { (items.len()) " " @if items.len() == 1 { "line" } @else { "lines" } } |
| 926 | @if let Some(a) = newest { |
| 927 | span class="now-fold-age" { "last written " (age_words(a)) } |
| 928 | } |
| 929 | } |
| 930 | ol class="now-queue now-fold-rows" { |
| 931 | @for it in items { (row(it)) } |
| 932 | } |
| 933 | } |
| 934 | } |
| 935 | } |
| 936 | |
| 937 | fn slug(s: &str) -> String { |
| 938 | s.to_ascii_lowercase().replace(' ', "-") |
| 939 | } |
| 940 | |
| 941 | fn settled_entry(it: &Item) -> Markup { |
| 942 | html! { |
| 943 | li class=(format!("now-tl now-tl-{}", it.status)) id=(it.id) { |
| 944 | span class="now-tl-when mono" title=(it.updated_utc) { (age_words(it.age_s)) } |
| 945 | div class="now-tl-body" { |
| 946 | span class=(format!("now-verdict now-verdict-{}", it.status)) { (it.status) } |
| 947 | span class="now-id" { (it.id) } |
| 948 | p class="now-tl-item" data-verbatim { (keeper_name(&it.item)) } |
| 949 | @if let Some(n) = last_note(it) { |
| 950 | p class="now-tl-evidence" data-verbatim { (note_markup(n, it.stream)) } |
| 951 | } |
| 952 | @if withdrawn(it) { p class="now-withdrawn" { (WITHDRAWN_NOTE) } } |
| 953 | (line_foot(it)) |
| 954 | } |
| 955 | } |
| 956 | } |
| 957 | } |
| 958 | |
| 959 | /// The UTC day a line was last written, "2026-10-24", or "date unknown". |
| 960 | fn day_of(it: &Item) -> String { |
| 961 | let s = if it.updated_utc.is_empty() { &it.opened_utc } else { &it.updated_utc }; |
| 962 | if parse_utc(s).is_some() { s[..10].to_string() } else { "date unknown".into() } |
| 963 | } |
| 964 | |
| 965 | fn river(items: &[&Item]) -> Markup { |
| 966 | // One segment per line, warm to cold, newest first: the stream's pulse at a glance. |
| 967 | let mut sorted: Vec<&Item> = items.to_vec(); |
| 968 | sorted.sort_by_key(|i| if i.age_s < 0 { i64::MAX } else { i.age_s }); |
| 969 | html! { |
| 970 | div class="now-river" aria-hidden="true" { |
| 971 | @for it in sorted { |
| 972 | span class=(format!("now-seg now-{}", warmth(it.age_s))) title=(format!("{} {}", it.id, age_words(it.age_s))) {} |
| 973 | } |
| 974 | } |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | fn stat(n: usize, label: &str, class: &str) -> Markup { |
| 979 | html! { |
| 980 | div class=(format!("now-stat {class}")) { |
| 981 | span class="now-stat-n" { (n) } |
| 982 | span class="now-stat-l" { (label) } |
| 983 | } |
| 984 | } |
| 985 | } |
| 986 | |
| 987 | fn state_words(state: &str) -> &'static str { |
| 988 | match state { |
| 989 | "answering" => "Answering", |
| 990 | "not-answering" => "Not answering", |
| 991 | "planned" => "Planned", |
| 992 | "not-trained" => "Not trained yet", |
| 993 | "retired" => "Retired", |
| 994 | _ => "Status unknown", |
| 995 | } |
| 996 | } |
| 997 | |
| 998 | /// One model card. Its box link goes to the ledger line that carries its |
| 999 | /// plan, else to its design source, else to the plan itself. |
| 1000 | fn model_card(m: &Model, now: &Now) -> Markup { |
| 1001 | let foot = match m.plan_ledger.as_deref().and_then(|id| now.items.iter().find(|i| i.id == id)) { |
| 1002 | Some(it) => foot_labelled(&line_url(it), &format!("Plan: ledger {} on the forge", it.id), Target::Evidence), |
| 1003 | None => match &m.source { |
| 1004 | Some(s) => foot_labelled(&s.url, &s.label, Target::Source), |
| 1005 | None => foot_labelled(&now.plan.url, &now.plan.label, Target::Source), |
| 1006 | }, |
| 1007 | }; |
| 1008 | html! { |
| 1009 | article class=(format!("now-card now-model now-model-{}", m.state)) id=(m.key) { |
| 1010 | header class="now-card-top" { |
| 1011 | span class="now-model-track" { (m.track) } |
| 1012 | span class=(format!("now-model-state now-model-state-{}", m.state)) { (state_words(&m.state)) } |
| 1013 | } |
| 1014 | h3 class="now-item" { (m.name) } |
| 1015 | p class="now-note now-model-role" { (m.role) } |
| 1016 | @match m.state.as_str() { |
| 1017 | "answering" => { |
| 1018 | p class="now-done" { span class="now-done-k" { "serving" } " " span class="mono" { (m.served_as.as_deref().unwrap_or("")) } ", answered the Spark's check at " span class="mono" { (now.models_checked_utc) } } |
| 1019 | } |
| 1020 | "not-answering" => { |
| 1021 | p class="now-done" { "Did not answer the Spark's check at " span class="mono" { (now.models_checked_utc) } "." } |
| 1022 | } |
| 1023 | "unknown" => { |
| 1024 | p class="now-done" { "The Spark has not published a model check yet." } |
| 1025 | } |
| 1026 | _ => {} |
| 1027 | } |
| 1028 | @if !m.figures.is_empty() { |
| 1029 | dl class="now-model-figs" { |
| 1030 | @for f in &m.figures { |
| 1031 | dt { (f.label) } |
| 1032 | dd { |
| 1033 | (f.value) " " |
| 1034 | @if f.receipt.is_empty() { |
| 1035 | "receipt" |
| 1036 | } @else { |
| 1037 | a class="now-ref" href=(f.receipt) target="_blank" rel="noopener noreferrer" { "receipt" } |
| 1038 | (crate::forge::receipt_code(&f.receipt)) |
| 1039 | } |
| 1040 | } |
| 1041 | } |
| 1042 | } |
| 1043 | } |
| 1044 | (foot) |
| 1045 | } |
| 1046 | } |
| 1047 | } |
| 1048 | |
| 1049 | fn models_section(now: &Now) -> Markup { |
| 1050 | html! { |
| 1051 | section class="now-section" id="models" aria-labelledby="now-models-h" { |
| 1052 | div class="container" { |
| 1053 | p class="kicker" { "On the Spark" } |
| 1054 | h2 id="now-models-h" class="now-h2" { "Models doing the work" } |
| 1055 | p class="now-sub" { |
| 1056 | "The models the plan names, what each one is for, and whether it answered the Spark's own check of its model servers. The Spark checks every five minutes; this page shows the check from its last build" |
| 1057 | @if now.models_checked_utc != "never" { " (" span class="mono" { (now.models_checked_utc) } ")" } |
| 1058 | ". Every speed links to its receipt. A token is a word or a piece of one. The plan: " |
| 1059 | @if now.plan.url.is_empty() { |
| 1060 | (now.plan.label) |
| 1061 | } @else { |
| 1062 | a class="prose-link" href=(now.plan.url) { (now.plan.label) } |
| 1063 | (crate::forge::receipt_code(&now.plan.url)) |
| 1064 | } |
| 1065 | "." |
| 1066 | } |
| 1067 | div class="now-grid" { |
| 1068 | @for m in &now.models { (model_card(m, now)) } |
| 1069 | } |
| 1070 | } |
| 1071 | } |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | /// One limit's row: its label, its meter, what is left, and when it resets. |
| 1076 | fn usage_row(l: &UsageLimit) -> Markup { |
| 1077 | html! { |
| 1078 | div class="now-usage-row" { |
| 1079 | span class="now-usage-k" { (l.label) } |
| 1080 | meter class="now-usage-meter" min="0" max="100" low="70" high="90" optimum="0" value=(l.used_pct) { |
| 1081 | (l.used_pct) "% used" |
| 1082 | } |
| 1083 | span class="now-usage-v" { strong { (100 - l.used_pct) "% left" } " " span class="now-usage-used" { "(" (l.used_pct) "% used)" } } |
| 1084 | @if !l.resets_utc.is_empty() { |
| 1085 | span class="now-usage-reset" { "resets " span class="mono" { (l.resets_utc) } } |
| 1086 | } |
| 1087 | } |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | /// A reading older than this is called out as old. |
| 1092 | const USAGE_STALE_S: i64 = 2 * 3600; |
| 1093 | |
| 1094 | /// Drake's Claude plans: how much of each limit is left, and the two ways a |
| 1095 | /// visitor can give compute instead of money (an agent on their own plan, or a |
| 1096 | /// Spark qualifying the same gates). |
| 1097 | fn usage_section(now: &Now) -> Markup { |
| 1098 | let built = parse_utc(&now.built_utc); |
| 1099 | html! { |
| 1100 | section class="now-section" id="claude" aria-labelledby="now-claude-h" { |
| 1101 | div class="container" { |
| 1102 | p class="kicker" { "Paying for the work" } |
| 1103 | h2 id="now-claude-h" class="now-h2" { "How much Claude is left" } |
| 1104 | p class="now-sub" { |
| 1105 | "Many of the agents on this page are Claude models made by Anthropic (Opus, Fable, Sonnet and Haiku), running on Drake's own three Claude subscriptions. The plans allow a set amount of use in each five-hour session and in each week. The Spark reads the plan's own usage meter every five minutes and publishes the percentages, never the login." |
| 1106 | } |
| 1107 | p class="now-sub" { |
| 1108 | "The same work also runs on subscriptions Drake pays for himself: OpenAI Codex, Google Gemini and xAI Grok. Those plans publish no usage meter here, so this page shows no percentage for them. The Claude meter is the only one the Spark can read." |
| 1109 | } |
| 1110 | div class="now-usage-wrap" { |
| 1111 | article class="now-usage" { |
| 1112 | @match &now.claude { |
| 1113 | Some(u) => { |
| 1114 | header class="now-card-top" { |
| 1115 | span class="now-usage-plan" { "Claude " (u.plan) " plan" } |
| 1116 | span class="now-age mono" { "read " (u.checked_utc) } |
| 1117 | } |
| 1118 | @if built.zip(parse_utc(&u.checked_utc)).is_some_and(|(b, c)| b - c > USAGE_STALE_S) { |
| 1119 | p class="now-done" { "This is the last reading the Spark published; it has not read a newer one since." } |
| 1120 | } |
| 1121 | @if u.limits.len() > 1 { |
| 1122 | div class="now-usage-menu" { |
| 1123 | @for (i, _) in u.limits.iter().enumerate() { |
| 1124 | input type="radio" name="now-usage" id=(format!("now-usage-{i}")) class="now-usage-radio" checked[i == 0]; |
| 1125 | } |
| 1126 | div class="now-usage-tabs" role="tablist" aria-label="Usage limits: choose one to read" { |
| 1127 | @for (i, l) in u.limits.iter().enumerate() { |
| 1128 | label class="now-usage-tab" for=(format!("now-usage-{i}")) { |
| 1129 | span class="now-usage-tab-k" { (l.label) } |
| 1130 | span class="now-usage-tab-v" { (100 - l.used_pct) "% left" } |
| 1131 | } |
| 1132 | } |
| 1133 | } |
| 1134 | div class="now-usage-panels" { |
| 1135 | @for (i, l) in u.limits.iter().enumerate() { |
| 1136 | div class=(format!("now-usage-panel now-usage-panel-{i}")) { |
| 1137 | (usage_row(l)) |
| 1138 | } |
| 1139 | } |
| 1140 | } |
| 1141 | } |
| 1142 | } @else { |
| 1143 | @for l in &u.limits { (usage_row(l)) } |
| 1144 | } |
| 1145 | } |
| 1146 | None => { |
| 1147 | p class="now-done" { "The Spark has not published a reading of the plan yet." } |
| 1148 | } |
| 1149 | } |
| 1150 | (foot_labelled(&super::boxlink::source_href(USAGE_SOURCE), "Source on the forge", Target::Source)) |
| 1151 | } |
| 1152 | aside class="now-give" aria-labelledby="now-give-h" { |
| 1153 | h3 id="now-give-h" class="now-give-h" { "Give compute, not money" } |
| 1154 | p { |
| 1155 | "The work runs on plans and on one Spark. Both can come from you, and Drake takes no payment for either." |
| 1156 | } |
| 1157 | ul class="now-give-steps" { |
| 1158 | li { |
| 1159 | strong { "Your agent, your plan. " } |
| 1160 | "Pick any repository on " a class="prose-link" href="/agents/" { "Agents" } " and give your agent its instructions: the rules mine follow and that repository's own AGENTS.md. It claims an open issue and opens a pull request that leads with its evidence, like mine do. Its own subscription pays for it (Claude, Codex, Gemini or Grok); nothing of yours is sent to the Spark." |
| 1161 | } |
| 1162 | li { |
| 1163 | strong { "Your Spark. " } |
| 1164 | "A second GB10 can qualify the same gates and publish its own receipt. The GPU gates are written to run on any Spark, and a PASS from your machine is evidence, not a claim." |
| 1165 | } |
| 1166 | } |
| 1167 | p class="now-give-note" { "No keys are collected. Your agent runs on your account, your Spark on your network, and only merged evidence reaches this page." } |
| 1168 | p class="now-give-btn" { "Join in Open Humanity: " code { (HUMANITY) } } |
| 1169 | } |
| 1170 | } |
| 1171 | } |
| 1172 | } |
| 1173 | } |
| 1174 | } |
| 1175 | |
| 1176 | /// Keeper's name tag carries a small dachshund, the picture in "How this page is made". |
| 1177 | fn owner_chip(it: &Item) -> Markup { |
| 1178 | let label = owner_label(it); |
| 1179 | html! { |
| 1180 | span class=(format!("now-owner now-owner-{}", it.owner_kind)) { |
| 1181 | @if label.starts_with("Keeper") { |
| 1182 | img class="now-owner-dog" src="/assets/keeper.svg" alt="" width="42" height="14"; |
| 1183 | } |
| 1184 | (label) |
| 1185 | } |
| 1186 | } |
| 1187 | } |
| 1188 | |
| 1189 | pub fn render_now_page(now: &Now) -> Markup { |
| 1190 | let open: Vec<&Item> = now.items.iter().filter(|i| i.status == "open").collect(); |
| 1191 | let settled: Vec<&Item> = now.items.iter().filter(|i| i.status == "done" || i.status == "dropped").collect(); |
| 1192 | let hands: usize = open.iter().filter(|i| i.owner_kind == "agent" && i.age_s >= 0 && i.age_s < 2 * 3600).map(|i| i.owner.as_str()).collect::<std::collections::BTreeSet<_>>().len(); |
| 1193 | let for_drake: Vec<&Item> = open.iter().copied().filter(|i| i.owner_kind == "operator").collect(); |
| 1194 | let next: Vec<&Item> = open.iter().copied().filter(|i| i.owner_kind != "operator" && (i.owner_kind == "unassigned" || i.notes.is_empty())).collect(); |
| 1195 | let moving: Vec<&Item> = open.iter().copied().filter(|i| i.owner_kind != "operator" && !(i.owner_kind == "unassigned" || i.notes.is_empty())).collect(); |
| 1196 | let mut settled_sorted = settled.clone(); |
| 1197 | settled_sorted.sort_by_key(|i| if i.age_s < 0 { i64::MAX } else { i.age_s }); |
| 1198 | let (moving_now, moving_quiet): (Vec<&Item>, Vec<&Item>) = moving.iter().copied().partition(|i| is_current(i)); |
| 1199 | let (next_now, next_quiet): (Vec<&Item>, Vec<&Item>) = next.iter().copied().partition(|i| is_current(i)); |
| 1200 | let (settled_now, settled_old): (Vec<&Item>, Vec<&Item>) = settled_sorted.iter().copied().partition(|i| is_current(i)); |
| 1201 | // Older settled lines, one fold per UTC day, newest day first. |
| 1202 | let mut settled_days: Vec<(String, Vec<&Item>)> = Vec::new(); |
| 1203 | for it in &settled_old { |
| 1204 | let d = day_of(it); |
| 1205 | match settled_days.last_mut() { |
| 1206 | Some((day, list)) if *day == d => list.push(it), |
| 1207 | _ => settled_days.push((d, vec![it])), |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | html! { |
| 1212 | section class="now-hero" aria-labelledby="now-title" { |
| 1213 | div class="container" { |
| 1214 | div class="now-hero-top" { |
| 1215 | div class="now-hero-text" { |
| 1216 | p class="kicker" { "Now" } |
| 1217 | h1 id="now-title" class="now-title" { "What is being done, right now." } |
| 1218 | p class="now-lead" { |
| 1219 | "This is the working ledger of Aien, published as it is written. Every line is a promise with an owner and an observable finish. Agents write their progress here; the operator writes decisions here. Nothing on this page is composed by hand. Lines written in the last day are shown open; older lines are folded below, each one click away." |
| 1220 | } |
| 1221 | p class="now-lead" { |
| 1222 | a href="/hive/" { strong { "Hive" } } |
| 1223 | " / Watch the agents work, see their exact models, and follow Drake's instructions and corrections live. " |
| 1224 | a href="/learn/" { "Learn to structure your own work with AI." } |
| 1225 | } |
| 1226 | } |
| 1227 | figure class="now-keeper" { |
| 1228 | img src="/assets/keeper.svg" width="600" height="200" alt="Keeper, the merge desk that lands finished changes: a big cartoon dachshund, long and low, wearing a gold key on its red collar."; |
| 1229 | figcaption { "Keeper, the merge desk" } |
| 1230 | } |
| 1231 | } |
| 1232 | @if now.items.is_empty() { |
| 1233 | p class="now-empty" { "No ledger has been published yet. The page will fill itself the moment one arrives." } |
| 1234 | } @else { |
| 1235 | div class="now-stats" { |
| 1236 | (stat(hands, "agents writing in the last two hours", "now-stat-hot")) |
| 1237 | (stat(moving_now.len(), "lines in motion, written in the last day", "")) |
| 1238 | (stat(moving_quiet.len() + next_quiet.len(), "open lines quiet for over a day, quiet and queued", "")) |
| 1239 | (stat(settled_now.len(), "settled in the last day", "now-stat-done")) |
| 1240 | (stat(for_drake.len(), "waiting on the operator", "now-stat-op")) |
| 1241 | } |
| 1242 | nav class="now-jump" aria-label="On this page" { |
| 1243 | a href="#claude" { "Paying for the work" } |
| 1244 | @if !for_drake.is_empty() { a href="#operator" { "Operator " span { (for_drake.len()) } } } |
| 1245 | a href="#streams" { "In motion " span { (moving_now.len()) } } |
| 1246 | a href="#models" { "Models " span { (now.models.len()) } } |
| 1247 | @if !moving_quiet.is_empty() { a href="#quiet" { "Quiet " span { (moving_quiet.len()) } } } |
| 1248 | @if !next.is_empty() { a href="#next" { "Queued " span { (next.len()) } } } |
| 1249 | @if !settled_sorted.is_empty() { a href="#settled" { "Settled " span { (settled_sorted.len()) } } } |
| 1250 | a href="#how" { "How it is made" } |
| 1251 | } |
| 1252 | p class="now-stamp" { |
| 1253 | "Ledger last written " span class="mono" { (now.ledger_written_utc) } |
| 1254 | ". Page built " span class="mono" { (now.built_utc) } |
| 1255 | ". It is rebuilt only when a reviewed release is published, not on a timer." |
| 1256 | } |
| 1257 | @if !now.pulse.is_empty() { |
| 1258 | ul class="now-pulse" { |
| 1259 | @for p in &now.pulse { |
| 1260 | li { span class="now-pulse-k" { (p.key) } span class="now-pulse-v mono" { (p.value) } } |
| 1261 | } |
| 1262 | } |
| 1263 | } |
| 1264 | } |
| 1265 | } |
| 1266 | } |
| 1267 | |
| 1268 | (usage_section(now)) |
| 1269 | |
| 1270 | @if !for_drake.is_empty() { |
| 1271 | section class="now-section now-op-section" id="operator" aria-labelledby="now-op-h" { |
| 1272 | div class="container" { |
| 1273 | p class="kicker" { "On the operator's desk" } |
| 1274 | h2 id="now-op-h" class="now-h2" { "Decisions Drake is making" } |
| 1275 | p class="now-sub" { "Work that cannot move until a human answers. Each line names the answer it needs." } |
| 1276 | div class="now-grid" { |
| 1277 | @for it in &for_drake { (card(it)) } |
| 1278 | } |
| 1279 | } |
| 1280 | } |
| 1281 | } |
| 1282 | |
| 1283 | section class="now-section" id="streams" aria-labelledby="now-streams-h" { |
| 1284 | div class="container" { |
| 1285 | p class="kicker" { "In motion" } |
| 1286 | h2 id="now-streams-h" class="now-h2" { "What the agents are doing" } |
| 1287 | p class="now-sub" { "Lines written in the last day, grouped by stream. The bar under each name is the stream's pulse: one segment per line, bright when written in the last half hour, fading as it cools." } |
| 1288 | @if moving_now.is_empty() { |
| 1289 | p class="now-empty" { "No line in motion was written in the last day." } |
| 1290 | } |
| 1291 | @for s in STREAMS { |
| 1292 | @let in_stream: Vec<&Item> = moving_now.iter().copied().filter(|i| i.stream == s).collect(); |
| 1293 | @if !in_stream.is_empty() { |
| 1294 | div class="now-stream" id=(format!("stream-{}", slug(s))) { |
| 1295 | header class="now-stream-head" { |
| 1296 | h3 class="now-stream-name" { (s) } |
| 1297 | span class="now-stream-n" { (in_stream.len()) " " @if in_stream.len() == 1 { "line" } @else { "lines" } } |
| 1298 | } |
| 1299 | (river(&in_stream)) |
| 1300 | div class="now-grid" { |
| 1301 | @for it in &in_stream { (card(it)) } |
| 1302 | } |
| 1303 | } |
| 1304 | } |
| 1305 | } |
| 1306 | } |
| 1307 | } |
| 1308 | |
| 1309 | (models_section(now)) |
| 1310 | |
| 1311 | @if !moving_quiet.is_empty() { |
| 1312 | section class="now-section" id="quiet" aria-labelledby="now-quiet-h" { |
| 1313 | div class="container" { |
| 1314 | p class="kicker" { "Quiet" } |
| 1315 | h2 id="now-quiet-h" class="now-h2" { "Open, not written in the last day" } |
| 1316 | p class="now-sub" { "Still open, with an owner and notes, but nobody has written to them for over a day. Folded by stream; open a stream to read every line and its latest note." } |
| 1317 | div class="now-folds" { |
| 1318 | @for s in STREAMS { |
| 1319 | @let in_stream: Vec<&Item> = moving_quiet.iter().copied().filter(|i| i.stream == s).collect(); |
| 1320 | @if !in_stream.is_empty() { |
| 1321 | (fold(&format!("quiet-{}", slug(s)), s, &in_stream)) |
| 1322 | } |
| 1323 | } |
| 1324 | } |
| 1325 | } |
| 1326 | } |
| 1327 | } |
| 1328 | |
| 1329 | @if !next.is_empty() { |
| 1330 | section class="now-section" id="next" aria-labelledby="now-next-h" { |
| 1331 | div class="container" { |
| 1332 | p class="kicker" { "Next" } |
| 1333 | h2 id="now-next-h" class="now-h2" { "What is queued" } |
| 1334 | p class="now-sub" { "Promised, with a finish line, not yet picked up or not yet reported on." } |
| 1335 | @if !next_now.is_empty() { |
| 1336 | ol class="now-queue" { |
| 1337 | @for it in &next_now { (row(it)) } |
| 1338 | } |
| 1339 | } |
| 1340 | @if !next_quiet.is_empty() { |
| 1341 | div class="now-folds" { |
| 1342 | (fold("queued-older", "Queued, not written in the last day", &next_quiet)) |
| 1343 | } |
| 1344 | } |
| 1345 | } |
| 1346 | } |
| 1347 | } |
| 1348 | |
| 1349 | @if !settled_sorted.is_empty() { |
| 1350 | section class="now-section" id="settled" aria-labelledby="now-settled-h" { |
| 1351 | div class="container" { |
| 1352 | p class="kicker" { "Settled" } |
| 1353 | h2 id="now-settled-h" class="now-h2" { "Decisions made, with their evidence" } |
| 1354 | p class="now-sub" { "A line closes on evidence (a commit, a receipt, a file) or is dropped for a stated reason. The last day is shown open, newest first; earlier days are folded by date (UTC)." } |
| 1355 | @if settled_now.is_empty() { |
| 1356 | p class="now-empty" { "Nothing settled in the last day." } |
| 1357 | } @else { |
| 1358 | ol class="now-timeline" { |
| 1359 | @for it in &settled_now { (settled_entry(it)) } |
| 1360 | } |
| 1361 | } |
| 1362 | div class="now-folds" { |
| 1363 | @for (day, list) in &settled_days { |
| 1364 | details class="now-fold" id=(format!("settled-{day}")) { |
| 1365 | summary class="now-fold-sum" { |
| 1366 | span class="now-fold-name" { "Settled " (day) } |
| 1367 | span class="now-fold-n" { (list.len()) " " @if list.len() == 1 { "line" } @else { "lines" } } |
| 1368 | } |
| 1369 | ol class="now-timeline now-fold-rows" { |
| 1370 | @for it in list { (settled_entry(it)) } |
| 1371 | } |
| 1372 | } |
| 1373 | } |
| 1374 | } |
| 1375 | } |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | section class="now-section now-how" id="how" aria-labelledby="now-how-h" { |
| 1380 | div class="container" { |
| 1381 | p class="kicker" { "How this page is made" } |
| 1382 | h2 id="now-how-h" class="now-h2" { "One file, no hands" } |
| 1383 | p class="now-sub" { |
| 1384 | "The coordinator and every agent append to one tab separated file on the Spark. A publisher pushed that file to the " |
| 1385 | code { "aienos.com data/now" } |
| 1386 | " branch" |
| 1387 | " whenever it changed; that push has been paused since 7 November 2026, so this page shows the last copy pushed, dated in the stamp at the top of this page. The site builder reads it at build time and writes this page and " |
| 1388 | a class="prose-link" href="/now.json" { "/now.json" } |
| 1389 | ". A line that is not in the file is not here. Every card, queue row and settled entry links to its own line of that file, and the commits and evidence folders named in a note link to the forge; issue and pull request numbers stay plain text. Owners shown as \"agent\" are autonomous coding agents; the operator is one person. Keeper, the merge desk that lands finished changes, was called Renda until 24 October 2026: this page shows the new name, and the ledger on the forge keeps each line as it was written. Keeper is the dachshund at the top of this page; a small one marks every line Keeper owns." |
| 1390 | } |
| 1391 | } |
| 1392 | } |
| 1393 | } |
| 1394 | } |
| 1395 | |
| 1396 | #[cfg(test)] |
| 1397 | mod tests { |
| 1398 | use super::*; |
| 1399 | |
| 1400 | /// A page with no ledger and no model check; tests override what they need. |
| 1401 | fn blank() -> Now { |
| 1402 | let (plan, models) = models_from(ROSTER, &None, &[]); |
| 1403 | Now { built_utc: String::new(), ledger_written_utc: String::new(), items: vec![], pulse: vec![], models_checked_utc: "never".into(), plan, models, claude: None } |
| 1404 | } |
| 1405 | |
| 1406 | const SAMPLE: &str = "id\topened_utc\towner\tstatus\titem\tdone_when\tevidence\tupdated_utc\n\ |
| 1407 | L001\t2026-10-19T16:43Z\tsa-0-abc123def\topen\tAgent: w4-gemv\thandoff written\tstarted | chip PASS 15.63 tok/s\t2026-10-19T18:00Z\n\ |
| 1408 | L002\t2026-10-19T16:43Z\tdrake\topen\tDecide: register the speed gate\tDrake answer recorded\t\t2026-10-19T16:43Z\n\ |
| 1409 | L003\t2026-10-19T16:43Z\tdesk\tdone\tCreate label alpha-tester\tlabel exists\tgh label list shows it \u{2014} done, aien-dev/aien-sovereign-core-mv#8\t2026-10-19T17:00Z\n\ |
| 1410 | L004\t2026-10-19T16:43Z\tunassigned\topen\tResearch: omega#583 simulator\tPR merged\t\t2026-10-19T16:43Z\n"; |
| 1411 | |
| 1412 | #[test] |
| 1413 | fn parses_and_classifies() { |
| 1414 | let items = parse_ledger(SAMPLE, parse_utc("2026-10-19T18:10Z").unwrap()); |
| 1415 | assert_eq!(items.len(), 4); |
| 1416 | assert_eq!(items[0].line, 2, "the header is line 1"); |
| 1417 | assert_eq!(items[3].line, 5); |
| 1418 | assert_eq!(items[0].stream, "Engine speed"); |
| 1419 | assert_eq!(items[0].owner_kind, "agent"); |
| 1420 | assert_eq!(items[0].age_s, 600); |
| 1421 | assert_eq!(items[0].notes.len(), 2); |
| 1422 | assert_eq!(items[1].owner_kind, "operator"); |
| 1423 | assert_eq!(items[3].stream, "Research"); |
| 1424 | assert!(!items[2].notes[0].contains('\u{2014}'), "dash must be cleaned"); |
| 1425 | } |
| 1426 | |
| 1427 | #[test] |
| 1428 | fn time_round_trips() { |
| 1429 | for s in ["2026-10-19T16:43Z", "2000-02-29T00:00Z", "2026-01-01T23:59Z"] { |
| 1430 | assert_eq!(fmt_utc(parse_utc(s).unwrap()), s); |
| 1431 | } |
| 1432 | assert_eq!(age_words(0), "just now"); |
| 1433 | assert_eq!(age_words(59 * 60), "59 min ago"); |
| 1434 | assert_eq!(age_words(3 * 3600), "3 hours ago"); |
| 1435 | assert_eq!(warmth(10 * 60), "hot"); |
| 1436 | assert_eq!(warmth(90 * 60), "warm"); |
| 1437 | } |
| 1438 | |
| 1439 | #[test] |
| 1440 | fn page_holds_invariants() { |
| 1441 | let at = parse_utc("2026-10-19T18:10Z").unwrap(); |
| 1442 | let now = Now { |
| 1443 | built_utc: fmt_utc(at), |
| 1444 | ledger_written_utc: "2026-10-19T18:00Z".into(), |
| 1445 | items: parse_ledger(SAMPLE, at), |
| 1446 | pulse: vec![Pulse { key: "memory free".into(), value: "50 GiB".into() }], |
| 1447 | ..blank() |
| 1448 | }; |
| 1449 | let page = render_now_page(&now).into_string(); |
| 1450 | for must in ["id=\"operator\"", "id=\"streams\"", "id=\"next\"", "id=\"settled\"", "Engine speed", "15.63 tok/s", "now-verdict-done", "L004"] { |
| 1451 | assert!(page.contains(must), "missing {must}"); |
| 1452 | } |
| 1453 | assert!(!page.contains('\u{2014}') && !page.contains('\u{2013}')); |
| 1454 | // The Renda workers were retired; their dials must not come back. |
| 1455 | assert!(!page.contains("renda") && !page.contains("<script"), "no Renda dials and no script on /now/"); |
| 1456 | // Every card, queue row and timeline entry links to its own ledger line. |
| 1457 | assert_eq!(crate::components::boxlink::check_boxes(&page), Ok(4 + 3 + 1), "four ledger boxes, three model cards and the Claude plan card"); |
| 1458 | for line in 2..=5 { |
| 1459 | assert!(page.contains(&format!("href=\"{}#L{line}\"", LEDGER_URL.replace("https://github.com/aien-dev/", "https://interplane.io/drakestapleton/"))), "line {line} link missing"); |
| 1460 | } |
| 1461 | assert!(page.contains("Ledger line 2 on the forge")); |
| 1462 | // The issue named in L003's note has no forge page: it stays plain text. |
| 1463 | assert!(!page.contains("issues/8\""), "an issue reference is never linked"); |
| 1464 | let json = to_json(&now); |
| 1465 | assert!(json.contains("\"L001\"") && json.contains("\"stream\": \"Engine speed\"")); |
| 1466 | } |
| 1467 | |
| 1468 | #[test] |
| 1469 | fn old_lines_fold_but_stay_in_the_page() { |
| 1470 | // Three days after SAMPLE was written every line is old. |
| 1471 | let at = parse_utc("2026-10-22T18:10Z").unwrap(); |
| 1472 | let now = Now { built_utc: fmt_utc(at), ledger_written_utc: "2026-10-19T18:00Z".into(), items: parse_ledger(SAMPLE, at), pulse: vec![], ..blank() }; |
| 1473 | let page = render_now_page(&now).into_string(); |
| 1474 | assert!(page.contains("No line in motion was written in the last day.")); |
| 1475 | assert!(page.contains("Nothing settled in the last day.")); |
| 1476 | let quiet = page.find("<details class=\"now-fold\" id=\"quiet-engine-speed\">").expect("quiet fold missing"); |
| 1477 | let queued = page.find("<details class=\"now-fold\" id=\"queued-older\">").expect("queued fold missing"); |
| 1478 | let settled = page.find("<details class=\"now-fold\" id=\"settled-2026-10-19\">").expect("settled day fold missing"); |
| 1479 | // Each old line sits inside its fold, keeps its anchor, note and ledger link. |
| 1480 | assert!(page[quiet..].find("id=\"L001\"").unwrap() < page[quiet..].find("</details>").unwrap()); |
| 1481 | assert!(page[queued..].find("id=\"L004\"").unwrap() < page[queued..].find("</details>").unwrap()); |
| 1482 | assert!(page[settled..].find("id=\"L003\"").unwrap() < page[settled..].find("</details>").unwrap()); |
| 1483 | assert!(page.contains("15.63 tok/s") && page.contains("done when PR merged")); |
| 1484 | assert_eq!(crate::components::boxlink::check_boxes(&page), Ok(4 + 3 + 1), "four ledger boxes, three model cards and the Claude plan card"); |
| 1485 | // Operator lines never fold. |
| 1486 | let op = page.find("id=\"operator\"").unwrap(); |
| 1487 | assert!(page[op..].find("id=\"L002\"").unwrap() < page[op..].find("id=\"streams\"").unwrap()); |
| 1488 | assert!(page.contains("open lines quiet for over a day")); |
| 1489 | assert!(!page.contains('\u{2014}') && !page.contains('\u{2013}')); |
| 1490 | } |
| 1491 | |
| 1492 | /// A roster that exercises every state rule, apart from the live one. |
| 1493 | const STATES_ROSTER: &str = r#"{"plan": {"label": "p", "url": ""}, "models": [ |
| 1494 | {"key": "a", "name": "A", "served_match": "35b", "absent": "not-answering", "track": "t", "role": "r", "plan_ledger": null, "figures": []}, |
| 1495 | {"key": "b", "name": "B", "served_match": "27b", "absent": "planned", "track": "t", "role": "r", "plan_ledger": null, "figures": []}, |
| 1496 | {"key": "c", "name": "C", "served_match": null, "absent": "not-trained", "track": "t", "role": "r", "plan_ledger": null, "figures": []}, |
| 1497 | {"key": "d", "name": "D", "served_match": "8b", "absent": "retired", "track": "t", "role": "r", "plan_ledger": null, "figures": []} |
| 1498 | ]}"#; |
| 1499 | |
| 1500 | #[test] |
| 1501 | fn models_follow_the_check() { |
| 1502 | let by = |m: &[Model], k: &str| m.iter().find(|x| x.key == k).unwrap().state.clone(); |
| 1503 | // No check published: a servable model reads unknown, never answering or down. |
| 1504 | let (_, m) = models_from(STATES_ROSTER, &None, &[]); |
| 1505 | assert_eq!(by(&m, "a"), "unknown"); |
| 1506 | assert_eq!(by(&m, "b"), "planned"); |
| 1507 | assert_eq!(by(&m, "c"), "not-trained"); |
| 1508 | assert_eq!(by(&m, "d"), "retired", "a retired model stays retired without a check"); |
| 1509 | // The check names the 35B: answering. A planned model stays planned until it answers. |
| 1510 | let (checked, ids) = parse_models_check("checked\t2026-10-24T20:00:01Z\nmodel\tqwen3.6-35b-a3b-fp8\nmodel\tTandemLLM\nbogus line\n"); |
| 1511 | assert_eq!(checked.as_deref(), Some("2026-10-24T20:00:01Z")); |
| 1512 | let (_, m) = models_from(STATES_ROSTER, &checked, &ids); |
| 1513 | assert_eq!(by(&m, "a"), "answering"); |
| 1514 | assert_eq!(by(&m, "b"), "planned"); |
| 1515 | assert_eq!(by(&m, "d"), "retired"); |
| 1516 | let (_, m) = models_from(STATES_ROSTER, &checked, &["Qwen3.8-27B".to_string(), "x-8b".to_string()]); |
| 1517 | assert_eq!(by(&m, "a"), "not-answering"); |
| 1518 | assert_eq!(by(&m, "b"), "answering"); |
| 1519 | assert_eq!(by(&m, "d"), "answering", "a retired model that answers the check is reported, not hidden"); |
| 1520 | // The real roster: both Qwen models were retired on 2026-11-06, and the |
| 1521 | // Omega LLM is planned for serving. A stray 35B answer is still shown. |
| 1522 | let (_, m) = models_from(ROSTER, &None, &[]); |
| 1523 | assert_eq!(by(&m, "model-35b"), "retired"); |
| 1524 | assert_eq!(by(&m, "model-27b"), "retired"); |
| 1525 | assert_eq!(by(&m, "model-own"), "planned"); |
| 1526 | let (_, m) = models_from(ROSTER, &checked, &ids); |
| 1527 | assert_eq!(by(&m, "model-35b"), "answering"); |
| 1528 | assert_eq!(state_words("retired"), "Retired"); |
| 1529 | // On the page: every card has its GitHub link, ids outside the roster never show. |
| 1530 | let now = Now { models_checked_utc: checked.unwrap(), models: models_from(ROSTER, &Some("x".into()), &ids).1, ..blank() }; |
| 1531 | let page = render_now_page(&now).into_string(); |
| 1532 | assert!(page.contains("id=\"models\"") && page.contains("Models doing the work") && page.contains("qwen3.6-35b-a3b-fp8")); |
| 1533 | assert!(!page.contains("TandemLLM"), "only roster models are shown"); |
| 1534 | assert!(page.contains("Q36_CEILING.md"), "35B figures link their receipt"); |
| 1535 | assert_eq!(crate::components::boxlink::check_boxes(&page), Ok(3 + 1)); |
| 1536 | assert!(!page.contains('\u{2014}') && !page.contains('\u{2013}')); |
| 1537 | } |
| 1538 | |
| 1539 | /// Problems where the roster still presents a retired model as answering today. |
| 1540 | fn retired_model_problems(roster_json: &str) -> Vec<String> { |
| 1541 | let roster: Roster = serde_json::from_str(roster_json).expect("roster parses"); |
| 1542 | let mut out = Vec::new(); |
| 1543 | for m in &roster.models { |
| 1544 | let role = m.role.to_ascii_lowercase(); |
| 1545 | if role.contains("qwen") && m.absent != "retired" { |
| 1546 | out.push(format!("{}: a Qwen model that is not marked retired", m.key)); |
| 1547 | } |
| 1548 | if m.absent == "retired" && !m.role.starts_with("Retired on 2026-11-06") { |
| 1549 | out.push(format!("{}: a retired card must open with its retirement date", m.key)); |
| 1550 | } |
| 1551 | if m.absent == "retired" && (role.contains("today") || role.contains("answers aien") || role.contains("will reach")) { |
| 1552 | out.push(format!("{}: a retired card says it serves now", m.key)); |
| 1553 | } |
| 1554 | } |
| 1555 | out |
| 1556 | } |
| 1557 | |
| 1558 | #[test] |
| 1559 | fn no_retired_model_reads_as_served_today() { |
| 1560 | // Qwen3.6-35B-A3B and Qwen3.8-27B were retired on 2026-11-06 and nothing |
| 1561 | // serves them. Their cards keep the dated figures, never a present role. |
| 1562 | assert_eq!(retired_model_problems(ROSTER), Vec::<String>::new()); |
| 1563 | let page = render_now_page(&blank()).into_string(); |
| 1564 | assert!(page.contains(">Retired</span>"), "retired cards say Retired"); |
| 1565 | assert!(!page.contains("answers Aien and the agents today")); |
| 1566 | assert!(page.contains("Q36_CEILING.md"), "the dated 35B figures keep their receipt"); |
| 1567 | // Negative controls: each old wording is refused. |
| 1568 | let live = ROSTER.replacen( |
| 1569 | "Retired on 2026-11-06, and nothing serves it now. Until then it was the borrowed brain that answered Aien and the agents:", |
| 1570 | "The borrowed brain that answers Aien and the agents today:", |
| 1571 | 1, |
| 1572 | ); |
| 1573 | let unmarked = ROSTER.replacen("\"absent\": \"retired\",\n \"track\": \"Track A", "\"absent\": \"not-answering\",\n \"track\": \"Track A", 1); |
| 1574 | let guest = ROSTER.replacen( |
| 1575 | "Retired on 2026-11-06 before it was offered. It was planned as the second model for guest access beside the 35B, and nothing serves it.", |
| 1576 | "The second model for guest access: visitors with a key will reach both the 35B and the 27B on the Spark.", |
| 1577 | 1, |
| 1578 | ); |
| 1579 | for (name, bad) in [("live", &live), ("unmarked", &unmarked), ("guest", &guest)] { |
| 1580 | assert_ne!(bad.as_str(), ROSTER, "{name}: mutation applied"); |
| 1581 | assert!(!retired_model_problems(bad).is_empty(), "{name} must be refused"); |
| 1582 | } |
| 1583 | } |
| 1584 | |
| 1585 | #[test] |
| 1586 | fn keeper_replaces_renda_in_prose_only() { |
| 1587 | for (from, to) in [ |
| 1588 | ("Renda reviewing on the motor", "Keeper reviewing on the motor"), |
| 1589 | ("renda1 pass done; RENDA paused", "keeper1 pass done; KEEPER paused"), |
| 1590 | ("publication remains Renda-owned.", "publication remains Keeper-owned."), |
| 1591 | ("(Renda, desk)", "(Keeper, desk)"), |
| 1592 | ("throughsoleRenda, installedRenda11:13, RendaL708", "throughsoleKeeper, installedKeeper11:13, KeeperL708"), |
| 1593 | ("handed to Renda. Then renda.json stays", "handed to Keeper. Then renda.json stays"), |
| 1594 | // Paths, file names and identifiers keep the old name so they still resolve. |
| 1595 | ("~/.local/state/aien-local-ci/renda-queue/acks", "~/.local/state/aien-local-ci/renda-queue/acks"), |
| 1596 | ("evidence/renda-pr-fastpath-L593 and renda_metrics.py", "evidence/renda-pr-fastpath-L593 and renda_metrics.py"), |
| 1597 | ("agent now-renda-dashboard, Rendan, rendas", "agent now-renda-dashboard, Rendan, rendas"), |
| 1598 | ] { |
| 1599 | assert_eq!(keeper_name(from), to); |
| 1600 | } |
| 1601 | let tsv = "id\topened_utc\towner\tstatus\titem\tdone_when\tevidence\tupdated_utc\nL009\t2026-10-19T16:43Z\trenda2\topen\tRenda merges the queue\tRenda idle\tsee evidence/renda-x/ | Renda done\t2026-10-19T17:00Z\n"; |
| 1602 | let at = parse_utc("2026-10-19T18:10Z").unwrap(); |
| 1603 | let now = Now { items: parse_ledger(tsv, at), ..blank() }; |
| 1604 | let page = render_now_page(&now).into_string(); |
| 1605 | let owned = parse_ledger(&tsv.replace("\trenda2\t", "\tkeeper\t"), at); |
| 1606 | assert_eq!(owner_label(&owned[0]), "Keeper"); |
| 1607 | assert!(page.contains("Keeper merges the queue") && page.contains("Keeper done") && page.contains(">Keeper 2<"), "prose and owner renamed"); |
| 1608 | assert!(!page.contains("Renda merges"), "old name left in prose"); |
| 1609 | // The machine record keeps the ledger as written. |
| 1610 | assert!(to_json(&now).contains("Renda merges the queue")); |
| 1611 | } |
| 1612 | |
| 1613 | #[test] |
| 1614 | fn empty_ledger_is_honest() { |
| 1615 | let now = Now { built_utc: "2026-10-19T18:10Z".into(), ledger_written_utc: "never".into(), items: vec![], pulse: vec![], ..blank() }; |
| 1616 | let page = render_now_page(&now).into_string(); |
| 1617 | assert!(page.contains("No ledger has been published yet")); |
| 1618 | } |
| 1619 | |
| 1620 | #[test] |
| 1621 | fn claude_plan_shows_what_is_left_and_how_to_give() { |
| 1622 | let tsv = "checked\t2026-10-24T22:40:00Z\nplan\tMax 20x\n\ |
| 1623 | limit\tsession\t39\t2026-10-25T02:09:59Z\t\n\ |
| 1624 | limit\tweekly_all\t23.4\t2026-10-31T15:59:59Z\t\n\ |
| 1625 | limit\tweekly_scoped\t34\t2026-10-31T15:59:59Z\tFable<script>\n\ |
| 1626 | limit\tsomething_new\t5\t2026-10-31T15:59:59Z\t\n"; |
| 1627 | let u = parse_usage(tsv).expect("a reading"); |
| 1628 | assert_eq!(u.checked_utc, "2026-10-24T22:40Z"); |
| 1629 | assert_eq!(u.plan, "Max 20x"); |
| 1630 | let labels: Vec<&str> = u.limits.iter().map(|l| l.label.as_str()).collect(); |
| 1631 | assert_eq!(labels, ["This five-hour session", "This week, all models", "This week, Fablescript only"], "unknown kinds are left out"); |
| 1632 | assert_eq!(u.limits[1].used_pct, 23); |
| 1633 | assert!(parse_usage("plan\tMax\nlimit\tsession\t1\tx\t\n").is_none(), "no time, no reading"); |
| 1634 | |
| 1635 | let now = Now { built_utc: "2026-10-24T22:45Z".into(), claude: Some(u.clone()), ..blank() }; |
| 1636 | let page = render_now_page(&now).into_string(); |
| 1637 | assert!(page.contains("61% left") && page.contains("77% left") && page.contains("66% left")); |
| 1638 | // The limits are one menu: a radio and a chip per window, one panel open. |
| 1639 | assert_eq!(page.matches("class=\"now-usage-radio\"").count(), 3, "one radio per limit"); |
| 1640 | assert_eq!(page.matches("class=\"now-usage-tab\"").count(), 3, "one chip per limit"); |
| 1641 | assert_eq!(page.matches("now-usage-panel-").count(), 3, "one panel per limit"); |
| 1642 | assert!(page.contains("id=\"now-usage-0\"") && page.contains("for=\"now-usage-2\"")); |
| 1643 | assert!(page.contains("checked") && !page.contains("checked id=\"now-usage-1\""), "the first limit opens"); |
| 1644 | assert!(page.contains("61% left") && page.contains("77% left"), "each chip carries its own figure"); |
| 1645 | assert!(page.contains(&format!("<code>{HUMANITY}</code>")), "the way in is Open Humanity"); |
| 1646 | assert!(!page.contains("X Money") && !page.contains("Send Money"), "no money ask is rendered"); |
| 1647 | assert!(!page.to_ascii_lowercase().contains("aienscore"), "retired X handle must not be rendered"); |
| 1648 | assert!(!page.contains("has not read a newer one"), "a fresh reading is not called old"); |
| 1649 | assert_eq!(crate::components::boxlink::check_boxes(&page), Ok(3 + 1)); |
| 1650 | |
| 1651 | let old = Now { built_utc: "2026-10-25T03:00Z".into(), claude: Some(u), ..blank() }; |
| 1652 | assert!(render_now_page(&old).into_string().contains("has not read a newer one")); |
| 1653 | let none = render_now_page(&blank()).into_string(); |
| 1654 | assert!(none.contains("has not published a reading of the plan yet") && none.contains(HUMANITY)); |
| 1655 | } |
| 1656 | |
| 1657 | #[test] |
| 1658 | fn keeper_wears_the_dachshund() { |
| 1659 | let tsv = "id\topened_utc\towner\tstatus\titem\tdone_when\tevidence\tupdated_utc\nL031\t2026-10-19T16:43Z\tkeeper\topen\tLand the queue\tqueue empty\tstarted\t2026-10-19T17:00Z\nL032\t2026-10-19T16:43Z\tsa-0-abc123def\topen\tOther work\tdone\tstarted\t2026-10-19T17:00Z\n"; |
| 1660 | let now = Now { items: parse_ledger(tsv, parse_utc("2026-10-19T18:10Z").unwrap()), ..blank() }; |
| 1661 | let page = render_now_page(&now).into_string(); |
| 1662 | assert_eq!(page.matches("class=\"now-owner-dog\"").count(), 1, "only Keeper's tag carries the dog"); |
| 1663 | assert_eq!(page.matches("src=\"/assets/keeper.svg\"").count(), 2, "the big dog in the hero and the one tag"); |
| 1664 | assert!(page.contains("a big cartoon dachshund") && !page.contains("two cartoon dachshunds"), "one big dog, no old card"); |
| 1665 | assert!(page.contains("href=\"#claude\""), "the jump bar reaches the Claude plan"); |
| 1666 | assert!(std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../public/assets/keeper.svg").exists()); |
| 1667 | } |
| 1668 | |
| 1669 | fn hrefs(segs: &[Seg]) -> Vec<(String, String)> { |
| 1670 | segs.iter().filter_map(|s| s.href.as_ref().map(|h| (s.text.clone(), h.clone()))).collect() |
| 1671 | } |
| 1672 | |
| 1673 | fn joined(segs: &[Seg]) -> String { |
| 1674 | segs.iter().map(|s| s.text.as_str()).collect() |
| 1675 | } |
| 1676 | |
| 1677 | #[test] |
| 1678 | fn linkify_issues_and_pull_requests_stay_plain_text() { |
| 1679 | let segs = linkify("Research: omega#583 simulator; aien-dev/aienos.com#44 merged, arch#276.", Some("omega-mv")); |
| 1680 | assert!(hrefs(&segs).is_empty(), "issues have no forge page: {:?}", hrefs(&segs)); |
| 1681 | assert_eq!(joined(&segs), "Research: omega#583 simulator; aien-dev/aienos.com#44 merged, arch#276."); |
| 1682 | let segs = linkify("see https://github.com/aien-dev/omega-mv/pull/9 now", None); |
| 1683 | assert!(hrefs(&segs).is_empty(), "a GitHub URL in a note is never linked"); |
| 1684 | } |
| 1685 | |
| 1686 | #[test] |
| 1687 | fn linkify_commit_uses_the_repo_named_earlier_in_the_note() { |
| 1688 | let segs = linkify("sc alpha/ceiling-and-model@56d42869 commit 39e79fad docs (omega rig/speech@3aebf9ee),", None); |
| 1689 | assert_eq!( |
| 1690 | hrefs(&segs), |
| 1691 | vec![ |
| 1692 | ("alpha/ceiling-and-model@56d42869".into(), "https://interplane.io/drakestapleton/aien-sovereign-core-mv/commit/56d42869".into()), |
| 1693 | ("rig/speech@3aebf9ee".into(), "https://interplane.io/drakestapleton/omega-mv/commit/3aebf9ee".into()), |
| 1694 | ] |
| 1695 | ); |
| 1696 | assert_eq!(segs.last().unwrap().text, "),", "trailing punctuation stays outside the link"); |
| 1697 | } |
| 1698 | |
| 1699 | #[test] |
| 1700 | fn linkify_commit_falls_back_to_the_stream_repo_or_stays_text() { |
| 1701 | let segs = linkify("feat/goodbye-panel-off@2954f5e pushed", Some("aienux")); |
| 1702 | assert_eq!(hrefs(&segs), vec![("feat/goodbye-panel-off@2954f5e".into(), "https://interplane.io/drakestapleton/aienux/commit/2954f5e".into())]); |
| 1703 | let segs = linkify("feat/goodbye-panel-off@2954f5e pushed", None); |
| 1704 | assert!(hrefs(&segs).is_empty(), "no repository to resolve against: stays text"); |
| 1705 | assert_eq!(joined(&segs), "feat/goodbye-panel-off@2954f5e pushed"); |
| 1706 | } |
| 1707 | |
| 1708 | #[test] |
| 1709 | fn linkify_repo_named_in_one_clause_does_not_carry_past_a_semicolon() { |
| 1710 | // Ledger L402: works/cudaplusplus is a drakestapleton.com branch, not a .github one. |
| 1711 | let note = "(read-only): .github profile/cudaplusplus@ef6abb8; drakestapleton.com lists works, so works/cudaplusplus@62a663d (/cudaplusplus work page)"; |
| 1712 | let segs = linkify(note, Some("aienos.com")); |
| 1713 | let h = hrefs(&segs); |
| 1714 | assert_eq!(h[0].1, "https://interplane.io/drakestapleton/.github/commit/ef6abb8"); |
| 1715 | assert!(h.iter().all(|(t, _)| t != "works/cudaplusplus@62a663d"), "no repo in its own clause: stays text: {h:?}"); |
| 1716 | assert_eq!(joined(&segs), note); |
| 1717 | let segs = linkify("omega-mv a/x@56d42869; b/y@2954f5e", Some("aienux")); |
| 1718 | assert_eq!(hrefs(&segs).len(), 1, "b/y follows a clause that named omega-mv"); |
| 1719 | // A clause that names no repository keeps the stream's home. |
| 1720 | let segs = linkify("alpha/x@56d42869; feat/y@2954f5e", Some("aienux")); |
| 1721 | assert_eq!(hrefs(&segs)[1].1, "https://interplane.io/drakestapleton/aienux/commit/2954f5e"); |
| 1722 | } |
| 1723 | |
| 1724 | #[test] |
| 1725 | fn linkify_evidence_folder_on_the_branch_in_the_same_note() { |
| 1726 | let segs = linkify( |
| 1727 | "receipts alpha/fresh-account-evidence@997d22bd evidence/alpha-fresh-account-20261019/; see evidence/other/x.json.", |
| 1728 | Some("aien-sovereign-core-mv"), |
| 1729 | ); |
| 1730 | let h = hrefs(&segs); |
| 1731 | assert_eq!(h[1], ("evidence/alpha-fresh-account-20261019/".into(), "https://interplane.io/drakestapleton/aien-sovereign-core-mv/tree/alpha/fresh-account-evidence/evidence/alpha-fresh-account-20261019".into())); |
| 1732 | assert_eq!(h[2], ("evidence/other/x.json".into(), "https://interplane.io/drakestapleton/aien-sovereign-core-mv/blob/alpha/fresh-account-evidence/evidence/other/x.json".into())); |
| 1733 | assert_eq!(joined(&segs), "receipts alpha/fresh-account-evidence@997d22bd evidence/alpha-fresh-account-20261019/; see evidence/other/x.json."); |
| 1734 | // Without a branch in the note the path stays text. |
| 1735 | let segs = linkify("evidence/symbolic-rewrite/VERDICT.md written", Some("omega-mv")); |
| 1736 | assert!(hrefs(&segs).is_empty()); |
| 1737 | // The first branch wins over one in parentheses: the Rig's own branch, not Omega's. |
| 1738 | let segs = linkify("aien-rig speech/v0@af71f46 (omega rig/speech@3aebf9ee); evidence/speech/2026-10-19-gb10/README.md", Some("aien-rig")); |
| 1739 | assert_eq!(hrefs(&segs)[2].1, "https://interplane.io/drakestapleton/aien-rig/blob/speech/v0/evidence/speech/2026-10-19-gb10/README.md"); |
| 1740 | } |
| 1741 | |
| 1742 | #[test] |
| 1743 | fn linkify_bare_urls() { |
| 1744 | let segs = linkify("live: https://www.aienos.com/now/ and /now.json", None); |
| 1745 | assert_eq!(hrefs(&segs), vec![("https://www.aienos.com/now/".into(), "https://www.aienos.com/now/".into())]); |
| 1746 | } |
| 1747 | |
| 1748 | #[test] |
| 1749 | fn linkify_leaves_lookalikes_alone() { |
| 1750 | // An upstream model name with a revision, a mail address, a number |
| 1751 | // with a hash that names no repository, a bare sha, a dotted version. |
| 1752 | for plain in [ |
| 1753 | "NVFP4 nvidia/Qwen3.8-Flash-Next-NVFP4@fc694b54 132.7GB", |
| 1754 | "mail drake@example.com", |
| 1755 | "task#3 and #276 alone", |
| 1756 | "worktree omega-research-584 @a8ffd2b9", |
| 1757 | "v0.1.0 tagged, pid 3643684", |
| 1758 | "z-lab/Qwen3.8-27B-DFlash2 rev 50307d4c", |
| 1759 | ] { |
| 1760 | let segs = linkify(plain, Some("omega-mv")); |
| 1761 | assert!(hrefs(&segs).is_empty(), "{plain:?} must stay plain: {:?}", hrefs(&segs)); |
| 1762 | assert_eq!(joined(&segs), plain); |
| 1763 | } |
| 1764 | } |
| 1765 | |
| 1766 | #[test] |
| 1767 | fn notes_render_links_with_escaping_intact() { |
| 1768 | let m = note_markup("omega#583 <b>x</b> & done", "Research").into_string(); |
| 1769 | assert!(!m.contains("<a "), "an issue has no forge page: {m}"); |
| 1770 | assert!(m.starts_with("omega#583"), "{m}"); |
| 1771 | let m = note_markup("alpha/x@56d42869 <b>x</b> & done", "Alpha release").into_string(); |
| 1772 | assert!(m.contains("<a class=\"now-ref\" href=\"https://interplane.io/drakestapleton/aien-sovereign-core-mv/commit/56d42869\"")); |
| 1773 | assert!(m.contains("</a> <code>rad:z44GqrPVAPjZkhoD2MWVjqy18ighN 56d42869</code>"), "{m}"); |
| 1774 | assert!(m.contains("<b>x</b> & done"), "{m}"); |
| 1775 | } |
| 1776 | } |