code wiki / (root) / nx_world_state.nx

nx_world_state.nx

buildroot/runtime/nx_world_state.nx

13697 B328 linesdepth 3pulls 3 transitivereach 5 importersview sourcekind librarytopic world
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_tier.nx nx_directors_note.nx nx_world_state.nx nx_batch_audit_sidecar.nx nx_batch_audit_sidecar_test.nx nx_world_state_test.nx

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

103struct WorldState

consts

54const NX_CONT_CONSISTENT: nx_int = 0
55const NX_CONT_VIOLATES_OUTFIT: nx_int = 1 // outfit changed without story beat
56const NX_CONT_VIOLATES_LOCATION_TELEPORT: nx_int = 2 // location changed without transit
57const NX_CONT_VIOLATES_TIME_REVERSAL: nx_int = 3 // clock went backwards
58const NX_CONT_VIOLATES_CHARACTER_ABSENT: nx_int = 4 // character not registered
59const NX_CONT_VIOLATES_UNIVERSE_MISMATCH: nx_int = 5 // wrong universe_id
60const NX_CONT_N_VERDICTS: nx_int = 6
73const NX_WS_CHAR_F_ID: nx_int = 0
74const NX_WS_CHAR_F_IDENTITY_SEED: nx_int = 1 // per-NGP consistency seed
75const NX_WS_CHAR_F_ARCHETYPE_ID: nx_int = 2
76const NX_WS_CHAR_F_OUTFIT_ID: nx_int = 3
77const NX_WS_CHAR_F_LOCATION_ID: nx_int = 4
78const NX_WS_CHAR_F_AFFECT_AXIS: nx_int = 5
79const NX_WS_CHAR_F_LAST_SEEN_MIN: nx_int = 6 // day_clock at last scene
80const NX_WS_CHAR_FIELDS: nx_int = 7
84const NX_WS_LOC_F_ID: nx_int = 0
85const NX_WS_LOC_F_SETTING_SEED: nx_int = 1
86const NX_WS_LOC_F_TIME_FIRST_SEEN: nx_int = 2
87const NX_WS_LOC_FIELDS: nx_int = 3
95const NX_WS_BEAT_NONE: nx_int = 0
96const NX_WS_BEAT_OUTFIT_CHANGE_OK: nx_int = 1
97const NX_WS_BEAT_LOCATION_CHANGE_OK: nx_int = 2
98const NX_WS_BEAT_BOTH_OK: nx_int = 3
99const NX_WS_BEAT_N_KINDS: nx_int = 4
117const NX_WS_BYTES: nx_int = 88 // 11 fields * 8

functions

62func nx_cont_verdict_is_valid(v: nx_int) -> nx_int
121func nx_world_alloc(universe_id: nx_int, parent_universe_id: nx_int,
called by 3: mainnx_world_branchmain calls 1: sys_mmap
146func nx_world_register_character(ws: *WorldState, id: nx_int,
called by 2: mainmain
165func nx_world_register_location(ws: *WorldState, id: nx_int,
called by 2: mainmain
179func nx_world_find_character_slot(ws: *WorldState, char_id: nx_int) -> nx_int
189func nx_world_get_char_field(ws: *WorldState, char_id: nx_int,
called by 1: main calls 1: nx_world_find_character_slot
202func nx_world_arm_beat(ws: *WorldState, kind: nx_int) -> nx_int
212func _ws_beat_permits_outfit(beat: nx_int) -> nx_int
called by 1: nx_continuity_check
218func _ws_beat_permits_location(beat: nx_int) -> nx_int
called by 1: nx_continuity_check
233func nx_continuity_check(ws: *WorldState, dn: *DirectorsNote) -> nx_int
270func nx_world_commit_scene(ws: *WorldState, dn: *DirectorsNote,
297func nx_world_branch(parent: *WorldState, new_universe_id: nx_int) -> *WorldState
called by 1: main calls 1: nx_world_alloc