nx_world_state.nx
buildroot/runtime/nx_world_state.nx
about
nx_world_state.nx -- CANVAS-style carry-forward visual memory +
per-scene continuity verifier.
Direct port of the world-class architecture from:
* CANVAS (arxiv 2604.13452) -- Continuity-Aware Narratives via
Visual Agentic Storyboarding. Continuity plan P = (C, L, O)
and visual memory M = (Mc, Ml, Mf).
* Narrative Graph Prompting (ICCV 2025 AISTORY workshop) --
typed hyper-nodes with unique consistency seeds per entity.
* OpenAI Agents DungeonMaster pattern -- engine owns the world
state, deterministic rules live in code (here in NishiLang).
The substrate's existing nx_arc treated each stage as an
independent draw from pools. That's WRONG for the D&D-campaign-
in-a-multiverse arc model (see feedback-arcs-as-dnd-campaign-
multiverse-continuity): renders are scenes in a chained narrative,
not random rolls. This module owns the carry-forward.
Scope of v1: characters + locations + monotonic day_clock +
universe_id (for multiverse branching). Objects/inventory queued
for v2 (CANVAS's O mapping) once we see how it's used in
nx_batch_audit_sidecar.
genealogy_id: canvas_2026 + narrative_graph_prompting_iccv2025 +
openai_agents_dungeonmaster_pattern
lineage_id: world_state_v1
nx_safety_envelope:
intended_use: "World-state container -- terrain + biome +
event-trace registers consumed by per-kind
generators"
sil_target: SIL1
asil_target: QM
dal_target: NONE
evidence: [sealed_state_kind_enum,
fixed_capacity_pools,
no_FP_in_state_management]
hazard_register: [bug-tape-state-overflow-on-cap-exhaustion,
bug-tape-event-trace-truncation]
dependencies 3 imports · 3 importers
imports: nx_syscalls.nxnx_tier.nxnx_directors_note.nx
imported by: nx_batch_audit_sidecar.nxnx_batch_audit_sidecar_test.nxnx_world_state_test.nx
structs
| 103 | struct WorldState |
consts
| 54 | const NX_CONT_CONSISTENT: nx_int = 0 |
| 55 | const NX_CONT_VIOLATES_OUTFIT: nx_int = 1 // outfit changed without story beat |
| 56 | const NX_CONT_VIOLATES_LOCATION_TELEPORT: nx_int = 2 // location changed without transit |
| 57 | const NX_CONT_VIOLATES_TIME_REVERSAL: nx_int = 3 // clock went backwards |
| 58 | const NX_CONT_VIOLATES_CHARACTER_ABSENT: nx_int = 4 // character not registered |
| 59 | const NX_CONT_VIOLATES_UNIVERSE_MISMATCH: nx_int = 5 // wrong universe_id |
| 60 | const NX_CONT_N_VERDICTS: nx_int = 6 |
| 73 | const NX_WS_CHAR_F_ID: nx_int = 0 |
| 74 | const NX_WS_CHAR_F_IDENTITY_SEED: nx_int = 1 // per-NGP consistency seed |
| 75 | const NX_WS_CHAR_F_ARCHETYPE_ID: nx_int = 2 |
| 76 | const NX_WS_CHAR_F_OUTFIT_ID: nx_int = 3 |
| 77 | const NX_WS_CHAR_F_LOCATION_ID: nx_int = 4 |
| 78 | const NX_WS_CHAR_F_AFFECT_AXIS: nx_int = 5 |
| 79 | const NX_WS_CHAR_F_LAST_SEEN_MIN: nx_int = 6 // day_clock at last scene |
| 80 | const NX_WS_CHAR_FIELDS: nx_int = 7 |
| 84 | const NX_WS_LOC_F_ID: nx_int = 0 |
| 85 | const NX_WS_LOC_F_SETTING_SEED: nx_int = 1 |
| 86 | const NX_WS_LOC_F_TIME_FIRST_SEEN: nx_int = 2 |
| 87 | const NX_WS_LOC_FIELDS: nx_int = 3 |
| 95 | const NX_WS_BEAT_NONE: nx_int = 0 |
| 96 | const NX_WS_BEAT_OUTFIT_CHANGE_OK: nx_int = 1 |
| 97 | const NX_WS_BEAT_LOCATION_CHANGE_OK: nx_int = 2 |
| 98 | const NX_WS_BEAT_BOTH_OK: nx_int = 3 |
| 99 | const NX_WS_BEAT_N_KINDS: nx_int = 4 |
| 117 | const NX_WS_BYTES: nx_int = 88 // 11 fields * 8 |
functions
| 62 | func nx_cont_verdict_is_valid(v: nx_int) -> nx_int |
| 121 | func nx_world_alloc(universe_id: nx_int, parent_universe_id: nx_int, |
| 146 | func nx_world_register_character(ws: *WorldState, id: nx_int, |
| 165 | func nx_world_register_location(ws: *WorldState, id: nx_int, |
| 179 | func nx_world_find_character_slot(ws: *WorldState, char_id: nx_int) -> nx_int |
| 189 | func nx_world_get_char_field(ws: *WorldState, char_id: nx_int, |
| 202 | func nx_world_arm_beat(ws: *WorldState, kind: nx_int) -> nx_int |
| 212 | func _ws_beat_permits_outfit(beat: nx_int) -> nx_int called by 1: nx_continuity_check |
| 218 | func _ws_beat_permits_location(beat: nx_int) -> nx_int called by 1: nx_continuity_check |
| 233 | func nx_continuity_check(ws: *WorldState, dn: *DirectorsNote) -> nx_int |
| 270 | func nx_world_commit_scene(ws: *WorldState, dn: *DirectorsNote, |
| 297 | func nx_world_branch(parent: *WorldState, new_universe_id: nx_int) -> *WorldState |