code wiki / (root) / nx_sol_gate.nx

nx_sol_gate.nx source

↩ module page · 115 lines · 6698 B

1// nx_sol_gate.nx -- STATUTE OF LIMITATIONS GATE. 2// Proves exact proleptic-Gregorian day numbers (epoch, pre-epoch, a 30-year span with its 7 leap days), 3// leap-year classification at the 4/100/400 boundaries, Feb-29 -> Feb-28 clamping on year addition, the 4// OPEN/EXPIRED boundary (a claim may be filed ON the deadline day), tolling that pushes the deadline out by 5// exactly the tolled days, the discovery rule, and the fail-closed refusals (no accrual / zero period / 6// negative toll -> SOL_UNKNOWN -> UNDETERMINED). Every date hand-verified. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 7 8import "nx_sol_lib.nx" 9import "nx_matter_lib.nx" 10 11func sg_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 12func sg_putn(v: i64) -> i64 { 13 let t: *u8 = sys_mmap(32) 14 var o: i64 = 0 15 var m: i64 = v 16 if m < 0 { t[o] = 45 as u8; o = o + 1; m = 0 - m } 17 let d: *u8 = sys_mmap(32) 18 var k: i64 = 0 19 if m == 0 { d[0] = 48 as u8; k = 1 } 20 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 21 var i: i64 = 0 22 while i < k { t[o] = d[k - 1 - i]; o = o + 1; i = i + 1 } 23 sys_write(1, t, o) 24 return 0 25} 26func sg_ck(cnt: *i64, name: *u8, got: i64, want: i64) -> i64 { 27 if got == want { 28 cnt[0] = cnt[0] + 1 29 sg_puts(" PASS " as *u8); sg_puts(name); sg_puts(" = " as *u8); sg_putn(got); sg_puts("\n" as *u8) 30 return 1 31 } 32 cnt[1] = cnt[1] + 1 33 sg_puts(" FAIL " as *u8); sg_puts(name); sg_puts(" got " as *u8); sg_putn(got) 34 sg_puts(" want " as *u8); sg_putn(want); sg_puts("\n" as *u8) 35 return 0 36} 37func sg_ckstr(cnt: *i64, name: *u8, got: *u8, want: *u8) -> i64 { 38 if mt_streq(got, want) == 1 { 39 cnt[0] = cnt[0] + 1 40 sg_puts(" PASS " as *u8); sg_puts(name); sg_puts(" = " as *u8); sg_puts(got); sg_puts("\n" as *u8) 41 return 1 42 } 43 cnt[1] = cnt[1] + 1 44 sg_puts(" FAIL " as *u8); sg_puts(name); sg_puts(" got " as *u8); sg_puts(got); sg_puts("\n" as *u8) 45 return 0 46} 47 48func main(argc: i64, argv: *i64) -> i64 { 49 let cnt: *i64 = sys_mmap(16) as *i64 50 cnt[0] = 0 51 cnt[1] = 0 52 53 sg_puts("NISHI-SOL-GATE (statute of limitations: exact Gregorian deadlines, tolling, discovery, fail-closed)\n" as *u8) 54 55 // ---- exact day-number core ---- 56 sg_ck(cnt, "S1 1970-01-01 = day 0 (epoch)" as *u8, sol_days_from_civil(1970, 1, 1), 0) 57 sg_ck(cnt, "S2 1969-12-31 = day -1 (pre-epoch, floor-div branch)" as *u8, sol_days_from_civil(1969, 12, 31), 0 - 1) 58 sg_ck(cnt, "S3 2000-01-01 = 10957 (30yr = 10950 + 7 leap days)" as *u8, sol_days_from_civil(2000, 1, 1), 10957) 59 60 // ---- leap-year classification at the 4 / 100 / 400 boundaries ---- 61 sg_ck(cnt, "S4 2000 leap (div 400)" as *u8, sol_is_leap(2000), 1) 62 sg_ck(cnt, "S5 1900 NOT leap (div 100 not 400)" as *u8, sol_is_leap(1900), 0) 63 sg_ck(cnt, "S6 2024 leap (div 4)" as *u8, sol_is_leap(2024), 1) 64 sg_ck(cnt, "S7 2023 NOT leap" as *u8, sol_is_leap(2023), 0) 65 66 // ---- Feb-29 accrual + N years clamps to Feb-28 in a non-leap target year ---- 67 sg_ck(cnt, "S8 2024-02-29 + 1yr -> 2025-02-28 (day 20147, clamped)" as *u8, sol_add_years_civil(2024, 2, 29, 1), 20147) 68 sg_ck(cnt, "S9 civil 2025-02-28 = 20147 (proves the clamp is a real date)" as *u8, sol_days_from_civil(2025, 2, 28), 20147) 69 sg_ck(cnt, "S10 2024-02-29 + 2yr -> 2026-02-28 (day 20512)" as *u8, sol_add_years_civil(2024, 2, 29, 2), 20512) 70 71 // ---- 2-year SOL accrued on the leap day; status across the boundary ---- 72 let deadline: i64 = sol_deadline_years(1, 2024, 2, 29, 2, 0) 73 sg_ck(cnt, "S11 deadline = 20512" as *u8, deadline, 20512) 74 sg_ck(cnt, "S12 as of 2026-02-15 -> OPEN" as *u8, sol_status(deadline, sol_days_from_civil(2026, 2, 15)), SOL_OPEN) 75 sg_ck(cnt, "S13 days remaining on 2026-02-15 = 13" as *u8, sol_days_remaining(deadline, sol_days_from_civil(2026, 2, 15)), 13) 76 sg_ck(cnt, "S14 ON the deadline day -> still OPEN (may file on the last day)" as *u8, sol_status(deadline, deadline), SOL_OPEN) 77 sg_ck(cnt, "S15 days remaining on the deadline day = 0" as *u8, sol_days_remaining(deadline, deadline), 0) 78 sg_ck(cnt, "S16 as of 2026-03-01 -> TIME-BARRED" as *u8, sol_status(deadline, sol_days_from_civil(2026, 3, 1)), SOL_EXPIRED) 79 sg_ck(cnt, "S17 overdue by 1 day on 2026-03-01" as *u8, sol_days_remaining(deadline, sol_days_from_civil(2026, 3, 1)), 0 - 1) 80 81 // ---- discovery rule: clock starts at the later of act and discovery ---- 82 let act: i64 = sol_days_from_civil(2020, 1, 1) 83 let disc: i64 = sol_days_from_civil(2024, 1, 1) 84 sg_ck(cnt, "S18 discovery rule picks the later (discovery) date" as *u8, sol_effective_accrual(act, disc, 1), disc) 85 sg_ck(cnt, "S19 standard claim uses the act date" as *u8, sol_effective_accrual(act, disc, 0), act) 86 sg_ck(cnt, "S20 discovery before the act is floored to the act (fail-safe)" as *u8, sol_effective_accrual(disc, act, 1), disc) 87 88 // ---- *FAIL-CLOSED: an uncomputable deadline is never open or barred ---- 89 sg_ck(cnt, "S21 no accrual established -> SOL_UNKNOWN" as *u8, sol_deadline_years(0, 2020, 1, 1, 2, 0), SOL_UNKNOWN) 90 sg_ck(cnt, "S22 zero-year period -> SOL_UNKNOWN" as *u8, sol_deadline_years(1, 2020, 1, 1, 0, 0), SOL_UNKNOWN) 91 sg_ck(cnt, "S23 negative tolling -> SOL_UNKNOWN" as *u8, sol_deadline_years(1, 2020, 1, 1, 2, 0 - 5), SOL_UNKNOWN) 92 sg_ck(cnt, "S24 unknown deadline -> UNDETERMINED (not OPEN, not BARRED)" as *u8, sol_status(SOL_UNKNOWN, 20000), SOL_UNDETERMINED) 93 94 // ---- tolling pushes the deadline out by exactly the tolled days ---- 95 let base: i64 = sol_deadline_years(1, 2020, 1, 1, 2, 0) 96 let tolled: i64 = sol_deadline_years(1, 2020, 1, 1, 2, 90) 97 sg_ck(cnt, "S25 base 2yr deadline from 2020-01-01 = 18993 (2022-01-01)" as *u8, base, 18993) 98 sg_ck(cnt, "S26 tolling 90 days pushes the deadline out by exactly 90" as *u8, tolled - base, 90) 99 100 // ---- status labels ---- 101 sg_ckstr(cnt, "S27 label OPEN" as *u8, sol_status_str(SOL_OPEN), "OPEN" as *u8) 102 sg_ckstr(cnt, "S28 label TIME-BARRED" as *u8, sol_status_str(SOL_EXPIRED), "TIME-BARRED" as *u8) 103 sg_ckstr(cnt, "S29 label UNDETERMINED-FOR-REVIEW" as *u8, sol_status_str(SOL_UNDETERMINED), "UNDETERMINED-FOR-REVIEW" as *u8) 104 105 sg_puts("nx_sol_gate: pass=" as *u8); sg_putn(cnt[0]) 106 sg_puts(" fail=" as *u8); sg_putn(cnt[1]); sg_puts("\n" as *u8) 107 if cnt[1] == 0 { 108 sg_puts("SOL nx_sol: VERDICT=GREEN (exact Gregorian SOL deadlines, tolling + discovery rule, fail-closed on missing data)\n" as *u8) 109 sys_exit(0) 110 return 0 111 } 112 sg_puts("SOL nx_sol: VERDICT=RED\n" as *u8) 113 sys_exit(1) 114 return 1 115}