nx_legal_serve.nx source
↩ module page · 37 lines · 3003 B
1// nx_legal_serve.nx -- SERVE-WRAPPER making the LEGAL role's capability MCP-callable (operator 2026-07-10). Library-role
2// pattern (3rd instance): nx_legal_compliance is a PURE-LOGIC lib (classify + ESIGN/UETA verdict, no imports, no main); this
3// wrapper IMPORTS it + EXERCISES the safety-critical INVARIANT: an EXCLUDED testamentary instrument (a will) is NEVER
4// e-signed VALID (15 U.S.C. 7003(a)(1)), while a general contract with intent+consent+attribution+retainability IS. Clean
5// exit 0 + JSON verdict so nishi_crew dispatches `legal legal`. nx_legal_compliance imports NOTHING (pure) -> import BOTH it
6// and nx_syscalls (for my sys_* helpers), no double-import. LV_INVALID_VOID=2, LV_VALID=0, DT_CONTRACT=1 (from the lib).
7// license_tier: ORIGINAL expect_exit: 0
8import "nx_syscalls.nx"
9import "nx_legal_compliance.nx"
10
11func lsv_raw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
12func lsv_w2(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){ if s[n]==(39 as u8) { let q: *u8=sys_mmap(1); q[0]=34 as u8; sys_write(1,q,1) } else { sys_write(1,(s as i64+n) as *u8,1) } n=n+1 } return 0 }
13func lsv_bit(b: i64) -> i64 { let d: *u8=sys_mmap(1); d[0]=(48+b) as u8; sys_write(1,d,1); return 0 }
14
15func main() -> i64 {
16 let reason: *i64 = sys_mmap(8) as *i64
17 let regime: *i64 = sys_mmap(8) as *i64
18 // classify a will by its label, confirm it is an EXCLUDED testamentary instrument.
19 let dt_will: i64 = nx_legal_doc_classify("Last Will and Testament" as *u8)
20 let excluded: i64 = nx_legal_is_excluded(dt_will)
21 // INVARIANT: the will, e-signed in a state that does NOT permit e-wills (e_wills_allowed=0), even with every element
22 // present, is routed to REQUIRES_WET -> LV_INVALID_VOID (2). It must NEVER return LV_VALID (0).
23 let v_will: i64 = nx_legal_verdict(dt_will, 0, 1, 1, 1, 1, 2, 1, reason, regime)
24 // a general contract (DT_CONTRACT=1) with intent+consent+attribution+retainable e-signs VALID (0).
25 let v_contract: i64 = nx_legal_verdict(1, 0, 1, 1, 1, 1, 0, 0, reason, regime)
26 var will_void: i64=0; if v_will==2 { will_void=1 }
27 var contract_valid: i64=0; if v_contract==0 { contract_valid=1 }
28 var ok: i64=0; if excluded==1 { if will_void==1 { if contract_valid==1 { ok=1 } } }
29 lsv_w2("{'v':1,'api':'nishi-crew-legal/v1','role':'legal','activity':'legal','capability':'ESIGN/UETA compliance -- an excluded testamentary instrument (will) is NEVER e-signed VALID; a general contract with intent+consent+attribution+retainability IS','selftest':{'will_classified_excluded':" as *u8); lsv_bit(excluded)
30 lsv_w2(",'will_verdict_void_never_valid':" as *u8); lsv_bit(will_void)
31 lsv_w2(",'contract_verdict_valid':" as *u8); lsv_bit(contract_valid)
32 lsv_w2("},'verdict':'" as *u8)
33 if ok==1 { lsv_w2("GREEN (safety invariant upheld: void-never-valid)'}" as *u8) } else { lsv_w2("RED'}" as *u8) }
34 lsv_w2("\n" as *u8)
35 if ok==1 { sys_exit(0); return 0 }
36 sys_exit(1); return 1
37}