code wiki / _hdl_build / nx_connect_lds_reconnect.nx
nx_connect_lds_reconnect.nx source
↩ module page · 117 lines · 7858 B
1// nx_connect_lds_reconnect.nx -- CONNECT / LDS-community vertical: MEMBER <-> MISSIONARY RECONNECTION.
2// The signature capability of the LDS beachhead: help members reconnect with the missionaries who
3// taught them, and returned missionaries catch up with the members/families they served -- a real,
4// cherished LDS relationship no incumbent (Meetup/Tandem/Match/Mutual/Facebook groups) models.
5//
6// 2026-07-23 LIBRARY SPLIT (the DRY note below is now DISCHARGED): the model itself moved to
7// nx_connect_lds_reconnect_lib.nx so THIS gate and the LIVE app (nx_connect_serve, which surfaces
8// reconnection at /connect/reconnect) bind ONE implementation of the law and cannot drift apart.
9// This file is now purely the VERIFIER: the synthetic corpus + the 8 checks. Its emitted output is
10// byte-identical to the pre-split version, which is the proof that the extraction changed no behavior.
11//
12// THE MODEL (see the library for the full statement): a person carries {mission, areas bitmask, time
13// window}. Two people could have KNOWN each other only if SAME MISSION and shared AREA and time
14// OVERLAP -- all three NECESSARY. Discovery is consent-gated both ways (Art.9-style). The DATE lane is
15// unreachable when a minor is involved, in both directions.
16//
17// 8 checks incl. 3 negative controls. 100% sovereign. license_tier: ORIGINAL expect_exit: 0
18import "nx_syscalls.nx"
19import "nx_connect_lds_reconnect_lib.nx"
20
21func sw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
22func sn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 }
23
24// allocate one 8-slot record and fill it through the shared library constructor.
25func rec(band: i64, mission: i64, areas: i64, s: i64, e: i64, optin: i64, token: i64, conf: i64) -> *i64 {
26 let p: *i64 = sys_mmap(RC_REC_SLOTS*8) as *i64
27 rc_mk(p, band, mission, areas, s, e, optin, token, conf)
28 return p
29}
30
31func tcheck(pass: i64, label: *u8, fails: *i64) -> i64 {
32 sw(" " as *u8); sw(label); sw(": " as *u8)
33 if pass==1 { sw("PASS\n" as *u8) } else { sw("FAIL\n" as *u8); fails[0]=fails[0]+1 }
34 return 0
35}
36
37func main() -> i64 {
38 let fails: *i64 = sys_mmap(16) as *i64
39 fails[0]=0
40
41 // synthetic corpus (deterministic, ZERO real PII). areas bits: A1=1 A2=2 A3=4 A4=8. months since epoch.
42 // ELDER_A adult mission7 areas{A1,A2}=3 served 100..124 optin token=1 confirms {B}=2
43 // MEMBER_B adult mission7 area {A2}=2 lived 110..130 optin token=2 confirms {A}=1 -> MUTUAL confirm, real overlap
44 // MEMB_B2 adult mission7 area {A2}=2 lived 110..130 optin token=16 confirms {}=0 -> same overlap, NOT confirmed (inferred)
45 // MEMBER_C adult mission7 area {A4}=8 lived 110..130 optin -> same mission, DIFFERENT area
46 // MEMBER_D adult mission7 area {A2}=2 lived 200..220 optin -> same mission+area, NO time overlap
47 // MEMBER_E adult mission9 area {A2}=2 lived 110..124 optin -> DIFFERENT mission
48 // MEMBER_F adult mission7 area {A2}=2 lived 110..130 OPT-OUT -> real overlap but consent=0
49 // YOUTH_G MINOR mission7 area {A2}=2 lived 110..124 optin -> a youth the missionary taught
50 let a: *i64 = rec(RC_BAND_ADULT, 7, 3, 100,124, 1, 1, 2)
51 let b: *i64 = rec(RC_BAND_ADULT, 7, 2, 110,130, 1, 2, 1)
52 let b2: *i64 = rec(RC_BAND_ADULT, 7, 2, 110,130, 1, 16, 0)
53 let c: *i64 = rec(RC_BAND_ADULT, 7, 8, 110,130, 1, 4, 0)
54 let d: *i64 = rec(RC_BAND_ADULT, 7, 2, 200,220, 1, 8, 0)
55 let e: *i64 = rec(RC_BAND_ADULT, 9, 2, 110,124, 1, 32, 0)
56 let f: *i64 = rec(RC_BAND_ADULT, 7, 2, 110,130, 0, 64, 0)
57 let g: *i64 = rec(RC_BAND_MINOR, 7, 2, 110,124, 1, 128, 0)
58
59 let s_ab: i64 = rc_score(a,b)
60 let s_ab2: i64 = rc_score(a,b2)
61 let s_ac: i64 = rc_score(a,c)
62 let s_ad: i64 = rc_score(a,d)
63 let s_ae: i64 = rc_score(a,e)
64 let s_af: i64 = rc_score(a,f)
65 let raw_af: i64 = rc_raw(a,f)
66 let g_date: i64 = rc_lane(a,g,RC_LANE_DATE)
67 let g_friend: i64 = rc_lane(a,g,RC_LANE_FRIEND)
68
69 sw("=== nx_connect_lds_reconnect -- member <-> missionary reconnection (LDS vertical) ===\n" as *u8)
70 sw("reconnection strength 0..100 (internal rank; surfaces people who actually overlapped):\n" as *u8)
71 sw(" ELDER_A x MEMBER_B (same mission+area+time, MUTUALLY confirmed) = " as *u8); sn(s_ab); sw("\n" as *u8)
72 sw(" ELDER_A x MEMB_B2 (same overlap, inferred/not confirmed) = " as *u8); sn(s_ab2); sw("\n" as *u8)
73 sw(" ELDER_A x MEMBER_C (same mission, DIFFERENT area) = " as *u8); sn(s_ac); sw(" (not the pair)\n" as *u8)
74 sw(" ELDER_A x MEMBER_D (same mission+area, NO time overlap) = " as *u8); sn(s_ad); sw(" (a later missionary, not the teacher)\n" as *u8)
75 sw(" ELDER_A x MEMBER_E (DIFFERENT mission) = " as *u8); sn(s_ae); sw("\n" as *u8)
76 sw(" ELDER_A x MEMBER_F (real overlap but OPTED OUT) score=" as *u8); sn(s_af); sw(" raw=" as *u8); sn(raw_af); sw(" (privacy wins)\n" as *u8)
77 sw(" ELDER_A x YOUTH_G DATE lane = " as *u8); sn(g_date); sw(" (EXCLUDED) ; FRIEND lane = " as *u8); sn(g_friend); sw("\n" as *u8)
78 sw("-- gate checks --\n" as *u8)
79
80 // T1: a real, mutually-confirmed overlap surfaces strongly
81 var t1: i64=0; if s_ab>=60 { t1=1 }
82 tcheck(t1, "T1 real overlap reconnects (>=60): finds the companions/converts who were there" as *u8, fails)
83
84 // T2: NECESSITY of shared area -- same mission, different area -> 0
85 var t2: i64=0; if s_ac==0 { t2=1 }
86 tcheck(t2, "T2 area NECESSARY (same mission, different area -> 0)" as *u8, fails)
87
88 // T3: NECESSITY of time overlap -- same mission+area but disjoint dates -> 0 (a later missionary is not the teacher)
89 var t3: i64=0; if s_ad==0 { t3=1 }
90 tcheck(t3, "T3 time NECESSARY (same mission+area, no overlap -> 0)" as *u8, fails)
91
92 // T4: NECESSITY of same mission
93 var t4: i64=0; if s_ae==0 { t4=1 }
94 tcheck(t4, "T4 mission NECESSARY (different mission -> 0)" as *u8, fails)
95
96 // T5: NEG-CONTROL consent gate -- opted-out member hidden though the underlying overlap is real
97 var t5: i64=0; if s_af==0 { if raw_af>0 { t5=1 } }
98 tcheck(t5, "T5 NEG-CONTROL consent-gated (opt-out hidden; consent-blind would leak raw>0)" as *u8, fails)
99
100 // T6: a mutually-confirmed memory outranks inferred overlap
101 var t6: i64=0; if s_ab>s_ab2 { if s_ab2>0 { t6=1 } }
102 tcheck(t6, "T6 confirmed 'I remember you' > inferred overlap (both surfaced, confirmed ranks higher)" as *u8, fails)
103
104 // T7: SAFETY -- returned missionary + a youth they taught: DATE unreachable, community reconnection allowed
105 var t7: i64=0; if g_date<0 { if g_friend>0 { t7=1 } }
106 tcheck(t7, "T7 SAFETY missionary<->youth: DATE EXCLUDED, friendship/community allowed (by construction)" as *u8, fails)
107
108 // T8: NEG-CONTROL -- a naive same-mission matcher would falsely surface C and D; area+time is what makes it correct
109 var t8: i64=0; if rc_mission_only(a,c)>0 { if rc_mission_only(a,d)>0 { if s_ac==0 { if s_ad==0 { t8=1 } } } }
110 tcheck(t8, "T8 NEG-CONTROL mission-only matcher false-surfaces C+D; area^time necessity rejects them" as *u8, fails)
111
112 sw(" fails=" as *u8); sn(fails[0]); sw("\n" as *u8)
113 if fails[0]==0 { sw("VERDICT: GREEN (reconnection finds real overlaps; consent-private; missionary<->youth romance walled by construction)\n" as *u8); sys_exit(0) }
114 sw("VERDICT: RED\n" as *u8)
115 sys_exit(1)
116 return 1
117}