nx_grounding.nx source
↩ module page · 155 lines · 6916 B
1// nx_grounding.nx -- EVIDENCE-TIER / ANTI-OVER-OPTIMISM rung. Every datum this
2// ecosystem emits carries a grounding tier that says how much to trust it, and
3// a composite claim is only as trustworthy as its WEAKEST input. This exists
4// so the system stops presenting a number I typed from memory (a CPI score, a
5// bulk price) with the same authority as a number two independent methods
6// verified against published literature (a peptide mass). That conflation is
7// the exact over-optimism this rung refuses to allow.
8//
9// THE TIERS, weakest to strongest:
10// ATTESTED an operator DECLARED it done; the system cannot check it
11// (e.g. "the cGMP facility is qualified"). Trust = the operator.
12// ASSERTED a constant entered from domain knowledge with NO in-system
13// external oracle (e.g. a CPI score, a bulk cost, a regulatory
14// tier). Plausible, internally consistent, UNVERIFIED. A gate that
15// checks the code returns this constant proves nothing about the
16// constant's truth.
17// DERIVED computed from stronger inputs by sound arithmetic, but not
18// itself checked against an external reference (e.g. a peptide's
19// isoelectric point, an ion m/z). As true as its inputs + the math.
20// VALIDATED a model checked against PUBLISHED data points (e.g. the freezing
21// curve vs Goff/Hartel; the z-value recovered from two legal
22// schedules landing in the published band).
23// ANCHORED verified by an INDEPENDENT second method AND external ground
24// truth (e.g. a peptide mass: residue-sum == elemental-sum ==
25// published formula == published mass). The strongest claim.
26//
27// THE COMPOSITION LAW: a chain is as strong as its weakest link. An "effective
28// manufacturing cost" that multiplies an ASSERTED bulk price by a DERIVED
29// formula is ASSERTED, not DERIVED -- gnd_compose takes the MINIMUM. This is
30// what stops a pile of asserted constants from laundering itself into a
31// confident-looking result.
32//
33// gnd_is_verified draws the honest line: only VALIDATED and ANCHORED count as
34// "verified". Everything the go-to-market / cost / regulatory layer emits is
35// ASSERTED or below, and this function will say so -- in the machine output,
36// not just in prose.
37//
38// genealogy_id: rigor + service_infrastructure + liar_killer
39
40import "nx_syscalls.nx"
41
42// ===== Tiers (higher = stronger) ======================================
43
44const GND_UNKNOWN: i64 = 0
45const GND_ATTESTED: i64 = 1
46const GND_ASSERTED: i64 = 2
47const GND_DERIVED: i64 = 3
48const GND_VALIDATED: i64 = 4
49const GND_ANCHORED: i64 = 5
50
51func gnd_name(t: i64) -> *u8 {
52 if t == GND_ATTESTED { return "ATTESTED" as *u8 }
53 if t == GND_ASSERTED { return "ASSERTED" as *u8 }
54 if t == GND_DERIVED { return "DERIVED" as *u8 }
55 if t == GND_VALIDATED { return "VALIDATED" as *u8 }
56 if t == GND_ANCHORED { return "ANCHORED" as *u8 }
57 return "UNKNOWN" as *u8
58}
59
60// One-line meaning, for a self-documenting output.
61func gnd_meaning(t: i64) -> *u8 {
62 if t == GND_ATTESTED { return "operator declared; system cannot verify" as *u8 }
63 if t == GND_ASSERTED { return "domain-knowledge constant; no in-system external check" as *u8 }
64 if t == GND_DERIVED { return "computed from stronger inputs; not independently checked" as *u8 }
65 if t == GND_VALIDATED { return "model checked against published data" as *u8 }
66 if t == GND_ANCHORED { return "independent method + external literature agree" as *u8 }
67 return "ungrounded" as *u8
68}
69
70func gnd_valid(t: i64) -> i64 {
71 if t < GND_UNKNOWN { return 0 }
72 if t > GND_ANCHORED { return 0 }
73 return 1
74}
75
76// ===== The composition law: weakest link =============================
77
78func gnd_compose(a: i64, b: i64) -> i64 {
79 if a < b { return a }
80 return b
81}
82
83func gnd_compose3(a: i64, b: i64, c: i64) -> i64 {
84 let ab: i64 = gnd_compose(a, b)
85 return gnd_compose(ab, c)
86}
87
88// Minimum tier across an array of tiers -- the grounding of a claim built from
89// all of them. An empty set is UNKNOWN (nothing to stand on).
90func gnd_min(tiers: *i64, n: i64) -> i64 {
91 if n <= 0 { return GND_UNKNOWN }
92 var i: i64 = 0
93 var m: i64 = GND_ANCHORED
94 while i < n {
95 if tiers[i] < m { m = tiers[i] }
96 i = i + 1
97 }
98 return m
99}
100
101// ===== The honest line ================================================
102
103// Only VALIDATED and ANCHORED are "verified". This is the function that
104// refuses to let the go-to-market layer claim more than it has.
105func gnd_is_verified(t: i64) -> i64 {
106 if t >= GND_VALIDATED { return 1 }
107 return 0
108}
109
110// Usable to INFORM a decision (DERIVED and up) vs merely a placeholder.
111func gnd_decision_usable(t: i64) -> i64 {
112 if t >= GND_DERIVED { return 1 }
113 return 0
114}
115
116// A claim that must not be presented as fact without a caveat: anything below
117// VALIDATED. Returns 1 when a caveat is REQUIRED.
118func gnd_needs_caveat(t: i64) -> i64 {
119 if t < GND_VALIDATED { return 1 }
120 return 0
121}
122
123// ===== Grounding of THIS ecosystem's actual claim classes =============
124//
125// Named so the facades and any auditor read the SAME source of truth about
126// what is verified and what is asserted. These are deliberately honest -- the
127// business layer is ASSERTED, and this says so.
128
129const GC_PEPTIDE_MASS: i64 = 0 // ANCHORED (residue-sum == elemental == lit)
130const GC_MOLECULAR_FORMULA: i64 = 1 // ANCHORED (integer, vs published formula)
131const GC_FREEZING_CURVE: i64 = 2 // VALIDATED (vs Goff/Hartel points)
132const GC_PASTEURIZATION_Z: i64 = 3 // VALIDATED (recovered from 2 legal schedules)
133const GC_ISOELECTRIC_POINT: i64 = 4 // DERIVED (bisection over integer pKa set)
134const GC_ION_MZ: i64 = 5 // DERIVED (mass + proton convention)
135const GC_INGREDIENT_COST: i64 = 6 // ASSERTED (indicative bulk range)
136const GC_CPI_SCORE: i64 = 7 // ASSERTED (typed from memory)
137const GC_REGULATORY_CLASS: i64 = 8 // ASSERTED (correct, but no in-system oracle)
138const GC_TRIAL_COST: i64 = 9 // ASSERTED (order-of-magnitude planning)
139const GC_CGMP_FLAG: i64 = 10 // ATTESTED (operator declaration)
140const GC_N: i64 = 11
141
142func gnd_class_tier(gc: i64) -> i64 {
143 if gc == GC_PEPTIDE_MASS { return GND_ANCHORED }
144 if gc == GC_MOLECULAR_FORMULA { return GND_ANCHORED }
145 if gc == GC_FREEZING_CURVE { return GND_VALIDATED }
146 if gc == GC_PASTEURIZATION_Z { return GND_VALIDATED }
147 if gc == GC_ISOELECTRIC_POINT { return GND_DERIVED }
148 if gc == GC_ION_MZ { return GND_DERIVED }
149 if gc == GC_INGREDIENT_COST { return GND_ASSERTED }
150 if gc == GC_CPI_SCORE { return GND_ASSERTED }
151 if gc == GC_REGULATORY_CLASS { return GND_ASSERTED }
152 if gc == GC_TRIAL_COST { return GND_ASSERTED }
153 if gc == GC_CGMP_FLAG { return GND_ATTESTED }
154 return GND_UNKNOWN
155}