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.

ST10b: measured against plain prompts. Eight prompts written five ways by one writer, judged blind by two models of other families: raea/story as the editor of a draft (read back into story data, checked, fixed by beat) ties a hard editing prompt and beats plain 26 of 32 votes (p = 0.001); a script drafted straight into story data reads worst (7 of 32 over plain). docs/story.md 'Measured' has the numbers and the caveats; the write and score guides lead with draft, read back, check, fix by beat (raea-skills #117, pin to 9e535c8). bench: the extractor's mechanical slips tidied, every arm reusable, the fuzzer counts a clear RangeError as a refusal.

shinyobjectz873179a540e0
diff --git a/docs/story.feature b/docs/story.feature
index a91e4aa8..657b0875 100644
--- a/docs/story.feature
+++ b/docs/story.feature
@@ -222,3 +222,27 @@ Feature: Story: a story as ECS data, read through many frameworks, generated wit
Given a public-domain feature film told shot by shot, its scenes grouped
Then the extractor chains through it and the checks and lenses run on what it reads
And the generator writes scenes top-down from premise to world to scenes to shots, each level checked
+
+ Rule: ST10. Proven against plain prompts
+
+ Scenario: ST10a. Edge cases and fuzzing
+ Given 29 odd and broken stories, each with what should happen, and valid stories with one field made the wrong type
+ Then anything fromData accepts, every reader reads without crashing (fromData holds a story to storySchema)
+ And unsets takes a fact back, two beats never share an id, seconds is never negative, a telling that shows
+ nothing is a finding
+ And the plan:
+ | crate | file | lines | job |
+ | sdk | sdk/story/bench/edges.ts | 230 | the edge cases, run and reported |
+ | sdk | sdk/story/bench/fuzz.ts | 80 | wrong-typed fields through every reader |
+ | sdk | sdk/story/src/data.ts | 40 | shapeErrors: the schema as the reader's gate |
+
+ Scenario: ST10b. The same prompts with and without it
+ Given eight prompts written five ways by one writer (plain; plain and an editor; plain and raea/story as the
+ editor; written as story data; story data then a screenwriter), judged blind by two models of other families
+ Then raea/story as the editor of a draft ties a strong editing prompt and beats plain (26 of 32, p = 0.001)
+ And written straight into story data a script reads worst (7 of 32 over plain), so the guides say: write the
+ script, read it back as data, check it, fix by beat
+ And the plan:
+ | crate | file | lines | job |
+ | sdk | sdk/story/bench/ab.ts | 330 | the five arms, extraction, the judges |
+ | sdk | sdk/story/bench/ab-report.ts | 140 | ranks, pairs, extraction, cost |
diff --git a/docs/story.md b/docs/story.md
index c7c191e9..4d409f4f 100644
--- a/docs/story.md
+++ b/docs/story.md
@@ -15,7 +15,9 @@ seeded sampling, the mutations, story as data and as story lines, the state at a
typed questions about a beat (story as decisions), and checks in `raea check`. The skill carries it as
`craft/story/`. Shane paused the small story models the same day ("screw the model, just finish and wrap the sdk"):
the code that built their data and trained them stays in `sdk/story/models/` with its corpus in `~/.vd/story`, not
-part of the package, for whenever they're picked up again.
+part of the package, for whenever they're picked up again. Measured the same day against plain prompts (see "Measured: the same
+prompts with and without it"), it makes a script better as the editor of a draft (read back, checked, fixed by beat:
+tied with a strong editing prompt, both well over plain) and worse as the language a script is drafted in.
## In one paragraph
@@ -436,6 +438,86 @@ Within an account, the audience is the same, so distribution is held as far as t
beside it.
- Taste for the decision model comes from Shane's notes, not from engagement, which mostly measures the news.
+## Measured: the same prompts with and without it (11-22)
+
+`sdk/story/bench/` holds three benches: `edges.ts` (29 odd and broken stories, each with what should happen), `fuzz.ts`
+(valid stories with one field made the wrong type, run through every reader) and `ab.ts` with `ab-report.ts` (the
+same prompts written five ways, judged blind). Run data is in `~/.vd/story/ab/run1` to `run3`; run3 is the complete
+one; the three runs and their smoke tests cost about $14.70 together.
+
+### What the edges and the fuzzer found, and what changed
+
+The fuzzer found 21 places where `fromData` accepted something a reader then crashed on, and a test story found that
+`unsets` did nothing. All are fixed (ST10a):
+
+- **`fromData` holds a story to `storySchema()`** (`shapeErrors`): a field of the wrong type, or a field in the wrong
+ place, is refused with where it is. 270 of the 1,572 corpus stories carried one that used to be dropped silently:
+ `turns` on a beat (103, so the writer thought a beat moved a value and it didn't), `believes` as text (97), a
+ `dilemma`, `claim` or `ends` on a beat, a `setup`, `asks` or `reveals` on an event.
+- **`unsets`** takes a fact back from the event's agents and from the audience, and a claim can't rest on a fact that
+ has since been undone.
+- **Two beats with one id** are an error, both in `fromData` and in the checks: a composition finds its Sequence by id.
+- **`seconds`** can't be negative, a telling that shows no event is a finding, and `asker` says when it's asked about a
+ beat that isn't there.
+
+What held without a change: cause cycles and self-causes are refused; a mystery's detective acting on an unseen clue is
+a belief error that a fair-play clue removes; a flashback hook passes when its fact is hidden then paid; a negative arc
+needs no settled need; Japanese keys and text round-trip through story lines; 20 seeds of a story with choice points
+give 20 distinct stories; every mutant raises a finding. Scale: checks, the McKee lens and a window over 2,000 events
+and 2,000 beats take about 0.4 s each, and one beat's 20 typed questions take 8 ms after a 1.2 s setup.
+
+### The A/B: five ways to write the same prompt
+
+Eight prompts (a 30 s tent launch, a 45 s coffee brand film, a 3 minute whodunit with fair play, a wordless
+kishotenketsu, a 40-shot short film, an RPG quest with a lying quest giver, a tragedy, a 15 s sunscreen ad; made-up
+brands), two samples each, one writer (Claude Sonnet 5.5) for every arm:
+
+- **A, plain**: the prompt, a beat script back (what's on screen, who says what, seconds), one call.
+- **C, plain + an editor**: A, then one round where the writer critiques its own script against the same things the
+ checks and the prompt's lenses hold (said in words: therefore or but, never and then; setups paid; no acting on
+ what a character can't know; the arc settled; proof shown; the framework's stages), and rewrites.
+- **D, plain + raea/story as the editor**: A's script read back blind into story data by another model (Gemini 3.7
+ Flash), `checkStory` and the prompt's lenses run on it, the findings handed to the writer by beat number, and one
+ rewrite. C's round with the editor's eye replaced by the exact checks.
+- **B, written as story data**: the writer writes the story itself in the data, under the guide; the checks and
+ lenses find what's wrong and the writer repairs it, up to two rounds; its beats become the beat script.
+- **E, story data, then a screenwriter**: B's checked story handed to the writer as story lines, to write the beat
+ script from.
+
+Every arm ends as the same numbered beat script. Two judges of other families (GPT-5.4, Gemini 3.1 Pro) ranked all five
+for each prompt, letters shuffled, and scored each 1 to 10 on cause, setups, clarity, the brief, feeling and overall.
+
+| arm | mean rank (of 5) | ranked first | overall | over plain |
+|---|---|---|---|---|
+| D, plain + raea/story as the editor | **1.91** | 47% | **8.44** | 26 of 32 (p = 0.001) |
+| C, plain + an editor | 1.97 | 44% | 8.22 | 26 of 32 (p = 0.001) |
+| A, plain | 3.22 | 3% | 7.31 | |
+| E, story data, then a screenwriter | 3.59 | 6% | 7.03 | 12 of 32 (p = 0.22) |
+| B, written as story data | 4.31 | 0% | 6.38 | 7 of 32 (p = 0.002) |
+
+D and C tie (16 of 32). D came first on both the long film and the whodunit, where there's most to track (40 shots;
+clues the detective may only act on once shown), and on the tent launch; C came first on the coffee film,
+the kishotenketsu, the quest and the tragedy. Their cost was alike ($0.12 a story against $0.12).
+
+**What it means.** raea/story makes a script better as the editor of a draft, not as the language it's drafted in.
+Written straight into the data, a story passes its checks (13 of 16 by the last round) and reads worst: fewer, more
+abstract beats, a narrator saying what the screen should show ("You want to go. The tent is what stops you."), causes
+that hold in the data and don't show on screen. The judges scored B's cause and setups lower than plain's (6.4 against
+7.2), although its data has every cause. Handing that story to a screenwriter (E) recovers most of the loss but not
+all of it. Read back from a draft instead, the checks name holes by beat (on one tent launch: four events with no cause
+the viewer saw, four beats that only follow the one before, the hero's arc never settled, the brand never in the
+mentor's place), and the rewrite fixes what a viewer can see.
+
+So the way to use it, for a person or an agent: **write the script, read it back as story data, check it, fix by beat,
+and keep the story file for what the checks hold from then on** (the composition's beats, `raea check`, the cuts). The
+data is the checker's language, and the script is the viewer's.
+
+**How far to trust it.** 16 prompt samples and two LLM judges, who agreed on the best of five 9 times in 16; one writer
+model; the extraction is noisy (a B story that passed its own checks still reads back with 1.3 findings a beat, about
+the level of every arm), so it's a guide to the rewrite, not a score. D's own extraction score is the lowest (1.44 a
+beat) partly because it was fixed against the same kind of reading. The edits that won are the ones a human editor
+would also make; the checks don't know whether a line lands.
+
## Build order
| step | what | confidence |
diff --git a/sdk/guides/craft/story/score.md b/sdk/guides/craft/story/score.md
index 91ce7d17..f88fba6e 100644
--- a/sdk/guides/craft/story/score.md
+++ b/sdk/guides/craft/story/score.md
@@ -1,6 +1,14 @@
# Scoring a story
-A story that passes its checks holds together. Whether it's good is a different question, answered three ways.
+A story that passes its checks holds together. Whether it's good is a different question, answered four ways.
+
+## 0. Read a draft back, then check it
+
+The best use, measured: a draft script read back into story data (only what it shows), checked, and fixed by beat.
+On eight prompts it tied a hard editing pass and beat the plain draft 26 of 32 judge votes; it came first where
+there's most to track (a 40-shot film, a whodunit's fair-play clues). Treat the findings as a list for the rewrite,
+not a score: reading a script back is noisy (a story that passes its own checks still reads back with about one
+finding a beat).
## 1. Read it through lenses
diff --git a/sdk/guides/craft/story/write.md b/sdk/guides/craft/story/write.md
index 94466f69..e3bed32f 100644
--- a/sdk/guides/craft/story/write.md
+++ b/sdk/guides/craft/story/write.md
@@ -1,5 +1,16 @@
# Writing a story
+**Draft the script first, then the story.** Measured on eight prompts written five ways (docs/story.md, "Measured"):
+a script drafted straight into story data passes its checks and reads worst of all (fewer, more abstract beats, a
+narrator saying what the screen should show); a plain draft read back into story data, checked, and fixed by beat
+reads best, tied with a hard editing pass and well over the plain draft (26 of 32 judge votes). So:
+
+1. Write the script as a screenwriter would: what's on screen and what's said, beat by beat.
+2. Read it back into a story (below), recording only what the script shows: an event with no shown reason gets no
+ `because`, a beat that moves nothing gets no `turns`.
+3. `checkStory` and the brief's lenses: each finding names a beat. Fix the script there, so the screen shows it.
+4. Keep the story file. From then on it's what the composition's beats, `raea check` and the other cuts hold to.
+
A story is a module, `NAME.story.ts`, with one default export made by `story()`. tsc checks its references: a beat
that shows an event you didn't write, an agent you didn't declare, a setup nobody planted, won't compile.
diff --git a/sdk/story/bench/ab.ts b/sdk/story/bench/ab.ts
index 25ae8e8c..d8fe5ca2 100644
--- a/sdk/story/bench/ab.ts
+++ b/sdk/story/bench/ab.ts
@@ -194,7 +194,7 @@ async function checkedEdit(p: Prompt, a: Arm): Promise<Arm> {
const msgs = [{ role: "system", content: PLAIN }, { role: "user", content: p.brief }, { role: "assistant", content: JSON.stringify(a.final) },
{ role: "user", content: `A story checker read your script back as story data, from the screen and the lines alone, and found:\n${list}\nEach is what a viewer can't see on screen: a beat with no shown reason, a turn nothing set up, a setup never paid, an arc never settled. Fix each one so the screen shows it (or leave it where it's a choice you mean), then rewrite. Answer with one JSON object {"title": string, "beats": [...same shape as before]}.` }];
const r = await ask(WRITER, msgs);
- return { arm: "D", final: parse(r.text), calls: 2, usd: a.usd + r.usd + ex.usd, ms: a.ms + r.ms, log: [{ found: found.map((f) => `${f.level} ${f.check}`), finish: r.finish }] };
+ return { arm: "D", final: parse(r.text), calls: 2, usd: a.usd + r.usd + ex.usd, ms: a.ms + r.ms, log: [{ found: found.map((f) => `${f.level} ${f.check}`), said: list, finish: r.finish }] };
}
async function written(p: Prompt, b: Arm): Promise<Arm> {
const data = b.final?.data;
@@ -207,21 +207,43 @@ async function written(p: Prompt, b: Arm): Promise<Arm> {
}
// ---- scoring ----
+/**
+ * The extractor's mechanical slips, tidied before fromData reads it (never a story's content): null fields dropped, a
+ * lone key where a list goes wrapped, a fact used but not declared declared with its own words, and a narrator who acts
+ * made an agent. What's left wrong goes back to the extractor.
+ */
+const LISTS = { ev: ["with", "needs", "sets", "unsets", "learns", "proof", "dilemma"], beat: ["shows", "reveals", "hides", "asks"], agent: ["believes"] };
+function tidy(j: J): J {
+ const drop = (o: J) => { for (const k of Object.keys(o)) if (o[k] === null) delete o[k]; };
+ const wrap = (o: J, ks: string[]) => { for (const k of ks) if (typeof o[k] === "string") o[k] = [o[k]]; };
+ j.facts ??= {};
+ for (const a of Object.values((j.agents ?? {}) as J)) if (a && typeof a === "object") { drop(a); wrap(a, LISTS.agent); }
+ const facts = (xs: unknown) => { if (Array.isArray(xs)) for (const f of xs) if (typeof f === "string" && !(f in j.facts)) j.facts[f] = f; };
+ for (const e of Object.values((j.world ?? {}) as J)) if (e && typeof e === "object") {
+ drop(e); wrap(e, LISTS.ev);
+ if (e.who === "narrator" && !j.agents?.narrator) (j.agents ??= {}).narrator = {};
+ for (const k of ["needs", "sets", "unsets", "learns", "proof"]) facts(e[k]);
+ }
+ for (const t of Object.values((j.tellings ?? {}) as J)) if (Array.isArray(t)) for (const b of t) if (b && typeof b === "object") {
+ drop(b); wrap(b, LISTS.beat); for (const k of ["reveals", "hides", "asks"]) facts(b[k]);
+ }
+ return j;
+}
type Extracted = { checks: J[] | null; errors: string[]; usd: number; beats: number; data?: J };
async function extract(s: string): Promise<Extracted> {
let usd = 0;
const msgs: J[] = [{ role: "system", content: EXTRACT }, { role: "user", content: s }];
- for (let t = 0; t < 2; t++) {
+ for (let t = 0; t < 3; t++) {
const r = await ask(EXTRACTOR, msgs, { tokens: 30000 });
usd += r.usd;
- const j = parse(r.text);
+ const raw = parse(r.text), j = raw ? tidy(raw) : null;
const d = j ? fromData(j) : { story: null, errors: [{ at: "", says: "not JSON" }] };
if (d.story && !d.errors.length) {
try { return { checks: checkStory(d.story, "main").map((f) => ({ check: f.check, level: f.level, about: f.about, says: f.says })), errors: [], usd, beats: (j!.tellings?.main ?? []).length, data: j! }; }
catch (e) { writeFileSync(join(OUT, `crash-extract-${Date.now()}.json`), JSON.stringify({ story: j, stack: String((e as Error).stack) })); return { checks: null, errors: [`crash: ${(e as Error).message}`], usd, beats: 0 }; }
}
msgs.push({ role: "assistant", content: r.text }, { role: "user", content: `Fix these and answer with the whole JSON object:\n${d.errors.slice(0, 20).map((e) => `- ${e.at}: ${e.says}`).join("\n")}` });
- if (t === 1) return { checks: null, errors: d.errors.slice(0, 5).map((e) => `${e.at}: ${e.says}`), usd, beats: 0 };
+ if (t === 2) return { checks: null, errors: d.errors.slice(0, 5).map((e) => `${e.at}: ${e.says}`), usd, beats: 0 };
}
return { checks: null, errors: ["unreachable"], usd, beats: 0 };
}
@@ -249,8 +271,8 @@ await pool(units, JOBS, async ({ p, s }) => {
const [a, b] = await Promise.all([reused(p.id, s, "A") ?? plain(p), reused(p.id, s, "B") ?? sdk(p)]);
const [c, d, e] = await Promise.all([
ARMS.includes("C") ? reused(p.id, s, "C") ?? edited(p, a) : null,
- ARMS.includes("D") ? checkedEdit(p, a) : null,
- ARMS.includes("E") ? written(p, b) : null,
+ ARMS.includes("D") ? reused(p.id, s, "D") ?? checkedEdit(p, a) : null,
+ ARMS.includes("E") ? reused(p.id, s, "E") ?? written(p, b) : null,
]);
const arms = [a, c, b, d, e].filter((x): x is Arm => !!x && ARMS.includes(x.arm));
const scored = await Promise.all(arms.map(async (x) => {
diff --git a/sdk/story/bench/fuzz.ts b/sdk/story/bench/fuzz.ts
index e1e11b0c..81d863ce 100644
--- a/sdk/story/bench/fuzz.ts
+++ b/sdk/story/bench/fuzz.ts
@@ -51,6 +51,7 @@ for (let i = 0; i < N; i++) {
];
for (const [name, fn] of readers) {
try { fn(); } catch (e) {
+ if (e instanceof RangeError) continue; // a clear refusal (asking about a beat that isn't there), not a crash
const where = p.map((k) => (typeof k === "number" ? "[]" : k)).join(".").replace(/world\.\w+/, "world.E").replace(/agents\.\w+/, "agents.A").replace(/tellings\.\w+/, "tellings.T");
const key = `${where} = ${JSON.stringify(v)} | ${name} | ${String((e as Error).message).slice(0, 60)}`;
const c = crashes.get(key);
diff --git a/skills b/skills
index 4a77a0b0..9e535c80 160000
--- a/skills
+++ b/skills
@@ -1 +1 @@
-Subproject commit 4a77a0b00ee02e713fc7ce8b80769ba6600e2f8f
+Subproject commit 9e535c80d50dd8c6e712d4815e059da8b3b8d7fa