nx_fin_grant_gate.nx source
↩ module page · 42 lines · 2109 B
1// nx_fin_grant_gate.nx -- GATE for the grants arm: SBIR/STTR eligibility (pass + each failing condition),
2// program-fit ranking, draft completeness + readiness, and the phase award caps -- hand-computed. Exits 0 iff
3// all pass. license_tier: ORIGINAL
4import "nx_gate.nx"
5import "nx_fin_grant.nx"
6
7func chk(name: *u8, got: i64, want: i64, st: *i64) -> i64 {
8 if got == want { st[0] = st[0] + 1; gw(" PASS " as *u8); gw(name); gw("\n" as *u8) }
9 else { st[1] = st[1] + 1; gw(" FAIL " as *u8); gw(name); gw(" got=" as *u8); gn(got); gw(" want=" as *u8); gn(want); gw("\n" as *u8) }
10 return 0
11}
12
13func main() -> i64 {
14 let st: *i64 = sys_mmap(16) as *i64
15 st[0] = 0; st[1] = 0
16
17 // eligibility: small for-profit, 50 employees, 100% US-owned -> ELIGIBLE
18 chk("SBIR eligible (small/50/100%/forprofit)" as *u8, gr_sbir_eligible(1, 50, 100, 1), 1, st)
19 chk("not-small -> ineligible" as *u8, gr_sbir_eligible(0, 50, 100, 1), 0, st)
20 chk("600 employees -> ineligible" as *u8, gr_sbir_eligible(1, 600, 100, 1), 0, st)
21 chk("40% US-owned -> ineligible" as *u8, gr_sbir_eligible(1, 50, 40, 1), 0, st)
22 chk("nonprofit -> ineligible" as *u8, gr_sbir_eligible(1, 50, 100, 0), 0, st)
23
24 // fit score: topic 80 + phase-ready 20 + novelty 3*10 = 130
25 chk("fit score = 130" as *u8, gr_fit_score(80, 1, 3, 20, 10), 130, st)
26
27 // draft completeness
28 chk("all 5 sections -> complete 5" as *u8, gr_draft_complete(1, 1, 1, 1, 1), 5, st)
29 chk("3 sections -> 3" as *u8, gr_draft_complete(1, 1, 0, 1, 0), 3, st)
30 chk("5 -> ready" as *u8, gr_draft_ready(5), 1, st)
31 chk("3 -> not ready" as *u8, gr_draft_ready(3), 0, st)
32
33 // award caps (cents)
34 chk("Phase I cap = $275,000" as *u8, gr_award_cap(1), 27500000, st)
35 chk("Phase II cap = $1,800,000" as *u8, gr_award_cap(2), 180000000, st)
36 chk("bad phase -> 0" as *u8, gr_award_cap(3), 0, st)
37
38 gw("nx_fin_grant_gate: PASS=" as *u8); gn(st[0]); gw(" FAIL=" as *u8); gn(st[1]); gw("\n" as *u8)
39 if st[1] == 0 { gw("R8 nx_fin_grant: GREEN\n" as *u8); return 0 }
40 gw("R8 nx_fin_grant: RED\n" as *u8)
41 return 1
42}