code wiki / (root) / nx_narrative_ingest.nx

nx_narrative_ingest.nx

buildroot/runtime/nx_narrative_ingest.nx

19222 B530 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind orphan library
docsdependenciesstructsconstsfunctions

about

nx_narrative_ingest.nx -- DEPRECATED in favor of nx_text_ingest.nx. >>> NEW CODE: import "nx_text_ingest.nx" and call nx_text_ingest(db, media_id). >>> Targets the canonical media-agnostic StoryBeat schema >>> (nx_storybeat.nx + nx_storydb.nx + nx_media_pool.nx). >>> >>> This file is kept in tree only to avoid breaking any in-flight >>> dependents from the concurrent-agent edit window 2026-05-16/17. >>> Remove after audit that no consumer remains. ----- ORIGINAL HEADER BELOW (predates the multi-media schema) ----- Foundation S-class ingester following the proven nx_coq_ingest / nx_lean_ingest / nx_rfc_ingest pattern. Takes raw story text (literotica chapter, hentai script, novel excerpt, fan-fic, etc.) and parses it into a structured StoryDb of scenes + paragraphs + beats that downstream extractors / arc recognizers / director pipelines can consume. Scope of THIS file: structural ingestion only. No NLP / no semantic extraction / no domain tagging / no arc recognition. That's the next layer (nx_story_element_extract.nx, nx_story_beat_extract.nx, nx_plot_arc_recognize.nx). Why structural-first: the same prose-tree shape works for ANY narrative source. Browser-driven URL fetch, manual paste, voice dictation, file-system batch -- all converge here. Sources expected: * URL via nishi-browser fetch (Phase 7) * Manual paste (user pastes chapter text) * Voice/conversation ("ingest this scene for me") * Batch (directory of .txt files) Substrate-native: no AI, no external network, no libc. Uses canonical nx_lex / nx_ascii / nx_syscalls per cardinals. genealogy_id: wiedijk_qed_1994 (the unified-ingestion vision) + propp_morphology_1928 (narrative structure roots) lineage_id: formal_statement_parsing -> narrative_prose_parsing

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_lex.nx nx_ascii.nx nx_narrative_ingest.nx

imports: nx_syscalls.nxnx_lex.nxnx_ascii.nx

imported by: nobody (leaf or entry point)

structs

105struct StoryBeat
121struct StoryScene
131struct StoryChapter
148struct StoryDb

consts

91const NX_NARR_BEAT_UNKNOWN: i64 = 0 // not yet classified
92const NX_NARR_BEAT_NARRATION: i64 = 1 // pure prose paragraph
93const NX_NARR_BEAT_DIALOGUE: i64 = 2 // contains quoted speech
94const NX_NARR_BEAT_ACTION: i64 = 3 // short, verb-heavy
95const NX_NARR_BEAT_DESCRIPTION: i64 = 4 // long, adjective-heavy
96const NX_NARR_BEAT_TRANSITION: i64 = 5 // scene-break marker (***, ---)
97const NX_NARR_BEAT_HEADING: i64 = 6 // chapter/section title
117const NX_NARR_BEAT_BYTES: i64 = 72
129const NX_NARR_SCENE_BYTES: i64 = 40
140const NX_NARR_CHAPTER_BYTES: i64 = 48
144const NX_NARR_MAX_BEATS: i64 = 65536 // ~65k paragraphs / chapter book
145const NX_NARR_MAX_SCENES: i64 = 4096
146const NX_NARR_MAX_CHAPTERS: i64 = 256

functions

165func nx_narr_db_alloc(src: *u8, src_len: i64) -> *StoryDb
called by 1: nx_narr_ingest calls 1: sys_mmap
182func nx_narr_beat_at(db: *StoryDb, i: i64) -> *StoryBeat
called by 1: nx_narr_emit_beat
186func nx_narr_scene_at(db: *StoryDb, i: i64) -> *StoryScene
called by 1: nx_narr_ingest
190func nx_narr_chapter_at(db: *StoryDb, i: i64) -> *StoryChapter
called by 1: nx_narr_ingest
203func nx_narr_is_scene_break(src: *u8, pos: i64, len: i64) -> i64
called by 1: nx_narr_ingest
235func nx_narr_is_heading(src: *u8, pos: i64, len: i64) -> i64
called by 1: nx_narr_ingest
255func nx_narr_advance_line(src: *u8, pos: *i64, len: i64) -> i64
266func nx_narr_skip_blank_lines(src: *u8, pos: *i64, len: i64) -> i64
called by 1: nx_narr_ingest
306func nx_narr_emit_beat(db: *StoryDb, kind: i64, start: i64, end: i64,
343func nx_narr_ingest(src: *u8, src_len: i64) -> *StoryDb