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.

25.1 KB
Raw Blame
@spec
Feature: Make: scenes, kits and shots built to a frozen plan and held to a review loop the agent can't skip
  Shane, 2026-11-23, after a deep dive into apekshik's AnyScene, AnyKit and AnyShot (github.com/apekshik, MIT): "lets
  take all three learn form them and adopt that review loop internally wholesale. i think this is ley for us. all 11
  points seem relevant to adopt or itnegrate intoexisting systems, or converting into a typescript planning and review
  sdk as part of it". Decided the same day: the contract goes on brief.ts; the gate uses `raea ask`; internal and cloud
  are built together. Plan: ~/.claude/plans/dreamy-floating-dijkstra-of-771a18a0-2207-4b03-80e7-ddbec117bc80.md.

  What the three repos showed (their builder/CRAFT.md and agent/KIT.md say it outright): the quality came from a loop,
  not a model or a setting. Render it and look; name the problem precisely; fix it in a script so a rebuild keeps it;
  check the fix from a view that shows it (a camera 30 cm off the floor shows a floating chair a wide shot hides); get
  an independent critic, because the builder stops seeing its own flaws. And a Stop hook that won't let the agent end
  until every deliverable exists and the critic passes, with a cap and a stall rule so it can't loop forever.

  The model this file sets:
    1. One loop, three kinds of job: a scene (a dressed, lit place from references or a brief), a kit (a set of props
       that belong together, from style references) and a shot (stills or camera moves of a built scene, from words).
    2. The plan is the contract: `make` on the project's brief.ts (core/brief make.rs), typed from Rust, written by the
       agent before it builds, and read by Rust. Every object carries its real size and whether it came from the
       reference or was invented; every dial its value, where the value came from, and what it meant here.
    3. Done is decided in code (`raea make status`), never by the agent saying so, and enforced where the agent stops:
       the Stop hook of every agent raea installs hooks for, locally and on raea cloud.
    4. Three tiers of gate, each gating once it has earned it: measured checks always; `raea ask` questions one by one,
       once each is calibrated on the person's labels; a fresh critic's fixes always (fixed or answered), its score
       once `raea judge calibrate` agrees with the person's eye.
    5. Every job ends with its notes, including what the skill got wrong for it, so the next job starts from them.
    6. Every object is planned at a level of detail, by how large it is meant to be seen, and every render says
       when a shot shows one closer than that (MK21-MK24).

  Background:
    Given raea's scene loop as advice (sdk/guides/craft/bevy/scenes.md, from the 11-06 research): brief, routing,
      build big to small, `raea render --review` (hero, front, right, top, iso and low cameras in colour and clay;
      core/review), `raea judge` (frozen rubric; clef, kimi or claude; pass, done, stall in code; apps/judge),
      `raea scene lint` (raea-sys-contact) and `raea gen check`
    And `raea ask` (docs/ask.feature): typed clef questions with a ledger that calibrates each question on labels
    And the raea plugin's hooks (skills/skills/hooks/hooks.json -> `raea hook claude`, apps/check hook.rs), whose Stop
      branch already blocks a turn's end to hand over what the person sent from the app
    And the project's record (.raea/record/, core/facts record.rs): what each render and check found, and when

  Rule: the plan and done (MK0-MK3)


    @done
    Scenario: MK0. The contract: `make` on brief.ts
      Given a brief.ts whose default export has `make: kit({...})`, `scene({...})` or `shot({...})` (raea/brief)
      Then core/brief reads it as `Make`: its kind, references, style (one paragraph: era, palette, materials, wear and
        one fictional maker), dials, objects, shots, deliverables and a round cap (8 by default)
      And each object has an id, a label, one size (`h`, `dims` [w, d, h] or `max` for things that lie flat), a route
        (solid, rule, gen, library, picture), a prompt, `source` (reference or invented), a `crop` in reference 0, a
        place (x, y, z, rot) for a scene, the generator it was picked from and why, and the fixes made by script
      And each dial is `{ value, source: customer | reference, means }`, from its kind's set (scene: density, tidiness,
        wear, wetness, time_of_day, weather, atmosphere, power, warmth, look; kit: count, variety, detail, wear,
        wetness, warmth, look; shot: res, seconds, lens, handheld, look)
      And the TypeScript is generated from those types (sdk/raea/src/brief.gen.ts), so tsc checks what Rust reads
      And `doctor` names what the plan still lacks: no objects, an object with no size or no route, a dial outside its
        kind's set, a generated object with no prompt

    @needs:MK0 @done
    Scenario: MK1. `raea make status`: what's missing, decided in code
      Given a project whose brief has `make`
      When `raea make status [DIR] [--json]` runs
      Then it lists what's missing for the kind:
        | kind  | deliverables (under out/, overridable with `deliverables`)                                              |
        | scene | stills/ with 3 or more pictures                                                                          |
        | kit   | kit/<id>/<id>.glb, kit/<id>/<id>_lod1.glb and kit/thumbs/<id>.png per object, kit/lineup.png, kit/kit.json |
        | shot  | shots/<name>.png or shots/<name>.mp4 per shot                                                            |
      And NOTES.md beside the brief, with a "What the skill got wrong" section
      And each gate's state: the record's last render or check of every composition the plan names is newer than the
        file and found no error; the critic has judged a round newer than the newest deliverable; each blocking defect
        of that round is fixed (the round passed) or answered in NOTES.md by its id
      And the judge's rounds, passes in a row and stall, read from review/judge.log.jsonl as `raea judge` keeps them
      And `done` is true when nothing is missing and every gate is clear, and also when the job is capped (its rounds
        reached the cap) or stalled; a capped or stalled job is delivered short, with what's missing listed

    @needs:MK1 @done
    Scenario: MK2. The Stop hook: the agent can't end a job that isn't done
      Given an agent session (Claude Code, codex, gemini, kimi) with raea's hooks, in a project whose brief has `make`
      When its turn is about to end and `raea make status` isn't done
      Then the hook blocks the stop with "Not done:" and what's missing, and the agent keeps going
      And a session blocked three times with the same list goes through (the agent is going in circles; the status
        says so), as PL7's keeper stops after asks that change nothing
      And a project without `make` is never blocked, and a brief that doesn't load blocks nothing (the hook says why)

    @needs:MK2 @done
    Scenario: MK3. Gates in plan.org
      Given the project's plan.org (docs/plan.feature)
      Then `raea make status --plan` writes each gate as a check line under the job's task (sdk/task `setCheck`), so
        the person, the app and the cloud see the same list the hook holds the agent to

  Rule: the three tiers of gate (MK4-MK6)

    @needs:MK1 @done
    Scenario: MK4. Defects as calibrated ask questions
      Given the judge's yes/no defects (apps/judge rubric.rs: floating, intersecting, blobby, stand_in, clones,
        flat_colour, plastic, ...) and the loop's own (a cohesion outlier on a reference sheet, a real brand, garbled
        hero text, a disconnected assembly, opaque glass, a camera through a wall)
      Then each is an ask question with versioned words (core/ask), answered on the gate's sheet and kept in the ledger
      And it gates once `raea ask calibrate` passes it on the person's labels (16 problem, 16 clean, held-out AUC 0.8);
        until then its answer shows in the status as advice

    @needs:MK1 @done
    Scenario: MK5. A rubric per kind for the fresh critic
      Then `raea judge --kind scene|kit|shot` asks the kind's categories (scene: layout, props, screens and signage,
        materials, light, atmosphere, plausibility, composition; kit: cohesion, reference fidelity, brief, mesh,
        texture, assembly, scale, labels; shot: framing, move, focus, clearance, continuity, grade)
      And the critic is told the bar is a production base an artist then refines, judged at normal viewing distance,
        no points off for choices that differ from the reference, at most five fixes, most damaging first

    @needs:MK5 @done
    Scenario: MK6. The critic's score gates once it is calibrated
      Given `raea judge calibrate` reporting agreement with the person's eye for a kind
      Then that kind's jobs also need two fresh passes in a row to be done; before that, fixed-or-answered is enough

  Rule: measured placement (MK7-MK9)

    @done
    Scenario: MK7. Grounding at contact points
      Given a part whose box bottom isn't where it touches down (splayed feet, a handle, an origin offset)
      Then `raea scene lint` casts rays down from its lowest vertices (its feet), ignoring itself, volumes and decals,
        and reports `floats` (the gap, and a `{y, dy}` fix that settles it down) or `sunk` (a fix that raises it);
        a part whose feet reach nothing reads as mounted (a wall or ceiling holds it) or as a warning in the air, so
        signs, pendants and lamps on cords aren't errors; a stool whose box clips a table's edge rests by its feet

    @done
    Scenario: MK8. The clip check, for every level
      Then `raea scene lint` (raea-sys-contact) reports clips with their depth and the move that clears them
        (`{part, axis, by}`), and faces z-fighting: two parts' faces in one plane over each other (an error from
        1 cm², a warning under), and doubled faces inside one model (a warning), on every lint, no flag needed

    @done
    Scenario: MK9. Re-drop after every move
      Then a part moved sideways by a clip's fix is settled onto what's under its new place in the same pass (the fix
        carries its `dy`), and a stool under a table rests on the floor by its feet, so nothing hovers at table height

  Rule: kits (MK10-MK13)

    @needs:MK1 @done
    Scenario: MK10. References made in one style, checked on one sheet
      Then `raea make refs` makes each object's reference with `raea gen image` with the style images as input, the
        plan's style paragraph and the scan template (`--dry` quotes it), and writes review/refs.png (`raea make sheet
        refs` again): the style images, then every reference labelled with its size, before any 3D
      And outliers (another style, a real brand, cropped, two objects) are regenerated first: the cheapest place to fix
        cohesion

    @needs:MK10 @done
    Scenario: MK11. Both generators, picked on clay
      Then `raea make gen` sends every reference to Tripo H3.1 (face limit 150k heroes, 60k small) and Meshy (fal),
        `raea make pick-sheet` fits both to size and renders reference | Tripo | Tripo clay | Meshy | Meshy clay under
        one light (review/picks.png), and `raea make pick ID tripo|meshy "why"` records the pick and its one-line why (the earlier ~150 props: Meshy ~70%, small items and printed labels; Tripo the big
        hard-surface heroes)

    @needs:MK11 @done
    Scenario: MK12. Prep and LOD
      Then `raea make prep` fits each pick with `raea gen check -o` (front +z, real metres, bottom-centre) and writes a
        quarter-triangle ID_lod1.glb (blender/decimate.py), each with its .glb.json saying how it was made

    @needs:MK12 @done
    Scenario: MK13. A kit is a component set
      Then `raea make kit` lands it in shared/components/<kit>/ (one component per object importing its model and LOD
        from beside it: compositions import .glb files as their path), with lineup.tsx (a 1 m bar, labels), cover.png,
        thumbnails and kit.json, and the job's own out/kit/ record that `raea make status` counts

  Rule: shots (MK14-MK17)

    @done
    Scenario: MK14. Camera moves, focus and the handheld walk
      Then raea/camera has static, dolly, truck, pedestal, crane, pan, tilt, orbit, dollyZoom (the lens solved per
        frame to hold the subject) and path (Catmull-Rom), focus track, point and rack with holds, and
        `handheld({ profile: "walk" })`: steps at 1.8 Hz, an aim on a spring, small reframes, nothing above 1.9 Hz

    @needs:MK14 @done
    Scenario: MK15. Blocking: framing sheets and a lens chart
      Then `raea make framing` renders each shot's first, middle and last frame (`raea render --at`) onto
        review/framing.png, a row a shot stamped with its name and time, and `raea make lenschart SHOT` its first frame
        at 18, 24, 35, 50, 85 and 135 mm (RAEA_LENS keeps the scene's camera and sets its lens)

    @needs:MK14 @done
    Scenario: MK16. Clearance on every frame
      Then `raea scene stage --clearance 0.45` finds every run of frames where the camera is nearer a solid than that
        (a box first, a model's triangles when its box comes close; inside a part said so), leaving out volumes,
        particles, decals, see-through parts (glass) and anything under 5 cm

    @needs:MK14 @done
    Scenario: MK17. Shots from words and from a floor plan
      Then the shot-language guide (bevy/shots) maps a crew's words to moves (push in, truck, reveal, rack focus,
        walkthrough at 0.4-0.6 m/s and 1.5-1.7 m); a path drawn on `raea make plan`'s floor plan (its metres, x right,
        z away from the entrance) is `walkPath(points)`: an even walking pace at eye height, corners rounded; grade looks
        (clean, cinematic, gritty, vintage) are `gradeLook()` presets in raea/post_process

  Rule: the plan, drawn (MK18)

    @needs:MK0 @done
    Scenario: MK18. `raea make plan`: a floor plan, a grey box and a comparison
      Then it draws review/plan/floor-plan.png (every placed object's footprint turned by its rot and labelled with its
        height, invented ones dashed, a metre grid, the entrance the camera looks in from), renders a grey box of the
        plan from the entrance (blockout.tsx, and `raea render --review` sheets of it) and puts the reference, the
        blockout and the floor plan on comparison.png, for the person to approve before anything is generated

  Rule: planned detail (MK21-MK24)
    Shane, 2026-11-24: "define objects at an LOD level based on either us grayboxing or thinking of them as generally
    distant objects and alert agents when an LOD that was at 3 or 4 for example is now appearing in frame at LOD 2
    level or 1, or 0 ... helpful for planning objects as generally distant and unseen objects versus close ones and
    knowing if we forgot about something over time". A level is how large a part is planned to be seen, which is how
    much of it gets built; the frames are measured against it on every render, so a camera move added later, or a
    box that was meant to be replaced, is said the next time anything is drawn.

    @done
    Scenario: MK21. A part shown closer than its planned detail is said
      Given a level is how much of the frame a part's box spans through the frame's camera, the larger of its width's
        and its height's share: 0 the hero (50% or more), 1 featured (20%), 2 dressing (8%), 3 background (2%), 4 far
      And a part's plan is its own `lod` (Mesh3d, Model, and every part inside an Entity with a transform or a Group
        that has one), else the `lod` of the plan's object of its name
      When a frame shows a planned part at a finer level than its plan (raea-runtime-lod-plan)
      Then the render's end checks, `raea scene stage` and `raea check --quick` say `lod-closer`: the part, its plan,
        the level it is seen at, how much of the frame it spans at its largest and on which frame, how many frames it
        is closer on, and the fix (build it for that level and plan it there, or keep the camera off it)
      And one level finer is a warning, two or more an error, which fails the render as any error does
      And a part out of the frame, behind the camera, or with another mesh's box across every line to it isn't seen;
        a part the camera stands in or beside is measured at its nearest point; RAEA_LOD_CHECK=0 leaves the check out

    @needs:MK21 @done
    Scenario: MK22. The plan carries each object's level
      Given `lod: 0..4` on an object of `make` in brief.ts (core/brief make.rs; `doctor` refuses a level past 4)
      Then a render of a composition under that brief holds the parts named as the objects' ids to those levels
        (runtime/lod-plan plan.rs reads the brief only when its words plan a level, once a version)
      And `raea make plan` labels each footprint with its level and writes each grey box with its object's id as its
        name and its `lod`, so the blockout is held to the plan it draws

    @needs:MK21 @done
    Scenario: MK23. `raea scene lod`: every part's plan beside what the frames show
      When `raea scene lod EDIT.tsx [--from N] [--to N] [--json]` steps the frames without drawing
      Then it lists every part: its planned level, the finest level a frame shows it at, how much of the frame it
        spans there, on which frame, and how many frames it is in; parts seen closer than planned first (the widest
        gap on top), then the rest of the planned, then the parts with no plan by how large they get
      And a planned part no frame shows as close as its plan says so (built finer than it is ever seen)
      And a level the plan gives a name that no part in the frames goes by is listed, since it holds nothing
      And it exits 1 when a part is seen two or more levels finer than planned

    @needs:MK22 @done
    Scenario: MK24. A job is held at a part seen closer than planned
      Given a job whose composition's last render or check found `lod-closer`
      Then `raea make status` has a `lod` gate for that composition, open with the parts' names, until each is built
        for the level it is seen at and replanned, kept out of the camera's way, or answered in NOTES.md on a line
        with `lod` and its name; the Stop hook holds the agent there as at any open gate
      And 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; `also`: the other lines a brief rotates, any
        one of which lands it, each found in the brief) 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: any goal, held to rules (MK28-MK29)
    Shane, 11-26, asking whether raea make is just a version of /goal: "when we use these things, they should just
    probably be consolidated into one workflow, because in any case we'll have a goal or a brief or something that
    dictates what we need. And then we essentially just need to make sure that it can't stop unless all the goals pass,
    or all the rules in the brief". /goal in raea.app's chat let the agent end the loop by writing "GOAL MET"; a goal it
    can declare met is advice. So /goal and raea make are one loop: a goal is a fifth kind of job, its words become
    rules in brief.ts before the work starts, and only `raea make status` says it's met.

    @needs:MK2
    Scenario: MK28. A goal as rules: `make: goal({...})`
      Given work that isn't a scene, kit, shot or cut (fix a bug, write a page, ship a change)
      When the agent writes `make: goal({ goal: "the person's words", rules: [...] })` before it starts
      Then core/brief reads `goal` (goal.rs): the goal as the person said it, and `rules`, each an id and exactly one of
        `run` (a command that must exit 0 in the brief's folder, within `timeout` seconds, 300 by default), `file` (a
        file that must exist: a deliverable) or `says` (words that must be true of the work)
      And `doctor` names what it lacks: no goal, no rules, an id that isn't [a-z0-9_] or is listed twice, a rule with
        none or more than one of run, file and says, a timeout with no run
      And a goal job needs no NOTES.md "What the skill got wrong" section (no skill made it) and has no render critic

    @needs:MK28
    Scenario: MK29. Held by a command's exit and a fresh critic, never the agent's word
      Given a goal job
      Then `raea make status` runs every `run` rule at every status, the Stop hook's included, and holds the job on one
        that fails or outlives its timeout, with its exit code and last line ("run")
      And a `says` rule is clear only when review/goal.judge.json, written by `raea make judge [DIR] [--by claude|kimi]`
        (a fresh session that may only read: Read, Grep and Glob), found it true at a time no earlier than the work's
        newest file, the job's own review/, .raea/, NOTES.md, .git and node_modules left out, compared at whole seconds
        ("says")
      And `file` rules are its deliverables, listed under missing
      And raea.app's /goal is this job: it writes the rules first, and only the status ends the loop

  Rule: raea cloud (MK19-MK20)

    @needs:MK2 @done
    Scenario: MK19. Three skills on raea cloud
      Then raea cloud has "Scene from references" (plan, spend, first cut, deliver), "Kit from style" (reference
        sheet, spend, deliver) and "Shots of a scene" (framing, deliver) as skill templates (GET|POST
        /v1/skills/templates), each with a workflow whose agent steps are checked by a `raea make status` line: run as
        `raea make status --json` on the box in the project's folder, "says done" holding on its done and "raea make
        status: critic, review/refs.png" on each named gate and file

    @needs:MK19 @done
    Scenario: MK20. Retry-safe jobs and a live view
      Then a project is keyed by a hash of its inputs (or the caller's Idempotency-Key; plan.org's :INPUTS:): the same
        ask from the API, the studio, a form or a webhook returns the finished project, attaches to the running one or
        resumes a failed one without paying again; one a person stopped doesn't hold the ask
      And every picture the agent opens goes to the live watch as a raea.seen event (its path, and a preview when the
        bytes are under 600 KB), and a raea.heartbeat every 20 s repeats the milestones so far for anyone who joins late