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.

ST9: docs: any length (state, story lines, windowed generator and extractor, hierarchy next) and its plan rows

shinyobjectzaa9dc07369a3
diff --git a/docs/story.feature b/docs/story.feature
index 8dc032c1..30f49373 100644
--- a/docs/story.feature
+++ b/docs/story.feature
@@ -194,3 +194,30 @@ Feature: Story: a story as ECS data, read through many frameworks, generated wit
| guides | sdk/guides/craft/story/write.md | 90 | the three layers, into the project |
| guides | sdk/guides/craft/story/check.md | 60 | each finding and its fix |
| guides | sdk/guides/craft/story/score.md | 50 | lenses, the critic, a real shape |
+
+ Rule: ST9. Any length
+
+ Scenario: ST9a. Story lines
+ Then a story reads and writes as one keyword-led line per value, fact, agent, event and beat (toLines, fromLines)
+ And every valid corpus story reads back from its lines exactly, and a broken line names where
+ And the plan:
+ | crate | file | lines | job |
+ | sdk | sdk/story/src/lines.ts | 160 | to and from story lines |
+ | sdk | sdk/story/test/lines.test.ts | 80 | the round trip, broken lines, the corpus |
+
+ Scenario: ST9b. Windows, not whole stories
+ Given the state at a beat (what the audience knows, open questions, suspense, levels, tension, unpaid setups,
+ unsettled wants, events ahead) stays about the same size at any length
+ Then the generator writes a beat from its state and the beats around it, and the extractor reads a script a
+ chunk at a time with what earlier chunks found, merged
+ And on Birds the chained extractor beats the whole-story extractor, and the windowed generator beats its zero-shot
+ And the plan:
+ | crate | file | lines | job |
+ | sdk | sdk/story/src/state.ts | 120 | stateAt, windowAt |
+ | sdk | sdk/story/models/lib.ts | 180 | chunkSteps, mergeSteps, stepSchema |
+ | sdk | sdk/story/models/known.ts | 30 | prompts for the chain, from raea/story |
+
+ Scenario: ST9c. A feature-length story
+ 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
diff --git a/docs/story.md b/docs/story.md
index 1ba6e014..7c244ab4 100644
--- a/docs/story.md
+++ b/docs/story.md
@@ -240,6 +240,39 @@ export default story({
- **The audience's feeling** per beat (curiosity, concern, relief, delight) is a target, so a story can be checked
against the curve it means to draw.
+## Any length
+
+A story has no length cap. The checks and lenses are ordinary code over the whole telling, so they run on 55 beats
+or 2,000 alike in milliseconds. Only the models have a context window, so no model call ever holds the whole story.
+Each one reads the story's state at a beat plus a window around it. Length becomes a number of steps, like a game
+tick, never a bigger prompt.
+
+- **State** (`src/state.ts`, `stateAt`): what the systems hold just before beat k. That is what the audience knows,
+ the open questions, suspense, each value's level, tension, setups planted but not paid, each agent's unsettled
+ want, need or lie, and the events not yet shown. It is about the same size at minute 3 or minute 100. It carries
+ what the earlier text would have carried.
+- **Story lines** (`src/lines.ts`, `toLines` / `fromLines`): one keyword-led line per value, fact, agent, event and
+ beat, the way Fountain writes a screenplay. They read back exactly: every valid corpus story round-trips. The
+ TypeScript data stays the story; lines are what people skim and models read and write a line at a time. They save
+ only about 22% against JSON (Birds: 2,924 tokens to 2,294), so the format is not what solves length; windows are.
+- **The generator** reads `windowAt`: the world's values, facts and agents, the events it can still use (unshown,
+ or shown by a neighbour), the state, three beats before and two after, and writes the beat between, as JSON
+ under that story's beat schema. On Birds the window shrinks from 7,300 characters at beat 3 to 2,900 at beat 55
+ as events get shown.
+- **The extractor** reads a script six beats at a time (`models/lib.ts` `chunkSteps`). Each step gets KNOWN (the
+ keys earlier steps found, as story lines) and its chunk of script, and answers only what's new plus the chunk's
+ beats. `story_models.py chain` runs the steps in order and merges them. On gold answers the merge is exact for all
+ 1,571 corpus stories. The whole-story extractor stays as the baseline the chained one has to beat on Birds.
+- **The critic**: for structure, the exact checks are the critic at any length, on the extractor's reading. The
+ learned critic earns its place on what code can't see: prose read a window at a time, and taste learned from the
+ launch pairs.
+- **Hierarchy, next**: a feature is about 200 world events (that fits in a window) but 1,500 or more shots (that
+ doesn't and needn't). A beat's `scene` groups its shots. Work goes top-down: premise, then world, then scenes,
+ then shots a scene at a time, each level checked before the next. KNOWN and the generator's event list grow with
+ the world, not the telling; past a few hundred events they'll be cut to the current act's.
+- **Proof at length**: Birds (55 shots, by another author) now. Next is a public-domain feature (Keaton's
+ *Sherlock Jr.*, 1924) to prove the loop at real length.
+
## Lenses: the frameworks
A lens is a module with the same shape for every framework: