nx_matter_intake_lib.nx source
↩ module page · 39 lines · 2710 B
1// nx_matter_intake_lib.nx -- Nishi Office: NEW-MATTER INTAKE (F511 composition / logical
2// integration). ONE flow chaining all 6 office capabilities: conflict-check -> open matter ->
3// trust retainer -> Box the engagement letter (privileged + Bates) -> docket the deadline ->
4// client e-signs (UETA consent). This is the atlas-recombination showcase: the suite working
5// TOGETHER, compliance gated at every step. Composes the 5 capability libs (which transitively
6// pull nx_sign_envelope_lib + nx_matter_lib + registry/canon). LIB (no main). license_tier: ORIGINAL
7
8import "nx_sign_ceremony_lib.nx"
9import "nx_box_lib.nx"
10import "nx_trust_lib.nx"
11import "nx_docket_lib.nx"
12
13// Full intake. Returns the docketed deadline day on SUCCESS; <0 = a compliance GATE fired:
14// -1 = conflict of interest (adverse party already adverse in another matter; RPC 1.7/1.9)
15// -2 = docket rule not found (fail-closed; never a silent wrong date)
16// -3 = signature refused (no client consent; UETA)
17func intake_new_matter(prefix: *u8, client_id: *u8, client_name: *u8, matter_id: *u8, title: *u8, area: *u8, retainer_cents: i64, adverse: *u8, deadline_rule: *u8, trigger_day: i64, consent: *u8) -> i64 {
18 // ---- VALIDATE: all compliance gates fire BEFORE any write (validate-then-commit), so no
19 // gate can ever leave a half-open matter (defensive at the boundary, rule 12) ----
20 let cbuf: *u8 = sys_mmap(512)
21 if mt_conflict(prefix, adverse, cbuf) > 0 { return 0 - 1 } // GATE 1 conflict (RPC 1.7/1.9)
22 let mo: *i64 = sys_mmap(16) as *i64
23 if dk_rule_days(prefix, deadline_rule, mo) < 0 { return 0 - 2 } // GATE 2 docket rule exists (fail-closed)
24 if sc_consent_ok(consent) == 0 { return 0 - 3 } // GATE 3 UETA/ESIGN consent+intent
25 // ---- COMMIT: every gate passed; these writes cannot leave partial state ----
26 mt_client_put(prefix, client_id, client_name, "client@firm" as *u8)
27 mt_matter_put(prefix, matter_id, client_id, title, area)
28 mt_party_add(prefix, matter_id, 0, adverse, "adverse" as *u8)
29 trust_put(prefix, client_id, 0, matter_id, "deposit" as *u8, retainer_cents) // RPC 1.15 retainer
30 let bates: *u8 = sys_mmap(64)
31 box_bates(prefix, 1, bates)
32 box_doc_put(prefix, matter_id, "ENG" as *u8, "Engagement Letter" as *u8, "nxc1-eng0000000" as *u8, "yes" as *u8, bates) // privileged + Bates
33 let dl: i64 = dk_compute(prefix, deadline_rule, trigger_day) // URCP deadline (rule already validated)
34 let g: *u8 = sys_mmap(40)
35 se_genesis(g)
36 let h: *u8 = sys_mmap(40)
37 sc_sign(matter_id, 0, client_name, trigger_day, consent, g, h) // UETA-attributed signature (consent pre-validated)
38 return dl
39}