code wiki / _hdl_build / nx_tpl_ingest.nx
nx_tpl_ingest.nx
buildroot/runtime/_hdl_build/nx_tpl_ingest.nx
about
nx_tpl_ingest.nx -- R4 of the SITE FACTORY: consume the STRUCTURE/FLOW of open free web templates
(html5up / freewebsitetemplates / Figma-community exports / any HTML) into a sovereign, content-addressed
PATTERN CORPUS -- NOT their files or assets. For each template we extract only uncopyrightable IDEAS:
- the page ARCHETYPE (landing / ecommerce / social / media / resume / hub / brochure),
- the ORDERED SECTION SEQUENCE (information-architecture / layout flow, by first-occurrence offset),
- conversion-funnel signals + accessibility/responsive markers (feeds the award/ADA graders).
Each distinct (archetype, section-sequence) collapses to ONE corpus pattern via a deterministic key, so
"thousands of templates" become a COMPACT library of DISTINCT layout archetypes that R5 (nx_site_archetype)
selects + composes and nx_ui_judge/nx_ui_contrast measure. We emit OUR sovereign markup downstream; we never
redistribute a foreign template's bytes -- only the abstract structure (settled legal posture, site-factory R4).
BUDGET-GUARDED BY CONSTRUCTION ([[feedback-substrate-generators-must-have-budget-guard]]): declares an upfront
ceiling on templates examined AND corpus bytes, TRAPS FAIL-FAST at the ceiling (never runs unbounded), is
resumable (skip-if-present, both in-run and cross-run), and reports its footprint. This is exactly the
unbounded-generation anti-pattern that once produced the 70 GB waste incident -- it cannot recur here.
usage: nx_tpl_ingest <template-dir> [max_templates]
Composes the PROVEN writer mechanics of nx_corpus_ingest (fresh-segid batching, skip-if-present) over the
content-addressed seg_store. Pure sovereign string processing. license_tier: ORIGINAL
dependencies 1 imports · 4 importers
imports: nx_docportal_search_seg.nx
imported by: nx_site_archetype.nxnx_tpl_ingest_gate.nxnx_tpl_parts.nxnx_tpl_site.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 21 | const TI_MAGIC_1125899906842597: i64 = 1125899906842597 |
| 22 | const TI_MAGIC_131072: i64 = 131072 |
| 23 | const TI_MAGIC_1024: i64 = 1024 |
| 24 | const TI_MAGIC_5000: i64 = 5000 |
| 25 | const TI_MAGIC_67108864: i64 = 67108864 |
| 27 | const TI_ARCH_LANDING: i64 = 1 |
| 28 | const TI_ARCH_ECOM: i64 = 2 |
| 29 | const TI_ARCH_SOCIAL: i64 = 3 |
| 30 | const TI_ARCH_MEDIA: i64 = 4 |
| 31 | const TI_ARCH_RESUME: i64 = 5 |
| 32 | const TI_ARCH_HUB: i64 = 6 |
| 33 | const TI_ARCH_BROCHURE: i64 = 7 |
| 34 | const TI_ARCH_PORTFOLIO: i64 = 8 |
| 35 | const TI_ARCH_GALLERY: i64 = 9 |
| 36 | const TI_ARCH_BLOG: i64 = 10 |
| 38 | const TI_RAWCAP: i64 = 2097152 // 2 MiB largest template we read (guard vs absurd files) |
| 39 | const TI_MINDOC: i64 = 40 // below this = not a real template |
| 40 | const TI_SEENCAP: i64 = 20000 // in-run dedup memory (bounded) |
| 41 | const TI_KEYW: i64 = 48 // bytes per stored key slot |
| 42 | const TI_RECCAP: i64 = 2048 // per-pattern record cap |
functions
| 44 | func ti_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 45 | func ti_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } |
| 46 | func ti_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { d[o + i] = s[i]; i = i + 1 } return o + i } |
| 47 | func ti_catn(d: *u8, o: i64, v: i64) -> i64 |
| 58 | func ti_num(v: i64) -> i64 { let b: *u8 = sys_mmap(28); let e: i64 = ti_catn(b, 0, v); sys_write(1, b, e); return 0 } |
| 59 | func ti_puts(s: *u8) -> i64 { sys_write(1, s, ti_len(s)); return 0 } |
| 60 | func ti_atoi(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } return v } |
| 61 | func ti_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while 1 == 1 { let ca: i64 = a[i] as i64; let cb: i64 = b[i] as i64; if ca != cb { return 0 } if ca == 0 { return 1 } i = i + 1 } return 1 } |
| 62 | func ti_suffix(name: *u8, suf: *u8) -> i64 |
| 71 | func ti_find_ci(h: *u8, start: i64, n: i64, needle: *u8) -> i64 |
| 84 | func ti_has(h: *u8, n: i64, needle: *u8) -> i64 { if ti_find_ci(h, 0, n, needle) >= 0 { return 1 } return 0 } |
| 85 | func ti_count_ci(h: *u8, n: i64, needle: *u8) -> i64 |
| 100 | func ti_cta_off(h: *u8, start: i64, n: i64) -> i64 |
| 111 | func ti_seq(h: *u8, n: i64, out: *u8) -> i64 |
| 183 | func ti_classify(h: *u8, n: i64) -> i64 |
| 233 | func ti_arch_name(code: i64, out: *u8) -> i64 |
| 250 | func ti_hash(s: *u8, n: i64) -> i64 |
| 258 | func ti_mkkey(archcode: i64, seq: *u8, keyout: *u8) -> i64 |
| 272 | func ti_build_record(h: *u8, n: i64, archcode: i64, seq: *u8, src: *u8, out: *u8) -> i64 |
| 294 | func ti_seen(seenbuf: *u8, nseen: i64, key: *u8) -> i64 |
| 305 | func ti_run(tpldir: *u8, prefix: *u8, max_tpl: i64, max_bytes: i64, counts: *i64) -> i64 called by 4: mainmainmainmain calls 20: ss_manifest_filess_openti_putsss_beginsys_getdents64dirent_type+14 |
| 404 | func main(argc: i64, argv: *i64) -> i64 |