code wiki / _hdl_build / nx_connect_events.nx
nx_connect_events.nx source
↩ module page · 169 lines · 8803 B
1// nx_connect_events.nx -- CONNECT real-world MEETUP EVENTS + RSVP (the direct Meetup axis; the LDS
2// census MU cell). Group-scoped events with capacity, IDEMPOTENT RSVP (rule 10), cancel-frees-seat,
3// and the YOUTH-SAFETY wall extended to real-world gatherings: a MINOR may RSVP only to a YOUTH event
4// and only while the confirmed roster carries >=2 adults (the Church two-deep norm as an admission
5// invariant, mirroring nx_connect_lds_room). Age is the VERIFIED band (nx_connect_idage spine), and an
6// UNKNOWN band is treated as MINOR (fail-closed). Zero fees BY CONSTRUCTION: organizer + RSVP prices
7// live in a data table checked to be 0 for connection features -- the NEG-CONTROL is the documented
8// Meetup model (organizer $23.99/month + $2 RSVP fee, banked: knowledge/library/conncomp_meetup_wiki.txt)
9// which the same checker FLAGS. A no-wall incumbent admission model (Discord/Meetup-style: any adult,
10// any minor, no structural wall) is the safety NEG-CONTROL: it admits exactly the lone-adult+minor
11// contact ours refuses. 100% sovereign. license_tier: ORIGINAL expect_exit: 0
12import "nx_syscalls.nx"
13
14import "nx_connect_events_lib.nx"
15const K_MAGIC_2399: i64 = 2399
16
17func sw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
18func 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 }
19func tcheck(pass: i64, label: *u8, fails: *i64) -> i64 {
20 sw(" " as *u8); sw(label); sw(": " as *u8)
21 if pass==1 { sw("PASS\n" as *u8) } else { sw("FAIL\n" as *u8); fails[0]=fails[0]+1 }
22 return 0
23}
24func count_paid_connection(prices: *i64, isconn: *i64, n: i64) -> i64 {
25 var c: i64=0; var i: i64=0
26 while i<n { if isconn[i]==1 { if prices[i]>0 { c=c+1 } } i=i+1 }
27 return c
28}
29
30func main() -> i64 {
31 let fails: *i64 = sys_mmap(16) as *i64
32 fails[0]=0
33 sw("=== nx_connect_events -- meetup events + RSVP (two-deep youth wall; zero fees by construction) ===\n" as *u8)
34
35 // ---- world setup ----
36 let ctx: *i64 = sys_mmap(16*8) as *i64
37 let rs_event: *i64 = sys_mmap(RS_MAX*8) as *i64
38 let rs_user: *i64 = sys_mmap(RS_MAX*8) as *i64
39 let rs_active: *i64 = sys_mmap(RS_MAX*8) as *i64
40 let nrs: *i64 = sys_mmap(8) as *i64
41 nrs[0]=0
42 let ev_group: *i64 = sys_mmap(EV_MAX*8) as *i64
43 let ev_cap: *i64 = sys_mmap(EV_MAX*8) as *i64
44 let ev_youth: *i64 = sys_mmap(EV_MAX*8) as *i64
45 let mb_group: *i64 = sys_mmap(MB_MAX*8) as *i64
46 let mb_user: *i64 = sys_mmap(MB_MAX*8) as *i64
47 let nmb: *i64 = sys_mmap(8) as *i64
48 nmb[0]=0
49 let ua_user: *i64 = sys_mmap(UA_MAX*8) as *i64
50 let ua_minor: *i64 = sys_mmap(UA_MAX*8) as *i64
51 let nua: *i64 = sys_mmap(8) as *i64
52 nua[0]=0
53 ctx[CX_RSEV]=rs_event as i64; ctx[CX_RSUS]=rs_user as i64; ctx[CX_RSAC]=rs_active as i64
54 ctx[CX_NRS]=nrs as i64
55 ctx[CX_EVGRP]=ev_group as i64; ctx[CX_EVCAP]=ev_cap as i64; ctx[CX_EVYTH]=ev_youth as i64
56 ctx[CX_MBGRP]=mb_group as i64; ctx[CX_MBUS]=mb_user as i64; ctx[CX_NMB]=nmb as i64
57 ctx[CX_UAUS]=ua_user as i64; ctx[CX_UAMIN]=ua_minor as i64; ctx[CX_NUA]=nua as i64
58
59 // users: 100..102 adults, 200..201 minors (verified bands); 300 = UNKNOWN band (must fail closed)
60 ua_user[0]=100; ua_minor[0]=0
61 ua_user[1]=101; ua_minor[1]=0
62 ua_user[2]=102; ua_minor[2]=0
63 ua_user[3]=200; ua_minor[3]=1
64 ua_user[4]=201; ua_minor[4]=1
65 nua[0]=5
66 // group 7 members: all of the above incl the unknown-band user 300
67 mb_group[0]=7; mb_user[0]=100
68 mb_group[1]=7; mb_user[1]=101
69 mb_group[2]=7; mb_user[2]=102
70 mb_group[3]=7; mb_user[3]=200
71 mb_group[4]=7; mb_user[4]=201
72 mb_group[5]=7; mb_user[5]=300
73 nmb[0]=6
74 // event 0: adults-only picnic (cap 3). event 1: YOUTH game night (cap 10, youth-flagged)
75 ev_group[0]=7; ev_cap[0]=3; ev_youth[0]=0
76 ev_group[1]=7; ev_cap[1]=10; ev_youth[1]=1
77
78 // T1: three adult RSVPs admitted
79 let r1a: i64 = ev_rsvp(ctx, 0, 100)
80 let r1b: i64 = ev_rsvp(ctx, 0, 101)
81 let r1c: i64 = ev_rsvp(ctx, 0, 102)
82 var t1: i64=0
83 if r1a==1 { if r1b==1 { if r1c==1 { if ev_count_active(ctx,0)==3 { t1=1 } } } }
84 tcheck(t1, "T1 create + 3 RSVPs admitted, roster=3" as *u8, fails)
85
86 // T2: IDEMPOTENT re-RSVP -- roster unchanged (safe to run twice, rule 10)
87 let r2: i64 = ev_rsvp(ctx, 0, 100)
88 var t2: i64=0
89 if r2==2 { if ev_count_active(ctx,0)==3 { t2=1 } }
90 tcheck(t2, "T2 idempotent RSVP: repeat returns already-in, roster unchanged" as *u8, fails)
91
92 // T3: capacity -- event 0 is FULL (cap 3): minor 200 would be refused anyway; use adult via new member
93 mb_group[6]=7; mb_user[6]=103
94 nmb[0]=7
95 ua_user[5]=103; ua_minor[5]=0
96 nua[0]=6
97 let r3full: i64 = ev_rsvp(ctx, 0, 103)
98 let rc: i64 = ev_cancel(ctx, 0, 102)
99 let r3in: i64 = ev_rsvp(ctx, 0, 103)
100 var t3: i64=0
101 if r3full==(0-2) { if rc==1 { if r3in==1 { if ev_count_active(ctx,0)==3 { t3=1 } } } }
102 tcheck(t3, "T3 capacity enforced; cancel frees the seat" as *u8, fails)
103
104 // T4: non-member refused (group-scoped events)
105 let r4: i64 = ev_rsvp(ctx, 0, 999)
106 var t4: i64=0; if r4==(0-1) { t4=1 }
107 tcheck(t4, "T4 non-member RSVP refused (events are group-scoped)" as *u8, fails)
108
109 // T5: TWO-DEEP admission -- youth event: minor denied at 1 adult, admitted at 2 adults
110 let r5a: i64 = ev_rsvp(ctx, 1, 100)
111 let r5deny: i64 = ev_rsvp(ctx, 1, 200)
112 let r5b: i64 = ev_rsvp(ctx, 1, 101)
113 let r5ok: i64 = ev_rsvp(ctx, 1, 200)
114 var t5: i64=0
115 if r5a==1 { if r5deny==(0-3) { if r5b==1 { if r5ok==1 { if ev_count_adults(ctx,1)==2 { if ev_count_minors(ctx,1)==1 { t5=1 } } } } } }
116 tcheck(t5, "T5 youth event: minor DENIED at 1 adult, admitted at two-deep (>=2 adults)" as *u8, fails)
117
118 // T6: adult cancels -> adults=1 with a minor present: roster flagged UNSAFE + next minor denied
119 let r6c: i64 = ev_cancel(ctx, 1, 101)
120 let safe6: i64 = ev_roster_safe(ctx, 1)
121 let r6deny: i64 = ev_rsvp(ctx, 1, 201)
122 var t6: i64=0
123 if r6c==1 { if safe6==0 { if r6deny==(0-3) { t6=1 } } }
124 tcheck(t6, "T6 adult cancel drops two-deep: roster flagged unsafe, next minor denied" as *u8, fails)
125
126 // T7: minors cannot RSVP to a NON-youth event at all (no unmoderated adult-space admission)
127 let r7: i64 = ev_rsvp(ctx, 0, 201)
128 var t7: i64=0
129 if r7==(0-4) { t7=1 }
130 if ev_count_active(ctx,0)!=3 { t7=0 }
131 tcheck(t7, "T7 minor on a non-youth event refused (no unmoderated adult-space admission)" as *u8, fails)
132
133 // T8: FAIL-CLOSED age -- unknown-band user 300 treated as MINOR (denied where a minor is denied)
134 let r8: i64 = ev_rsvp(ctx, 0, 300)
135 var t8: i64=0; if r8==(0-4) { t8=1 }
136 tcheck(t8, "T8 unknown age band = treated as minor (fail-closed age assurance)" as *u8, fails)
137
138 // T9: ZERO FEES by construction vs the documented Meetup model (cited, banked bytes on disk):
139 // organizer $23.99/month + $2 RSVP fee -- the SAME checker flags the incumbent table.
140 let prices: *i64 = sys_mmap(8*8) as *i64
141 let isconn: *i64 = sys_mmap(8*8) as *i64
142 prices[0]=0; isconn[0]=1
143 prices[1]=0; isconn[1]=1
144 let viol: i64 = count_paid_connection(prices, isconn, 2)
145 let meetup_prices: *i64 = sys_mmap(8*8) as *i64
146 let meetup_isconn: *i64 = sys_mmap(8*8) as *i64
147 meetup_prices[0]=K_MAGIC_2399; meetup_isconn[0]=1
148 meetup_prices[1]=200; meetup_isconn[1]=1
149 let meetup_viol: i64 = count_paid_connection(meetup_prices, meetup_isconn, 2)
150 var t9: i64=0
151 if viol==0 { if meetup_viol==2 { t9=1 } }
152 sw(" our fees: organizer=0 rsvp=0; Meetup-model flagged=" as *u8); sn(meetup_viol); sw(" (organizer 23.99/mo + 2 RSVP, cited conncomp_meetup_wiki)\n" as *u8)
153 tcheck(t9, "T9 zero organizer/RSVP fees; NEG Meetup fee model flagged by the same checker" as *u8, fails)
154
155 // T10: NEG-CONTROL no-wall incumbent admission admits the LONE-ADULT+MINOR contact ours refuses
156 let ev2: i64 = 2
157 ev_group[2]=7; ev_cap[2]=10; ev_youth[2]=1
158 let rw1: i64 = ev_rsvp_nowall(ctx, ev2, 103)
159 let rw2: i64 = ev_rsvp_nowall(ctx, ev2, 201)
160 var t10: i64=0
161 if rw1==1 { if rw2==1 { if ev_count_adults(ctx,ev2)==1 { if ev_count_minors(ctx,ev2)==1 { t10=1 } } } }
162 tcheck(t10, "T10 NEG-CONTROL: no-wall incumbent admits lone-adult+minor (exactly what ours denies)" as *u8, fails)
163
164 sw(" fails=" as *u8); sn(fails[0]); sw("\n" as *u8)
165 if fails[0]==0 { sw("VERDICT: GREEN (events+RSVP live: idempotent, capacity, group-scoped, two-deep youth wall, zero fees by construction)\n" as *u8); sys_exit(0) }
166 sw("VERDICT: RED\n" as *u8)
167 sys_exit(1)
168 return 1
169}