nx_entity_pin.nx source
↩ module page · 46 lines · 2164 B
1// nx_entity_pin.nx -- ENTITY PIN PROJECTION, the program (S11, 2026-09-17). See nx_entity_pin_lib.nx for the why.
2//
3// usage: nx_entity_pin [dir=<status-prefix>] <entity name> [<entity name> ...]
4//
5// dir= is a PATH PREFIX (default knowledge/status/), so a gate can point it at a fixture prefix; nx_entity_dossier
6// writes <prefix>dossier-<slug>.txt and this program upserts <prefix>entitypin.tsv, the ONE table the search ranker
7// reads (nx_docportal_search_seg, S11). The plan that closes an operator REJECT is two rows:
8// 1 nx_entity_dossier <name> (resolve the alias to the canonical landing, write the dossier)
9// 2 nx_entity_pin <name> (project it into the served table; the ranker reloads on the next query)
10// Exit 0 with every outcome receipted (PIN / MISSING / UNRESOLVED per name, ENTITYPIN totals last); exit 2 = usage.
11// license_tier: ORIGINAL
12import "nx_syscalls.nx"
13import "nx_entity_pin_lib.nx"
14
15const EPM_STATUS_DEFAULT: *u8 = "knowledge/status/"
16const EPM_DIR_KEY: *u8 = "dir="
17const EPM_EXIT_USAGE: i64 = 2
18
19func epm_starts(s: *u8, pfx: *u8) -> i64 { var i: i64 = 0; while pfx[i] != (0 as u8) { if s[i] != pfx[i] { return 0 } i = i + 1 } return 1 }
20
21func main(argc: i64, argv: *i64) -> i64 {
22 if argc < 2 {
23 ep_puts("usage: nx_entity_pin [dir=<status-prefix>] <entity name> [<entity name> ...]\n" as *u8)
24 sys_exit_group(EPM_EXIT_USAGE)
25 return EPM_EXIT_USAGE
26 }
27 var prefix: *u8 = EPM_STATUS_DEFAULT
28 let names: *i64 = sys_mmap(argc * 8) as *i64
29 var nnames: i64 = 0
30 var a: i64 = 1
31 while a < argc {
32 let s: *u8 = argv[a] as *u8
33 if epm_starts(s, EPM_DIR_KEY) == 1 { prefix = ((s as i64) + ep_slen(EPM_DIR_KEY)) as *u8 }
34 else { names[nnames] = s as i64; nnames = nnames + 1 }
35 a = a + 1
36 }
37 if nnames == 0 {
38 ep_puts("usage: nx_entity_pin [dir=<status-prefix>] <entity name> [<entity name> ...]\n" as *u8)
39 sys_exit_group(EPM_EXIT_USAGE)
40 return EPM_EXIT_USAGE
41 }
42 let counts: *i64 = sys_mmap(EP_C_N * 8) as *i64
43 ep_project(prefix, names, nnames, counts)
44 sys_exit_group(0)
45 return 0
46}