nx_entity_pin_lib.nx
buildroot/runtime/nx_entity_pin_lib.nx
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
imports: nx_syscalls.nx
imported by: nx_entity_pin.nxnx_entity_pin_gate.nx
structs
| none |
consts
| 19 | const EP_DOSSIER_PREFIX: *u8 = "dossier-" |
| 20 | const EP_DOSSIER_EXT: *u8 = ".txt" |
| 21 | const EP_TSV_NAME: *u8 = "entitypin.tsv" |
| 22 | const EP_PATH_CAP: i64 = 1024 |
| 23 | const EP_FIELD_CAP: i64 = 512 |
| 24 | const EP_LINE_CAP: i64 = 2048 // one row: six fields, the url the longest (EP_FIELD_CAP), never more |
| 25 | const EP_STAT_BYTES: i64 = 256 |
| 26 | const EP_STAT_SIZE_OFF: i64 = 48 |
| 27 | const EP_READ_CHUNK: i64 = 65536 |
| 28 | const EP_FILE_MODE: i64 = 420 // 0644 |
| 29 | const EP_C_ROWS: i64 = 0 |
| 30 | const EP_C_PINNED: i64 = 1 |
| 31 | const EP_C_MISSING: i64 = 2 |
| 32 | const EP_C_UNRESOLVED: i64 = 3 |
| 33 | const EP_C_N: i64 = 4 |
| 34 | const EP_CH_TAB: i64 = 9 |
| 35 | const EP_CH_NL: i64 = 10 |
| 36 | const EP_CH_CR: i64 = 13 |
| 37 | const EP_CH_SPACE: i64 = 32 |
| 38 | const EP_CH_QUOTE: i64 = 34 |
| 39 | const EP_CH_MINUS: i64 = 45 |
| 40 | const EP_CH_ZERO: i64 = 48 |
| 41 | const EP_CH_NINE: i64 = 57 |
| 42 | const EP_CH_A: i64 = 65 |
| 43 | const EP_CH_Z: i64 = 90 |
| 44 | const EP_CH_LA: i64 = 97 |
| 45 | const EP_CH_LZ: i64 = 122 |
| 46 | const EP_CH_UPPER_TO_LOWER: i64 = 32 |
| 47 | const EP_TEN: i64 = 10 |
functions
| 49 | func ep_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 50 | func 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 } |
| 51 | func ep_catn(d: *u8, o: i64, v: i64) -> i64 |
| 63 | func 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 |
| 64 | func ep_alnum(c: i64) -> i64 called by 1: ep_norm |
| 70 | func ep_norm(name: *u8, dst: *u8, cap: i64) -> i64 |
| 86 | func ep_slug(name: *u8, dst: *u8, cap: i64) -> i64 |
| 93 | func ep_read(path: *u8, lenout: *i64) -> *u8 called by 2: pg_table_countep_project calls 6: sys_openat_rdsys_mmapsys_fstat_fdsys_munmapsys_readsys_close |
| 118 | func ep_free(buf: *u8, n: i64) -> i64 { if (buf as i64) != 0 { sys_munmap(buf, n + 1) } return 0 } |
| 120 | func ep_find(buf: *u8, n: i64, needle: *u8) -> i64 |
| 134 | func ep_num_at(buf: *u8, n: i64, off: i64) -> i64 called by 1: ep_row_from_dossier |
| 150 | func ep_str_at(buf: *u8, n: i64, off: i64, dst: *u8, cap: i64) -> i64 called by 1: ep_row_from_dossier |
| 170 | func ep_puts(s: *u8) -> i64 { sys_write(1, s, ep_slen(s)); return 0 } |
| 171 | func 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 } |
| 173 | func ep_row_has_key(buf: *u8, n: i64, off: i64, key: *u8) -> i64 called by 1: ep_project |
| 181 | func ep_row_from_dossier(dbuf: *u8, dn: i64, key: *u8, asof: i64, rowbuf: *u8) -> i64 |
| 217 | func ep_project(prefix: *u8, names: *i64, nnames: i64, counts: *i64) -> i64 |