Universe: contract

Checked by: tests/contract/test_workflow_contract_docs.py.

Contract maturity: exact-current authored contracts. Executable authority: src/fx_games/workflows/universe/. The semantic vocabulary it projects is ratified separately in taxonomy V0, which stays the documentation-only authority over entity classes, source roles, and the ratification rules; this document describes the workflow that implements it. The committed fixture world is src/fx_games/workflows/universe/inputs/lantern_ferry.

A universe answers a different question from every other workflow here. The others produce something to play; this one produces something to explore: typed entities, their relationships, the tensions between them, the questions the source leaves open, and exactly one concept image per admitted entity. It is judged on the set, not on single images — can a cold reader who has not seen the synopsis explain how the world works, who disagrees, and why?

Its taxonomy home is universe (asset taxonomy): the prefix carries no camera and no genre, because half the workflow is modality-free.

The workflow is an FX workflow file, workflow.yaml, over its own node types in nodes/, its prompt templates in prompts/, the JSON Schemas its structured steps answer to in schemas/ (generated from models.py, and held to it by a test), and FX's built-in image.resize, structured.generate, image.generate and package types (fx/<type>@1). uv run python -m grida.fx plan|run universe plans and runs it.

Sources

The inputs are universe_id, title, medium, a poster, a synopsis, an expansion direction, a census bounding the entity count, and the rights the gallery records. Three source roles enter, and the workflow keeps them distinct rather than flattening them into one prompt:

RoleAuthority
PosterLiteral visual evidence and art grammar only. Its typography, layout, and marketing hierarchy are never world facts.
SynopsisExplicit world facts. Its paragraphs are the only admissible synopsis evidence ids.
Expansion directionRationale for how the world may be expanded. Cited as a requirement id, never as evidence.

The world.source step numbers the synopsis's paragraphs (synopsis_p01…) and the direction's - <requirement_id>: bullets while planning, and carries the medium's contract (anime_2d or live_action) with them. The census bounds only the total: the distribution across the eight entity classes is irregular on purpose, because a per-class quota produces padding rather than a world. Nothing a run makes authorizes publication: the gallery's manifest records publication_authorized: false beside the rights it was given.

Two phases, inferred

How many entities exist — and therefore how many image branches the gallery has — is a result of the world phase, so FX infers two phases from the repeat over the admitted plan:

world:     source, poster_small → propose ◁ proposal_ok → projection → plan ◁ plan_ok
           → review → admit
look:      projection → grammar ◁ grammar_ok
entity[e]: context → direct ◁ direct_ok → brief → draw → sealed → review → record
close:     package

◁ marks a deterministic judge. The four groups are the steps a reader sees. Phase 1 is priced exactly by the plan; phase 2 is priced when its list exists, at most census.max_entities entries. A run goes on into it inside its ceiling, unless --yes-up-to stops it: the gallery then does not start when its worst case would take the run past that amount.

Rules that hold across both:

What the set-level plan enforces

plan_ok checks the gallery as a set before any image is paid for:

The motif axis exists because a cold-reader pass found four entries that had different registers and the same picture — a crowd beside ropes in front of a timber frame, four times.

Identity: what re-bills what

Each step's identity is its node type's locked version (fx.lock; the node modules, the universe models and the medium contracts count as their source) and what it reads. Each paid call is kept in FX's call cache by the request it sends, the rendered prompt included, so editing one prompt template re-bills only the steps that render it and what reads their answers:

EditRe-bills
prompts/direction-entity.md, or a medium's compile guidancethe entity directions, then their images and reviews
image_prompt wording in universe_prompts.py, or a medium's render or negative blockthe images and their reviews
prompts/review-image.md, or a medium's review criteriathe image reviews only

Anything that decides what a step produces is in what it reads: the image size comes from the plan entry's concept mode through tables.size_by_mode, so changing a size draws new pictures.

Rerolling one image

A take is drawn once; running again restores it from the cache. To draw a rejected image again:

uv run python -m grida.fx reroll out/runs/universe/<run> "entity['low_marsh'].draw"

records the next take of that one entity in the takes file (universe.takes.yaml, at the root of the project you run from) and spends nothing. The next live run draws that take and takes every other branch from the cache. python -m grida.fx pick chooses which take a later run keeps.

Image route

Concept images are opaque text-to-image at their exact canvas, on the route the workflow's fx.yaml names by default: OpenRouter's Sunburst generation route, verified live on 2026-09-09 at 2560 by 1440, 2560 by 1712 and 1712 by 2560. The routes: of the fx.yaml you run from may choose the OpenAI or fal Sunburst route instead; an unsupported size is refused before any spend, and a run never falls back to another provider.

The gallery asks for three sizes (tables.size_by_mode): 2560 by 1440, 2560 by 1712 and 1712 by 2560. On the default route FX prices a maximum-quality image at USD 0.22–0.52 at 2560 by 1440 and USD 0.28–0.65 at the other two, and holds the high until OpenRouter reports the bill. The September canaries at these sizes cost $0.227414 to $0.294423, but on 2026-10-07 OpenRouter billed twice September's image output for a 1024-by-1024 image, so budget up to about USD 0.45–0.59 an image. Image output for a 36-image gallery is therefore roughly USD 8–11 at September's bills and up to about USD 16–21 at twice them, before its structured calls. An image's size follows its entity's concept mode, so until the census's list exists the plan prices each image at the route's whole range, up to USD 0.70; once it exists, the plan puts 36 images at no more than USD 23.40. Structured calls go to the configured text model through OpenRouter, priced at USD 0.02–0.60 each.

Running it

Offline, no provider:

uv run python -m grida.fx plan universe --inputs src/fx_games/workflows/universe/inputs/lantern_ferry/inputs.yaml
uv run python -m pytest -q tests/unit/workflows/universe

Live, with a ceiling: the world phase usually costs about USD 0.5, and the gallery is where the money is, so the first command stops before it once its price is known:

uv run python -m grida.fx run universe --inputs <dir>/inputs.yaml --live --max-usd 15 --yes-up-to 1
uv run python -m grida.fx run universe --inputs <dir>/inputs.yaml --live --max-usd 15

The second command continues from the first's cache: the world is not proposed again, and the gallery is drawn inside the ceiling. Raise that ceiling for a large census: a 36-image gallery's images alone may bill up to about USD 21. uv run python -m grida.fx inspect universe reads the newest run back with no provider call, and FX's viewer (uv run python -m grida.fx start --open) shows the gallery's pictures.

Outputs

Under the run folder's outputs/:

Graph

FX plans the committed lantern_ferry world offline; this is the shape of that plan, the world phase, since the gallery's size is known only once its list exists. scripts/write_workflow_contracts.py --write regenerates the block, and the check above fails when it drifts:

{
  "graph_kind": "fx-graph-v1",
  "topology_sha256": "bd449c3afde320a4b9a15d5aecc74a07e20a8c3a9f0ee2b6e4b3da53c16e0943",
  "node_count": 43,
  "operation_counts": {
    "local": 24,
    "structured_generate": 19
  },
  "outputs": [
    "outputs/gallery/",
    "outputs/manifest.json",
    "outputs/universe.json"
  ],
  "type_ids": [
    "universe/close",
    "universe/look/grammar",
    "universe/look/grammar_ok",
    "universe/look/projection",
    "universe/world/admit",
    "universe/world/plan",
    "universe/world/plan_ok",
    "universe/world/poster_small",
    "universe/world/projection",
    "universe/world/proposal_ok",
    "universe/world/propose",
    "universe/world/review",
    "universe/world/source"
  ]
}

Known limits