code wiki / (root) / nx_commons_witness.nx

nx_commons_witness.nx

buildroot/runtime/nx_commons_witness.nx

6114 B129 linesdepth 5pulls 5 transitivereach 1 importersview sourcekind librarytopic commons
docsdependenciesstructsconstsfunctions

about

nx_commons_witness.nx -- the PRODUCER of witnessed_permil, the term nx_commons_lib leans on hardest and which, until now, NOTHING in the estate emitted. ★ A GUARD WHOSE INPUT THE PREVIOUS STEP DOES NOT EMIT IS A GUARD NOBODY CAN USE. nx_commons_lib scores standing from third-party-attested giving, and the sybil ring collapses precisely because it cannot manufacture witnesses. But no organ computed that number, so the whole rule was unusable in practice -- a ruler with no way to take a reading. KNOWN GOOD MATCHED: nx_trust_corroborate (the spore's sovereign trust bootstrap, 2026-06-05). Its rule is exactly right and is adopted here verbatim in spirit: - a claim is admitted only if >= K INDEPENDENT sources present the EXACT SAME bytes - WE hash every source's view with our own sha256; a source's self-claimed hash is never trusted - K=1 is HEARSAY and is forbidden by construction; K>=2 is corroboration "A single tampered source cannot reach K alone" is the same anti-sybil property as the trust-flow cap in nx_commons_lib, one layer further down. TWO IMPROVEMENTS, each measured by nx_commons_witness_gate rather than asserted: 1. PLURALITY TARGET, NOT SOURCE-0 TARGET. The known good computes let agree = tc_agreement_count(fps, fps, n_sources) where the target fingerprint IS source 0's. So admission counts agreement WITH SOURCE 0, not with the majority. If source 0 is poisoned and K-1 accomplices present the identical poison, the claim is admitted while ANY NUMBER of honest sources presenting the true bytes are simply not consulted. ★★★★★★ AN AGREEMENT COUNT ANCHORED ON ONE PARTICULAR SOURCE IS NOT A MAJORITY, IT IS THAT SOURCE'S OPINION WEARING A QUORUM'S CLOTHES. Here the target is the largest agreement CLUSTER, so poison must out-number truth, not merely occupy index 0. 2. PARTY EXCLUSION -- the thing a commons needs and a trust store does not. "The person I billed says I helped them" is K=1 hearsay dressed as attestation, and it is exactly what the rent-extractor has in abundance: every counterparty will confirm the fee-justifying service was rendered. Neither the giver nor the receiver counts toward corroboration of their own exchange. A witness with a stake is a participant. Integer only, no floats. Thresholds named (law 11). license_tier: ORIGINAL

dependencies 2 imports · 1 importers

nx_sha256.nx nx_syscalls.nx nx_commons_witness.nx nx_commons_witness_gate.nx

imports: nx_sha256.nxnx_syscalls.nx

imported by: nx_commons_witness_gate.nx

structs

none

consts

39const CWIT_HASHLEN: i64 = 32
40const CWIT_K_MIN: i64 = 2 // hearsay floor -- one voice is never corroboration
41const CWIT_FULL: i64 = 5 // independent attestors for a full 1000-permil reading
42const CWIT_SCALE: i64 = 1000

functions

44func cwit_hash_eq(a: *u8, b: *u8) -> i64
51func cwit_is_independent(attestor: i64, giver: i64, receiver: i64) -> i64
60func cwit_plurality_agreement(views: *u8, stride: i64, len: i64,
92func cwit_permil(agreement: i64, k: i64) -> i64
102func cwit_witnessed_permil(views: *u8, stride: i64, len: i64,
114func cwit_source0_agreement(views: *u8, stride: i64, len: i64, n: i64) -> i64