code wiki / (root) / nx_term_cooccur.nx

nx_term_cooccur.nx

buildroot/runtime/nx_term_cooccur.nx

11853 B329 linesdepth 4pulls 6 transitivereach 9 importersview sourcekind librarytopic term
docsdependenciesstructsconstsfunctions

about

nx_term_cooccur.nx -- pairwise term co-occurrence counts. Tracks how often every (term_a, term_b) pair appears together within the same beat (or, optionally, within the same scene). Foundation for arc-anchor discovery: the most-common (OUTFIT + LOCATION) pair in a corpus is a candidate "scene anchor" that the director-initiative layer can surface as a recurring motif. Per cardinals: feedback-self-surfacing-intelligence: Counts are LIVE measurements; STAGE2 promotion of a pair to an arc-anchor proposal happens at NX_COOCCUR_PROMOTE_N (5) joint sightings with 0 user dismissals. feedback-loras-and-negatives-are-patches: Pure integer counts; no opaque embedding distance. Auditable. feedback-user-owns-every-bit: Snapshots to nishi-library only via explicit caller request. Storage: bounded open-addressing hash table keyed by the canonical pair-key (term_a << 32 | term_b) with term_a < term_b enforced at insertion. Cap defaults to 65536 pairs; caller sizes via nx_cooccur_alloc_sized for larger corpora. nx_safety_envelope: intended_use: "Pairwise co-occurrence counts of registered terms within ingestion groupings (per-beat or per-scene)." sil_target: SIL2 asil_target: QM dal_target: DAL C iec_62304_class: NONE evidence: [no_floating_point, fixed_capacity_hash_table, bounded_probe_length_per_jpl_rule_2, canonical_pair_ordering_enforced, counts_are_monotonic_non_decreasing] hazard_register: [bug-tape-pair-key-hash-collision, bug-tape-overflow-returns-error, bug-tape-self-pair-silently-skipped] residual_risk: "Open-addressing probe limit caps recall on

dependencies 4 imports · 6 importers

nx_syscalls.nx nx_storybeat.nx nx_storydb.nx nx_term_registry.nx nx_term_cooccur.nx nx_arc_anchor.nx nx_arc_anchor_test.nx nx_caption_emit_test.nx nx_content_guard_test.nx nx_ingest_cli.nx nx_scene_index_test.nx

imports: nx_syscalls.nxnx_storybeat.nxnx_storydb.nxnx_term_registry.nx

imported by: nx_arc_anchor.nxnx_arc_anchor_test.nxnx_caption_emit_test.nxnx_content_guard_test.nxnx_ingest_cli.nxnx_scene_index_test.nx

structs

61struct CooccurPair
78struct Cooccur

consts

52const NX_COOCCUR_GROUP_BEAT: i64 = 1
53const NX_COOCCUR_GROUP_SCENE: i64 = 2
57const NX_COOCCUR_PROMOTE_N: i64 = 5
70const NX_COOCCUR_PAIR_BYTES: i64 = 48
74const NX_COOCCUR_DEFAULT_CAP: i64 = 65536
75const NX_COOCCUR_PROBE_LIMIT: i64 = 64
76const NX_COOCCUR_PER_GROUP_TERMS_MAX: i64 = 64
84const NX_COOCCUR_BYTES: i64 = 24

functions

88func nx_cooccur_alloc_sized(cap: i64) -> *Cooccur
called by 1: nx_cooccur_alloc calls 1: sys_mmap
99func nx_cooccur_alloc() -> *Cooccur
103func nx_cooccur_pair_at(co: *Cooccur, i: i64) -> *CooccurPair
109func nx_cooccur_make_key(a: i64, b: i64) -> i64
called by 1: nx_cooccur_observe
115func nx_cooccur_mix(k: i64) -> i64
called by 1: nx_cooccur_observe
130func nx_cooccur_observe(co: *Cooccur, a: i64, b: i64,
171func nx_cooccur_observe_group(co: *Cooccur, term_ids: *i64,
210func nx_cooccur_observe_db(co: *Cooccur, db: *StoryDb) -> i64
239func nx_cooccur_top_k(co: *Cooccur, out: *CooccurPair, k: i64) -> i64