code wiki / _hdl_build / nx_canoncat.nx

nx_canoncat.nx

buildroot/runtime/_hdl_build/nx_canoncat.nx

12307 B249 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_canoncat -- concatenate N canon files into one, renumbering feature part references. ★THE ENTIRE "PERFECT ONE UNIT, THEN AGGREGATE" MECHANISM IS THIS ORGAN (plan rung S4). A skull, a hand, a torso are each authored and gated as their OWN canon; composition into a body is a cat. That is only true because of one discipline enforced here: P and R rows pass through BYTE-VERBATIM. This organ does not parse them beyond the leading letter, so when the canon grows fields (P grew mat, then rotZ, then rotY) concatenation keeps working without an edit here -- an organ that re-emitted parsed fields would silently STRIP any field added after it was written, which is exactly how format evolution corrupts a pipeline. F rows are the one exception, because they carry the ONLY cross-row reference in the format: a part INDEX, where parts are numbered by order of P appearance. File k's F rows are shifted by the P count of files 0..k-1. Everything after the index is passed through verbatim for the same reason as above. Fail-closed on purpose: - an F row referencing a part its OWN file never declared is a corrupt canon -> refuse (exit 5), because shifting a dangling index would turn one file's corruption into another file's feature. - an unknown row type -> refuse (exit 6). A row this organ cannot classify is a row whose renumbering rule is UNKNOWN; passing it through silently would be a guess with a file format. usage: nx_canoncat <out.canon> <in1.canon> [in2.canon ...] nx_canoncat selftest

dependencies 1 imports · 0 importers

nx_gate_verdict.nx nx_canoncat.nx

imports: nx_gate_verdict.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main cc_streq cc_gate gv_ctr sys_mmap gv_head gv_puts sys_write sys_openat_wr cc_cat sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close cc_one cc_wnum sys_openat_wr ↻ sys_read_file ↻ gv_check gv_puts ↻ gv_verdict gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_journal sys_openat_append sys_mmap ↻ gv_catn sys_mmap ↻ sys_munmap ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real gv_cat sys_write ↻ sys_close ↻

structs

none

consts

27const CC_MAXIN: i64 = 8388608 // 8MB per input canon -- far above any real canon, refuses beyond
28const CC_MAXOUT: i64 = 67108864

functions

30func cc_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main
31func cc_pn(v: i64) -> i64
called by 1: main
40func cc_streq(a: *u8, b: *u8) -> i64
called by 1: main
46func cc_wnum(out: *u8, pos: *i64, v: i64) -> i64
called by 1: cc_one
58func cc_one(inb: *u8, n: i64, out: *u8, opos: *i64, pbase: i64) -> i64
called by 1: cc_cat calls 1: cc_wnum
122func cc_cat(outpath: *u8, files: *i64, nf: i64) -> i64
144func cc_gate() -> i64
228func main(argc: i64, argv: *i64) -> i64