code wiki / (root) / nx_storydb.nx

nx_storydb.nx

buildroot/runtime/nx_storydb.nx

8624 B252 linesdepth 3pulls 4 transitivereach 14 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_storydb.nx -- top-level container for ingested narrative. A StoryDb holds everything produced by an ingestion session: - beats arena (every StoryBeat across every medium) - scenes arena (groups of consecutive related beats) - chapters arena (groups of scenes that share arc context) - media_pool (raw bytes of every ingested item) - summary arena (string bytes for synopsis / extracted text) One StoryDb per ingestion session. Multiple sessions for the same user merge into the persistent corpus through nx_corpus_ (separate module, not built yet). All arenas are fixed-capacity append-only; downstream consumers hold cheap i64 indices, never pointers. See: docs/NISHI_MEDIA_INGESTION_ROADMAP.md nx_safety_envelope: intended_use: "Top-level container for one ingestion session. Holds beats / scenes / chapters / media-pool / summary-strings." sil_target: SIL2 asil_target: QM dal_target: DAL C iec_62304_class: NONE evidence: [no_floating_point, fixed_capacity_append_only_arenas, cheap_i64_indices_no_pointers_to_caller, media_pool_reference_indirected] hazard_register: [bug-tape-arena-overflow-silent, bug-tape-scene-spans-disjoint-from-beats] residual_risk: "Default caps may overflow on book-length ingestions; caller can request larger StoryDb via nx_storydb_alloc_sized." verdict: NOT_YET_EVALUATED

dependencies 3 imports · 13 importers

nx_syscalls.nx nx_storybeat.nx nx_media_pool.nx nx_storydb.nx nx_arc_anchor_test.nx nx_caption_emit.nx nx_caption_emit_test.nx nx_content_guard.nx nx_content_guard_test.nx nx_ingest_cli.nx nx_scene_index.nx nx_scene_index_test.nx nx_term_cooccur.nx nx_term_extract.nx

diagram shows first 10 each side; +0 more imports, +3 more importers in the complete lists below.

imports: nx_syscalls.nxnx_storybeat.nxnx_media_pool.nx

imported by: nx_arc_anchor_test.nxnx_caption_emit.nxnx_caption_emit_test.nxnx_content_guard.nxnx_content_guard_test.nxnx_ingest_cli.nxnx_scene_index.nxnx_scene_index_test.nxnx_term_cooccur.nxnx_term_extract.nxnx_term_extract_test.nxnx_text_ingest.nxnx_text_ingest_test.nx

structs

49struct StoryScene
67struct StoryChapter
85struct StoryDb

consts

41const NX_MAGIC_1024: i64 = 1024
60const NX_STORYSCENE_BYTES: i64 = 64
76const NX_STORYCHAPTER_BYTES: i64 = 48
80const NX_STORYDB_BEATS_CAP: i64 = 65536 // 8 MiB worth of beats
81const NX_STORYDB_SCENES_CAP: i64 = 4096
82const NX_STORYDB_CHAPTERS_CAP: i64 = 256
83const NX_STORYDB_SUMMARY_CAP: i64 = 1048576 // 1 MiB summary text
105const NX_STORYDB_BYTES: i64 = 120

functions

109func nx_storydb_alloc_sized(beats_cap: i64, scenes_cap: i64,
141func nx_storydb_alloc() -> *StoryDb
147func nx_storydb_beat_at(db: *StoryDb, i: i64) -> *StoryBeat
151func nx_storydb_scene_at(db: *StoryDb, i: i64) -> *StoryScene
155func nx_storydb_chapter_at(db: *StoryDb, i: i64) -> *StoryChapter
162func nx_storydb_push_beat(db: *StoryDb, beat_kind: i64, media_type: i64,
175func nx_storydb_open_scene(db: *StoryDb, beat_first: i64,
called by 1: nx_text_ingest calls 1: nx_storydb_scene_at
193func nx_storydb_close_scene(db: *StoryDb, scene_id: i64, beat_last: i64)
called by 1: nx_text_ingest calls 1: nx_storydb_scene_at
200func nx_storydb_open_chapter(db: *StoryDb, scene_first: i64,
215func nx_storydb_close_chapter(db: *StoryDb, chapter_id: i64,
225func nx_storydb_load_u8(p: *u8, i: i64) -> i64
230func nx_storydb_store_u8(p: *u8, i: i64, v: i64)
241func nx_storydb_intern_summary(db: *StoryDb, s: *u8, n: i64) -> i64