code wiki / _hdl_build / nx_dr_census.nx

nx_dr_census.nx source

↩ module page · 141 lines · 11532 B

1// nx_dr_census.nx -- HONEST MEASURED census of Nishi's disaster-recovery / backup / archiving capability vs the 2// S-class bar (rsync / restic-borg / S3-Glacier+Object-Lock / ZFS-snapshot / Bacula / Time-Machine). Drives the 3// GENERAL nx_capability_census engine: each axis = DATA ROW (competitor TERM + our organ + our exceed-gate), graded 4// NEVER self-scored against the sovereign-banked knowledge/fetched/dr_*.raw corpus (nx_dr_research_fetch, 27 srcs). 5// Honest finding it encodes: the DR PRIMITIVES exist + several are sovereign-AHEAD (own-SSH pull replacing rsync/scp; 6// byte-identity + chaos-proven verify; additive-only never-delete; no-shell getdents/FXP inspection) -- but 7// INCREMENTAL, SNAPSHOT, DEDUP, IMMUTABILITY/WORM, ENCRYPTION-AT-REST, RESTORE-TEST, RETENTION/GFS, COMPRESSION are 8// GENUINE GAPS = the build ladder to S-class-exceed. GREEN = measurement honest + grounded, NOT "we win". 9// Sovereign nx_cc->nxasm (no gcc). expect_exit: 0 license_tier: ORIGINAL 10import "nx_capability_census.nx" 11import "nx_syscalls.nx" 12const K_MAGIC_2097152: i64 = 2097152 13 14func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 15func wn(v: i64) -> i64 { var m: i64=v; if m<0{w("-" as *u8);m=0-m} let t:*u8=sys_mmap(24); var k:i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i:i64=0; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1} sys_write(1,o,k); return 0 } 16 17func row(label: *u8, term: *u8, organ: *u8, exceed: *u8, subj: *i64, ns: i64, buf: *u8, cap: i64, st: *i64) -> i64 { 18 let comp: i64 = cc_comp_attest(subj, ns, term, buf, cap) 19 let our: i64 = cc_our_grade(organ, exceed) 20 let v: i64 = cc_verdict(comp, our) 21 w(" "); w(cc_verdict_str(v)); w(" us="); w(cc_grade_str(our)); w(" them(src="); wn(comp); w(") "); w(label); w("\n") 22 st[0]=st[0]+1 23 if our>=3 { st[1]=st[1]+1 } 24 if our==4 { st[2]=st[2]+1 } 25 if v==3 { st[3]=st[3]+1 } 26 if v==2 { st[4]=st[4]+1 } 27 if v==1 { st[5]=st[5]+1 } 28 if v==0 { st[6]=st[6]+1 } 29 st[7]=st[7]+comp 30 return 0 31} 32 33func main() -> i64 { 34 w("=== NISHI DISASTER-RECOVERY / BACKUP / ARCHIVE vs S-class (rsync/restic/S3-Glacier/ZFS/Bacula) -- CENSUS ===\n" as *u8) 35 w("them(src) = sovereign-banked knowledge/fetched/dr_*.raw attestation (0 = run nx_dr_research_fetch)\n" as *u8) 36 w("us = EXCEEDS(exceed-gate on disk) > PRESENT(organ on disk) > ABSENT. Never self-scored.\n\n" as *u8) 37 38 let cap: i64 = K_MAGIC_2097152 39 let buf: *u8 = sys_mmap(cap) 40 let st: *i64 = sys_mmap(128) as *i64 41 var z: i64 = 0; while z < 8 { st[z]=0; z=z+1 } 42 43 let subj: *i64 = sys_mmap(8 * 32) as *i64 44 subj[0]="knowledge/fetched/dr_a_backup.raw" as *u8 as i64 45 subj[1]="knowledge/fetched/dr_a_disaster_recovery.raw" as *u8 as i64 46 subj[2]="knowledge/fetched/dr_a_rpo.raw" as *u8 as i64 47 subj[3]="knowledge/fetched/dr_a_dr_audit.raw" as *u8 as i64 48 subj[4]="knowledge/fetched/dr_b_incremental.raw" as *u8 as i64 49 subj[5]="knowledge/fetched/dr_b_differential.raw" as *u8 as i64 50 subj[6]="knowledge/fetched/dr_b_snapshot.raw" as *u8 as i64 51 subj[7]="knowledge/fetched/dr_b_cdp.raw" as *u8 as i64 52 subj[8]="knowledge/fetched/dr_c_rsync.raw" as *u8 as i64 53 subj[9]="knowledge/fetched/dr_c_rclone.raw" as *u8 as i64 54 subj[10]="knowledge/fetched/dr_c_bacula.raw" as *u8 as i64 55 subj[11]="knowledge/fetched/dr_c_s3_glacier.raw" as *u8 as i64 56 subj[12]="knowledge/fetched/dr_c_time_machine.raw" as *u8 as i64 57 subj[13]="knowledge/fetched/dr_d_scrubbing.raw" as *u8 as i64 58 subj[14]="knowledge/fetched/dr_d_integrity.raw" as *u8 as i64 59 subj[15]="knowledge/fetched/dr_d_checksum.raw" as *u8 as i64 60 subj[16]="knowledge/fetched/dr_d_bitrot.raw" as *u8 as i64 61 subj[17]="knowledge/fetched/dr_e_worm.raw" as *u8 as i64 62 subj[18]="knowledge/fetched/dr_e_airgap.raw" as *u8 as i64 63 subj[19]="knowledge/fetched/dr_e_ransomware.raw" as *u8 as i64 64 subj[20]="knowledge/fetched/dr_e_encryption.raw" as *u8 as i64 65 subj[21]="knowledge/fetched/dr_f_dedup.raw" as *u8 as i64 66 subj[22]="knowledge/fetched/dr_f_compression.raw" as *u8 as i64 67 subj[23]="knowledge/fetched/dr_f_cas.raw" as *u8 as i64 68 subj[24]="knowledge/fetched/dr_g_rotation.raw" as *u8 as i64 69 subj[25]="knowledge/fetched/dr_g_zfs.raw" as *u8 as i64 70 subj[26]="knowledge/fetched/dr_g_btrfs.raw" as *u8 as i64 71 let ns: i64 = 27 72 73 let none: *u8 = "runtime/nx_DOES_NOT_EXIST_zzqq.nx" as *u8 74 let rep_gate: *u8 = "runtime/_hdl_build/nx_ha_replication_gate.nx" as *u8 75 let chaos_gate: *u8 = "runtime/_hdl_build/nx_ha_chaos_gate.nx" as *u8 76 77 // ===== SECTION 1: CORE DR PRIMITIVES (expect PRESENT -- the pieces exist) ===== 78 w(" -- SECTION 1: core DR primitives (copy-to-separate-device / verify / catalog / transport) --\n" as *u8) 79 row("BACKUP copy data to a SEPARATE device (3-2-1: off primary)" as *u8, "backup" as *u8, "runtime/_hdl_build/nx_dr_archive.nx" as *u8, none, subj, ns, buf, cap, st) 80 row("CHECKSUM integrity verify (SHA-256)" as *u8, "checksum" as *u8, "runtime/nx_sha256.nx" as *u8, none, subj, ns, buf, cap, st) 81 row("RECURSIVE + STREAMING whole-tree archive (multi-GB)" as *u8, "archive" as *u8, "runtime/_hdl_build/nx_dr_tree.nx" as *u8, none, subj, ns, buf, cap, st) 82 row("PROVENANCE receipt / backup CATALOG" as *u8, "catalog" as *u8, "runtime/_hdl_build/nx_receipt.nx" as *u8, none, subj, ns, buf, cap, st) 83 row("DATA-DRIVEN manifest (what to protect)" as *u8, "backup" as *u8, "knowledge/hosting/archive_manifest.conf" as *u8, none, subj, ns, buf, cap, st) 84 row("REMOTE PULL transport (fetch source -> local)" as *u8, "rsync" as *u8, "runtime/_hdl_build/nx_aw_fetch.nx" as *u8, none, subj, ns, buf, cap, st) 85 row("OFF-DEVICE transport to separate media" as *u8, "storage" as *u8, "runtime/_hdl_build/nx_aw_send.nx" as *u8, none, subj, ns, buf, cap, st) 86 row("DIRECTORY INSPECTION (manifest authoring)" as *u8, "backup" as *u8, "runtime/_hdl_build/nx_lsdir.nx" as *u8, none, subj, ns, buf, cap, st) 87 88 // ===== SECTION 2: SOVEREIGN + DETERMINISM MOAT (EXCEEDS where a gate is on disk) ===== 89 w("\n -- SECTION 2: sovereign + determinism moat (own-SSH pull, byte-identity, chaos-proven, additive-only) --\n" as *u8) 90 row("BYTE-IDENTITY verified copy (deterministic, proven)" as *u8, "data integrity" as *u8, "runtime/_hdl_build/nx_ha_replication.nx" as *u8, rep_gate, subj, ns, buf, cap, st) 91 row("DR SURVIVES fault injection (chaos-proven restore)" as *u8, "disaster recovery" as *u8,"runtime/_hdl_build/nx_ha_failover.nx" as *u8, chaos_gate, subj, ns, buf, cap, st) 92 row("SOVEREIGN own-SSH/sftp pull (NO rsync/scp/curl binary)" as *u8, "rsync" as *u8, "runtime/_hdl_build/nx_aw_fetch.nx" as *u8, none, subj, ns, buf, cap, st) 93 row("NO-SHELL remote inspection (FXP READDIR, no /bin/ls)" as *u8, "backup" as *u8, "runtime/_hdl_build/nx_aw_lsdir.nx" as *u8, none, subj, ns, buf, cap, st) 94 row("ADDITIVE-ONLY never-delete (history sacred)" as *u8, "continuous data protection" as *u8, "runtime/_hdl_build/nx_dr_archive.nx" as *u8, none, subj, ns, buf, cap, st) 95 row("SOVEREIGN FORMAT (content-addressed .docs/.keys, crash-safe binary-search -- NOT ad-hoc TSV)" as *u8, "storage" as *u8, "runtime/nx_seg_store.nx" as *u8, "runtime/nx_seg_store_gate.nx" as *u8, subj, ns, buf, cap, st) 96 row("INTEROPERABLE (documented sovereign format; foreign READ at edge, never a dep)" as *u8, "backup" as *u8, "runtime/nx_seg_store.nx" as *u8, none, subj, ns, buf, cap, st) 97 98 // ===== SECTION 3: GENUINE GAPS -> the build ladder to S-class-exceed ===== 99 w("\n -- SECTION 3: HONEST GAPS today (real ABSENTs -> the build targets to EXCEED) --\n" as *u8) 100 row("INCREMENTAL / differential (only changed data)" as *u8, "incremental" as *u8, "runtime/_hdl_build/nx_dr_incremental.nx" as *u8, none, subj, ns, buf, cap, st) 101 row("SNAPSHOT (atomic point-in-time)" as *u8, "snapshot" as *u8, "runtime/_hdl_build/nx_dr_snapshot.nx" as *u8, none, subj, ns, buf, cap, st) 102 row("DEDUPLICATION (store once by hash)" as *u8, "deduplication" as *u8, "runtime/_hdl_build/nx_dr_dedup.nx" as *u8, "runtime/_hdl_build/nx_dr_dedup_gate.nx" as *u8, subj, ns, buf, cap, st) 103 row("IMMUTABILITY / WORM (ransomware-proof)" as *u8, "write once" as *u8, "runtime/_hdl_build/nx_dr_worm.nx" as *u8, none, subj, ns, buf, cap, st) 104 row("ENCRYPTION at rest (archive confidentiality)" as *u8, "encryption" as *u8, "runtime/_hdl_build/nx_dr_encrypt.nx" as *u8, "runtime/_hdl_build/nx_dr_encrypt_gate.nx" as *u8, subj, ns, buf, cap, st) 105 row("RESTORE-TEST (prove recoverability, verify-restore)" as *u8, "recovery point" as *u8, "runtime/_hdl_build/nx_dr_restore_verify.nx" as *u8, "runtime/_hdl_build/nx_dr_restore_verify_gate.nx" as *u8, subj, ns, buf, cap, st) 106 row("RETENTION / rotation (GFS, versioned history)" as *u8, "rotation" as *u8, "runtime/_hdl_build/nx_dr_retention.nx" as *u8, "runtime/_hdl_build/nx_dr_retention_gate.nx" as *u8, subj, ns, buf, cap, st) 107 row("COMPRESSION (archive space efficiency)" as *u8, "compression" as *u8, "runtime/_hdl_build/nx_dr_compress.nx" as *u8, none, subj, ns, buf, cap, st) 108 row("SCHEDULED / automated periodic backup" as *u8, "continuous data protection" as *u8, "runtime/_hdl_build/nx_dr_schedule.nx" as *u8, "runtime/_hdl_build/nx_dr_schedule_gate.nx" as *u8, subj, ns, buf, cap, st) 109 110 let total: i64 = st[0] 111 let have: i64 = st[1] 112 let permil: i64 = (have * 1000) / total 113 w("\n TALLY: axes=" as *u8); wn(total) 114 w(" HAVE(organ on disk)=" as *u8); wn(have); w(" (" as *u8); wn(permil); w("permil)" as *u8) 115 w(" EXCEEDS-measured=" as *u8); wn(st[2]) 116 w("\n verdicts: AHEAD=" as *u8); wn(st[3]); w(" PARITY=" as *u8); wn(st[4]); w(" GAP=" as *u8); wn(st[5]); w(" BOTH-ABSENT=" as *u8); wn(st[6]) 117 w("\n corpus attestations summed=" as *u8); wn(st[7]); w("\n" as *u8) 118 119 let g_real: i64 = cc_our_grade("runtime/nx_sha256.nx" as *u8, none) 120 let g_fake: i64 = cc_our_grade(none, none) 121 var liar_ok: i64 = 1 122 if g_real != 3 { liar_ok = 0 } 123 if g_fake != 0 { liar_ok = 0 } 124 var corpus_ok: i64 = 0 125 if st[7] > 0 { corpus_ok = 1 } 126 127 w("\n honesty: liar-kill(real=" as *u8); wn(g_real); w(" fake=" as *u8); wn(g_fake); w(")=" as *u8) 128 if liar_ok==1 { w("ARMED" as *u8) } else { w("DISARMED" as *u8) } 129 w(" corpus-grounded=" as *u8) 130 if corpus_ok==1 { w("YES" as *u8) } else { w("NO(run researcher)" as *u8) } 131 w("\n" as *u8) 132 133 w("\n=== DR-CENSUS verdict=" as *u8) 134 if liar_ok==1 { if corpus_ok==1 { 135 w("GREEN (measurement honest + grounded). Read: DR primitives PRESENT, " as *u8); wn(st[2]) 136 w(" measured sovereign exceed-gate(s); " as *u8); wn(st[5]); w(" GAP(s) = incremental/snapshot/dedup/WORM/encryption/restore-test/retention/compression = the ladder to S-class-exceed.\n" as *u8) 137 sys_exit(0); return 0 138 } } 139 w("RED (a real row faked PRESENT, or corpus unbanked -> run nx_dr_research_fetch)\n" as *u8) 140 sys_exit(1); return 1 141}