# ScaenaPublic The pure core of Scaena, Domi's video studio: canon parser and claim checker, hook templates and (later) the timeline model, ffmpeg argument compiler, ASS subtitle builder, audits, similarity scoring, hook evolution and Thompson sampling. Pure Rust, no I/O. Used by Praeco Domi by git tag. ## What's in v0 Crate `scaena-core` (`crates/scaena-core`), tag `core-v0.1.0`. Pure Rust, `#![forbid(unsafe_code)]`, no I/O; dependencies are serde, thiserror and unicode-segmentation only. Builds for Windows, Android (`aarch64-linux-android`) and the web (`wasm32-unknown-unknown`). If you redistribute it, alone or inside your own app, show the Exhibit B credit (see [Licence](#licence)). ```toml scaena-core = { git = "https://gitea.marek-novak.cz/mnovak/ScaenaPublic.git", tag = "core-v0.1.0" } ``` ### `scaena_core::canon`: canon files ```rust pub fn parse(file_stem: &str, text: &str) -> Result; // CanonError { line, code } pub struct CanonFile { pub id: String, pub front: FrontMatter, pub facts: Vec } pub struct FrontMatter { pub name, one_liner, audience, price, clicks: String, pub status: Status, pub aula: Option, pub site: Option } pub enum Status { Released, Beta, Planned } pub struct Fact { pub id: u32, pub text: String, pub assumption: bool, pub line: usize } impl CanonFile { fn fact(&self, id: u32) -> Option<&Fact>; fn urls(&self) -> Vec; fn adhoc(id: &str, name: &str, facts: Vec<(u32, String)>) -> CanonFile; } pub struct Canon; // new, insert (duplicate id = error), get, apps, fact, allowed_urls pub fn is_valid_app_id(id: &str) -> bool; pub fn is_assumption_value(value: &str) -> bool; ``` The format of `apps/.md` (UTF-8, at most 64 KiB): ```markdown --- id: tabula name: Tabula one_liner: Notes that stay on your own computer. audience: People who want notes without an account. price: (assumption) one-time purchase clicks: New note in 1 click. status: released aula: https://aula.marek-novak.cz/tabula/ --- ## What it does - [F1] Tabula keeps notes on your own computer. - [F2] It syncs between your devices without a cloud account. (assumption) ``` - Front matter: flat `key: value` lines between two `---` lines. Required: `id name one_liner audience price clicks status`; optional: `aula`, `site` (each a single `https://` URL). Unknown, duplicate, missing or empty keys are errors. `id` equals the file stem: 1–32 of `[a-z0-9-]`, no leading or trailing `-`. `status` is `released`, `beta` or `planned`. - Facts: `- [F] `, `n` 1–9999 without leading zeros, unique, under any heading. Any bullet line starting `[F` that does not match exactly is an error. A fact ending in `(assumption)` is unconfirmed; the marker is removed from `text` and `assumption` is set (a marker elsewhere in the text also sets it). - Hostile input: a leading BOM and CRLF line endings are accepted; a lone CR, control characters other than tab, bidi controls, zero-width space, word joiner, BOM inside the text and tag characters are errors. - Allowed URLs: `aula`, `site` and every `https://` URL in a fact's text. ### `scaena_core::claims`: the claim checker ```rust pub fn check(text: &str, canon: &Canon) -> Report; pub struct Report { pub refs: Vec /* sorted, unique */, pub problems: Vec } // ok() = no problems pub struct Ref { pub app: String, pub fact: u32 } pub enum Problem { Unsourced { sentence }, MissingFact { r }, UnknownApp { r }, Unconfirmed { r }, MalformedRef { text }, UrlNotInCanon { url }, HiddenCharacter { codepoint } } // non_exhaustive impl Problem { pub fn reason(&self) -> String } // plain English pub fn strip_refs(text: &str) -> String; pub fn sentences(text: &str) -> Vec; pub fn states_fact(sentence: &str, canon: &Canon) -> bool; ``` - References look like `[tabula#F3]`; several may be adjacent (`[tabula#F3][tabula#F7]`), at the end of the sentence they support (before or after its full stop). A sentence ends at `.`, `!`, `?` or `…` followed by whitespace, and at every line break; `1.2` and URLs do not end one. The checker cannot tell whether a fact really supports its sentence: a valid reference anywhere in a sentence sources the whole sentence. - Fail closed: every sentence needs a reference to a confirmed fact unless it is one of a short list of plain phrases ("Here's what's new.", "Try it today.", "Try Tabula today.", "Learn more.", "Thanks for reading."…). So numbers, prices, platforms and feature claims always need one. - Rejected: unsourced sentences, references to unknown apps or missing facts, references to `(assumption)` facts ("unconfirmed fact"), malformed references (`[F3]`, `[Tabula#F3]`, `tabula#F3`…), URLs not in `Canon::allowed_urls` (`scheme://`, `www.` and bare `host.tld/path` forms), hidden or direction-changing characters. ### `scaena_core::hooks`: hook templates ```rust pub fn parse(md: &str) -> Result, HookError>; // brand/hooks.md: "- [H]