code wiki / _hdl_build / nx_pattern_emit10_demo.nx
nx_pattern_emit10_demo.nx source
↩ module page · 61 lines · 3118 B
1// nx_pattern_emit10_demo.nx -- the TEAM authoring both sides of race 4 (no Claude logic):
2// LANE A core _pe_jpgtlv = the closest COVERED pattern (WIRE_TLV 1/2 type-first) applied to a
3// JPEG marker stream -- expected to LOSE (no prefix/standalone/inclusive-length concepts);
4// the loss measures the gap on novel ground.
5// LANE B core _pe_jpgmk = WIRE_MARKER (emit10) with the real JPEG spec: prefix 0xFF,
6// standalone {SOI D8, EOI D9, RST D0..D7}, terminator SOS DA -- expected to MATCH.
7// Both lanes' programs authored by the IO_CONTRACT emitter (count key NSEG=). Refusal rail:
8// a spec listing the terminator as standalone must be REFUSED. license_tier: ORIGINAL
9import "nx_pattern_emit7.nx"
10import "nx_pattern_emit9.nx"
11import "nx_pattern_emit10.nx"
12import "nx_syscalls.nx"
13
14func d10_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
15
16func main() -> i64 {
17 // lane A core: covered-pattern attempt (WIRE_TLV on JPEG = the honest mis-fit)
18 let a: i64 = pe7_author_wire_tlv("_pe_jpgtlv" as *u8,
19 "runtime/_hdl_build/_pe_jpgtlv.nx" as *u8,
20 "runtime/_hdl_build/_pe_jpgtlv_test.nx" as *u8,
21 1, 2, 1)
22
23 // lane B core: WIRE_MARKER with the JPEG spec
24 let sa: *i64 = sys_mmap(128) as *i64
25 sa[0] = 10
26 sa[1] = 0xD8; sa[2] = 0xD9
27 sa[3] = 0xD0; sa[4] = 0xD1; sa[5] = 0xD2; sa[6] = 0xD3
28 sa[7] = 0xD4; sa[8] = 0xD5; sa[9] = 0xD6; sa[10] = 0xD7
29 let b: i64 = pe10_author_wire_marker("_pe_jpgmk" as *u8,
30 "runtime/_hdl_build/_pe_jpgmk.nx" as *u8,
31 "runtime/_hdl_build/_pe_jpgmk_test.nx" as *u8,
32 0xFF, sa, 0xDA)
33
34 // refusal: terminator listed standalone
35 let badsa: *i64 = sys_mmap(32) as *i64
36 badsa[0] = 2; badsa[1] = 0xD8; badsa[2] = 0xDA
37 let r1: i64 = pe10_author_wire_marker("_pe_badmk" as *u8,
38 "/tmp/_pe_badmk.nx" as *u8, "/tmp/_pe_badmk_test.nx" as *u8, 0xFF, badsa, 0xDA)
39
40 // both lane programs via IO_CONTRACT (count key NSEG=, JPEG marker census)
41 let types: *i64 = sys_mmap(64) as *i64
42 let labels: *i64 = sys_mmap(64) as *i64
43 types[0] = 0xD8; labels[0] = "SOI=\x00" as *u8 as i64
44 types[1] = 0xE0; labels[1] = "APP0=\x00" as *u8 as i64
45 types[2] = 0xDB; labels[2] = "DQT=\x00" as *u8 as i64
46 types[3] = 0xC2; labels[3] = "SOF=\x00" as *u8 as i64
47 types[4] = 0xC4; labels[4] = "DHT=\x00" as *u8 as i64
48 types[5] = 0xDA; labels[5] = "SOS=\x00" as *u8 as i64
49 let la: i64 = pe9_author_census_lane("runtime/_hdl_build/_pe_lane_jpgtlv.nx" as *u8,
50 "_pe_jpgtlv" as *u8, types, labels, 6, "NSEG=\x00" as *u8)
51 let lb: i64 = pe9_author_census_lane("runtime/_hdl_build/_pe_lane_jpgmk.nx" as *u8,
52 "_pe_jpgmk" as *u8, types, labels, 6, "NSEG=\x00" as *u8)
53
54 if a == 1 { if b == 1 { if r1 == 0 { if la == 1 { if lb == 1 {
55 d10_w("TEAM AUTHORED race-4 sides: _pe_jpgtlv+lane (covered-pattern attempt) and _pe_jpgmk+lane (WIRE_MARKER, JPEG spec) + terminator-standalone spec REFUSED\n" as *u8)
56 sys_exit(0)
57 } } } } }
58 d10_w("author failed (or a refusal rail broke)\n" as *u8)
59 sys_exit(1)
60 return 1
61}