nx_ediscovery_lib.nx source
↩ module page · 87 lines · 3908 B
1// nx_ediscovery_lib.nx -- F994: E-DISCOVERY PRODUCTION SCREEN (EDRM review -> produce), on the CID plane.
2//
3// The catastrophic e-discovery failure is INADVERTENT DISCLOSURE: a privileged document handed to
4// opposing counsel by accident. Firms spend fortunes on review to prevent it and still fail, because
5// production is treated as a DENY-list (produce everything except what we remembered to withhold). The
6// sovereign inversion: production is an ALLOW-LIST. A document is producible ONLY if it was affirmatively
7// reviewed and marked RESPONSIVE. Privileged, non-responsive, and -- critically -- UNREVIEWED documents
8// are all non-producible BY DEFAULT. You cannot produce what you have not screened, so the accident
9// cannot happen by omission.
10//
11// FAIL-CLOSED DEFAULT: a document with no classification is UNREVIEWED, and unreviewed is not producible.
12// An unknown/garbage status is likewise not producible -- only the exact string "responsive" opens the gate.
13//
14// ed_screen counts every non-producible document in a proposed production set; a set is safe to produce
15// ONLY when that count is zero. ed_privilege_count feeds the privilege log (the withheld-doc deliverable).
16//
17// SCALE ENVELOPE (declared): ed_screen is O(set size) reg_get lookups. DRY: composes nx_matter_lib
18// (reg_put/reg_get/mt_field/canon_encode). license_tier: ORIGINAL LIB.
19
20import "nx_matter_lib.nx"
21
22const ED_PRODUCIBLE: i64 = 1
23
24// classify a document. status = "responsive" | "privileged" | "nonresponsive" | "unreviewed".
25func ed_classify(prefix: *u8, doc_id: *u8, status: *u8) -> i64 {
26 let k: *i64 = sys_mmap(8 * 1) as *i64
27 let v: *i64 = sys_mmap(8 * 1) as *i64
28 k[0] = ("status" as *u8) as i64
29 v[0] = status as i64
30 let rec: *u8 = sys_mmap(256)
31 let rl: i64 = canon_encode(k, v, 1, rec)
32 return reg_put(prefix, "ed:" as *u8, "ed:__idx__" as *u8, doc_id, rec, rl)
33}
34
35// retrieve a doc's status into out; an unclassified doc defaults to "unreviewed" (fail-closed).
36func ed_status(prefix: *u8, doc_id: *u8, out: *u8) -> i64 {
37 let po: *i64 = sys_mmap(16) as *i64
38 let lo: *i64 = sys_mmap(16) as *i64
39 if reg_get(prefix, "ed:" as *u8, doc_id, po, lo) != 1 {
40 mt_catcopy(out, 0, "unreviewed" as *u8)
41 out[10] = 0 as u8
42 return 0
43 }
44 mt_field(po[0] as *u8, lo[0], "status" as *u8, 6, out)
45 if out[0] == (0 as u8) { mt_catcopy(out, 0, "unreviewed" as *u8); out[10] = 0 as u8 }
46 return 1
47}
48
49// ★THE ALLOW-LIST GATE: 1 only if the doc is affirmatively RESPONSIVE. Everything else -- privileged,
50// nonresponsive, unreviewed, unknown -- returns 0. Production requires an explicit yes.
51func ed_is_producible(prefix: *u8, doc_id: *u8) -> i64 {
52 let st: *u8 = sys_mmap(64)
53 ed_status(prefix, doc_id, st)
54 if mt_streq(st, "responsive" as *u8) == 1 { return ED_PRODUCIBLE }
55 return 0
56}
57
58// ★SCREEN a proposed production set (array of *u8 doc-id pointers). Returns the count of NON-producible
59// documents in it. 0 means every document is cleared for production; any other number means STOP.
60func ed_screen(prefix: *u8, doc_ids: *i64, n: i64) -> i64 {
61 var blocked: i64 = 0
62 var i: i64 = 0
63 while i < n {
64 if ed_is_producible(prefix, doc_ids[i] as *u8) == 0 { blocked = blocked + 1 }
65 i = i + 1
66 }
67 return blocked
68}
69
70// 1 only if the ENTIRE set is safe to produce (zero blocked).
71func ed_set_clean(prefix: *u8, doc_ids: *i64, n: i64) -> i64 {
72 if ed_screen(prefix, doc_ids, n) == 0 { return 1 }
73 return 0
74}
75
76// count the PRIVILEGED documents in a set (the privilege-log population).
77func ed_privilege_count(prefix: *u8, doc_ids: *i64, n: i64) -> i64 {
78 let st: *u8 = sys_mmap(64)
79 var priv: i64 = 0
80 var i: i64 = 0
81 while i < n {
82 ed_status(prefix, doc_ids[i] as *u8, st)
83 if mt_streq(st, "privileged" as *u8) == 1 { priv = priv + 1 }
84 i = i + 1
85 }
86 return priv
87}