code wiki / _hdl_build / nx_janitor_scrub_gate.nx

nx_janitor_scrub_gate.nx source

↩ module page · 52 lines · 4323 B

1import "nx_gate_gn.nx" 2import "nx_gate_base.nx" 3// nx_janitor_scrub_gate.nx -- proves the JANITOR's third-party cleanup capability is real, SAFE, and never-brick. 4// T1 POLICY : the auditor's 3 debt classes map to the right safe actions (format->MIGRATE, lang->QUARANTINE, web->REVIEW). 5// T2 MIGRATE : a real non-sov data file (the RACI tsv) migrates into the seg_store BYTE-EXACT (ver==tot). 6// T3 NEVER-BRICK : the source file is STILL THERE after the migrate (additive #13, reversible #26 -- no delete). 7// T4 QUARANTINE : a third-party-lang file is FLAGGED in the ledger (recorded, not deleted); an unflagged one isn't. 8// T5 HONEST : migrating a non-existent file yields 0 rows (no fake cleanup); byte-verify is the teeth. 9// expect_exit: 0 license_tier: ORIGINAL 10import "nx_janitor_scrub.nx" 11import "nx_syscalls.nx" 12 13func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw(" 14" as *u8); return ok } 15 16func main() -> i64 { 17 gw("=== nx_janitor_scrub_gate: does the janitor CLEAN third-party debt, safely + never-brick? ===\n" as *u8) 18 var pass: i64=0; var total: i64=0 19 20 // T1 POLICY -- composes the auditor's sav_class_of (1=lang 2=format 3=web) 21 let af: i64=jan_action(2); let al: i64=jan_action(1); let aw: i64=jan_action(3) 22 total=total+1; if af==JAN_MIGRATE { if al==JAN_QUARANTINE { if aw==JAN_REVIEW { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } 23 gw("T1 POLICY: NONSOV_FORMAT->MIGRATE(\x00" as *u8); gn(af); gw(") THIRDPARTY_LANG->QUARANTINE(\x00" as *u8); gn(al); gw(") WEB_BOUNDARY->REVIEW(\x00" as *u8); gn(aw); gw(")\n" as *u8) 24 25 // T2 MIGRATE a real non-sov file (RACI tsv) -> seg_store, byte-exact 26 let totp: *i64=sys_mmap(16) as *i64; let verp: *i64=sys_mmap(16) as *i64 27 jan_migrate("knowledge/registry/nishi_raci.tsv\x00" as *u8, "knowledge/store/janitor-test\x00" as *u8, totp, verp) 28 total=total+1; if verp[0]==totp[0] { if totp[0]>0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } 29 gw("T2 MIGRATE: nishi_raci.tsv -> seg_store rows=\x00" as *u8); gn(totp[0]); gw(" verified=\x00" as *u8); gn(verp[0]); gw(" (byte-exact)\n" as *u8) 30 31 // T3 NEVER-BRICK: the source is STILL there (additive, no delete) 32 let srcalive: i64=jan_exists("knowledge/registry/nishi_raci.tsv\x00" as *u8) 33 total=total+1; if srcalive==1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } 34 gw("T3 NEVER-BRICK(#13/#26): source file INTACT after migrate(\x00" as *u8); gn(srcalive); gw(") = additive, reversible, no delete\n" as *u8) 35 36 // T4 QUARANTINE: flag a third-party-lang file (recorded, not deleted) 37 jan_quarantine_record("runtime/_hdl_build/_library_server.py\x00" as *u8) 38 let q1: i64=jan_is_quarantined("runtime/_hdl_build/_library_server.py\x00" as *u8) 39 let q0: i64=jan_is_quarantined("runtime/_hdl_build/nx_janitor_scrub.nx\x00" as *u8) 40 total=total+1; if q1==1 { if q0==0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } 41 gw("T4 QUARANTINE: _library_server.py flagged(\x00" as *u8); gn(q1); gw("), a sovereign organ not flagged(\x00" as *u8); gn(q0); gw(") = flag, never delete\n" as *u8) 42 43 // T5 HONEST: migrating a non-existent file = 0 rows (no fake cleanup) 44 let totp2: *i64=sys_mmap(16) as *i64; let verp2: *i64=sys_mmap(16) as *i64 45 jan_migrate("knowledge/registry/__no_such_file__.tsv\x00" as *u8, "knowledge/store/janitor-test2\x00" as *u8, totp2, verp2) 46 total=total+1; if totp2[0]==0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } 47 gw("T5 HONEST: migrate(non-existent)=\x00" as *u8); gn(totp2[0]); gw(" rows (no fake cleanup; byte-verify has teeth)\n" as *u8) 48 49 gw("\n=== nx_janitor_scrub_gate \x00" as *u8); gn(pass); gw("/\x00" as *u8); gn(total) 50 if pass==total { gw(" GREEN -- the janitor CLEANS the auditor's debt: migrates non-sov formats to seg_store byte-exact (additive, source intact), flags third-party-lang for operator-gated retirement, never deletes. Audit->clean is one loop now.\n" as *u8); sys_exit(0); return 0 } 51 gw(" RED\n" as *u8); sys_exit(1); return 1 52}