code wiki / (root) / nx_entity_pin_lib.nx

nx_entity_pin_lib.nx

buildroot/runtime/nx_entity_pin_lib.nx

14065 B319 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind librarytopic entity
docsdependenciesstructsconstsfunctions

about

nx_entity_pin_lib.nx -- ENTITY PIN PROJECTION (S11, 2026-09-17): the decision core nx_entity_pin and its gate share. WHY. Operator REJECT 2026-09-16 ("i just tried julia kyoka on nishifamily.com/search and it still isnt very good results"): the canonical entity page (the javdatabase idol page) was in the ranker's candidate set but says JULIA, so a token scorer put albums and three results pages above it. The estate ALREADY resolves the alias: nx_entity_dossier picks the canonical landing out of the same search and writes knowledge/status/dossier-<slug>.txt with the card. What was missing is the wire: this lib projects those resolutions into ONE served table the ranker reads, <status-prefix>entitypin.tsv rows <query>\t<cid>\t<url>\t<jp>\t<authority>\t<asof>\n (query = the entity name lowercased, single-spaced; cid = the landing document; a truncate-write that keeps every other row). The ranker (nx_docportal_search_seg, S11) loads the table once and reloads it when its size or mtime moves, and pins the cid to the top band for that exact query. NO third-party format, NO plane read per query. CONTRACT. ep_project(prefix, names, nnames, counts): for each name, read <prefix>dossier-<slug>.txt; a missing file is MISSING (counts[EP_C_MISSING]), found:false is UNRESOLVED (counts[EP_C_UNRESOLVED]), otherwise the row is upserted (counts[EP_C_PINNED]); counts[EP_C_ROWS] is the table's row count after the write. Every outcome prints a receipt line naming the entity, so a caller can never mistake "nothing pinned" for "pinned". license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_entity_pin_lib.nx nx_entity_pin.nx nx_entity_pin_gate.nx

imports: nx_syscalls.nx

imported by: nx_entity_pin.nxnx_entity_pin_gate.nx

structs

none

consts

19const EP_DOSSIER_PREFIX: *u8 = "dossier-"
20const EP_DOSSIER_EXT: *u8 = ".txt"
21const EP_TSV_NAME: *u8 = "entitypin.tsv"
22const EP_PATH_CAP: i64 = 1024
23const EP_FIELD_CAP: i64 = 512
24const EP_LINE_CAP: i64 = 2048 // one row: six fields, the url the longest (EP_FIELD_CAP), never more
25const EP_STAT_BYTES: i64 = 256
26const EP_STAT_SIZE_OFF: i64 = 48
27const EP_READ_CHUNK: i64 = 65536
28const EP_FILE_MODE: i64 = 420 // 0644
29const EP_C_ROWS: i64 = 0
30const EP_C_PINNED: i64 = 1
31const EP_C_MISSING: i64 = 2
32const EP_C_UNRESOLVED: i64 = 3
33const EP_C_N: i64 = 4
34const EP_CH_TAB: i64 = 9
35const EP_CH_NL: i64 = 10
36const EP_CH_CR: i64 = 13
37const EP_CH_SPACE: i64 = 32
38const EP_CH_QUOTE: i64 = 34
39const EP_CH_MINUS: i64 = 45
40const EP_CH_ZERO: i64 = 48
41const EP_CH_NINE: i64 = 57
42const EP_CH_A: i64 = 65
43const EP_CH_Z: i64 = 90
44const EP_CH_LA: i64 = 97
45const EP_CH_LZ: i64 = 122
46const EP_CH_UPPER_TO_LOWER: i64 = 32
47const EP_TEN: i64 = 10

functions

49func ep_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
50func ep_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; var p: i64 = o; while s[i] != (0 as u8) { d[p] = s[i]; p = p + 1; i = i + 1 } return p }
51func ep_catn(d: *u8, o: i64, v: i64) -> i64
63func ep_lower(c: i64) -> i64 { if c >= EP_CH_A { if c <= EP_CH_Z { return c + EP_CH_UPPER_TO_LOWER } } return c }
called by 1: ep_norm
64func ep_alnum(c: i64) -> i64
called by 1: ep_norm
70func ep_norm(name: *u8, dst: *u8, cap: i64) -> i64
called by 2: ep_slugep_project calls 2: ep_lowerep_alnum
86func ep_slug(name: *u8, dst: *u8, cap: i64) -> i64
called by 1: ep_project calls 1: ep_norm
93func ep_read(path: *u8, lenout: *i64) -> *u8
118func ep_free(buf: *u8, n: i64) -> i64 { if (buf as i64) != 0 { sys_munmap(buf, n + 1) } return 0 }
called by 2: pg_table_countep_project calls 1: sys_munmap
120func ep_find(buf: *u8, n: i64, needle: *u8) -> i64
called by 1: ep_row_from_dossier calls 1: ep_slen
134func ep_num_at(buf: *u8, n: i64, off: i64) -> i64
called by 1: ep_row_from_dossier
150func ep_str_at(buf: *u8, n: i64, off: i64, dst: *u8, cap: i64) -> i64
called by 1: ep_row_from_dossier
170func ep_puts(s: *u8) -> i64 { sys_write(1, s, ep_slen(s)); return 0 }
called by 2: mainep_project calls 2: sys_writeep_slen
171func ep_putn(v: i64) -> i64 { let t: *u8 = sys_mmap(32); let k: i64 = ep_catn(t, 0, v); sys_write(1, t, k); sys_munmap(t, 32); return 0 }
173func ep_row_has_key(buf: *u8, n: i64, off: i64, key: *u8) -> i64
called by 1: ep_project
181func ep_row_from_dossier(dbuf: *u8, dn: i64, key: *u8, asof: i64, rowbuf: *u8) -> i64
217func ep_project(prefix: *u8, names: *i64, nnames: i64, counts: *i64) -> i64