Skip to content

armgit / raea

Public Imported from GitHub
0

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.

MK25: under raea-app-make's 2000 lines and no new duplicate groups

shinyobjectz03c2e2ee1591
diff --git a/apps/make/src/lib.rs b/apps/make/src/lib.rs
index 4f7d2761..ed96aa3e 100644
--- a/apps/make/src/lib.rs
+++ b/apps/make/src/lib.rs
@@ -88,7 +88,7 @@ pub fn status_of(brief: &Path, make: &Make) -> Value {
let record = project.as_deref().map(raea_core_facts::record::read).unwrap_or_default();
let (rounds, verdict, judged_at) = judged(dir);
let ledger = asked::Ledger::read();
- let job = status::Job { make, dir, project: project.as_deref(), record: &record, rounds: &rounds, verdict: verdict.as_ref(), judged_at, ledger: &ledger, score_gates: raea_app_judge::kind_gates(status::kind_name(make.kind)) };
+ let job = status::Job { make, dir, project: project.as_deref(), record: &record, rounds: &rounds, verdict: verdict.as_ref(), judged_at, ledger: &ledger, score_gates: raea_app_judge::kind_gates(make.kind.name()) };
let mut s = status::status(&job);
s["brief"] = Value::String(brief.display().to_string());
s
diff --git a/apps/make/src/status.rs b/apps/make/src/status.rs
index c7218537..43d588ac 100644
--- a/apps/make/src/status.rs
+++ b/apps/make/src/status.rs
@@ -59,15 +59,6 @@ pub fn sheets(job: &Job) -> Vec<(&'static str, PathBuf)> {
out.into_iter().filter(|(_, f)| f.is_file()).collect()
}
-pub(crate) fn kind_name(k: make::Kind) -> &'static str {
- match k {
- make::Kind::Scene => "scene",
- make::Kind::Kit => "kit",
- make::Kind::Shot => "shot",
- make::Kind::Cut => "cut",
- }
-}
-
/// When a file last changed, and that as seconds since 1970 (a record entry's clock).
fn mtime(p: &Path) -> Option<SystemTime> {
std::fs::metadata(p).ok()?.modified().ok()
@@ -148,7 +139,7 @@ fn lods(job: &Job, notes: &str) -> Vec<Value> {
/// fixed (the round passed) or answered in NOTES.md by its name. Its score gates once the judge is calibrated.
fn critic(job: &Job, newest: Option<SystemTime>, notes: &str) -> Vec<Value> {
let Some(last) = job.rounds.last() else {
- let kind = kind_name(job.make.kind);
+ let kind = job.make.kind.name();
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",
@@ -164,7 +155,7 @@ fn critic(job: &Job, newest: Option<SystemTime>, notes: &str) -> Vec<Value> {
};
out.push(gate("critic", None, fresh, if fresh { format!("round {} judged after the newest deliverable", job.rounds.len()) } else { "the newest deliverable came after the last round: review and judge it again".into() }));
// the kind's own rubric (MK5): a round judged on another's doesn't count
- let kind = kind_name(job.make.kind);
+ let kind = job.make.kind.name();
if last["kind"].as_str() != Some(kind) {
let dir = last["dir"].as_str().unwrap_or("review/rN");
out.push(gate("rubric", None, false, format!("the last round wasn't judged on the {kind} rubric: raea judge {dir} --kind {kind} --by claude")));
@@ -196,12 +187,11 @@ 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);
- 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.iter().flat_map(|c| raea_runtime_cut_plan::gates(c, job.dir)).map(|g| gate(g.name, g.of.as_deref(), g.clear, g.says)));
- } else {
- gates.extend(lods(job, &notes));
- gates.extend(critic(job, newest, &notes));
+ gates.extend(lods(job, &notes));
+ match (&job.make.cut, job.make.kind) {
+ // a cut job: its brief's rules over every delivered file (MK25-MK27), and the person's review its critic
+ (Some(c), make::Kind::Cut) => gates.extend(raea_runtime_cut_plan::gates(c, job.dir).into_iter().map(|g| gate(g.name, g.of.as_deref(), g.clear, g.says))),
+ _ => gates.extend(critic(job, newest, &notes)),
}
let (asks, said) = crate::asked::gates(&sheets(job), job.ledger, &notes);
gates.extend(asks);
diff --git a/core/brief/src/cut.rs b/core/brief/src/cut.rs
index a3b6513a..fdb3a54c 100644
--- a/core/brief/src/cut.rs
+++ b/core/brief/src/cut.rs
@@ -141,13 +141,17 @@ pub fn deliverables(c: &Cut) -> Vec<String> {
/// 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();
- q.extend(c.count.iter().map(|n| ("count".to_string(), n.from.as_str())));
+ if let Some(n) = &c.count {
+ q.push(("count".into(), &n.from));
+ }
for (what, list) in [("say", &c.say), ("never", &c.never)] {
for p in list {
q.push((format!("{what} \"{}\"", p.text), &p.from));
}
}
- q.extend(c.cta.iter().map(|t| ("cta".to_string(), t.from.as_str())));
+ if let Some(cta) = &c.cta {
+ q.push(("cta".into(), &cta.from));
+ }
for o in &c.open {
q.push((format!("open \"{}\"", o.question), &o.from));
}
diff --git a/core/brief/src/make.rs b/core/brief/src/make.rs
index 51269389..101a041e 100644
--- a/core/brief/src/make.rs
+++ b/core/brief/src/make.rs
@@ -190,6 +190,14 @@ pub struct Shot {
pub fps: Option<f64>,
}
+impl Kind {
+ /// as brief.ts writes it, and as raea judge's rubrics are named
+ pub fn name(self) -> &'static str {
+ // in the enum's order
+ ["scene", "kit", "shot", "cut"][self as usize]
+ }
+}
+
/// Each kind's dials: what may be set, and what an unset one is read from the references as.
pub fn dials(kind: Kind) -> &'static [&'static str] {
match kind {
diff --git a/runtime/cut-plan/src/lib.rs b/runtime/cut-plan/src/lib.rs
index c26d32f8..41779fdb 100644
--- a/runtime/cut-plan/src/lib.rs
+++ b/runtime/cut-plan/src/lib.rs
@@ -5,7 +5,7 @@
//! 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::path::Path;
use raea_core_brief::cut::{self, Cut, norm};
use serde_json::Value;
@@ -29,16 +29,11 @@ fn shape(f: &Path) -> Option<(u32, u32, f64)> {
raea_io_soft::probe(f).ok().map(|p| (p.width.round() as u32, p.height.round() as u32, p.secs))
}
-/// 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).
+/// A report beside the file (FILE.words.json, FILE.frames-check.json), 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 changed = |p: &Path| std::fs::metadata(p).and_then(|m| m.modified()).ok();
+ let r = f.with_extension(ext);
+ let changed = |p: &Path| -> Option<std::time::SystemTime> { p.metadata().ok()?.modified().ok() };
let Some(at) = changed(&r) else { return Err(format!("never run: {run}")) };
if changed(f).is_some_and(|m| m > at) {
return Err(format!("the file changed after it: {run} again"));
@@ -52,8 +47,9 @@ fn heard(words: &Value) -> Vec<(String, f64, f64)> {
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);
+ let at = |k: &str| w[k].as_f64().or(w[format!("{k}_ms")].as_f64().map(|ms| ms * 0.001));
+ let s = at("start")?;
+ let e = at("end").unwrap_or(s);
(!t.is_empty()).then_some((t, s, e))
})
.collect()
@@ -166,7 +162,7 @@ fn file_gates(c: &Cut, plan: &cut::CutPlan, format: &str, f: &Path, rel: &str, s
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 screen = std::fs::read_to_string(f.with_extension("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();
@@ -251,9 +247,12 @@ pub fn gates(c: &Cut, dir: &Path) -> Vec<Gate> {
}
}
// 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) }));
+ for (i, p) in c.say.iter().enumerate() {
+ if p.every != Some(false) {
+ continue;
+ }
+ let by = said.iter().find_map(|(j, f)| (*j == i).then_some(f));
+ out.push(gate("say-once", None, by.is_some(), if let Some(f) = by { format!("\"{}\" in {f}", p.text) } else { format!("no cut says or shows \"{}\" (brief: \"{}\")", p.text, p.from) }));
}
out
}