nx_field_seedgen_lib.nx
buildroot/runtime/nx_field_seedgen_lib.nx
about
nx_field_seedgen_lib.nx -- THE DECISION CORE OF THE SEED GENERATOR (/compare/fieldwatch fleet campaign, 2026-09-05).
A domain's DECLARED population already exists on its board: the @cols rivals of <dom>.matrix, whose pages are already
mirrored and pinned as <dom>.refs rows. This lib turns those two data files into <dom>.seeds rows of kind `named`, one
per column that a refs row names, so every domain inherits a field on the next fieldbeat without a seat authoring URLs
by hand -- and it NEVER invents a URL: a column no refs row names is emitted as an UNSOURCED comment, counted, announced.
Discovery seeds (wiki-raw, gh-topic, md-list) stay hand-curated per domain; a derived file carries a marker line so the
generator only ever rewrites its own output and refuses a hand-authored file. Pure functions over buffers; the program
owns the reads and the write. Byte helpers come from the beat lib (one slen, one puts, one putn in this family).
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 2 imports · 2 importers
imports: nx_syscalls.nxnx_field_beat_lib.nx
imported by: nx_field_seedgen.nxnx_field_seedgen_gate.nx
structs
| none |
consts
| 13 | const SG_MAX_COLS: i64 = 16 // nx_compare_rank parses @cols with maxf=8; 16 is twice that so a wide board is never cut here |
| 14 | const SG_TOK_CAP: i64 = 48 |
| 15 | const SG_MAX_TOKS: i64 = 12 |
| 16 | const SG_TOK_MIN: i64 = 3 // shorter runs (4, 5, io) match everything and name nothing |
| 17 | const SG_SCORE_URL: i64 = 2 |
| 18 | const SG_SCORE_CITE: i64 = 1 |
| 19 | const SG_SCORE_MIN: i64 = 2 // one url hit, or two prose hits: a single word in a citation is not a member |
| 20 | const SG_SLUG_CAP: i64 = 16 |
| 21 | const SG_REF_F: i64 = 9 |
| 22 | const SG_F_KEY: i64 = 1 |
| 23 | const SG_F_CITE: i64 = 2 |
| 24 | const SG_F_URL: i64 = 3 |
| 25 | const SG_F_MIRROR: i64 = 4 // the seat's own declaration of what was fetched: a mirror banked as .img/.png/.pdf is an asset, whatever the url looks like |
| 26 | const SG_CH_PIPE: i64 = 124 |
| 27 | const SG_CH_A: i64 = 97 |
| 28 | const SG_CH_Z: i64 = 122 |
| 29 | const SG_CH_AU: i64 = 65 |
| 30 | const SG_CH_ZU: i64 = 90 |
| 31 | const SG_CH_0: i64 = 48 |
| 32 | const SG_CH_9: i64 = 57 |
| 33 | const SG_CASE_GAP: i64 = 32 |
| 34 | const SG_COLS_PFX: *u8 = "@cols " |
| 35 | const SG_MARKER: *u8 = " SEEDGEN-MARKER regenerable: rewritten by nx_field_seedgen while this line stands" |
| 36 | const SG_CLASS_GENERATED: i64 = 1 |
| 37 | const SG_CLASS_HAND: i64 = 2 // an existing seeds file without the marker: a seat curated it, never touched |
| 38 | const SG_CLASS_NO_MATRIX: i64 = 3 |
| 39 | const SG_CLASS_NO_COLS: i64 = 4 |
| 40 | const SG_CLASS_NO_SOURCED: i64 = 5 // every column unsourced: nothing written, so the beat keeps skipping the domain cleanly |
| 41 | const SG_CLASS_UNWRITABLE: i64 = 6 |
| 42 | const SG_CLASS_N: i64 = 7 |
functions
| 44 | func sg_lower(c: i64) -> i64 { if c >= SG_CH_AU { if c <= SG_CH_ZU { return c + SG_CASE_GAP } } return c } |
| 45 | func sg_is_alnum(c: i64) -> i64 called by 1: sg_tokens |
| 51 | func sg_putspan(fd: i64, b: *u8, s: i64, e: i64) -> i64 { if e > s { sys_write(fd, ((b as i64) + s) as *u8, e - s) } return 0 } |
| 52 | func sg_tok_at(toks: *u8, i: i64) -> *u8 { return ((toks as i64) + i * SG_TOK_CAP) as *u8 } |
| 54 | func sg_is_stop(t: *u8) -> i64 |
| 93 | func sg_cols(b: *u8, n: i64, spans: *i64) -> i64 |
| 122 | func sg_tokens(b: *u8, s: i64, e: i64, toks: *u8) -> i64 |
| 147 | func sg_contains_ci(hay: *u8, hs: i64, he: i64, tok: *u8) -> i64 |
| 161 | func sg_score(b: *u8, us: i64, ue: i64, cs: i64, ce: i64, toks: *u8, ntok: i64) -> i64 |
| 173 | func sg_url_is_page(b: *u8, s: i64, e: i64) -> i64 |
| 194 | func sg_mirror_is_page(refs: *u8, fs: *i64, nf: i64) -> i64 |
| 199 | func sg_url_ends(b: *u8, s: i64, e: i64, ext: *u8) -> i64 |
| 208 | func sg_pick(refs: *u8, n: i64, toks: *u8, ntok: i64, out: *i64) -> i64 |
| 235 | func sg_is_derived(b: *u8, n: i64) -> i64 |
| 241 | func sg_class_name(c: i64) -> *u8 called by 1: main |
| 249 | func sg_hash(fd: i64) -> i64 { let h: *u8 = sys_mmap(1); h[0] = FB_CH_HASH as u8; sys_write(fd, h, 1); return 0 } |
| 251 | func sg_emit(fd: i64, dom: *u8, ts: i64, mx: *u8, spans: *i64, ncols: i64, refs: *u8, rn: i64, counts: *i64) -> i64 |