code wiki / _hdl_build / nx_capgraph_gate.nx

nx_capgraph_gate.nx source

↩ module page · 218 lines · 9397 B

1// nx_capgraph_gate.nx -- the gate for nx_capgraph_lib. NON-VACUOUS BY CONSTRUCTION: every law tooth is 2// a MATCHED PAIR (the law fires) + (a control where it must NOT fire), so no tooth can pass by accident 3// or by a constant. T10 is the DYNAMIC-RANGE tooth: it turns RED if the graph ever loses the ability to 4// register progress -- the exact disease measured in nx_capaxes_derive, where evidence=0 by construction 5// pinned all 28 domains to headline 0 forever. 6// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 7import "nx_capgraph_lib.nx" 8 9func cgg_t(name: *u8, cond: i64, ctr: *i64) { 10 if cond == 1 { 11 cax_puts(" ok " as *u8) 12 ctr[0] = ctr[0] + 1 13 } else { 14 cax_puts(" FAIL " as *u8) 15 } 16 cax_puts(name) 17 cax_puts("\n" as *u8) 18 ctr[1] = ctr[1] + 1 19} 20 21func main(argc: i64, argv: *i64) -> i64 { 22 var ctr: *i64 = sys_mmap(64) as *i64 23 ctr[0] = 0 24 ctr[1] = 0 25 26 cax_puts("=== nx_capgraph_gate: many-axis capability GRAPH (levels + DAG + prediction) ===\n" as *u8) 27 28 cg_init(6) 29 cg_axis_set(0, "coverage" as *u8) 30 cg_axis_set(1, "quality" as *u8) 31 cg_axis_set(2, "scale" as *u8) 32 cg_axis_set(3, "evidence" as *u8) 33 cg_axis_set(4, "adoption" as *u8) 34 cg_axis_set(5, "grounding" as *u8) 35 36 cgg_t("T1 ladder: 3 is GATED" as *u8, cg_streq(cg_level_name(3), "GATED" as *u8), ctr) 37 cgg_t("T1b ladder: 4 is ADOPTED (gated-but-unadopted is NOT the top)" as *u8, cg_streq(cg_level_name(4), "ADOPTED" as *u8), ctr) 38 39 let toy: i64 = cg_addnode("demo_only" as *u8, CG_EV_DEMO) 40 cg_set(toy, 0, 5) 41 cgg_t("T2 L6 claim 5 backed by demo-only evidence is CAPPED to 1" as *u8, cg_get(toy, 0) == 1, ctr) 42 let ext: i64 = cg_addnode("external_battery" as *u8, CG_EV_EXT) 43 cg_set(ext, 0, 5) 44 cgg_t("T2b NEG-CONTROL: the SAME claim 5 with external evidence stays 5" as *u8, cg_get(ext, 0) == 5, ctr) 45 let gated: i64 = cg_addnode("gated_no_caller" as *u8, CG_EV_GATE) 46 cg_set(gated, 0, 5) 47 cgg_t("T2c a GATED capability with no production caller cannot reach ADOPTED" as *u8, cg_get(gated, 0) == 3, ctr) 48 49 let sk: i64 = cg_addnode("skewed" as *u8, CG_EV_EXT) 50 cg_set(sk, 0, 5) 51 cg_set(sk, 1, 5) 52 cg_set(sk, 2, 5) 53 cg_set(sk, 3, 0) 54 cg_set(sk, 4, 5) 55 cg_set(sk, 5, 5) 56 cg_relax() 57 cgg_t("T3 L1 gamed vector headlines 0 (weakest axis), not the average" as *u8, cg_own_headline(sk) == 0, ctr) 58 cgg_t("T3b L1 the starved axis is named as evidence, not coverage" as *u8, cg_starved_axis(sk) == 3, ctr) 59 let bal: i64 = cg_addnode("balanced" as *u8, CG_EV_EXT) 60 cg_set(bal, 0, 4) 61 cg_set(bal, 1, 4) 62 cg_set(bal, 2, 4) 63 cg_set(bal, 3, 4) 64 cg_set(bal, 4, 4) 65 cg_set(bal, 5, 4) 66 cg_relax() 67 cgg_t("T3c NEG-CONTROL: a balanced profile is NOT dragged to 0" as *u8, cg_own_headline(bal) == 4, ctr) 68 69 cg_init(2) 70 cg_axis_set(0, "capability" as *u8) 71 cg_axis_set(1, "evidence" as *u8) 72 let base: i64 = cg_addnode("prereq_base" as *u8, CG_EV_EXT) 73 let mid: i64 = cg_addnode("mid_layer" as *u8, CG_EV_EXT) 74 let top: i64 = cg_addnode("top_feature" as *u8, CG_EV_EXT) 75 cg_set(base, 0, 1) 76 cg_set(base, 1, 1) 77 cg_set(mid, 0, 5) 78 cg_set(mid, 1, 5) 79 cg_set(top, 0, 5) 80 cg_set(top, 1, 5) 81 cg_addedge(base, mid) 82 cg_addedge(mid, top) 83 cg_relax() 84 cgg_t("T4 L4 a node standing on a TOY prerequisite is capped to TOY" as *u8, cg_effective(mid) == 1, ctr) 85 cgg_t("T4b L4 the cap is TRANSITIVE: two hops up is still TOY" as *u8, cg_effective(top) == 1, ctr) 86 cgg_t("T4c the OWN level is untouched -- only the effective level is capped" as *u8, cg_own_headline(top) == 5, ctr) 87 88 cg_set(base, 0, 5) 89 cg_set(base, 1, 5) 90 cg_relax() 91 cgg_t("T4d NEG-CONTROL: raising the PREREQUISITE releases the whole chain" as *u8, cg_effective(top) == 5, ctr) 92 93 cg_init(2) 94 cg_axis_set(0, "capability" as *u8) 95 cg_axis_set(1, "evidence" as *u8) 96 let unk: i64 = cg_addnode("unmeasured_prereq" as *u8, CG_EV_EXT) 97 let dep: i64 = cg_addnode("dependent" as *u8, CG_EV_EXT) 98 cg_set(dep, 0, 4) 99 cg_set(dep, 1, 4) 100 cg_addedge(unk, dep) 101 cg_relax() 102 cgg_t("T5 L3 an UNMEASURED prerequisite does NOT drag the dependent to -1" as *u8, cg_effective(dep) == 4, ctr) 103 cgg_t("T5b L3 the unmeasured node reports UNMEASURED, never a silent 0" as *u8, cg_effective(unk) == CG_UNMEASURED, ctr) 104 105 cg_init(2) 106 cg_axis_set(0, "capability" as *u8) 107 cg_axis_set(1, "evidence" as *u8) 108 let hub: i64 = cg_addnode("weak_hub" as *u8, CG_EV_EXT) 109 let leaf: i64 = cg_addnode("weak_leaf" as *u8, CG_EV_EXT) 110 let c1: i64 = cg_addnode("consumer1" as *u8, CG_EV_EXT) 111 let c2: i64 = cg_addnode("consumer2" as *u8, CG_EV_EXT) 112 let c3: i64 = cg_addnode("consumer3" as *u8, CG_EV_EXT) 113 cg_set(hub, 0, 1) 114 cg_set(hub, 1, 1) 115 cg_set(leaf, 0, 1) 116 cg_set(leaf, 1, 1) 117 cg_set(c1, 0, 5) 118 cg_set(c1, 1, 5) 119 cg_set(c2, 0, 5) 120 cg_set(c2, 1, 5) 121 cg_set(c3, 0, 5) 122 cg_set(c3, 1, 5) 123 let indep: i64 = cg_addnode("independent_sota" as *u8, CG_EV_EXT) 124 cg_set(indep, 0, 5) 125 cg_set(indep, 1, 5) 126 cg_addedge(hub, c1) 127 cg_addedge(hub, c2) 128 cg_addedge(hub, c3) 129 cg_relax() 130 cgg_t("T6 leverage: the hub gates 3 descendants" as *u8, cg_descendants(hub) == 3, ctr) 131 cgg_t("T6b leverage: the leaf gates 0" as *u8, cg_descendants(leaf) == 0, ctr) 132 cgg_t("T7 ROCK: an equally-weak node that GATES MORE outranks the leaf" as *u8, cg_rock(hub) > cg_rock(leaf), ctr) 133 cgg_t("T7b ROCK: an UNBLOCKED node at SOTA scores 0 -- nothing to mine" as *u8, cg_rock(indep) == 0, ctr) 134 cgg_t("T7c ROCK: a node CLAIMING SOTA behind a weak prereq STILL carries a rock" as *u8, cg_rock(c1) > 0, ctr) 135 cgg_t("T7d MATRIX: propagation is PER-AXIS, the profile is not flattened" as *u8, cg_effective_axis(c1, 0) == 1, ctr) 136 137 cg_init(3) 138 cg_axis_set(0, "reasoning" as *u8) 139 cg_axis_set(1, "throughput" as *u8) 140 cg_axis_set(2, "evidence" as *u8) 141 let subj: i64 = cg_addnode("subject" as *u8, CG_EV_EXT) 142 cg_set(subj, 0, 4) 143 cg_set(subj, 1, 2) 144 cg_set(subj, 2, 4) 145 cg_relax() 146 var dem: *i64 = sys_mmap(128) as *i64 147 dem[0] = 3 148 dem[1] = 5 149 dem[2] = 3 150 cgg_t("T8 L7 a task demanding more throughput than we have FAILS on throughput" as *u8, cg_predict(subj, dem) == 1, ctr) 151 dem[0] = 3 152 dem[1] = 2 153 dem[2] = 3 154 cgg_t("T8b NEG-CONTROL: when ability >= demand on every axis, it PASSES (-1)" as *u8, cg_predict(subj, dem) == (0 - 1), ctr) 155 156 let ung: i64 = cg_addnode("ungrounded" as *u8, CG_EV_NONE) 157 cg_set(ung, 0, 5) 158 cgg_t("T9 L2 evidence=none => UNGROUNDED, refuses to carry a level" as *u8, cg_grounded(ung) == 0, ctr) 159 cgg_t("T9b L2 the claim itself is capped to 0 by L6, not silently kept at 5" as *u8, cg_get(ung, 0) == 0, ctr) 160 161 cg_init(2) 162 cg_axis_set(0, "coverage" as *u8) 163 cg_axis_set(1, "evidence" as *u8) 164 let prog: i64 = cg_addnode("progressing" as *u8, CG_EV_EXT) 165 cg_set(prog, 0, 4) 166 cg_set(prog, 1, 0) 167 cg_relax() 168 let before: i64 = cg_effective(prog) 169 cg_set(prog, 1, 3) 170 cg_relax() 171 let after: i64 = cg_effective(prog) 172 cgg_t("T10 DYNAMIC RANGE: landing real evidence MOVES the headline (0 -> 3)" as *u8, after > before, ctr) 173 cgg_t("T10b DYNAMIC RANGE: the move is the exact level earned, not a rounding" as *u8, after == 3, ctr) 174 cg_set(prog, 0, 5) 175 cg_relax() 176 cgg_t("T10c ANTI-GAMING: raising COVERAGE alone does NOT move the headline" as *u8, cg_effective(prog) == 3, ctr) 177 178 // ---- T11 CYCLES ARE REAL. The MEASURED graph is not acyclic (browser<->webscraping and 179 // deepresearch<->search are both live, derived from the import closure 2026-07-31). The relaxation 180 // must therefore converge on a general digraph, not hang and not mis-rank. A cycle names a 181 // CO-DEPENDENT CLUSTER: its members share a floor and can only be raised together. 182 cg_init(2) 183 cg_axis_set(0, "capability" as *u8) 184 cg_axis_set(1, "evidence" as *u8) 185 let ca: i64 = cg_addnode("cyc_a" as *u8, CG_EV_EXT) 186 let cb: i64 = cg_addnode("cyc_b" as *u8, CG_EV_EXT) 187 let cc: i64 = cg_addnode("cyc_c" as *u8, CG_EV_EXT) 188 cg_set(ca, 0, 1) 189 cg_set(ca, 1, 1) 190 cg_set(cb, 0, 5) 191 cg_set(cb, 1, 5) 192 cg_set(cc, 0, 4) 193 cg_set(cc, 1, 4) 194 cg_addedge(ca, cb) 195 cg_addedge(cb, ca) 196 cg_addedge(cb, cc) 197 cg_relax() 198 cgg_t("T11 CYCLE: relaxation TERMINATES on a 2-cycle (no hang, bounded fixpoint)" as *u8, cg_effective(ca) != CG_UNMEASURED, ctr) 199 cgg_t("T11b CYCLE: co-dependent members share the FLOOR -- both read the cycle minimum" as *u8, cg_effective(cb) == 1, ctr) 200 cgg_t("T11c CYCLE: the floor propagates OUT of the cycle to a downstream consumer" as *u8, cg_effective(cc) == 1, ctr) 201 cgg_t("T11d CYCLE: descendants terminates and counts the cycle peer" as *u8, cg_descendants(ca) == 2, ctr) 202 cg_set(ca, 0, 5) 203 cg_set(ca, 1, 5) 204 cg_relax() 205 cgg_t("T11e NEG-CONTROL: raising the cycle releases it AND its consumer" as *u8, cg_effective(cc) == 4, ctr) 206 207 cg_gate_log("knowledge/status/capgraph_gate.log" as *u8, "CAPGRAPHGATE" as *u8, ctr[0], ctr[1]) 208 cax_puts("\nCAPGRAPH-GATE " as *u8) 209 cax_puti(ctr[0]) 210 cax_puts("/" as *u8) 211 cax_puti(ctr[1]) 212 if ctr[0] == ctr[1] { 213 cax_puts(" GREEN\n" as *u8) 214 return 0 215 } 216 cax_puts(" RED\n" as *u8) 217 return 1 218}