nx_ingest_scene.nx
buildroot/runtime/nx_ingest_scene.nx
about
nx_ingest.nx -- WRITING arc, rung W-ING-1 (X-WRITE-ING-001): the content-agnostic
SCENE / ENTITY EXTRACTOR -- the ingestion point that turns generated prose into
reusable structured DATA for the companion (elder-ai) + image-gen. Per the
2026-06-12 fiction-ingestion seam, this is engine PLUMBING: register-blind, so
the SFW lane and the operator's local-LLM explicit lane run the SAME organ.
ROSTER-BASED + DETERMINISTIC (no LLM in the loop): the caller supplies the
character bible (a packed list of names); the extractor finds, per scene, who
is present and how strongly. That is exactly what image-gen needs (render the
characters present; the focus character is the subject) and what the companion
needs (who is in which scene, dialogue density).
REAL-TIME == PRIOR: the extractor is a pure function of (text, roster). Running
it on each scene as the LLM finishes it (streaming) yields byte-identical scene
records to running it once on the whole work (batch). The gate proves this.
Scene break = a blank line (>=2 consecutive '\n'). Character match = WHOLE-WORD,
case-insensitive ("Yuki" does NOT match inside "Yukiko"); a trailing apostrophe
is a boundary so possessives ("Kenji's") count as a mention. Marker breaks
(***, # heading) and a descriptor/outfit/setting lexicon are the next layers
(DATA-driven, rule 25) and ride on this same per-scene structure.
out[] layout, per scene s (stride = 5 + nnames; caller allocates
>= maxsc*(5+nnames) i64):
out[base+0] = char start (absolute in the buffer passed)
out[base+1] = char end (exclusive)
out[base+2] = dialogue segments (count of double-quote pairs)
out[base+3] = focus character index (most mentions; -1 if none present)
out[base+4] = total mentions across all roster names
out[base+5+k] = mentions of roster name k
ig_extract returns the scene count (capped at maxsc).
Pure integer, NO syscalls. Reuses nx_writecraft for char classification (DRY).
license_tier: ORIGINAL
module: nishi-core.write.ingest
depends: nishi-core.write.craft
capability: WRITE_SCENE_EXTRACT
dependencies 1 imports · 6 importers
imports: nx_writecraft.nx
imported by: nx_conflict.nxnx_descriptor.nxnx_emit.nxnx_ingest_gate.nxnx_register.nxnx_write_exceed_gate.nx
structs
| none |
consts
| none |
functions
| 42 | func ig_name_off(names: *u8, k: i64) -> i64 |
| 54 | func ig_match_at(t: *u8, pos: i64, nlim: i64, names: *u8, off: i64) -> i64 |
| 72 | func ig_count_name_in(t: *u8, a: i64, b: i64, names: *u8, off: i64) -> i64 called by 6: cf_detectdx_profileem_append_presentem_image_prompt_focusig_close_scenerg_score calls 1: ig_match_at |
| 89 | func ig_close_scene(t: *u8, a: i64, b: i64, names: *u8, nnames: i64, out: *i64, sc: i64) -> i64 |
| 125 | func ig_extract(t: *u8, n: i64, names: *u8, nnames: i64, out: *i64, maxsc: i64) -> i64 |