code wiki / _hdl_build / nx_sitededup_lib.nx

nx_sitededup_lib.nx

buildroot/runtime/_hdl_build/nx_sitededup_lib.nx

11680 B220 linesdepth 5pulls 8 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_sitededup_lib.nx -- THE ONE COPY OF THE NEAR-DUPLICATE COLLAPSE DECISION. module: nishi-core.search.sitededup capability: CORE_COMPUTE (pure; reads a conf, touches no store, writes no file) license_tier: ORIGINAL No hw writes (Rule 26). WHY A LIB AND NOT A FUNCTION INSIDE THE ACTUATOR: the actuator suppresses rows in a LIVE production shard and the gate proves the decision is correct. If each held its own copy of the rule they could disagree, and the one that ships is the one nobody proved. There is exactly one clusterer here, and both import it -- disagreement is impossible by construction. COMPOSES nx_simhash (Charikar STOC 2002 fingerprint, Manku WWW 2007 threshold). It does NOT contain a second fingerprinting ruler and must never grow one. The TEXT handed to that fingerprint is normalised by nx_textnorm_lib, which is likewise a single shared copy: the clusterer never sees raw bytes and never decides what normalisation means. ---- THE TRANSITIVITY HAZARD, HANDLED RATHER THAN ASSUMED ------------------------------- Near-duplication is NOT transitive: a~b and b~c does not give a~c. So a connected component of the near-dup graph can be a CHAIN whose endpoints are genuinely different documents, and collapsing it onto one survivor would suppress a document that is not a near-duplicate of anything left searchable -- i.e. it would DELETE INFORMATION, which is the one outcome this organ exists to avoid. The fix is not to hope chains are rare. sdd_mark_chained MEASURES every component's diameter (its widest internal pair) and any component wider than the threshold is marked UNSAFE and left ENTIRELY ALONE -- every member stays searchable. The organ abstains on exactly the cases it cannot justify, and reports how many. Abstain, never acquit; and here, abstain rather than destroy. The survivor of a safe component is therefore always within `k` bits of EVERY doc it replaces, which is the property that makes suppression defensible at all. DETERMINISM: union-by-lowest-cid means a component's root is its globally minimum cid no matter what order the unions happen in. Two runs over the same shard pick the same survivor, so the pass is idempotent and re-runnable -- it can never flip-flop and eat the corpus.

dependencies 3 imports · 2 importers

nx_syscalls.nx nx_simhash.nx nx_lineconf_lib.nx nx_sitededup_lib.nx nx_sitededup.nx nx_sitededup_gate.nx

imports: nx_syscalls.nxnx_simhash.nxnx_lineconf_lib.nx

imported by: nx_sitededup.nxnx_sitededup_gate.nx

structs

none

consts

39const SDD_HIST: i64 = 17
40const SDD_BITS: i64 = 64

functions

52func sdd_confpath() -> *u8 { return "knowledge/sitededup.conf" as *u8 }
53func sdd_confpath_up() -> *u8 { return "../knowledge/sitededup.conf" as *u8 }
57func sdd_conf_int(key: *u8) -> i64
64func sdd_conf_which() -> i64
69func sdd_conf_k() -> i64 { return sdd_conf_int("hamming_max" as *u8) }
called by 2: mainmain calls 1: sdd_conf_int
70func sdd_conf_maxdocs() -> i64 { return sdd_conf_int("max_docs" as *u8) }
called by 2: mainmain calls 1: sdd_conf_int
71func sdd_conf_showrows() -> i64 { return sdd_conf_int("show_rows" as *u8) }
called by 1: main calls 1: sdd_conf_int
72func sdd_conf_missing(v: i64) -> i64 { if v == LCF_MISS { return 1 } return 0 }
called by 2: mainmain
83func sdd_set_add(tab: *i64, mask: i64, cid: i64) -> i64
called by 2: mainmain
96func sdd_find(parent: *i64, x0: i64) -> i64
101func sdd_union(parent: *i64, cids: *i64, a: i64, b: i64) -> i64
called by 1: sdd_cluster calls 1: sdd_find
118func sdd_cluster(cids: *i64, fps: *i64, n: i64, k: i64, parent: *i64, hist: *i64, eparent: *i64) -> i64
145func sdd_mark_chained(fps: *i64, n: i64, k: i64, parent: *i64, unsafe_of: *i64) -> i64
called by 2: mainmain calls 2: sdd_findnx_simhash_hamming
190func sdd_is_suppressed(i: i64, parent: *i64, unsafe_of: *i64, eparent: *i64) -> i64
called by 2: mainmain calls 1: sdd_find
202func sdd_survivor_of(i: i64, parent: *i64, unsafe_of: *i64, eparent: *i64) -> i64
called by 2: mainmain calls 1: sdd_find
210func sdd_permil(part: i64, whole: i64) -> i64
called by 2: mainmain
219func sdd_clear_search_bit(flags: i64) -> i64 { return flags - (flags & 1) }
called by 2: mainmain
220func sdd_search_allowed(flags: i64) -> i64 { if (flags & 1) == 1 { return 1 } return 0 }
called by 2: mainmain