code wiki / (root) / nx_doc_envelope.nx

nx_doc_envelope.nx

buildroot/runtime/nx_doc_envelope.nx

14670 B355 linesdepth 10pulls 14 transitivereach 9 importersview sourcekind librarytopic doc
docsdependenciesstructsconstsfunctions

about

nx_doc_envelope.nx -- LEGAL RUNG D2: the e-signature ENVELOPE workflow. module: nishi-core.legal.doc_envelope capability: LEGAL_ESIGN_ENVELOPE The "DocuSign but better" WORKFLOW core. It orchestrates one document through create -> send -> sign (per recipient, in routing order) -> complete, binding the three already-GREEN legal organs into one client-facing flow: D0 nx_legal_compliance -- classify the document + pick its legal regime at CREATE; REFUSE to route a void instrument into the e-sign flow at SEND (never-route-a-void-instrument). D5 nx_doc_seal -- each signer's signature is a REAL RFC-8032 Ed25519 seal; SIGN verifies it; an envelope can only COMPLETE when every required signer has a VERIFIED, non-refused, VALID-verdict seal (all-signers-or-not-complete). D1 nx_doc_vault -- (gate-composed) the completed, sealed version is attached to the per-tenant additive vault. THE s-class-exceed property, carried LIVE through the workflow (a generic e-sign product lacks every one of these): * a will / codicil / testamentary trust in a NON-e-wills jurisdiction can NEVER be sent for e-signature -- it would produce a legally VOID instrument (UETA 3(b) / ESIGN 7003(a)). The refusal is at the workflow boundary (SEND), not merely at the crypto. This is the legal analog of Rule 26. * routing order is enforced -- recipient N+1 cannot sign before recipient N. * a forged or tampered signature can never complete an envelope. * decline / void retain full history (Rule 13 additive-only). * we do NOT over-refuse: a properly-executed e-will (in an e-wills state) routes through the stricter regime and completes. Representation: caller-allocated flat i64 record arrays (substrate scale- agnostic, no internal allocation), mirroring nx_doc_vault. Pure logic core -> the gate is self-contained (no socket, no fork). Composes: nx_legal_compliance (D0 classify+regime+verdict), nx_doc_seal (D5 NxSeal + verify). Distinct from nx_doc_seal because: that produces ONE signature; this is the multi-recipient lifecycle + status + audit around it. license_tier: ORIGINAL lineage_id: nishi_doc_envelope_d2

dependencies 3 imports · 9 importers

nx_syscalls.nx nx_legal_compliance.nx nx_doc_seal.nx nx_doc_envelope.nx nx_doc_annotate_gate.nx nx_doc_envelope_gate.nx nx_legal_portal.nx nx_legal_portal_boot.nx nx_legal_portal_boot_gate.nx nx_legal_portal_daemon.nx nx_legal_portal_gate.nx nx_legal_portal_live_gate.nx nx_legal_portal_post_gate.nx

imports: nx_syscalls.nxnx_legal_compliance.nxnx_doc_seal.nx

imported by: nx_doc_annotate_gate.nxnx_doc_envelope_gate.nxnx_legal_portal.nxnx_legal_portal_boot.nxnx_legal_portal_boot_gate.nxnx_legal_portal_daemon.nxnx_legal_portal_gate.nxnx_legal_portal_live_gate.nxnx_legal_portal_post_gate.nx

structs

none

consts

