nx_hold_pure_gate.nx source
↩ module page · 101 lines · 6951 B
1// nx_hold_pure_gate.nx -- INDEPENDENT GATE over the PURE DECISION CORE of nx_hold_lib.
2// ZERO registry writes. Proves the preservation rules and the FRCP 37(e) sanction ladder independently
3// of storage, so a seg_store stall (debt 1785519597) cannot make them unverifiable.
4//
5// The sanction ladder is swept EXHAUSTIVELY over all 16 (lost x reasonable-steps x restorable x intent)
6// combinations, with three invariants asserted across the whole sweep: no ESI lost is NEVER a sanction;
7// reasonable steps taken is NEVER a sanction (the safe harbour is absolute); and SEVERE requires intent
8// in every single cell -- negligence can never reach it by any path.
9// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
10
11import "nx_hold_lib.nx"
12import "nx_gate_verdict.nx"
13
14func main(argc: i64, argv: *i64) -> i64 {
15 let ctr: *i64 = gv_ctr()
16 let lbl: *u8 = sys_mmap(32)
17
18 gv_head("NISHI-HOLD-PURE-GATE (preservation duty + defensible hold + FRCP 37(e), zero storage)" as *u8)
19
20 // ---- D: when the duty attaches -- the EARLIER trigger wins ----
21 gv_check("D1 anticipation 20000 vs filing 20090 -> duty runs from 20000" as *u8, hd_duty_pure(20000, 20090) == 20000, ctr)
22 gv_check("D1a and NOT from the filing date" as *u8, hd_duty_pure(20000, 20090) == 20090 == 0, ctr)
23 gv_check("D2 order does not matter, the minimum wins" as *u8, hd_duty_pure(20090, 20000) == 20000, ctr)
24 gv_check("D3 filing only -> duty runs from filing" as *u8, hd_duty_pure(HD_UNSET, 20090) == 20090, ctr)
25 gv_check("D4 anticipation only -> duty runs from anticipation" as *u8, hd_duty_pure(20000, HD_UNSET) == 20000, ctr)
26 gv_check("D5 neither known -> no duty date" as *u8, hd_duty_pure(HD_UNSET, HD_UNSET) == HD_UNSET, ctr)
27 gv_check("D6 attached on the day itself" as *u8, hd_duty_attached_pure(20000, 20000) == 1, ctr)
28 gv_check("D7 not attached the day before" as *u8, hd_duty_attached_pure(20000, 19999) == 0, ctr)
29 gv_check("D8 an unknown duty date can never attach" as *u8, hd_duty_attached_pure(HD_UNSET, 20050) == 0, ctr)
30 gv_check("D9 an unknown as-of date is never guessed" as *u8, hd_duty_attached_pure(20000, HD_UNSET) == 0, ctr)
31
32 // ---- S: suspension of auto-deletion, counted independently of the notice ----
33 gv_check("S1 5 of 5 suspended -> 0 still purging" as *u8, hd_unsuspended_pure(5, 5) == 0, ctr)
34 gv_check("S2 3 of 5 suspended -> 2 still purging" as *u8, hd_unsuspended_pure(5, 3) == 2, ctr)
35 gv_check("S3 unknown suspended count -> assume NONE suspended (fail-safe)" as *u8, hd_unsuspended_pure(5, HD_UNSET) == 5, ctr)
36 gv_check("S4 unknown system total -> UNSET, never silently zero" as *u8, hd_unsuspended_pure(HD_UNSET, 3) == HD_UNSET, ctr)
37 gv_check("S5 over-suspension clamps to 0, never negative" as *u8, hd_unsuspended_pure(3, 9) == 0, ctr)
38
39 // ---- F: defensibility needs all four, independently ----
40 gv_check("F1 duty + notice + 0 unacked + 0 purging -> DEFENSIBLE" as *u8, hd_defensible_pure(1, 1, 0, 0) == 1, ctr)
41 gv_check("F2 duty never attached -> not defensible" as *u8, hd_defensible_pure(0, 1, 0, 0) == 0, ctr)
42 gv_check("F3 no notice issued -> not defensible" as *u8, hd_defensible_pure(1, 0, 0, 0) == 0, ctr)
43 gv_check("F4 ONE unacknowledged custodian -> not defensible" as *u8, hd_defensible_pure(1, 1, 1, 0) == 0, ctr)
44 gv_check("F5 notice sent but a system STILL purging -> not defensible" as *u8, hd_defensible_pure(1, 1, 0, 1) == 0, ctr)
45 gv_check("F6 unknown suspension state -> not defensible (fail-closed)" as *u8, hd_defensible_pure(1, 1, 0, HD_UNSET) == 0, ctr)
46
47 // ---- E: exposure ----
48 gv_check("E1 exposure = unacked + purging" as *u8, hd_exposure_pure(2, 3) == 5, ctr)
49 gv_check("E2 a fully-run hold has zero exposure" as *u8, hd_exposure_pure(0, 0) == 0, ctr)
50 gv_check("E3 unknown suspension -> exposure UNKNOWN, not zero" as *u8, hd_exposure_pure(0, HD_UNSET) == HD_UNSET, ctr)
51
52 // ---- P: release ----
53 gv_check("P1 unreleased hold is not premature" as *u8, hd_release_premature_pure(HD_UNSET, 20000) == 0, ctr)
54 gv_check("P2 released BEFORE the duty attached -> premature" as *u8, hd_release_premature_pure(19990, 20000) == 1, ctr)
55 gv_check("P3 released after the duty attached -> fine" as *u8, hd_release_premature_pure(20500, 20000) == 0, ctr)
56 gv_check("P4 released with NO duty date at all -> premature" as *u8, hd_release_premature_pure(20500, HD_UNSET) == 1, ctr)
57
58 // ---- T: EXHAUSTIVE FRCP 37(e) sweep over all 16 combinations ----
59 var no_loss_sanctioned: i64 = 0
60 var harbour_breached: i64 = 0
61 var severe_without_intent: i64 = 0
62 var severe_count: i64 = 0
63 var i: i64 = 0
64 while i < 16 {
65 let lost: i64 = (i / 8) % 2
66 let steps: i64 = (i / 4) % 2
67 let restorable: i64 = (i / 2) % 2
68 let intent: i64 = i % 2
69 let t: i64 = hd_sanction_tier(lost, steps, restorable, intent)
70 if lost == 0 {
71 if t != HD_NO_SANCTION { no_loss_sanctioned = no_loss_sanctioned + 1 }
72 }
73 if steps == 1 {
74 if t != HD_NO_SANCTION { harbour_breached = harbour_breached + 1 }
75 }
76 if t == HD_SEVERE {
77 severe_count = severe_count + 1
78 if intent != 1 { severe_without_intent = severe_without_intent + 1 }
79 }
80 i = i + 1
81 }
82 gv_check("T1 no ESI lost is NEVER a sanction, in all 8 such cells" as *u8, no_loss_sanctioned == 0, ctr)
83 gv_check("T2 reasonable steps is an ABSOLUTE safe harbour, in all 8 such cells" as *u8, harbour_breached == 0, ctr)
84 gv_check("T3 SEVERE never occurs without intent, anywhere in the sweep" as *u8, severe_without_intent == 0, ctr)
85 gv_check("T4 exactly ONE of 16 combinations reaches SEVERE" as *u8, severe_count == 1, ctr)
86
87 gv_check("T5 lost + no steps + unrestorable + no intent -> CURATIVE" as *u8, hd_sanction_tier(1, 0, 0, 0) == HD_CURATIVE, ctr)
88 gv_check("T6 same facts PLUS intent -> SEVERE" as *u8, hd_sanction_tier(1, 0, 0, 1) == HD_SEVERE, ctr)
89 gv_check("T7 lost but RESTORABLE -> no sanction" as *u8, hd_sanction_tier(1, 0, 1, 0) == HD_NO_SANCTION, ctr)
90 gv_check("T8 intent is irrelevant once the safe harbour applies" as *u8, hd_sanction_tier(1, 1, 0, 1) == HD_NO_SANCTION, ctr)
91 gv_check("T9 garbage flags fail closed to no sanction" as *u8, hd_sanction_tier(99, 0, 0, 1) == HD_NO_SANCTION, ctr)
92
93 hd_sanction_label(hd_sanction_tier(1, 0, 0, 1), lbl)
94 gv_check("T10 severe label" as *u8, mt_streq(lbl, "SEVERE-37e2" as *u8) == 1, ctr)
95 hd_sanction_label(hd_sanction_tier(1, 0, 0, 0), lbl)
96 gv_check("T10a curative label" as *u8, mt_streq(lbl, "CURATIVE-37e1" as *u8) == 1, ctr)
97 hd_sanction_label(hd_sanction_tier(1, 1, 0, 0), lbl)
98 gv_check("T10b safe-harbour label" as *u8, mt_streq(lbl, "NONE" as *u8) == 1, ctr)
99
100 return gv_verdict("LEGAL-HOLD-37E" as *u8, ctr, "duty on the earlier trigger; 37(e) safe harbour absolute; SEVERE needs intent" as *u8)
101}