nx_bki_alias_gate.nx source
↩ module page · 37 lines · 2646 B
1// Pure action identity checks; actual runner cache behavior requires integration evidence.
2import "nx_gate_verdict.nx"
3import "nx_build_key_identity_lib.nx"
4func bkig_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 }; return n }
5func bkig_eq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while i < BKI_DIGEST_BYTES { if a[i] != b[i] { return 0 }; i = i + 1 }; return 1 }
6func main() -> i64 {
7 let ctr: *i64 = gv_ctr()
8 gv_head("build debug logical path identity" as *u8)
9 let a: *u8 = sys_mmap(BKI_DIGEST_BYTES)
10 let b: *u8 = sys_mmap(BKI_DIGEST_BYTES)
11 let c: *u8 = sys_mmap(BKI_DIGEST_BYTES)
12 let d: *u8 = sys_mmap(BKI_DIGEST_BYTES)
13 let material: *u8 = "same-expanded-source-toolchain-debug-mode" as *u8
14 let n: i64 = bkig_len(material)
15 let root: *u8 = "runtime/nx_compare_regen.nx" as *u8
16 let isolated: *u8 = "runtime/nx_compare_regen_scoped.nx" as *u8
17 gv_check_eq("canonical debug accepted" as *u8, bki_digest(material,n,1,root,bkig_len(root),a),0,ctr)
18 gv_check_eq("isolated debug accepted" as *u8, bki_digest(material,n,1,isolated,bkig_len(isolated),b),0,ctr)
19 gv_check_eq("equal bytes different logical path split debug identity" as *u8,bkig_eq(a,b),0,ctr)
20 gv_check_eq("same logical path on another host accepted" as *u8,bki_digest(material,n,1,root,bkig_len(root),c),0,ctr)
21 gv_check_eq("same logical path stable" as *u8,bkig_eq(a,c),1,ctr)
22 sha256_digest(material,n,d)
23 gv_check_eq("old debug identity invalidated" as *u8,bkig_eq(a,d),0,ctr)
24 gv_check_eq("release accepted" as *u8,bki_digest(material,n,0,root,bkig_len(root),b),0,ctr)
25 gv_check_eq("release identity preserved" as *u8,bkig_eq(b,d),1,ctr)
26 gv_check_eq("release other path accepted" as *u8,bki_digest(material,n,0,isolated,bkig_len(isolated),c),0,ctr)
27 gv_check_eq("release remains content reusable" as *u8,bkig_eq(b,c),1,ctr)
28 let absolute: *u8 = "/volume1/runtime/a.nx" as *u8
29 gv_check_eq("absolute host path refused for debug" as *u8,bki_digest(material,n,1,absolute,bkig_len(absolute),c),BKI_INVALID,ctr)
30 let traversal: *u8 = "runtime/../a.nx" as *u8
31 gv_check_eq("traversal refused for debug" as *u8,bki_digest(material,n,1,traversal,bkig_len(traversal),c),BKI_INVALID,ctr)
32 gv_check_eq("empty path refused for debug" as *u8,bki_digest(material,n,1,root,0,c),BKI_INVALID,ctr)
33 gv_check_eq("invalid debug selector refused" as *u8,bki_digest(material,n,2,root,bkig_len(root),c),BKI_INVALID,ctr)
34 let rc: i64 = gv_verdict("NX-BUILD-KEY-IDENTITY" as *u8,ctr,"pure key identity; runner cache reuse requires integration" as *u8)
35 sys_exit(rc)
36 return rc
37}