nx_term_cooccur.nx
buildroot/runtime/nx_term_cooccur.nx
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
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
| 61 | struct CooccurPair |
| 78 | struct Cooccur |
consts
| 52 | const NX_COOCCUR_GROUP_BEAT: i64 = 1 |
| 53 | const NX_COOCCUR_GROUP_SCENE: i64 = 2 |
| 57 | const NX_COOCCUR_PROMOTE_N: i64 = 5 |
| 70 | const NX_COOCCUR_PAIR_BYTES: i64 = 48 |
| 74 | const NX_COOCCUR_DEFAULT_CAP: i64 = 65536 |
| 75 | const NX_COOCCUR_PROBE_LIMIT: i64 = 64 |
| 76 | const NX_COOCCUR_PER_GROUP_TERMS_MAX: i64 = 64 |
| 84 | const NX_COOCCUR_BYTES: i64 = 24 |
functions
| 88 | func nx_cooccur_alloc_sized(cap: i64) -> *Cooccur |
| 99 | func nx_cooccur_alloc() -> *Cooccur |
| 103 | func nx_cooccur_pair_at(co: *Cooccur, i: i64) -> *CooccurPair |
| 109 | func nx_cooccur_make_key(a: i64, b: i64) -> i64 called by 1: nx_cooccur_observe |
| 115 | func nx_cooccur_mix(k: i64) -> i64 called by 1: nx_cooccur_observe |
| 130 | func nx_cooccur_observe(co: *Cooccur, a: i64, b: i64, |
| 171 | func nx_cooccur_observe_group(co: *Cooccur, term_ids: *i64, |
| 210 | func nx_cooccur_observe_db(co: *Cooccur, db: *StoryDb) -> i64 called by 5: mainmainbuild_indexmainmain calls 3: sys_mmapnx_storydb_beat_atnx_cooccur_observe_group |
| 239 | func nx_cooccur_top_k(co: *Cooccur, out: *CooccurPair, k: i64) -> i64 |