code wiki / _hdl_build / nx_gonogo_gate.nx
nx_gonogo_gate.nx source
↩ module page · 67 lines · 5186 B
1// nx_gonogo_gate.nx -- GATE for the dmkt GO/NO-GO decision core (F317 / M9).
2//
3// Every tooth ships with its OPPOSITE, because the failure mode this gate exists to prevent is a
4// decision organ that quietly resolves an unknown into a confident answer. Verdict emission
5// INHERITS nx_gate_verdict (D001) so nx_gate_green can judge it and it lands a harness frame.
6// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
7import "nx_syscalls.nx"
8import "nx_gonogo.nx"
9import "nx_gate_verdict.nx"
10
11const GGT_MARGIN_OK: i64 = 500
12const GGT_MARGIN_FLOOR: i64 = 300
13const GGT_MARGIN_BAD: i64 = 100
14const GGT_RISK_OK: i64 = 30
15const GGT_RISK_CEIL: i64 = 50
16const GGT_RISK_BAD: i64 = 90
17const GGT_COV_OK: i64 = 900
18const GGT_COV_FLOOR: i64 = 800
19const GGT_COV_BAD: i64 = 100
20const GGT_DOM_OK: i64 = 400
21const GGT_DOM_FLOOR: i64 = 100
22const GGT_DOM_BAD: i64 = 50
23const GGT_DISABLED: i64 = 0
24
25func ggt_chk(name: *u8, got: i64, want: i64, ctr: *i64) -> i64 {
26 ctr[1] = ctr[1] + 1
27 if got == want { ctr[0] = ctr[0] + 1; sys_write(1, " PASS " as *u8, 7) } else { sys_write(1, " FAIL " as *u8, 7) }
28 var n: i64 = 0
29 while name[n] != (0 as u8) { n = n + 1 }
30 sys_write(1, name, n)
31 sys_write(1, "\n" as *u8, 1)
32 return 0
33}
34
35func main(argc: i64, argv: *i64) -> i64 {
36 let ctr: *i64 = gv_ctr()
37 ctr[0] = 0
38 ctr[1] = 0
39 let k: *i64 = sys_mmap(64) as *i64
40 // T1 everything satisfied and demand evidence present -> the only state that may say GO
41 ggt_chk("all gates pass + demand present -> GO" as *u8, gg_decide(GGT_MARGIN_OK, GGT_MARGIN_FLOOR, GGT_RISK_OK, GGT_RISK_CEIL, GGT_COV_OK, GGT_COV_FLOOR, GGT_DOM_OK, GGT_DOM_FLOOR, 1, k), GG_GO, ctr)
42 // T2 ★THE ASYMMETRY: margin fails AND demand is missing -> NO-GO, never BLOCKED. A product that
43 // loses money is rejectable with no market study at all. If this ever returns BLOCKED the gate
44 // has become an oracle that refuses to disqualify anything cheaply.
45 ggt_chk("margin fails + demand MISSING -> NO-GO (hard fail beats missing evidence)" as *u8, gg_decide(GGT_MARGIN_BAD, GGT_MARGIN_FLOOR, GGT_RISK_OK, GGT_RISK_CEIL, GGT_COV_OK, GGT_COV_FLOOR, GGT_DOM_OK, GGT_DOM_FLOOR, 0, k), GG_NOGO, ctr)
46 // T3 the OPPOSITE of T2: nothing fails, but demand evidence is absent -> must NOT invent a GO
47 ggt_chk("all gates pass + demand ABSENT -> BLOCKED-ON-EVIDENCE" as *u8, gg_decide(GGT_MARGIN_OK, GGT_MARGIN_FLOOR, GGT_RISK_OK, GGT_RISK_CEIL, GGT_COV_OK, GGT_COV_FLOOR, GGT_DOM_OK, GGT_DOM_FLOOR, 0, k), GG_BLOCKED, ctr)
48 // T4/T5/T6 each remaining hard gate fires on its own
49 ggt_chk("supply risk above ceiling -> NO-GO" as *u8, gg_decide(GGT_MARGIN_OK, GGT_MARGIN_FLOOR, GGT_RISK_BAD, GGT_RISK_CEIL, GGT_COV_OK, GGT_COV_FLOOR, GGT_DOM_OK, GGT_DOM_FLOOR, 1, k), GG_NOGO, ctr)
50 ggt_chk("capability coverage below floor -> NO-GO" as *u8, gg_decide(GGT_MARGIN_OK, GGT_MARGIN_FLOOR, GGT_RISK_OK, GGT_RISK_CEIL, GGT_COV_BAD, GGT_COV_FLOOR, GGT_DOM_OK, GGT_DOM_FLOOR, 1, k), GG_NOGO, ctr)
51 ggt_chk("domestic content below floor -> NO-GO (the strategic gate)" as *u8, gg_decide(GGT_MARGIN_OK, GGT_MARGIN_FLOOR, GGT_RISK_OK, GGT_RISK_CEIL, GGT_COV_OK, GGT_COV_FLOOR, GGT_DOM_BAD, GGT_DOM_FLOOR, 1, k), GG_NOGO, ctr)
52 // T7 coverage UNKNOWN while its gate is armed -> blocked, not guessed
53 ggt_chk("coverage UNKNOWN + gate armed -> BLOCKED (never guessed)" as *u8, gg_decide(GGT_MARGIN_OK, GGT_MARGIN_FLOOR, GGT_RISK_OK, GGT_RISK_CEIL, GG_UNKNOWN, GGT_COV_FLOOR, GGT_DOM_OK, GGT_DOM_FLOOR, 1, k), GG_BLOCKED, ctr)
54 // T8 INCLUSIVE BOUNDARY: exactly at the floor is a pass, not a fail
55 ggt_chk("margin exactly AT floor -> GO (floor is inclusive)" as *u8, gg_decide(GGT_MARGIN_FLOOR, GGT_MARGIN_FLOOR, GGT_RISK_OK, GGT_RISK_CEIL, GGT_COV_OK, GGT_COV_FLOOR, GGT_DOM_OK, GGT_DOM_FLOOR, 1, k), GG_GO, ctr)
56 // T9/T10 the WAIVER is explicit and auditable: a threshold of 0 disables that gate, both for a
57 // hard failure and for a missing input. Without these two teeth the waiver could rot silently.
58 ggt_chk("margin gate DISABLED (floor 0) + terrible margin -> GO" as *u8, gg_decide(1, GGT_DISABLED, GGT_RISK_OK, GGT_RISK_CEIL, GGT_COV_OK, GGT_COV_FLOOR, GGT_DOM_OK, GGT_DOM_FLOOR, 1, k), GG_GO, ctr)
59 ggt_chk("coverage gate DISABLED + coverage UNKNOWN -> GO (not blocked on an input nobody wants)" as *u8, gg_decide(GGT_MARGIN_OK, GGT_MARGIN_FLOOR, GGT_RISK_OK, GGT_RISK_CEIL, GG_UNKNOWN, GGT_DISABLED, GGT_DOM_OK, GGT_DOM_FLOOR, 1, k), GG_GO, ctr)
60 // T11 a NO-GO must not report missing evidence it never needed -- the reason vector has to be
61 // honest about WHY, or the operator chases a market study to fix a margin problem.
62 gg_decide(GGT_MARGIN_BAD, GGT_MARGIN_FLOOR, GGT_RISK_OK, GGT_RISK_CEIL, GGT_COV_OK, GGT_COV_FLOOR, GGT_DOM_OK, GGT_DOM_FLOOR, 0, k)
63 ggt_chk("NO-GO reports the failed gate, NOT the unrelated missing evidence" as *u8, k[0] + k[4], 1, ctr)
64 let rc: i64 = gv_verdict("GONOGO-GATE" as *u8, ctr, "three-state verdict: hard failure beats missing evidence (cheap disqualification survives), missing evidence never becomes a GO, thresholds of 0 are explicit auditable waivers" as *u8)
65 sys_exit(rc)
66 return rc
67}