code wiki / _hdl_build / nx_tpl_ingest.nx

nx_tpl_ingest.nx

buildroot/runtime/_hdl_build/nx_tpl_ingest.nx

21296 B423 linesdepth 4pulls 7 transitivereach 12 importersview sourcekind tooltopic tpl
docsdependenciesstructsconstsfunctions

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

nx_docportal_search_seg.nx nx_tpl_ingest.nx nx_site_archetype.nx nx_tpl_ingest_gate.nx nx_tpl_parts.nx nx_tpl_site.nx

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

main ti_puts ti_len ti_atoi ti_run ss_manifest_file sys_mmap ss_cat ss_readall sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close ss_open ss_open2 sys_mmap ↻ ss_manifest_dyn ss_manifest_file_dyn sys_mmap ↻ ss_cat ↻ ss_readall ↻ sys_munmap ss_cat ↻ ss_loadfile sys_map_file sys_openat_rd ↻ sys_lseek ↻ sys_close ↻ ss_readall ↻ ss_load_aux2 sys_mmap ↻ ss_cat ↻ ss_loadfile ↻ ss_r32 sys_munmap ↻ ssl_total_keys ss_r32 ↻ ssl_pow2 ssl_build

structs

none

consts

21const TI_MAGIC_1125899906842597: i64 = 1125899906842597
22const TI_MAGIC_131072: i64 = 131072
23const TI_MAGIC_1024: i64 = 1024
24const TI_MAGIC_5000: i64 = 5000
25const TI_MAGIC_67108864: i64 = 67108864
27const TI_ARCH_LANDING: i64 = 1
28const TI_ARCH_ECOM: i64 = 2
29const TI_ARCH_SOCIAL: i64 = 3
30const TI_ARCH_MEDIA: i64 = 4
31const TI_ARCH_RESUME: i64 = 5
32const TI_ARCH_HUB: i64 = 6
33const TI_ARCH_BROCHURE: i64 = 7
34const TI_ARCH_PORTFOLIO: i64 = 8
35const TI_ARCH_GALLERY: i64 = 9
36const TI_ARCH_BLOG: i64 = 10
38const TI_RAWCAP: i64 = 2097152 // 2 MiB largest template we read (guard vs absurd files)
39const TI_MINDOC: i64 = 40 // below this = not a real template
40const TI_SEENCAP: i64 = 20000 // in-run dedup memory (bounded)
41const TI_KEYW: i64 = 48 // bytes per stored key slot
42const TI_RECCAP: i64 = 2048 // per-pattern record cap

functions

44func ti_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
45func ti_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c }
46func 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 }
47func ti_catn(d: *u8, o: i64, v: i64) -> i64
58func 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 }
called by 3: mainmainmain calls 1: ti_catn
59func ti_puts(s: *u8) -> i64 { sys_write(1, s, ti_len(s)); return 0 }
60func 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 }
called by 3: mainmainmain
61func 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 }
called by 2: ti_seenmain
62func ti_suffix(name: *u8, suf: *u8) -> i64
71func ti_find_ci(h: *u8, start: i64, n: i64, needle: *u8) -> i64
84func ti_has(h: *u8, n: i64, needle: *u8) -> i64 { if ti_find_ci(h, 0, n, needle) >= 0 { return 1 } return 0 }
85func ti_count_ci(h: *u8, n: i64, needle: *u8) -> i64
100func ti_cta_off(h: *u8, start: i64, n: i64) -> i64
called by 2: ti_seqtp_scan calls 1: ti_find_ci
111func ti_seq(h: *u8, n: i64, out: *u8) -> i64
183func ti_classify(h: *u8, n: i64) -> i64
233func ti_arch_name(code: i64, out: *u8) -> i64
250func ti_hash(s: *u8, n: i64) -> i64
258func ti_mkkey(archcode: i64, seq: *u8, keyout: *u8) -> i64
272func ti_build_record(h: *u8, n: i64, archcode: i64, seq: *u8, src: *u8, out: *u8) -> i64
294func ti_seen(seenbuf: *u8, nseen: i64, key: *u8) -> i64
called by 3: sa_runti_runtp_run calls 1: ti_streq
305func ti_run(tpldir: *u8, prefix: *u8, max_tpl: i64, max_bytes: i64, counts: *i64) -> i64
404func main(argc: i64, argv: *i64) -> i64