code wiki / _hdl_build / nx_lcimport_test.nx
nx_lcimport_test.nx source
↩ module page · 45 lines · 2944 B
1// nx_lcimport_test.nx -- PERMANENT PROPERTY WITNESS for the estate's target-imports-target rule.
2//
3// WHY THIS IS A TEST AND NOT A COMMENT: nx_sourcing_path's ENTIRE composition strategy rests on one
4// language property -- a NishiLang target may `import` another TARGET (a file that itself defines
5// main()), the importing main() wins, and every imported symbol resolves. That property was
6// MEASURED on 2026-08-06 rather than assumed, and measuring it killed a planned lib-extraction
7// refactor of a freshly promoted organ. If it ever regresses, nx_sourcing_path silently loses its
8// duty core and the estate grows a SECOND duty implementation -- exactly the duplication the
9// operator called out. A property that load-bearing must be defended by something that RUNS, so
10// this file is named *_test and is therefore reachable by /api/gate_run (which fail-closed refuses
11// any target not ending in gate/test/kat).
12//
13// Supersedes the throwaway nx_lcimport_probe. license_tier: ORIGINAL No hw writes (Rule 26).
14// expect_exit: 0
15import "nx_syscalls.nx"
16import "nx_landed_cost.nx"
17import "nx_gate_verdict.nx"
18
19func main(argc: i64, argv: *i64) -> i64 {
20 var pass: i64 = 0
21 var total: i64 = 0
22 let rbuf: *u8 = sys_mmap(LC_REGBUF)
23 let rn: i64 = lc_load_regime(rbuf)
24 // T1 a CONST from the imported target resolved (the plane actually loaded through it)
25 total = total + 1; if rn > 0 { pass = pass + 1 }
26 // T2/T3 FUNCTIONS from the imported target resolved AND behave -- both directions, so a stub
27 // that always returned 0 or always 1 would fail one of them.
28 total = total + 1; if lc_is_domestic(rbuf, rn, "us" as *u8) == 1 { pass = pass + 1 }
29 total = total + 1; if lc_is_domestic(rbuf, rn, "cn" as *u8) == 0 { pass = pass + 1 }
30 // T4/T5 the regime logic the sourcing pricer depends on, still intact through the import
31 total = total + 1; if lc_is_col2(rbuf, rn, "ru" as *u8) == 1 { pass = pass + 1 }
32 total = total + 1; if lc_pref_ok(rbuf, rn, "ru" as *u8, 1) == 0 { pass = pass + 1 }
33 // T6 THIS file's main() is the one that ran. If the imported target's main() had won, control
34 // would never reach here and the gate output would be a corridor catalog instead of a verdict.
35 total = total + 1; pass = pass + 1
36 // Verdict emission INHERITS the shared base class (D001). A gate that rolls its own verdict
37 // cannot be judged by nx_gate_green and records no harness.jrnl frame, so its flake and erosion
38 // stay invisible -- which is why /api/promote REFUSES the hand-rolled form. It was right to.
39 let ctr__dry: *i64 = gv_ctr()
40 ctr__dry[0] = pass
41 ctr__dry[1] = total
42 let rc__dry: i64 = gv_verdict("LCIMPORT-TEST" as *u8, ctr__dry, "a target CAN import a target; the importing main() wins; imported consts and funcs resolve and behave BOTH ways -- nx_sourcing_path's duty core depends on this property" as *u8)
43 sys_exit(rc__dry)
44 return rc__dry
45}