code wiki / (root) / nx_doc_census_run_test.nx

nx_doc_census_run_test.nx source

↩ module page · 76 lines · 2995 B

1// nx_doc_census_run_test.nx -- end-to-end bits-up docs audit binary. 2// 3// Walks /tmp/nx_doc_census_fixture/ (created by smoke harness with 4// 4 synthetic .md files of known V2 compliance) + verifies counts 5// match. Exit 0 = PASS; non-zero = which assertion failed. 6// 7// Composes nx_dir_list + sys_openat_rd/read/close + nx_doc_classify 8// + nx_doc_census_accumulate -- all bits-up NishiLang. 9 10import "nx_syscalls.nx" 11import "nx_string_ops.nx" 12import "nx_dir.nx" 13import "nx_grep.nx" 14import "nx_etg.nx" 15import "nx_doc_census.nx" 16 17func main() -> i64 { 18 let path: *u8 = "/tmp/nx_doc_census_fixture" 19 let path_len: i64 = 26 20 21 let counts_buf: *u8 = sys_mmap(128) 22 let counts: *NxDocCensusCounts = counts_buf as *NxDocCensusCounts 23 nx_doc_census_init(counts) 24 25 let rc: i64 = nx_doc_census_walk_dir(path, path_len, counts) 26 if rc != 0 { return 10 } 27 28 // Smoke fixture creates 4 files: 29 // full_v2.md -- all 7 V2 axes met -> compliance_score=7 30 // partial_v2.md -- 3 of 7 axes met -> compliance_score=3 31 // v1_only.md -- 2 of 7 axes met -> compliance_score=2 32 // bare.md -- 0 of 7 axes met -> compliance_score=0 33 // 34 // Expected counts: 35 // n_total = 4 36 // n_quadrant_declared = 3 (full + partial + v1_only) 37 // n_topic_type_declared = 1 (full only) 38 // n_status_declared = 3 (full + partial + v1_only) 39 // n_trust_state_declared = 1 (full only) 40 // n_competitive_state_declared = 1 (full only) 41 // n_websearch_provenance = 1 (full only) 42 // n_bidirectional_links = 2 (full + partial) 43 // n_full_compliance = 1 (full only; score == 7) 44 // n_zero_compliance = 1 (bare only; score == 0) 45 // achieved sum = 7 + 3 + 2 + 0 = 12 46 // max possible = 4 * 7 = 28 47 // pct = 12 * 100 / 28 = 42 48 49 if counts.n_total != 4 { return 1 } 50 if counts.n_quadrant_declared != 3 { return 2 } 51 if counts.n_topic_type_declared != 1 { return 3 } 52 if counts.n_status_declared != 3 { return 4 } 53 if counts.n_trust_state_declared != 1 { return 5 } 54 if counts.n_competitive_state_declared != 1 { return 6 } 55 if counts.n_websearch_provenance != 1 { return 7 } 56 if counts.n_bidirectional_links != 2 { return 8 } 57 if counts.n_full_compliance != 1 { return 9 } 58 if counts.n_zero_compliance != 1 { return 11 } 59 60 let pct: i64 = nx_doc_census_pct_compliance(counts) 61 if pct != 42 { return 12 } 62 63 // 42% < 50% -> FALSIFIED (docs-proliferation pathology) 64 if nx_doc_census_to_etg_outcome(counts) != NX_ETG_OUTCOME_FALSIFIED { return 13 } 65 66 // Attest -- substrate-honest emission even on FALSIFIED outcome 67 let e_buf: *u8 = sys_mmap(128) 68 let e: *NxEtgEntry = e_buf as *NxEtgEntry 69 let rc_a: i64 = nx_doc_census_attest(counts, e, 0xC0DEC0DE, 1, 20260520) 70 if rc_a != 0 { return 14 } 71 if e.outcome != NX_ETG_OUTCOME_FALSIFIED { return 15 } 72 if e.claim_value != 4 { return 16 } 73 if e.measurement_value != 42 { return 17 } 74 75 return 0 76}