Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
MK25-MK27: a client's brief as rules, `make: cut({...})`, held by raea make status
shinyobjectzf02348c3979a
diff --git a/apps/make/src/cut.rs b/apps/make/src/cut.rsnew file mode 100644index 00000000..11abf515--- /dev/null+++ b/apps/make/src/cut.rs@@ -0,0 +1,254 @@+//! A cut job's gates (docs/make.feature MK25-MK27): the brief as rules (`make: cut({...})`, core/brief cut.rs), held+//! from what's on disk. The quotes: every rule's `from` is in the brief's text. The count: as many cuts as the brief+//! asks for, or an answer saying why not. The open items: each answered. Then each delivered file: its shape and+//! length; its words, heard after its last change (FILE.words.json, `raea words`), with every `say` phrase heard or+//! shown, no `never` phrase in its words or its text, and the CTA in its last seconds; and its frames check, run after+//! its last change (FILE.frames-check.json, `raea frames check`), with no face cut and no text too small.++use std::path::{Path, PathBuf};+use std::time::SystemTime;++use raea_core_brief::cut::{self, Cut, norm};+use serde_json::{Value, json};++use crate::mp4;++fn gate(name: &str, of: Option<&str>, clear: bool, says: String) -> Value {+ let mut g = json!({"gate": name, "clear": clear, "says": says});+ if let Some(of) = of {+ g["of"] = json!(of);+ }+ g+}++fn mtime(p: &Path) -> Option<SystemTime> {+ std::fs::metadata(p).ok()?.modified().ok()+}++/// FILE.words.json, FILE.frames-check.json, FILE.render.json beside FILE.mp4.+fn beside(f: &Path, ext: &str) -> PathBuf {+ f.with_extension(ext)+}++/// A report beside the file, read when it's newer than the file (a report from before the last change says nothing+/// about it now): Ok(json), or Err(why not).+fn fresh(f: &Path, ext: &str, run: &str) -> Result<Value, String> {+ let r = beside(f, ext);+ let Some(at) = mtime(&r) else { return Err(format!("never run: {run}")) };+ if mtime(f).is_some_and(|m| m > at) {+ return Err(format!("the file changed after it: {run} again"));+ }+ std::fs::read_to_string(&r).ok().and_then(|s| serde_json::from_str(&s).ok()).ok_or_else(|| format!("{} isn't JSON: {run} again", r.display()))+}++/// What a file says: its heard words with their times in seconds (`raea words`: start/end, or start_ms/end_ms).+fn heard(words: &Value) -> Vec<(String, f64, f64)> {+ let list = words.as_array().or_else(|| words["words"].as_array()).cloned().unwrap_or_default();+ list.iter()+ .filter_map(|w| {+ let t = norm(w["text"].as_str().or_else(|| w["word"].as_str())?);+ let s = w["start"].as_f64().or_else(|| w["start_ms"].as_f64().map(|m| m / 1000.0))?;+ let e = w["end"].as_f64().or_else(|| w["end_ms"].as_f64().map(|m| m / 1000.0)).unwrap_or(s);+ (!t.is_empty()).then_some((t, s, e))+ })+ .collect()+}++/// What a file shows: each text of its render manifest (FILE.render.json) and the second it's first on screen.+fn shown(manifest: &Value) -> Vec<(String, f64)> {+ let fps = manifest["fps"].as_f64().filter(|f| *f > 0.0).unwrap_or(30.0);+ let mut out: Vec<(String, f64)> = Vec::new();+ for fr in manifest["frames"].as_array().into_iter().flatten() {+ let at = fr["frame"].as_f64().unwrap_or(0.0) / fps;+ for t in fr["text"].as_array().into_iter().flatten() {+ let s = norm(t["text"].as_str().unwrap_or(""));+ if !s.is_empty() && t["opacity"].as_f64().unwrap_or(1.0) > 0.05 && !out.iter().any(|(o, _)| *o == s) {+ out.push((s, at));+ }+ }+ }+ out+}++/// `phrase` in `text` as whole words.+fn has(text: &str, phrase: &str) -> bool {+ !phrase.is_empty() && format!(" {text} ").contains(&format!(" {phrase} "))+}++/// `got`'s words with each compound the brief writes as one word joined back ("wish list" heard, "Wishlist" written),+/// each with the index of its first word in `got`.+fn joined<'a>(got: &[&'a str], want: &[&str]) -> Vec<(String, usize)> {+ let mut out = Vec::new();+ let mut i = 0;+ while i < got.len() {+ let k = (2..=3).rev().find(|&k| i + k <= got.len() && want.contains(&got[i..i + k].concat().as_str())).unwrap_or(1);+ out.push((got[i..i + k].concat(), i));+ i += k;+ }+ out+}++/// Where `phrase` (normalised) is first said in `got`: the index of its first word. Its words in order, compounds+/// joined, each at most `gap` words after the one before (1: word for word; people say "it's free, it's fun, and it's+/// easy" for "free, fun, and easy", which a gap of 2 takes and a reordered "fun, free, and easy" doesn't).+fn said_at(got: &[&str], phrase: &str, gap: usize) -> Option<usize> {+ let want: Vec<&str> = phrase.split(' ').filter(|w| !w.is_empty()).collect();+ let got = joined(got, &want);+ (0..got.len()).find(|&s| {+ if want.is_empty() || got[s].0 != want[0] {+ return false;+ }+ let mut at = s;+ want[1..].iter().all(|w| match (at + 1..(at + 1 + gap).min(got.len())).find(|&j| got[j].0 == *w) {+ Some(j) => {+ at = j;+ true+ }+ None => false,+ })+ })+ .map(|s| got[s].1)+}++/// How far apart a `say` phrase's words may be heard.+const SAY_GAP: usize = 2;++/// The share of `want`'s words that `got` has in order (longest common subsequence): a CTA heard with a word misheard+/// still lands.+fn in_order(want: &[&str], got: &[&str]) -> f64 {+ if want.is_empty() {+ return 1.0;+ }+ let mut row = vec![0usize; got.len() + 1];+ for w in want {+ let mut prev = 0;+ for (j, g) in got.iter().enumerate() {+ let keep = row[j + 1];+ row[j + 1] = if w == g { prev + 1 } else { row[j + 1].max(row[j]) };+ prev = keep;+ }+ }+ row[got.len()] as f64 / want.len() as f64+}++/// How much of the CTA a run of words must have, in order.+const CTA_SHARE: f64 = 0.85;++/// One delivered file's gates: shape, words (say, never, cta) and frames.+fn file_gates(c: &Cut, plan: &cut::CutPlan, format: &str, f: &Path, rel: &str, said: &mut Vec<(usize, String)>) -> Vec<Value> {+ let mut out = Vec::new();+ let shape = mp4::shape(f);+ match (shape, cut::ratio(format), cut::seconds(c, plan)) {+ (None, ..) => out.push(gate("shape", Some(rel), false, "not an MP4 or MOV with a video track".into())),+ (Some(s), Some((rw, rh)), len) => {+ let mut wrong = Vec::new();+ let (want, got) = (rw as f64 / rh as f64, s.w as f64 / s.h as f64);+ if (got / want - 1.0).abs() > 0.02 {+ wrong.push(format!("{}x{} isn't {format}", s.w, s.h));+ }+ if let Some([a, b]) = len+ && (s.seconds + 0.05 < a || s.seconds > b + 0.05)+ {+ wrong.push(format!("{:.1} s isn't {a}-{b} s", s.seconds));+ }+ out.push(gate("shape", Some(rel), wrong.is_empty(), if wrong.is_empty() { format!("{}x{}, {:.1} s", s.w, s.h, s.seconds) } else { wrong.join("; ") }));+ }+ _ => {}+ }+ // what it says and shows+ match fresh(f, "words.json", &format!("raea words {rel}")) {+ Err(why) => out.push(gate("words", Some(rel), false, why)),+ Ok(w) => {+ let words = heard(&w);+ let spoken: Vec<&str> = words.iter().map(|(t, ..)| t.as_str()).collect();+ let screen = std::fs::read_to_string(beside(f, "render.json")).ok().and_then(|s| serde_json::from_str::<Value>(&s).ok()).map(|m| shown(&m)).unwrap_or_default();+ let on_screen = |s: &str, p: &str, gap| said_at(&s.split(' ').collect::<Vec<_>>(), p, gap).is_some();+ let on = |p: &str| said_at(&spoken, p, SAY_GAP).is_some() || screen.iter().any(|(s, _)| on_screen(s, p, SAY_GAP));+ let missing: Vec<&str> = c.say.iter().filter(|p| p.every != Some(false) && !on(&norm(&p.text))).map(|p| p.text.as_str()).collect();+ said.extend(c.say.iter().enumerate().filter(|(_, p)| on(&norm(&p.text))).map(|(i, _)| (i, rel.to_string())));+ out.push(gate("say", Some(rel), missing.is_empty(), if missing.is_empty() { format!("says all {} of its phrases", c.say.iter().filter(|p| p.every != Some(false)).count()) } else { format!("never says or shows: {}", missing.iter().map(|m| format!("\"{m}\"")).collect::<Vec<_>>().join(", ")) }));+ let banned: Vec<String> = c+ .never+ .iter()+ .filter_map(|p| {+ let n = norm(&p.text);+ if let Some(i) = said_at(&spoken, &n, 1) {+ return Some(format!("\"{}\" heard at {:.1} s (brief: {})", p.text, words[i].1, p.from));+ }+ screen.iter().find(|(s, _)| on_screen(s, &n, 1)).map(|(_, at)| format!("\"{}\" on screen at {at:.1} s (brief: {})", p.text, p.from))+ })+ .collect();+ out.push(gate("never", Some(rel), banned.is_empty(), if banned.is_empty() { "says and shows none of the banned phrases".into() } else { banned.join("; ") }));+ if let Some(cta) = &c.cta {+ let within = cta.within.unwrap_or(cut::CTA_WITHIN);+ let end = shape.map(|s| s.seconds).or_else(|| words.last().map(|w| w.2)).unwrap_or(0.0);+ let want_s = norm(&cta.text);+ let want: Vec<&str> = want_s.split(' ').collect();+ let share = |got: &[&str]| {+ let j = joined(got, &want);+ in_order(&want, &j.iter().map(|(w, _)| w.as_str()).collect::<Vec<_>>())+ };+ let last: Vec<&str> = words.iter().filter(|w| w.2 >= end - within).map(|w| w.0.as_str()).collect();+ let heard_share = share(&last);+ let on_screen = screen.iter().any(|(s, at)| *at >= end - within && share(&s.split(' ').collect::<Vec<_>>()) >= CTA_SHARE);+ let ok = heard_share >= CTA_SHARE || on_screen;+ out.push(gate("cta", Some(rel), ok, if ok { format!("ends on the CTA ({})", if on_screen { "on screen" } else { "heard" }) } else { format!("the CTA isn't in its last {within:.0} s ({:.0}% of its words heard there): \"{}\"", heard_share * 100.0, cta.text) }));+ }+ }+ }+ // faces whole, text big enough: the frames check of the file as it is now+ if c.frames != Some(false) {+ match fresh(f, "frames-check.json", &format!("raea frames check {rel}")) {+ Err(why) => out.push(gate("frames", Some(rel), false, why)),+ Ok(r) => {+ let errors: Vec<&str> = r["findings"].as_array().into_iter().flatten().filter(|x| x["level"] == "error").filter_map(|x| x["says"].as_str()).collect();+ out.push(gate("frames", Some(rel), errors.is_empty(), match errors.as_slice() {+ [] => "no face cut, no text too small".into(),+ [one] => one.to_string(),+ many => format!("{} errors, first: {}", many.len(), many[0]),+ }));+ }+ }+ }+ out+}++/// The cut job's gates over its brief folder `dir`.+pub fn gates(c: &Cut, dir: &Path) -> Vec<Value> {+ let mut out = Vec::new();+ // the quotes: each rule is backed by the brief's own words+ match std::fs::read_to_string(dir.join(&c.brief)) {+ Err(_) => out.push(gate("quotes", None, false, format!("no brief text at {}: pdftotext -layout BRIEF.pdf {}", c.brief, c.brief))),+ Ok(t) => {+ let text = norm(&t);+ let unfound: Vec<String> = cut::quotes(c).into_iter().filter(|(_, from)| !has(&text, &norm(from))).map(|(what, from)| format!("{what} (\"{}\")", from.chars().take(60).collect::<String>())).collect();+ out.push(gate("quotes", None, unfound.is_empty(), if unfound.is_empty() { format!("all {} rules quote the brief", cut::quotes(c).len()) } else { format!("not in the brief's text, word for word: {}", unfound.join("; ")) }));+ }+ }+ let answered = |about: &str| c.open.iter().any(|o| o.about.as_deref() == Some(about) && o.answer.as_deref().is_some_and(|a| !a.trim().is_empty()));+ if let Some(n) = &c.count {+ let have = c.cuts.len() as u32;+ let ok = have >= n.value || answered("count");+ out.push(gate("count", None, ok, if have >= n.value { format!("{have} cuts planned; the brief asks for {}", n.value) } else if ok { format!("{have} of the brief's {} cuts, as answered", n.value) } else { format!("{have} cuts planned; the brief asks for {} (\"{}\"): plan them, or add an `open` item about \"count\" and get it answered", n.value, n.from) }));+ }+ for o in &c.open {+ let ok = o.answer.as_deref().is_some_and(|a| !a.trim().is_empty());+ out.push(gate("open", o.about.as_deref(), ok, if ok { format!("{} -> {}{}", o.question, o.answer.as_deref().unwrap_or(""), o.by.as_deref().map(|b| format!(" ({b})")).unwrap_or_default()) } else { format!("unanswered: {} (brief: \"{}\"): ask at the review, then write the answer and who gave it", o.question, o.from) }));+ }+ let mut said: Vec<(usize, String)> = Vec::new();+ for p in &c.cuts {+ for fmt in cut::formats(c, p) {+ let rel = cut::file(p, fmt);+ let f = dir.join(&rel);+ if f.is_file() {+ out.extend(file_gates(c, p, fmt, &f, &rel, &mut said));+ }+ }+ }+ // a phrase one cut is enough for+ for (i, p) in c.say.iter().enumerate().filter(|(_, p)| p.every == Some(false)) {+ let by: Vec<&String> = said.iter().filter(|(j, _)| *j == i).map(|(_, f)| f).collect();+ out.push(gate("say-once", None, !by.is_empty(), if let Some(f) = by.first() { format!("\"{}\" in {f}", p.text) } else { format!("no cut says or shows \"{}\" (brief: \"{}\")", p.text, p.from) }));+ }+ out+}diff --git a/apps/make/src/lib.rs b/apps/make/src/lib.rsindex 4f7d2761..66d75d7e 100644--- a/apps/make/src/lib.rs+++ b/apps/make/src/lib.rs@@ -6,9 +6,11 @@//! raea make plan|refs|sheet refs|gen|pick-sheet|pick|prep|kit|framing|lenschart ... (the steps, USAGE)pub mod asked;+pub mod cut;pub mod floor;pub mod kit;pub mod kitout;+pub mod mp4;pub mod plan;pub mod sheet;pub mod shots;@@ -212,3 +214,5 @@ pub fn cli(args: &[String]) -> Result<String, String> {mod tests;#[cfg(test)]mod tests_steps;+#[cfg(test)]+mod tests_cut;diff --git a/apps/make/src/mp4.rs b/apps/make/src/mp4.rsnew file mode 100644index 00000000..adbcf05a--- /dev/null+++ b/apps/make/src/mp4.rs@@ -0,0 +1,97 @@+//! A delivered cut's length and frame size, read from its own MP4 or MOV boxes (moov/mvhd and the video track's+//! tkhd), so `raea make status` holds a cut's shape with no decoder: a file re-encoded after its render (a loudness+//! pass) is read as it is now.++use std::path::Path;++/// Seconds, and the video track's width and height as displayed (a rotated phone take reads upright).+#[derive(Debug, Clone, Copy, PartialEq)]+pub struct Shape {+ pub seconds: f64,+ pub w: u32,+ pub h: u32,+}++fn be32(b: &[u8], at: usize) -> Option<u32> {+ Some(u32::from_be_bytes(b.get(at..at + 4)?.try_into().ok()?))+}+fn be64(b: &[u8], at: usize) -> Option<u64> {+ Some(u64::from_be_bytes(b.get(at..at + 8)?.try_into().ok()?))+}++/// The boxes in `b`: (kind, body).+fn boxes(b: &[u8]) -> Vec<(&[u8], &[u8])> {+ let mut out = Vec::new();+ let mut at = 0;+ while at + 8 <= b.len() {+ let Some(size) = be32(b, at) else { break };+ let kind = &b[at + 4..at + 8];+ let (head, len) = match size {+ 1 => (16, be64(b, at + 8).unwrap_or(0) as usize),+ 0 => (8, b.len() - at),+ n => (8, n as usize),+ };+ if len < head || at + len > b.len() {+ break;+ }+ out.push((kind, &b[at + head..at + len]));+ at += len;+ }+ out+}++/// The moov box's bytes: read from the file's top level, skipping mdat (the media) without reading it.+fn moov(path: &Path) -> Option<Vec<u8>> {+ use std::io::{Read, Seek, SeekFrom};+ let mut f = std::fs::File::open(path).ok()?;+ let end = f.metadata().ok()?.len();+ let mut at = 0u64;+ while at + 8 <= end {+ let mut head = [0u8; 16];+ f.seek(SeekFrom::Start(at)).ok()?;+ f.read_exact(&mut head[..8]).ok()?;+ let size = u32::from_be_bytes(head[..4].try_into().ok()?) as u64;+ let (skip, len) = match size {+ 1 => {+ f.read_exact(&mut head[8..16]).ok()?;+ (16, u64::from_be_bytes(head[8..16].try_into().ok()?))+ }+ 0 => (8, end - at),+ n => (8, n),+ };+ if len < skip {+ return None;+ }+ if &head[4..8] == b"moov" {+ let mut body = vec![0u8; (len - skip) as usize];+ f.seek(SeekFrom::Start(at + skip)).ok()?;+ f.read_exact(&mut body).ok()?;+ return Some(body);+ }+ at += len;+ }+ None+}++/// The file's length and its video's displayed size; None when it isn't an MP4 or MOV with a video track.+pub fn shape(path: &Path) -> Option<Shape> {+ let moov = moov(path)?;+ let top = boxes(&moov);+ let mvhd = top.iter().find(|(k, _)| *k == b"mvhd")?.1;+ // version 1 has 64-bit times: timescale at 20, duration at 24; version 0: 12 and 16+ let seconds = if mvhd.first() == Some(&1) { be64(mvhd, 24)? as f64 / be32(mvhd, 20)?.max(1) as f64 } else { be32(mvhd, 16)? as f64 / be32(mvhd, 12)?.max(1) as f64 };+ for (_, trak) in top.iter().filter(|(k, _)| *k == b"trak") {+ let inner = boxes(trak);+ let Some((_, tkhd)) = inner.iter().find(|(k, _)| *k == b"tkhd") else { continue };+ // width and height are 16.16 fixed point at the end of tkhd; the matrix before them says a turn+ let n = tkhd.len();+ let (w, h) = (be32(tkhd, n - 8)? >> 16, be32(tkhd, n - 4)? >> 16);+ if w == 0 || h == 0 {+ continue;+ }+ let a = be32(tkhd, n - 44)? as i32;+ let turned = a == 0;+ return Some(if turned { Shape { seconds, w: h, h: w } } else { Shape { seconds, w, h } });+ }+ None+}diff --git a/apps/make/src/status.rs b/apps/make/src/status.rsindex 30f6e550..58010a19 100644--- a/apps/make/src/status.rs+++ b/apps/make/src/status.rs@@ -64,6 +64,7 @@ pub(crate) fn kind_name(k: make::Kind) -> &'static str {make::Kind::Scene => "scene",make::Kind::Kit => "kit",make::Kind::Shot => "shot",+ make::Kind::Cut => "cut",}}@@ -151,7 +152,7 @@ fn critic(job: &Job, newest: Option<SystemTime>, notes: &str) -> Vec<Value> {let what = match job.make.kind {make::Kind::Kit => "raea render shared/components/KIT/lineup.tsx --review review/r1",make::Kind::Shot => "raea make framing --out review/r1",- make::Kind::Scene => "raea render EDIT.tsx --review review/r1",+ make::Kind::Scene | make::Kind::Cut => "raea render EDIT.tsx --review review/r1",};return vec![gate("critic", None, false, format!("no round yet: {what}, then raea judge review/r1 --kind {kind} --by claude --brief brief.ts"))];};@@ -195,8 +196,13 @@ pub fn status(job: &Job) -> Value {missing.push(format!("NOTES.md with a \"{SKILL_HEADING}\" section (one line per thing that cost time; what the guide got wrong for this job)"));}let mut gates = checks(job);- gates.extend(lods(job, ¬es));- gates.extend(critic(job, newest, ¬es));+ if job.make.kind == make::Kind::Cut {+ // the brief's rules over every delivered file (MK25-MK27); its critic is the person's review for now+ gates.extend(job.make.cut.as_ref().map(|c| crate::cut::gates(c, job.dir)).unwrap_or_default());+ } else {+ gates.extend(lods(job, ¬es));+ gates.extend(critic(job, newest, ¬es));+ }let (asks, said) = crate::asked::gates(&sheets(job), job.ledger, ¬es);gates.extend(asks);let cap = job.make.rounds.unwrap_or(make::ROUNDS) as usize;diff --git a/apps/make/src/tests_cut.rs b/apps/make/src/tests_cut.rsnew file mode 100644index 00000000..011e085e--- /dev/null+++ b/apps/make/src/tests_cut.rs@@ -0,0 +1,206 @@+//! A cut job held to its brief (MK25-MK27): the contract's doctor, the quotes, the count and open items, and each+//! delivered file's shape, words and frames, on fixtures written here (an MP4 is only its moov box).++use std::path::{Path, PathBuf};+use std::time::{Duration, SystemTime};++use raea_core_brief::{cut, make::Make, read};+use serde_json::{Value, json};++use crate::asked::Ledger;+use crate::mp4;+use crate::status::{Job, status};++fn dir(name: &str) -> PathBuf {+ let d = std::env::temp_dir().join(format!("raea-make-cut-{name}-{}", std::process::id()));+ let _ = std::fs::remove_dir_all(&d);+ std::fs::create_dir_all(&d).unwrap();+ d+}++fn put(d: &Path, rel: &str, bytes: &[u8]) -> PathBuf {+ let p = d.join(rel);+ std::fs::create_dir_all(p.parent().unwrap()).unwrap();+ std::fs::write(&p, bytes).unwrap();+ p+}++/// `p` as changed `secs` from now (a report written after its video is newer than it)+fn touch(p: &Path, secs: i64) {+ let t = if secs >= 0 { SystemTime::now() + Duration::from_secs(secs as u64) } else { SystemTime::now() - Duration::from_secs((-secs) as u64) };+ std::fs::File::options().write(true).open(p).unwrap().set_modified(t).unwrap();+}++fn bx(kind: &[u8; 4], body: &[u8]) -> Vec<u8> {+ let mut v = ((body.len() + 8) as u32).to_be_bytes().to_vec();+ v.extend_from_slice(kind);+ v.extend_from_slice(body);+ v+}++/// An MP4 that is only its boxes: `seconds` long, a w x h video track, turned a quarter when `turned`.+fn mp4_bytes(seconds: f64, w: u32, h: u32, turned: bool) -> Vec<u8> {+ let mut mvhd = vec![0u8; 100];+ mvhd[12..16].copy_from_slice(&1000u32.to_be_bytes());+ mvhd[16..20].copy_from_slice(&((seconds * 1000.0) as u32).to_be_bytes());+ let mut tkhd = vec![0u8; 84];+ let (a, b): (u32, u32) = if turned { (0, 0x0001_0000) } else { (0x0001_0000, 0) };+ tkhd[40..44].copy_from_slice(&a.to_be_bytes());+ tkhd[44..48].copy_from_slice(&b.to_be_bytes());+ tkhd[76..80].copy_from_slice(&(w << 16).to_be_bytes());+ tkhd[80..84].copy_from_slice(&(h << 16).to_be_bytes());+ let moov = bx(b"moov", &[bx(b"mvhd", &mvhd), bx(b"trak", &bx(b"tkhd", &tkhd))].concat());+ [bx(b"ftyp", b"isom\0\0\0\0"), bx(b"mdat", &[0u8; 64]), moov].concat()+}++const BRIEF: &str = "Deliverables: 10 total videos (4 solos / 1 mashup per angle).\nUse the phrase \"free, fun, and easy.\"\nDon't let it read as White Elephant.\nEnd on the CTA: \"Make your Wishlist and organize your Gift Exchange on Elfster. It's free.\"\nCTV specs from the client [TO CONFIRM]\n";++fn contract(extra: &str) -> Make {+ read(+ "make",+ &format!(+ r#"{{"kind": "cut", "cut": {{"brief": "media/brief.txt", "count": {{"value": 2, "from": "10 total videos"}}, "seconds": [20, 30], "formats": ["9:16"],+ "cuts": [{{"id": "a1_s1", "angle": "1", "hook": "Direct Problem", "text": "captions"}}, {{"id": "a1_s2"}}],+ "say": [{{"text": "free, fun, and easy", "from": "Use the phrase \"free, fun, and easy.\""}}],+ "never": [{{"text": "white elephant", "from": "Don't let it read as White Elephant."}}],+ "cta": {{"text": "Make your Wishlist and organize your Gift Exchange on Elfster. It's free.", "from": "End on the CTA"}}{extra}}}}}"#+ ),+ )+ .unwrap()+}++fn run(make: &Make, d: &Path) -> Value {+ status(&Job { make, dir: d, project: None, record: &[], rounds: &[], verdict: None, judged_at: None, ledger: &Ledger::default(), score_gates: false })+}++fn gates<'a>(s: &'a Value, name: &str) -> Vec<&'a Value> {+ s["gates"].as_array().unwrap().iter().filter(|g| g["gate"] == name).collect()+}++/// Words said evenly from 0.5 s, one every 0.6 s, as `raea words` writes them.+fn words(line: &str) -> String {+ let w: Vec<Value> = line.split_whitespace().enumerate().map(|(i, t)| json!({"text": t, "start": 0.5 + i as f64 * 0.6, "end": 0.8 + i as f64 * 0.6})).collect();+ serde_json::to_string(&w).unwrap()+}++/// A delivered file with its words and frames check written after it.+fn deliver(d: &Path, id: &str, said: &str, frame_errors: &[&str]) {+ let f = put(d, &format!("out/cuts/{id}_9x16.mp4"), &mp4_bytes(said.split_whitespace().count() as f64 * 0.6 + 1.0, 1080, 1920, false));+ touch(&f, -60);+ put(d, &format!("out/cuts/{id}_9x16.words.json"), words(said).as_bytes());+ let findings: Vec<Value> = frame_errors.iter().map(|e| json!({"level": "error", "kind": "face-cut", "says": e})).collect();+ put(d, &format!("out/cuts/{id}_9x16.frames-check.json"), json!({"findings": findings}).to_string().as_bytes());+}++const GOOD: &str = "So it draws the names for you it's free fun and easy to set up and everyone makes a wishlist so nobody draws their own name ever again Make your Wishlist and organize your Gift Exchange on Elfster It's free";++#[test]+fn the_contract_is_read_and_doctored() {+ let m = contract("");+ assert_eq!(m.kind, raea_core_brief::make::Kind::Cut);+ assert_eq!(raea_core_brief::make::deliverables(&m), vec!["out/cuts/a1_s1_9x16.mp4", "out/cuts/a1_s2_9x16.mp4"]);+ assert!(raea_core_brief::make::doctor(&m).is_empty(), "{:?}", raea_core_brief::make::doctor(&m));+ let bad: Make = read("make", r#"{"kind": "cut", "cut": {"brief": "b.txt", "cuts": [{"id": "A-1", "formats": ["tall"], "text": "both"}], "say": [{"text": "x", "from": ""}]}}"#).unwrap();+ let d = raea_core_brief::make::doctor(&bad).join("\n");+ for want in ["no `count`", "no `cta`", "ids are [a-z0-9_]", "isn't W:H", "no length", "captions, hook or none", "has no `from`"] {+ assert!(d.contains(want), "{want} in\n{d}");+ }+ let none: Make = read("make", r#"{"kind": "cut"}"#).unwrap();+ assert!(raea_core_brief::make::doctor(&none).iter().any(|x| x.contains("no `cut`")));+ assert_eq!(cut::norm("24/7 Virtual Vet Care. It’s free!"), "24 7 virtual vet care its free");+}++#[test]+fn every_rule_quotes_the_brief() {+ let d = dir("quotes");+ let s = run(&contract(""), &d);+ assert!(gates(&s, "quotes")[0]["says"].as_str().unwrap().contains("no brief text"));+ put(&d, "media/brief.txt", BRIEF.as_bytes());+ assert_eq!(gates(&run(&contract(""), &d), "quotes")[0]["clear"], true);+ // a rule the brief doesn't say, or says in other words, is held+ let invented = contract(r#", "open": [{"question": "Which code?", "from": "the offer is PETS99"}]"#);+ let s = run(&invented, &d);+ let g = gates(&s, "quotes")[0];+ assert_eq!(g["clear"], false);+ assert!(g["says"].as_str().unwrap().contains("Which code?"), "{g}");+}++#[test]+fn the_count_and_open_items_hold_the_job() {+ let d = dir("count");+ put(&d, "media/brief.txt", BRIEF.as_bytes());+ let mut m = contract("");+ m.cut.as_mut().unwrap().count.as_mut().unwrap().value = 10;+ assert_eq!(gates(&run(&m, &d), "count")[0]["clear"], false);+ let mut asked = contract(r#", "open": [{"question": "Only 2 interviews came: cut 2?", "from": "10 total videos", "about": "count"}]"#);+ asked.cut.as_mut().unwrap().count.as_mut().unwrap().value = 10;+ let s = run(&asked, &d);+ assert_eq!(gates(&s, "count")[0]["clear"], false, "an open item without its answer doesn't excuse the count");+ assert!(gates(&s, "open")[0]["says"].as_str().unwrap().starts_with("unanswered"));+ let o = &mut asked.cut.as_mut().unwrap().open[0];+ o.answer = Some("yes, the 2 we have".into());+ o.by = Some("Shane".into());+ let s = run(&asked, &d);+ assert_eq!(gates(&s, "count")[0]["clear"], true);+ assert_eq!(gates(&s, "open")[0]["clear"], true);+}++#[test]+fn a_delivered_cut_is_held_to_its_words_shape_and_frames() {+ let d = dir("files");+ put(&d, "media/brief.txt", BRIEF.as_bytes());+ put(&d, "NOTES.md", b"## What the skill got wrong\n- nothing\n");+ let m = contract("");+ let s = run(&m, &d);+ assert_eq!(s["done"], false);+ assert_eq!(s["missing"].as_array().unwrap().len(), 2, "{s}");+ deliver(&d, "a1_s1", GOOD, &[]);+ deliver(&d, "a1_s2", GOOD, &[]);+ let s = run(&m, &d);+ assert_eq!(s["done"], true, "{}", crate::status::text(&s));+ // a banned phrase heard, the CTA cut, a phrase missing, a face cut+ deliver(&d, "a1_s2", "we did a white elephant swap last year and it was chaos so we tried something new", &["a face is cut by the left edge from 4.0 s to 5.5 s"]);+ let s = run(&m, &d);+ assert_eq!(s["done"], false);+ let of = |name: &str| gates(&s, name).into_iter().find(|g| g["of"] == "out/cuts/a1_s2_9x16.mp4").unwrap().clone();+ assert!(of("never")["says"].as_str().unwrap().contains("\"white elephant\" heard at 2.3 s"), "{}", of("never"));+ assert_eq!(of("say")["clear"], false);+ assert_eq!(of("cta")["clear"], false);+ assert!(of("frames")["says"].as_str().unwrap().contains("left edge"));+ // the wrong shape, and a report from before the file's last change+ let f = put(&d, "out/cuts/a1_s1_9x16.mp4", &mp4_bytes(45.0, 1920, 1080, false));+ touch(&f, 60);+ let s = run(&m, &d);+ let shape = gates(&s, "shape").into_iter().find(|g| g["of"] == "out/cuts/a1_s1_9x16.mp4").unwrap().clone();+ assert!(shape["says"].as_str().unwrap().contains("1920x1080 isn't 9:16") && shape["says"].as_str().unwrap().contains("45.0 s isn't 20-30 s"), "{shape}");+ let words = gates(&s, "words").into_iter().find(|g| g["of"] == "out/cuts/a1_s1_9x16.mp4").unwrap().clone();+ assert!(words["says"].as_str().unwrap().contains("changed after it"), "{words}");+}++#[test]+fn an_mp4_is_measured_from_its_boxes() {+ let d = dir("mp4");+ let f = put(&d, "a.mp4", &mp4_bytes(29.5, 1080, 1920, false));+ assert_eq!(mp4::shape(&f), Some(mp4::Shape { seconds: 29.5, w: 1080, h: 1920 }));+ // a phone take stored sideways and turned by its matrix reads as shown+ let f = put(&d, "b.mov", &mp4_bytes(12.0, 1920, 1080, true));+ assert_eq!(mp4::shape(&f), Some(mp4::Shape { seconds: 12.0, w: 1080, h: 1920 }));+ assert_eq!(mp4::shape(&put(&d, "c.mp4", b"not a video")), None);+}++#[test]+fn heard_the_way_people_say_it() {+ // Gemini's Elfster A1 solo (11-25): the transcript splits "Wishlist" and the speaker fills the phrase out+ let d = dir("said");+ put(&d, "media/brief.txt", BRIEF.as_bytes());+ let m = contract("");+ let line = "so it draws the names for you and everyone gets a gift they want It's free it's fun and it's easy so set it up tonight with your whole family Make your wish list and organize your gift exchange on Elfster It's free";+ deliver(&d, "a1_s1", line, &[]);+ let s = run(&m, &d);+ let of = |s: &Value, name: &str| gates(s, name).into_iter().find(|g| g["of"] == "out/cuts/a1_s1_9x16.mp4").unwrap().clone();+ assert_eq!(of(&s, "say")["clear"], true, "{}", of(&s, "say"));+ assert_eq!(of(&s, "cta")["clear"], true, "{}", of(&s, "cta"));+ // the brief's order is the phrase: "fun, free and easy" isn't it+ deliver(&d, "a1_s1", &line.replace("It's free it's fun", "It's fun it's free"), &[]);+ assert_eq!(of(&run(&m, &d), "say")["clear"], false);+}diff --git a/core/brief/src/cut.rs b/core/brief/src/cut.rsnew file mode 100644index 00000000..f86f1b42--- /dev/null+++ b/core/brief/src/cut.rs@@ -0,0 +1,228 @@+//! A cut job's contract (docs/make.feature MK25): `make: cut({...})` on brief.ts, the client's brief made into rules+//! before anything is planned or cut. A brief read as context gets lost (11-25, Shane, on StreetTalk's street interview+//! ads: "you need to make the process of ingesting the brief more direct, or else it's just context that gets lost. It+//! needs to be written as a brief typescript rule that is then enforced"). Every rule quotes the brief line it came+//! from (`from`), and `raea make status` (apps/make cut.rs) finds each quote in the brief's text, so a rule can't be+//! invented and a brief line can't drift; then it holds every delivered file to the rules, from what's on disk.++use serde::{Deserialize, Serialize};+use ts_rs::TS;++#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]+#[serde(rename_all = "camelCase", deny_unknown_fields)]+#[ts(optional_fields)]+#[ts(rename = "MakeCut")]+pub struct Cut {+ /// the brief as text, relative to brief.ts (`pdftotext -layout brief.pdf media/brief.txt`): every `from` is found in it+ pub brief: String,+ /// how many cuts the brief asks for; fewer planned is held open until an answered `open` item about "count" says why+ pub count: Option<Quoted<u32>>,+ /// a cut's length when its own `seconds` says none: [least, most]+ pub seconds: Option<[f64; 2]>,+ /// the formats every cut is delivered in when its own `formats` says none: "9:16", "16:9", "1:1", "4:5"+ #[serde(default)]+ #[ts(as = "Option<Vec<String>>", optional)]+ pub formats: Vec<String>,+ #[serde(default)]+ #[ts(as = "Option<Vec<CutPlan>>", optional)]+ pub cuts: Vec<CutPlan>,+ /// what is said or shown: in every cut unless `every: false` (then in one or more)+ #[serde(default)]+ #[ts(as = "Option<Vec<Phrase>>", optional)]+ pub say: Vec<Phrase>,+ /// what no cut says or shows: a banned claim, a word, a name+ #[serde(default)]+ #[ts(as = "Option<Vec<Phrase>>", optional)]+ pub never: Vec<Phrase>,+ /// the line every cut ends on, heard or on screen in its last `within` seconds+ pub cta: Option<Cta>,+ /// the brief's open items ([TO CONFIRM]): each holds the job open until it has an answer+ #[serde(default)]+ #[ts(as = "Option<Vec<Open>>", optional)]+ pub open: Vec<Open>,+ /// every face whole and every text big enough, by the frames check of each file (true when left out)+ pub frames: Option<bool>,+}++/// A value with the brief's words for it.+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]+#[serde(deny_unknown_fields)]+#[ts(rename = "MakeQuoted")]+pub struct Quoted<T: TS> {+ pub value: T,+ /// the brief's own words, as they are in its text+ pub from: String,+}++#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]+#[serde(rename_all = "camelCase", deny_unknown_fields)]+#[ts(optional_fields)]+#[ts(rename = "MakeCutPlan")]+pub struct CutPlan {+ /// [a-z0-9_], unique: each format lands as out/cuts/<id>_<W>x<H>.mp4 ("a1_s1_9x16.mp4")+ pub id: String,+ pub angle: Option<String>,+ /// solo or mashup+ pub kind: Option<String>,+ /// one of the brief's hook types ("Direct Problem", "Reaction")+ pub hook: Option<String>,+ /// captions, hook (a text hook) or none+ pub text: Option<String>,+ #[serde(default)]+ #[ts(as = "Option<Vec<String>>", optional)]+ pub formats: Vec<String>,+ pub seconds: Option<[f64; 2]>,+}++#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]+#[serde(rename_all = "camelCase", deny_unknown_fields)]+#[ts(optional_fields)]+#[ts(rename = "MakePhrase")]+pub struct Phrase {+ /// as it's said or shown; compared in lower case, by letters and digits ("24/7" and "24-7" are the same)+ pub text: String,+ pub from: String,+ /// `say` only: false when one cut saying it is enough+ pub every: Option<bool>,+}++#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]+#[serde(rename_all = "camelCase", deny_unknown_fields)]+#[ts(optional_fields)]+#[ts(rename = "MakeCta")]+pub struct Cta {+ pub text: String,+ pub from: String,+ /// how near the end it must land, in seconds (8 when left out)+ pub within: Option<f64>,+}++#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]+#[serde(rename_all = "camelCase", deny_unknown_fields)]+#[ts(optional_fields)]+#[ts(rename = "MakeOpen")]+pub struct Open {+ pub question: String,+ pub from: String,+ /// what it decides: "count", "cta", "offer", a cut's id...+ pub about: Option<String>,+ /// the person's answer, as they gave it, and who gave it: until then the job can't be done+ pub answer: Option<String>,+ pub by: Option<String>,+}++/// How near the end the CTA lands when the contract says nothing.+pub const CTA_WITHIN: f64 = 8.0;++/// A format's frame shape, "9:16" -> (9, 16).+pub fn ratio(f: &str) -> Option<(u32, u32)> {+ let (w, h) = f.split_once(':')?;+ Some((w.trim().parse().ok().filter(|&w| w > 0)?, h.trim().parse().ok().filter(|&h| h > 0)?))+}++/// A cut's formats and its length: its own, else the contract's.+pub fn formats<'a>(c: &'a Cut, p: &'a CutPlan) -> &'a [String] {+ if p.formats.is_empty() { &c.formats } else { &p.formats }+}+pub fn seconds(c: &Cut, p: &CutPlan) -> Option<[f64; 2]> {+ p.seconds.or(c.seconds)+}++/// Where a cut's format lands, relative to the brief: out/cuts/a1_s1_9x16.mp4.+pub fn file(p: &CutPlan, format: &str) -> String {+ format!("out/cuts/{}_{}.mp4", p.id, format.replace(':', "x"))+}++/// Every file the contract asks for.+pub fn deliverables(c: &Cut) -> Vec<String> {+ c.cuts.iter().flat_map(|p| formats(c, p).iter().map(move |f| file(p, f))).collect()+}++/// Every `from` in the contract, with what it backs: the quotes `raea make status` finds in the brief's text.+pub fn quotes(c: &Cut) -> Vec<(String, &str)> {+ let mut q: Vec<(String, &str)> = Vec::new();+ if let Some(n) = &c.count {+ q.push(("count".into(), &n.from));+ }+ q.extend(c.say.iter().map(|p| (format!("say \"{}\"", p.text), p.from.as_str())));+ q.extend(c.never.iter().map(|p| (format!("never \"{}\"", p.text), p.from.as_str())));+ if let Some(cta) = &c.cta {+ q.push(("cta".into(), &cta.from));+ }+ q.extend(c.open.iter().map(|o| (format!("open \"{}\"", o.question), o.from.as_str())));+ q+}++/// What the contract lacks before it can be cut against, each with what to do.+pub fn doctor(c: &Cut) -> Vec<String> {+ let mut out = Vec::new();+ if c.brief.trim().is_empty() {+ out.push("no `brief`: the brief as text beside brief.ts (pdftotext -layout BRIEF.pdf media/brief.txt), which every `from` quotes".into());+ }+ if c.cuts.is_empty() {+ out.push("no cuts: list every cut the brief asks for, with its id, angle, hook and formats".into());+ }+ if c.count.is_none() {+ out.push("no `count`: how many cuts the brief asks for, with its words".into());+ }+ if c.cta.is_none() {+ out.push("no `cta`: the line the brief says every cut ends on (or an `open` item asking for it)".into());+ }+ let mut seen = std::collections::BTreeSet::new();+ for p in &c.cuts {+ if !seen.insert(p.id.as_str()) {+ out.push(format!("cut `{}` is listed twice", p.id));+ }+ if p.id.is_empty() || !p.id.chars().all(|ch| ch.is_ascii_lowercase() || ch.is_ascii_digit() || ch == '_') {+ out.push(format!("cut `{}`: ids are [a-z0-9_], the file it lands as", p.id));+ }+ let fs = formats(c, p);+ if fs.is_empty() {+ out.push(format!("cut `{}` has no formats: give it `formats`, or the contract's", p.id));+ }+ for f in fs.iter().filter(|f| ratio(f).is_none()) {+ out.push(format!("cut `{}`: format `{f}` isn't W:H (\"9:16\", \"16:9\", \"1:1\", \"4:5\")", p.id));+ }+ match seconds(c, p) {+ None => out.push(format!("cut `{}` has no length: `seconds: [least, most]`, its own or the contract's", p.id)),+ Some([a, b]) if !(a > 0.0 && a <= b) => out.push(format!("cut `{}`: seconds [{a}, {b}] isn't [least, most]", p.id)),+ _ => {}+ }+ if let Some(t) = &p.text+ && !matches!(t.as_str(), "captions" | "hook" | "none")+ {+ out.push(format!("cut `{}`: text is captions, hook or none, not `{t}`", p.id));+ }+ }+ for (what, from) in quotes(c) {+ if from.trim().is_empty() {+ out.push(format!("{what} has no `from`: the brief's own words for it"));+ }+ }+ for p in c.say.iter().chain(&c.never).filter(|p| norm(&p.text).is_empty()) {+ out.push(format!("phrase `{}` has no letters or digits to find", p.text));+ }+ out+}++/// Text as it's compared: lower case, letters and digits, one space between words ("24/7" -> "24 7").+pub fn norm(s: &str) -> String {+ let mut out = String::with_capacity(s.len());+ let mut gap = false;+ for ch in s.chars().flat_map(char::to_lowercase) {+ // a curly apostrophe or a plain one joins its word ("it's" is one word, "its" is another)+ if ch == '\'' || ch == '\u{2019}' {+ continue;+ }+ if ch.is_alphanumeric() {+ if gap && !out.is_empty() {+ out.push(' ');+ }+ gap = false;+ out.push(ch);+ } else {+ gap = true;+ }+ }+ out+}diff --git a/core/brief/src/lib.rs b/core/brief/src/lib.rsindex 38849104..d6614068 100644--- a/core/brief/src/lib.rs+++ b/core/brief/src/lib.rs@@ -4,6 +4,7 @@//! types (`declarations`), so what tsc checks is exactly what this crate reads.pub mod brief;+pub mod cut;pub mod make;pub mod parts;pub mod script;@@ -39,6 +40,7 @@ pub fn declarations() -> String {taste::Taste, taste::TasteSection, taste::Rule, taste::RuleCheck, taste::RuleLevel, taste::Check,parts::Parts, parts::Concept, parts::Level, parts::Count, parts::Part,make::Make, make::Kind, make::Source, make::DialValue, make::Dial, make::Route, make::Origin, make::Pick, make::Object, make::Shot,+ cut::Cut, cut::Quoted<u32>, cut::CutPlan, cut::Phrase, cut::Cta, cut::Open,));out.join("\n\n") + "\n"}diff --git a/core/brief/src/make.rs b/core/brief/src/make.rsindex bdc8bbdb..11e431fc 100644--- a/core/brief/src/make.rs+++ b/core/brief/src/make.rs@@ -19,6 +19,8 @@ pub enum Kind {Kit,/// stills or camera moves of a built scene, from wordsShot,+ /// ads cut from footage to a client's brief: its deliverables, phrases, claims and CTA as rules (cut.rs, MK25)+ Cut,}#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]@@ -52,6 +54,8 @@ pub struct Make {pub deliverables: Vec<String>,/// the most critic rounds the job gets; at the cap it is delivered with what's still missing (8 by default)pub rounds: Option<u32>,+ /// a cut job's contract: the brief as rules (cut.rs)+ pub cut: Option<crate::cut::Cut>,}#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]@@ -192,6 +196,7 @@ pub fn dials(kind: Kind) -> &'static [&'static str] {Kind::Scene => &["density", "tidiness", "wear", "wetness", "time_of_day", "weather", "atmosphere", "power", "warmth", "look"],Kind::Kit => &["count", "variety", "detail", "wear", "wetness", "warmth", "look"],Kind::Shot => &["res", "seconds", "lens", "handheld", "look"],+ Kind::Cut => &["look"],}}@@ -218,6 +223,7 @@ pub fn deliverables(m: &Make) -> Vec<String> {}// a shot is a still or a move, so either file answers; apps/make reads `a|b`Kind::Shot => m.shots.iter().map(|s| format!("out/shots/{0}.png|out/shots/{0}.mp4", s.name)).collect(),+ Kind::Cut => m.cut.as_ref().map(crate::cut::deliverables).unwrap_or_default(),}}@@ -233,6 +239,12 @@ pub fn doctor(m: &Make) -> Vec<String> {Kind::Scene | Kind::Kit if m.objects.is_empty() => out.push("no objects: list every object with its real size and route".into()),_ => {}}+ match (&m.cut, m.kind) {+ (Some(c), Kind::Cut) => out.extend(crate::cut::doctor(c)),+ (None, Kind::Cut) => out.push("no `cut`: the brief as rules (count, cuts, say, never, cta, open), each quoting it".into()),+ (Some(_), k) => out.push(format!("`cut` is for a cut job, not a {k:?}: drop it, or make this `cut({{...}})`")),+ _ => {}+ }if m.kind == Kind::Kit && m.style.is_none() {out.push("no `style`: one paragraph (era, palette, materials, wear, one fictional maker) every reference carries".into());}diff --git a/docs/make.feature b/docs/make.featureindex 2d77766f..754b1464 100644--- a/docs/make.feature+++ b/docs/make.feature@@ -244,6 +244,48 @@ Feature: Make: scenes, kits and shots built to a frozen plan and held to a reviewith `lod` and its name; the Stop hook holds the agent there as at any open gateAnd a job that plans a level and whose render found none shows the gate clear+ Rule: cuts from a client's brief (MK25-MK27)+ Shane, 11-25, on StreetTalk's street interview ads, cut by raea cloud agents from three clients' PDF briefs: "you+ need to make the process of ingesting the brief more direct, or else it's just context that gets lost. It needs to+ be written as a brief typescript rule that is then enforced ... I need raea make to be the standard". The agents had+ read the briefs and still shipped what a contract catches: held to one written from Elfster's brief, Gemini's four+ delivered solos (eight files) had "free, fun, and easy" missing from three, the CTA rewritten in one ("Download+ Elfster for free in the App Store") and missing from another, no frames check on any final file, and four of the+ ten cuts the brief asks for in its out/ folder.++ @needs:MK0+ Scenario: MK25. The brief as rules: `make: cut({...})`+ Given a client's brief as text beside brief.ts (pdftotext -layout BRIEF.pdf media/brief.txt)+ When the agent writes `make: cut({ cut: {...} })` before it plans a single cut+ Then core/brief reads `cut` (cut.rs): `brief` (that text), `count` (how many cuts the brief asks for), `seconds`+ and `formats`, each cut (id, angle, solo or mashup, hook, captions or a text hook, its own formats and length),+ `say` (phrases every cut says or shows, or one cut with `every: false`), `never` (phrases no cut says or+ shows), `cta` (the line every cut ends on, within its last 8 s) and `open` (the brief's [TO CONFIRM] items)+ And every rule has `from`: the brief's own words for it+ And each cut lands at a fixed path, out/cuts/<id>_<W>x<H>.mp4 for each of its formats+ And `doctor` names what the contract still lacks: no count, no cta, an id that isn't [a-z0-9_], a format that+ isn't W:H, a cut with no length, a rule with no `from`++ @needs:MK25+ Scenario: MK26. Held to the brief's own words, its count and its open items+ Given a cut contract+ Then `raea make status` finds every `from` in the brief's text, compared by letters and digits: a rule the brief+ doesn't say, or says in other words, holds the job ("quotes")+ And fewer cuts than `count` hold it, unless an `open` item about "count" has the person's answer ("count")+ And every `open` item without an answer holds it, so the agent stops at a review to ask ("open")++ @needs:MK25+ Scenario: MK27. Every delivered file held to the rules, from what's on disk+ Given a cut's file at its path+ Then its shape and length are read from its own MP4 boxes, so a file re-encoded after its render is read as it is+ now ("shape")+ And its words must be heard after its last change (FILE.words.json, `raea words`), and in them or its render's+ text (FILE.render.json): every `say` phrase ("say"), no `never` phrase, with the second it's heard ("never"),+ and the CTA in its last `within` seconds, 85% of its words in order ("cta")+ And its frames check must have run after its last change (FILE.frames-check.json, `raea frames check`) with no+ error: no face cut by the frame or a seam, no text under the size floor ("frames")+ And the cut job has no critic tier yet: the person's review is its critic+Rule: raea cloud (MK19-MK20)@needs:MK2 @donediff --git a/sdk/guides/craft/modes/pitch.md b/sdk/guides/craft/modes/pitch.mdindex ec15946b..a8d2e05c 100644--- a/sdk/guides/craft/modes/pitch.md+++ b/sdk/guides/craft/modes/pitch.md@@ -21,6 +21,25 @@ A viewer who had no plan to watch stops, believes the brief's `believe:` line, a- **Plan it.** Hook · problem · proof · ask as a storyboard, approved before anything renders. Chain its cuts on thethirds so the proof lands where the problem was (`raea guide match-cuts`).+## A client's brief is a contract++When a client hands you a brief (a PDF, a doc, an email of rules), make it rules before you plan a single cut, or it+is only context, and context gets lost. Run `pdftotext -layout BRIEF.pdf media/brief.txt`, then write+`make: cut({ cut: {...} })` on brief.ts from it:++- `count`, `seconds`, `formats` and every cut (id, angle, solo or mashup, hook, captions or a text hook);+- `say`: the phrases the brief asks every cut to say or show (`every: false` when one cut is enough);+- `never`: the claims, words and names it bans;+- `cta`: the exact line every cut ends on;+- `open`: each [TO CONFIRM], gap or contradiction in it, as a question for the review.++Every rule carries `from`, the brief's own words for it, copied exactly. `raea make status` finds each one in+media/brief.txt, so a rule can't be made up and a line can't be paraphrased away. Then it holds every file at+out/cuts/ID_WxH.mp4: its shape and length; its words (`raea words FILE`, run after its last change) for each `say`,+`never` and the CTA; and its frames check (`raea frames check FILE` on raea cloud; `frames: false` where there is+none). The job isn't done, and the Stop hook won't let you end, until every gate is clear and every `open` item has+the person's answer, written in with who gave it.+## The decisionsEach one has a default that comes easily. Question it before you take it.diff --git a/sdk/raea/src/brief.gen.ts b/sdk/raea/src/brief.gen.tsindex 7c6726d4..c2e41eae 100644--- a/sdk/raea/src/brief.gen.ts+++ b/sdk/raea/src/brief.gen.ts@@ -223,9 +223,13 @@ deliverables?: Array<string>,/*** the most critic rounds the job gets; at the cap it is delivered with what's still missing (8 by default)*/-rounds?: number, };+rounds?: number,+/**+ * a cut job's contract: the brief as rules (cut.rs)+ */+cut?: MakeCut, };-export type MakeKind = "scene" | "kit" | "shot";+export type MakeKind = "scene" | "kit" | "shot" | "cut";export type MakeSource = "customer" | "reference";@@ -320,3 +324,91 @@ composition?: string,* its frame rate, for the frames `seconds` spans (30 when left out)*/fps?: number, };++export type MakeCut = {+/**+ * the brief as text, relative to brief.ts (`pdftotext -layout brief.pdf media/brief.txt`): every `from` is found in it+ */+brief: string,+/**+ * how many cuts the brief asks for; fewer planned is held open until an answered `open` item about "count" says why+ */+count?: MakeQuoted<number>,+/**+ * a cut's length when its own `seconds` says none: [least, most]+ */+seconds?: [number, number],+/**+ * the formats every cut is delivered in when its own `formats` says none: "9:16", "16:9", "1:1", "4:5"+ */+formats?: Array<string>, cuts?: Array<MakeCutPlan>,+/**+ * what is said or shown: in every cut unless `every: false` (then in one or more)+ */+say?: Array<MakePhrase>,+/**+ * what no cut says or shows: a banned claim, a word, a name+ */+never?: Array<MakePhrase>,+/**+ * the line every cut ends on, heard or on screen in its last `within` seconds+ */+cta?: MakeCta,+/**+ * the brief's open items ([TO CONFIRM]): each holds the job open until it has an answer+ */+open?: Array<MakeOpen>,+/**+ * every face whole and every text big enough, by the frames check of each file (true when left out)+ */+frames?: boolean, };++export type MakeQuoted<T> = { value: T,+/**+ * the brief's own words, as they are in its text+ */+from: string, };++export type MakeCutPlan = {+/**+ * [a-z0-9_], unique: each format lands as out/cuts/<id>_<W>x<H>.mp4 ("a1_s1_9x16.mp4")+ */+id: string, angle?: string,+/**+ * solo or mashup+ */+kind?: string,+/**+ * one of the brief's hook types ("Direct Problem", "Reaction")+ */+hook?: string,+/**+ * captions, hook (a text hook) or none+ */+text?: string, formats?: Array<string>, seconds?: [number, number], };++export type MakePhrase = {+/**+ * as it's said or shown; compared in lower case, by letters and digits ("24/7" and "24-7" are the same)+ */+text: string, from: string,+/**+ * `say` only: false when one cut saying it is enough+ */+every?: boolean, };++export type MakeCta = { text: string, from: string,+/**+ * how near the end it must land, in seconds (8 when left out)+ */+within?: number, };++export type MakeOpen = { question: string, from: string,+/**+ * what it decides: "count", "cta", "offer", a cut's id...+ */+about?: string,+/**+ * the person's answer, as they gave it, and who gave it: until then the job can't be done+ */+answer?: string, by?: string, };diff --git a/sdk/raea/src/brief.ts b/sdk/raea/src/brief.tsindex 3fdcf45d..01d65b8b 100644--- a/sdk/raea/src/brief.ts+++ b/sdk/raea/src/brief.ts@@ -35,3 +35,5 @@ export const scene = (m: Omit<Make, "kind">): Make => ({ kind: "scene", ...m });export const kit = (m: Omit<Make, "kind">): Make => ({ kind: "kit", ...m });/** Shots of a built scene, each named for the file it lands as and described in a crew's words. */export const shot = (m: Omit<Make, "kind">): Make => ({ kind: "shot", ...m });+/** ads cut from footage to a client's brief: `cut: {...}` is the brief as rules, each quoting it (docs/make.feature MK25) */+export const cut = (m: Omit<Make, "kind">): Make => ({ kind: "cut", ...m });