46const ENV_DRAFT: i64 = 0
47const ENV_SENT: i64 = 1
48const ENV_COMPLETED: i64 = 2
49const ENV_DECLINED: i64 = 3
50const ENV_VOIDED: i64 = 4
53const ROLE_SIGNER: i64 = 0
54const ROLE_CC: i64 = 1 // informational copy; never signs
55const ROLE_APPROVER: i64 = 2 // reserved: approves without a cryptographic seal
58const RC_PENDING: i64 = 0
59const RC_VIEWED: i64 = 1
60const RC_SIGNED: i64 = 2
61const RC_DECLINED: i64 = 3
64const ENV_SEND_OK: i64 = 0
65const ENV_SEND_REFUSED_VOID: i64 = 1 // regime REQUIRES_WET -> never route into e-sign
66const ENV_SEND_BAD_STATE: i64 = 2 // not found / not in DRAFT
69const ENV_SIGN_OK: i64 = 0
70const ENV_SIGN_OUT_OF_ORDER: i64 = 1 // an earlier-order signer has not signed yet
71const ENV_SIGN_BAD_SEAL: i64 = 2 // seal refused / not VALID / does not verify
72const ENV_SIGN_BAD_STATE: i64 = 3 // envelope not found / not SENT
73const ENV_SIGN_NO_RCPT: i64 = 4 // recipient not on envelope, or not a signer
76const ENV_COMPLETE_OK: i64 = 0
77const ENV_COMPLETE_NOT_READY: i64 = 1
80const EV_CREATED: i64 = 0
81const EV_SENT: i64 = 1
82const EV_VIEWED: i64 = 2
83const EV_SIGNED: i64 = 3
84const EV_COMPLETED: i64 = 4
85const EV_DECLINED: i64 = 5
86const EV_VOIDED: i64 = 6
89const EF_ENV: i64 = 0 // envelope id
90const EF_DOC: i64 = 1 // vault doc id this envelope wraps
91const EF_DTYPE: i64 = 2 // D0 document type (classified at create)
92const EF_REGIME: i64 = 3 // D0 legal regime (decided at create)
93const EF_STATUS: i64 = 4
94const EF_NSIGN: i64 = 5 // required signer count (frozen at send)
95const EF_NDONE: i64 = 6 // signers that have signed
96const EF_TS: i64 = 7
97const EF_EWILLS: i64 = 8 // jurisdiction: e-wills statute present (0/1)
98const EF_STRIDE: i64 = 9
101const RF_ENV: i64 = 0
102const RF_RCPT: i64 = 1
103const RF_ROLE: i64 = 2
104const RF_ORDER: i64 = 3 // routing order (1,2,3,...)
105const RF_STATUS: i64 = 4
106const RF_SEALOK: i64 = 5 // 1 = a verified Ed25519 seal was recorded for this signer
107const RF_TS: i64 = 6
108const RF_STRIDE: i64 = 7
111const AF_ENV: i64 = 0
112const AF_KIND: i64 = 1
113const AF_ACTOR: i64 = 2
114const AF_TS: i64 = 3
115const AF_STRIDE: i64 = 4
117const ENV_ORDER_NONE: i64 = 2147483647

functions

120func ne_find_env(flat_env: *i64, ne: i64, env_id: i64) -> i64
130func ne_find_rcpt(flat_rc: *i64, nr: i64, env_id: i64, rcpt_id: i64) -> i64
144func nx_env_create(flat_env: *i64, ne: i64, cap: i64, env_id: i64, doc_id: i64,
163func nx_env_add_recipient(flat_rc: *i64, nr: i64, cap: i64, env_id: i64,
177func nx_env_status(flat_env: *i64, ne: i64, env_id: i64) -> i64
called by 3: mainmainlp_handle calls 1: ne_find_env
182func nx_env_regime(flat_env: *i64, ne: i64, env_id: i64) -> i64
called by 2: mainlp_handle calls 1: ne_find_env
187func nx_env_doctype(flat_env: *i64, ne: i64, env_id: i64) -> i64
called by 1: main calls 1: ne_find_env
194func nx_env_required_signers(flat_rc: *i64, nr: i64, env_id: i64) -> i64
206func nx_env_signed_count(flat_rc: *i64, nr: i64, env_id: i64) -> i64
223func ne_next_signer_order(flat_rc: *i64, nr: i64, env_id: i64) -> i64
called by 1: nx_env_sign
246func nx_env_send(flat_env: *i64, ne: i64, flat_rc: *i64, nr: i64, env_id: i64) -> i64
258func nx_env_mark_viewed(flat_rc: *i64, nr: i64, env_id: i64, rcpt_id: i64, ts: i64) -> i64
calls 1: ne_find_rcpt
271func nx_env_sign(flat_env: *i64, ne: i64, flat_rc: *i64, nr: i64,
295func nx_env_try_complete(flat_env: *i64, ne: i64, flat_rc: *i64, nr: i64, env_id: i64) -> i64
310func nx_env_decline(flat_env: *i64, ne: i64, flat_rc: *i64, nr: i64, env_id: i64, rcpt_id: i64) -> i64
called by 1: main calls 2: ne_find_envne_find_rcpt
321func nx_env_void(flat_env: *i64, ne: i64, env_id: i64) -> i64
calls 1: ne_find_env
329func nx_env_audit_add(flat_au: *i64, na: i64, cap: i64, env_id: i64, kind: i64, actor: i64, ts: i64) -> i64
called by 1: main
338func nx_env_audit_count(flat_au: *i64, na: i64, env_id: i64) -> i64
called by 1: main
348func nx_env_status_name(s: i64) -> *u8
called by 1: lp_handle