nx_evoracle.nx source
↩ module page · 286 lines · 17445 B
1// nx_evoracle.nx -- THE INDEPENDENCE LAW. Sibling of nx_evidence_verdict.nx (which grades what a claim's
2// EXECUTION earns); this grades WHOSE AUTHORITY that execution rests on.
3//
4// OPERATOR DIRECTIVE 2026-07-31: real 3rd party validated evidence, judged independently, so nishi cant
5// game the system but has to climb the hard thorough way like a PhD or a government certification.
6//
7// THE GAP THIS EXISTS TO KILL, MEASURED LIVE ON THE NAS 2026-07-31 (not inferred):
8// M1 knowledge/status/evclass_*.conf -- ZERO rows existed anywhere. find evclass . over 176,764 files
9// returned 0 matches (reader proven before the corpus was blamed). The whole attestation plane --
10// built, crypto-enforced, oracle-aware -- had never carried a single row. Every domain therefore
11// carried exactly ONE class (MECH), min_classes=2 could not be met, and PROVEN=0/40 was produced by
12// an EMPTY TABLE, not by any failed measurement.
13// M2 knowledge/attest_keys.conf is ABSENT, so at_verify_row refuses every signature.
14// M3 EV_CLASS_ORACLE had ONE consumer (nx_sota_status.nx:220) and NO producer (now nx_evoracle_sweep).
15// M4 nx_evattest.nx knew MECH|LLM|HUMAN only -- oracle rows verified by FALL-THROUGH. Now declared.
16//
17// THE FINDING THIS LIBRARY ENCODES -- KAT NAMES THE FORM, NOT THE PROVENANCE.
18// nx_x25519_kat_gate.nx cites RFC 7748 5.2/6.1 and cross-checks OpenSSL: questions AND answers authored
19// outside Nishi. It even found the RFC own 8448-3 vector internally inconsistent.
20// nx_lex_kat.nx tests all 256 bytes vs INLINED ground truth defined in that same file, by us.
21// A known-answer test whose answers you wrote yourself is a CONSISTENCY test, not an INDEPENDENCE test.
22// This is why independence must NEVER be classified by FILENAME: both files above end in _kat. The
23// name-suffix rule (gate|test|kat) is correct for PROMOTABILITY and catastrophic for INDEPENDENCE.
24//
25// PARTY-NESS (ISO/IEC 17000 series -- the vocabulary the accreditation world already settled).
26// FIRST the subject attests to itself (a supplier declaration of conformity). Self-consistency only.
27// SECOND a party with a user interest attests. THE OPERATOR OWN SIGNATURE IS THIS, NOT THIRD. It is a
28// management assertion, exactly as in a SOC 2 report -- which is why such reports carry a
29// SEPARATE auditor opinion. Valuable; not independence.
30// THIRD authority external to both provider and user, editable by neither: published normative vectors
31// (RFC/FIPS/NIST/ISO/IEEE/BIP/W3C/Khronos/ITU/Unicode) and differential agreement with a
32// reference implementation we did not write. We can never hire an accredited lab -- but we can
33// SIT AN EXTERNALLY SET EXAM.
34//
35// THE ANTI-GAMING PRINCIPLE: AN ORACLE ATTESTATION MUST BE DERIVED FROM AN EXECUTION, NEVER DECLARED.
36// A signature buys attribution and tamper-evidence; it does NOT buy truth, because whoever holds the key
37// can sign a false claim. What buys truth for a mechanical claim is RE-DERIVABILITY: ref= (the external
38// authority), refdig= (digest of the exact bytes compared -- prose can CLAIM RFC 7748, a digest COMMITS to
39// the bytes) and gate= (the re-derivation recipe). ENFORCED AT THE VERIFIER (nx_evattest at_verify_row),
40// not only in the producer -- the producer is one program among many. Same structure the field converged
41// on: ISO/IEC 17043 proficiency testing, SLSA/in-toto provenance, contamination-free benchmarks.
42//
43// FAIL-CLOSED: independence must be PROVEN and every doubt DOWNGRADES. A citation that might be decorative
44// is worth less than no citation, because it reads like proof. Undecidable => UNRESOLVED, never a guess.
45// No main, no syscalls -> any grader/census/gate imports it. license_tier: ORIGINAL
46
47// ---- party-ness tiers (ordered: a higher tier is strictly stronger evidence) ----
48const EVO_P_UNRESOLVED: i64 = 0
49const EVO_P_FIRST: i64 = 1
50const EVO_P_SECOND: i64 = 2
51const EVO_P_THIRD: i64 = 3
52
53// ---- why a candidate was refused third-party status (a diagnostic must NAME the defect, not just deny) --
54const EVO_R_OK: i64 = 0
55const EVO_R_NO_CITATION: i64 = 1
56const EVO_R_SELF_ORACLE: i64 = 2
57const EVO_R_NOT_DERIVED: i64 = 3
58const EVO_R_NO_REFDIGEST: i64 = 4
59
60func evo_starts(b: *u8, n: i64, at: i64, s: *u8) -> i64 {
61 var i: i64 = 0
62 while s[i] != (0 as u8) {
63 if at + i >= n { return 0 }
64 if b[at + i] != s[i] { return 0 }
65 i = i + 1
66 }
67 return 1
68}
69
70// Returns the index of the first occurrence, or -1. -1 (not 0) because 0 is a legitimate hit at the very
71// start of a file; conflating found-at-byte-0 with absent makes a detector silently blind to HEADERS --
72// and headers are exactly where citations live.
73func evo_find(b: *u8, n: i64, s: *u8) -> i64 {
74 var p: i64 = 0
75 while p < n {
76 if evo_starts(b, n, p, s) == 1 { return p }
77 p = p + 1
78 }
79 return 0 - 1
80}
81
82func evo_has(b: *u8, n: i64, s: *u8) -> i64 {
83 if evo_find(b, n, s) >= 0 { return 1 }
84 return 0
85}
86
87// ---- signal 1: does the source cite an EXTERNAL NORMATIVE AUTHORITY? ----
88func evo_cites_spec(b: *u8, n: i64) -> i64 {
89 if evo_has(b, n, "RFC " as *u8) == 1 { return 1 }
90 if evo_has(b, n, "RFC-" as *u8) == 1 { return 1 }
91 if evo_has(b, n, "RFC1" as *u8) == 1 { return 1 }
92 if evo_has(b, n, "RFC2" as *u8) == 1 { return 1 }
93 if evo_has(b, n, "RFC3" as *u8) == 1 { return 1 }
94 if evo_has(b, n, "RFC4" as *u8) == 1 { return 1 }
95 if evo_has(b, n, "RFC5" as *u8) == 1 { return 1 }
96 if evo_has(b, n, "RFC6" as *u8) == 1 { return 1 }
97 if evo_has(b, n, "RFC7" as *u8) == 1 { return 1 }
98 if evo_has(b, n, "RFC8" as *u8) == 1 { return 1 }
99 if evo_has(b, n, "RFC9" as *u8) == 1 { return 1 }
100 if evo_has(b, n, "FIPS" as *u8) == 1 { return 1 }
101 if evo_has(b, n, "NIST" as *u8) == 1 { return 1 }
102 if evo_has(b, n, "ISO/IEC" as *u8) == 1 { return 1 }
103 if evo_has(b, n, "IEEE 754" as *u8) == 1 { return 1 }
104 if evo_has(b, n, "IEEE754" as *u8) == 1 { return 1 }
105 if evo_has(b, n, "Khronos" as *u8) == 1 { return 1 }
106 if evo_has(b, n, "ITU-T" as *u8) == 1 { return 1 }
107 if evo_has(b, n, "Unicode" as *u8) == 1 { return 1 }
108 if evo_has(b, n, "BIP-39" as *u8) == 1 { return 1 }
109 if evo_has(b, n, "BIP39" as *u8) == 1 { return 1 }
110 if evo_has(b, n, "W3C" as *u8) == 1 { return 1 }
111 // DIALECTS ADDED AFTER THE FIRST CENSUS MEASURED MY OWN BLINDNESS (first run 10 THIRD / 23 UNRESOLVED).
112 // _f64_kat_vectors.nx says hardware-IEEE oracle (bare IEEE, not IEEE 754); nx_xxhash_kat.nx anchors to
113 // the CANONICAL reference vector XXH64(...). A citation I cannot parse is indistinguishable from a
114 // citation that is absent, so the first number was a FLOOR, not a measurement.
115 if evo_has(b, n, "IEEE" as *u8) == 1 { return 1 }
116 if evo_has(b, n, "canonical reference" as *u8) == 1 { return 1 }
117 if evo_has(b, n, "reference vector" as *u8) == 1 { return 1 }
118 if evo_has(b, n, "published vector" as *u8) == 1 { return 1 }
119 if evo_has(b, n, "spec vector" as *u8) == 1 { return 1 }
120 // ★SIXTH DIALECT BLINDNESS, found 2026-07-31 by asking why `finance` graded ALL-self while declaring
121 // gates for ISO 20022, IRC 1091, SEC EDGAR and XBRL. My authority list was crypto/IETF-centric: it had
122 // "ISO/IEC" but not bare "ISO ", and NOTHING for statutory or financial-reporting bodies. VERIFIED on
123 // disk before adding: nx_iso20022_lib.nx:1 cites "ISO 20022", nx_taxlot_lib.nx:4 cites "IRC section
124 // 1091". A standards body does not have to be IETF to be OUTSIDE this ecosystem -- a statute we cannot
125 // edit is exactly as independent as an RFC we cannot edit.
126 // ⚠TOKENS KEPT SPECIFIC ON PURPOSE. Bare "SEC" would match "section"/"SECURITY" and bare "IRC" would
127 // match Internet Relay Chat -- crediting first-party work as third-party is FAR worse than undercounting
128 // it, because an inflated independence number is the exact gaming this whole apparatus exists to stop.
129 // Undercounting is the safe direction; that is why these are phrases, not prefixes.
130 if evo_has(b, n, "ISO 20022" as *u8) == 1 { return 1 }
131 if evo_has(b, n, "ISO 4217" as *u8) == 1 { return 1 }
132 if evo_has(b, n, "ISO 8601" as *u8) == 1 { return 1 }
133 if evo_has(b, n, "IRC section" as *u8) == 1 { return 1 }
134 if evo_has(b, n, "XBRL" as *u8) == 1 { return 1 }
135 if evo_has(b, n, "EDGAR" as *u8) == 1 { return 1 }
136 if evo_has(b, n, "GAAP" as *u8) == 1 { return 1 }
137 if evo_has(b, n, "IFRS" as *u8) == 1 { return 1 }
138 return 0
139}
140
141// ---- signal 2: differential agreement with a reference implementation WE DID NOT WRITE ----
142func evo_cites_refimpl(b: *u8, n: i64) -> i64 {
143 if evo_has(b, n, "OpenSSL" as *u8) == 1 { return 1 }
144 if evo_has(b, n, "openssl" as *u8) == 1 { return 1 }
145 if evo_has(b, n, "reference implementation" as *u8) == 1 { return 1 }
146 if evo_has(b, n, "cross-check" as *u8) == 1 { return 1 }
147 if evo_has(b, n, "crosscheck" as *u8) == 1 { return 1 }
148 return 0
149}
150
151// ---- signal 3: DOES IT SUPPLY ITS OWN ANSWERS? the disqualifier ----
152func evo_self_oracle(b: *u8, n: i64) -> i64 {
153 if evo_has(b, n, "inlined ground truth" as *u8) == 1 { return 1 }
154 if evo_has(b, n, "inline ground truth" as *u8) == 1 { return 1 }
155 if evo_has(b, n, "func gt_" as *u8) == 1 { return 1 }
156 if evo_has(b, n, "func expect_" as *u8) == 1 { return 1 }
157 if evo_has(b, n, "own ground truth" as *u8) == 1 { return 1 }
158 // POSITIVE FIRST-PARTY MARKERS: nx_x86_kat_gate composes the team's own toolchain; nx_rvc_kat checks
159 // hand-computed base encodings. Both landed in UNRESOLVED when the truth (FIRST) is something we KNOW.
160 if evo_has(b, n, "hand-computed" as *u8) == 1 { return 1 }
161 if evo_has(b, n, "hand computed" as *u8) == 1 { return 1 }
162 if evo_has(b, n, "own toolchain" as *u8) == 1 { return 1 }
163 if evo_has(b, n, "AUTHOR=ORGAN" as *u8) == 1 { return 1 }
164 return 0
165}
166
167// ---- the classifier ----
168// THE ORDER OF THESE TESTS IS THE WHOLE SAFETY ARGUMENT: the disqualifier is checked BEFORE the citation,
169// so a file that name-drops an RFC while computing its own expected values is FIRST-party. A decorative
170// citation must never outrank a self-supplied answer -- the single move by which this classifier could be
171// gamed, closed BY CONSTRUCTION rather than by review.
172func evo_classify(b: *u8, n: i64) -> i64 {
173 if n <= 0 { return EVO_P_UNRESOLVED }
174 let selfo: i64 = evo_self_oracle(b, n)
175 let spec: i64 = evo_cites_spec(b, n)
176 let refimpl: i64 = evo_cites_refimpl(b, n)
177 if selfo == 1 { return EVO_P_FIRST }
178 if spec == 1 { return EVO_P_THIRD }
179 if refimpl == 1 { return EVO_P_THIRD }
180 return EVO_P_UNRESOLVED
181}
182
183func evo_refuse_reason(b: *u8, n: i64) -> i64 {
184 if evo_self_oracle(b, n) == 1 { return EVO_R_SELF_ORACLE }
185 if evo_classify(b, n) == EVO_P_THIRD { return EVO_R_OK }
186 return EVO_R_NO_CITATION
187}
188
189// ---- the ORACLE ROW contract: derived, not declared ----
190func evo_row_derived_ok(b: *u8, n: i64) -> i64 {
191 if evo_has(b, n, "ref=" as *u8) == 0 { return 0 }
192 if evo_has(b, n, "refdig=" as *u8) == 0 { return 0 }
193 if evo_has(b, n, "gate=" as *u8) == 0 { return 0 }
194 return 1
195}
196
197func evo_row_reason(b: *u8, n: i64) -> i64 {
198 if evo_has(b, n, "ref=" as *u8) == 0 { return EVO_R_NO_CITATION }
199 if evo_has(b, n, "refdig=" as *u8) == 0 { return EVO_R_NO_REFDIGEST }
200 if evo_has(b, n, "gate=" as *u8) == 0 { return EVO_R_NOT_DERIVED }
201 return EVO_R_OK
202}
203
204// ---- VALIDATION TIER: the distinction that stops this axis inflating itself ----
205// Found 2026-07-31 while about to extend the authority vocabulary a FOURTH time: three previous
206// extensions had each raised the number, and a lever that keeps producing a better result stops being
207// examined. Reading what `legal` actually cites stopped the extension -- nx_ediscovery_lib cites EDRM,
208// which is a reference model you DESIGN TOWARD, not a body that publishes answers you are GRADED AGAINST.
209// Crediting that as third-party validation would have been pure inflation.
210//
211// THREE TIERS OF "EXTERNAL", AND ONLY THE FIRST IS VALIDATION:
212// VALIDATED externally-PUBLISHED ANSWERS we are graded against -- RFC/FIPS test vectors, a canonical
213// reference value, differential parity with an implementation we did not write, or real
214// third-party DATA (a genuine SEC filing). We authored neither the questions nor the answers.
215// SPECIFIED an externally-DEFINED RULE we implement, tested with cases WE chose -- IRC 1091 wash-sale,
216// ISO 20022 message shape. The rule is external and un-editable by us; the tests are still
217// ours, so we can implement it correctly and still only probe where we thought to look.
218// (neither) a framework we designed toward -- EDRM, "TigerBeetle is the reference design". INFLUENCE,
219// NOT EVIDENCE. Deliberately unrepresented: there is no token for it and there must not be.
220//
221// ★★★NEVER SUM THESE INTO ONE HEADLINE. A mixed count reads as validation and is not. This function exists
222// so a reader can see the split; nx_evindep_gate reports them on separate lines for exactly that reason.
223const EVO_V_NONE: i64 = 0
224const EVO_V_SPECIFIED: i64 = 1
225const EVO_V_VALIDATED: i64 = 2
226
227// ---- ANSWER PROVENANCE: the hole every other clause is blind to ----
228// Found 2026-07-31 by nearly falling into it. The only remaining way to raise the VALIDATED count was to
229// write a gate against "RFC 8032 test vectors" -- and an agent can produce those in ten minutes by typing
230// them FROM ITS OWN RECALL. That gate compiles, runs GREEN, and yields a row with a real ref=, a real
231// refdig= and a real execution. EVERY CLAUSE IN THIS APPARATUS PASSES IT.
232// BECAUSE EVERY CLAUSE VERIFIES THE COMPARISON AND NONE VERIFIES THE PROVENANCE OF THE ANSWERS.
233// refdig= commits to the bytes we compared against; it CANNOT prove those bytes came from the IETF rather
234// than from the model that wrote the file. An LLM reciting what it believes a published vector says is
235// FIRST-PARTY DATA WEARING A THIRD-PARTY LABEL, and the forgery sits upstream of every check.
236//
237// So a row may be counted VALIDATED only if it says WHERE the answers came from and pins their bytes:
238// refsrc= the retrieval source of the external answers (a URL / spec document id)
239// refsrcdig= sha256 of the fetched answer file, pinned AT ACQUISITION -- separate from refdig=, which
240// digests the SUBJECT. Two different files, two different digests; conflating them is how
241// "I compared against something" gets read as "I compared against something external".
242// The answers must be FETCHED BYTE-EXACT (nx_https_get -> raw bytes), NEVER via a fetch tool that
243// summarises through a model, and NEVER from agent recall. If an agent typed it, it is not external.
244// DEGRADES, NEVER REFUSES (consistent with every other clause here): a row lacking answer provenance is
245// capped at SPECIFIED rather than rejected. The rows inherited from maker-authored KATs are legitimate
246// and must not be destroyed by a rule introduced after them -- but they cannot claim the top tier either.
247func evo_answers_external(b: *u8, n: i64) -> i64 {
248 if evo_has(b, n, "refsrc=" as *u8) == 0 { return 0 }
249 if evo_has(b, n, "refsrcdig=" as *u8) == 0 { return 0 }
250 return 1
251}
252
253// The tier a ROW may claim, as opposed to the tier its SUBJECT's citations suggest. Without pinned answer
254// provenance the top tier is unreachable, whatever the source file cites.
255func evo_row_tier(b: *u8, n: i64, subject_tier: i64) -> i64 {
256 if subject_tier != EVO_V_VALIDATED { return subject_tier }
257 if evo_answers_external(b, n) == 0 { return EVO_V_SPECIFIED }
258 return EVO_V_VALIDATED
259}
260
261func evo_validation_tier(b: *u8, n: i64) -> i64 {
262 if evo_classify(b, n) != EVO_P_THIRD { return EVO_V_NONE }
263 // strongest wins: a source citing BOTH a published vector and a rule is graded on the vector
264 if evo_has(b, n, "test vector" as *u8) == 1 { return EVO_V_VALIDATED }
265 if evo_has(b, n, "reference vector" as *u8) == 1 { return EVO_V_VALIDATED }
266 if evo_has(b, n, "canonical reference" as *u8) == 1 { return EVO_V_VALIDATED }
267 if evo_has(b, n, "published vector" as *u8) == 1 { return EVO_V_VALIDATED }
268 if evo_has(b, n, "KAT" as *u8) == 1 { return EVO_V_VALIDATED }
269 if evo_has(b, n, "FIPS" as *u8) == 1 { return EVO_V_VALIDATED }
270 if evo_has(b, n, "EDGAR" as *u8) == 1 { return EVO_V_VALIDATED }
271 if evo_cites_refimpl(b, n) == 1 { return EVO_V_VALIDATED }
272 if evo_has(b, n, "RFC " as *u8) == 1 { return EVO_V_VALIDATED }
273 return EVO_V_SPECIFIED
274}
275
276// ---- the independence clause, for the verdict law to consume ----
277// DEGRADES, NEVER CONVICTS. Returning 0 costs a domain its PROVEN status and nothing more (-> UNPROVEN),
278// never RED. HARD INVARIANT: a sibling is landing a change that makes POST /api/deploy REFUSE on RED; if an
279// unmet independence clause could produce RED, the hour this ships is the hour every deploy stops -- and a
280// control that halts all work gets disabled or routed around, which is how a gate becomes a hack.
281// RAISE THE CEILING; NEVER LOWER THE FLOOR ONTO SOMEONE FOOT.
282func evo_independence_ok(party: i64, min_party: i64) -> i64 {
283 if min_party <= 0 { return 1 }
284 if party < min_party { return 0 }
285 return 1
286}