The state mutation logic holds up perfectly under timeline scrubbing and
spatial navigation, proving the architecture is ready. With the visualization
client successfully rendering both the terminal REPL and the canvas grid, the
next phase is building the actual LLM ingestion pipeline to generate these
structures from raw text.
Because standard JSON is much easier for an LLM to generate reliably than
strict nested JSON-Lisp arrays, the standard approach is to have the model
output a standard JSON object, which a lightweight middleware script then
compiles down into the compact AST format for your lock-free memory database
or LPC virtual machine.
Here is the system prompt and schema design for the first extraction pass.
Pass 1: Topological & Geometric Extraction
The goal of this pass is strictly environmental. The model is instructed to
ignore characters and events, focusing entirely on carving out the spatial map
and determining the room dimensions for the visualizer.
System Prompt:
> You are a world-building spatial engine. Your task is to read a chunk of
narrative text and extract a topological map of the locations described.
> Rules:
> * Identify distinct rooms, areas, or zones mentioned in the text.
> * Create an uppercase ID for each (e.g., CH1_LIVING_ROOM).
> * Determine a logical grid size (width and height) for the 2D map based on
the description (e.g., a sprawling cavern is 8x8, a tight hallway is 2x5).
> * Identify obvious physical connections (exits) between these rooms and
specify the cardinal direction (north, south, east, west, up, down).
> * Do NOT include characters, items, or events in this output. Strict
environmental topology only.
>
Expected JSON Schema Output:
{
"zones": [
{
"id": "CH1_LIVING_ROOM",
"name": "The Dusty Living Room",
"description": "A sprawling room with a broken window. Dust motes dance
in the faded light.",
"grid": { "w": 6, "h": 5 },
"exits": [
{
"direction": "north",
"target_id": "CH1_KITCHEN",
"description": "A dark hallway",
"type": "walkable"
}
]
}
]
}
The Middleware Compiler
Once the LLM returns this JSON, your pipeline script assigns arbitrary
starting x and y coordinates to the first room. As it iterates through the
exits, it dynamically calculates the x and y for the connected rooms to build
out the Euclidean map.
Finally, the script serializes the whole object into the compact JSON-Lisp
arrays we used in the prototype ([ "room", "CH1_LIVING_ROOM", {attributes},
[exits] ]). This resulting AST-MD snapshot can then be written directly to
disk or loaded instantly into your engine's memory arenas.
If you are satisfied with this extraction logic, we can draft Pass 2, which
will scan the same text chunk againthis time armed with the known zone IDsto
populate the Write-Ahead Log with the entities and their sequential actions.