nx_storydb.nx
buildroot/runtime/nx_storydb.nx
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
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
| 49 | struct StoryScene |
| 67 | struct StoryChapter |
| 85 | struct StoryDb |
consts
| 41 | const NX_MAGIC_1024: i64 = 1024 |
| 60 | const NX_STORYSCENE_BYTES: i64 = 64 |
| 76 | const NX_STORYCHAPTER_BYTES: i64 = 48 |
| 80 | const NX_STORYDB_BEATS_CAP: i64 = 65536 // 8 MiB worth of beats |
| 81 | const NX_STORYDB_SCENES_CAP: i64 = 4096 |
| 82 | const NX_STORYDB_CHAPTERS_CAP: i64 = 256 |
| 83 | const NX_STORYDB_SUMMARY_CAP: i64 = 1048576 // 1 MiB summary text |
| 105 | const NX_STORYDB_BYTES: i64 = 120 |
functions
| 109 | func nx_storydb_alloc_sized(beats_cap: i64, scenes_cap: i64, |
| 141 | func nx_storydb_alloc() -> *StoryDb |
| 147 | func nx_storydb_beat_at(db: *StoryDb, i: i64) -> *StoryBeat |
| 151 | func nx_storydb_scene_at(db: *StoryDb, i: i64) -> *StoryScene |
| 155 | func nx_storydb_chapter_at(db: *StoryDb, i: i64) -> *StoryChapter |
| 162 | func nx_storydb_push_beat(db: *StoryDb, beat_kind: i64, media_type: i64, |
| 175 | func nx_storydb_open_scene(db: *StoryDb, beat_first: i64, |
| 193 | func nx_storydb_close_scene(db: *StoryDb, scene_id: i64, beat_last: i64) |
| 200 | func nx_storydb_open_chapter(db: *StoryDb, scene_first: i64, |
| 215 | func nx_storydb_close_chapter(db: *StoryDb, chapter_id: i64, |
| 225 | func nx_storydb_load_u8(p: *u8, i: i64) -> i64 called by 1: nx_storydb_intern_summary |
| 230 | func nx_storydb_store_u8(p: *u8, i: i64, v: i64) called by 1: nx_storydb_intern_summary |
| 241 | func nx_storydb_intern_summary(db: *StoryDb, s: *u8, n: i64) -> i64 |