@ours.network/tg-connector 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +2 -2
  2. package/dist/connector.js +1 -1
  3. package/package.json +1 -1
  4. package/dist/mufl_code/core/CLUSTER_API.md +0 -640
  5. package/dist/mufl_code/core/CLUSTER_CONTRACT.md +0 -121
  6. package/dist/mufl_code/core/CLUSTER_INTRODUCTION_PLAN.md +0 -200
  7. package/dist/mufl_code/core/CONFIGURATION_DESIGN.md +0 -35
  8. package/dist/mufl_code/core/CONFIGURATION_PLAN.md +0 -394
  9. package/dist/mufl_code/core/DEVELOPMENT.md +0 -168
  10. package/dist/mufl_code/core/EPHEMERAL_INVITE_PLAN.md +0 -465
  11. package/dist/mufl_code/core/GROUP_CHAT_DESIGN.md +0 -520
  12. package/dist/mufl_code/core/LICENSE +0 -98
  13. package/dist/mufl_code/core/README.md +0 -76
  14. package/dist/mufl_code/core/a2a_capabilities.mm +0 -350
  15. package/dist/mufl_code/core/a2a_cluster.mm +0 -601
  16. package/dist/mufl_code/core/a2a_control.mm +0 -89
  17. package/dist/mufl_code/core/a2a_messaging.mm +0 -2103
  18. package/dist/mufl_code/core/a2a_monitoring.mm +0 -94
  19. package/dist/mufl_code/core/a2a_protocol.mm +0 -231
  20. package/dist/mufl_code/core/config.mufl +0 -26
  21. package/dist/mufl_code/core/release-notes/2.0.md +0 -268
  22. package/dist/mufl_code/core/release-notes/2.1.md +0 -92
  23. package/dist/mufl_code/core/release-notes/2.2.md +0 -94
  24. package/dist/mufl_code/core/release-notes/3.0.md +0 -162
  25. package/dist/mufl_code/core/release-notes/3.1.md +0 -43
  26. package/dist/mufl_code/core/release-notes/README.md +0 -32
  27. package/dist/mufl_code/core/tests/README.md +0 -66
  28. package/dist/mufl_code/core/tests/run.sh +0 -67
  29. package/dist/mufl_code/core/tests/test.mjs +0 -467
  30. package/dist/mufl_code/core/tests/test_actor.mu +0 -287
  31. package/dist/mufl_code/core/version.mm +0 -24
@@ -1,520 +0,0 @@
1
- # Group Chat — Design (core 3.1)
2
-
3
- > **A group is a shared `chat_id` + a creator-authoritative roster + the full mesh
4
- > of mutual contacts it induces.** Joining a group makes members mutual contacts so
5
- > a message is a bare N-way fan-out over the existing encrypted channels — no group
6
- > key, no relay, no SPOF. v1 is invite-and-explicit-accept, owner-only disclosure,
7
- > one-by-one add, with admin remove + self leave and a lost-message repair path.
8
- > This design covers ONLY the shared mufl core change (a new `a2a_group` library +
9
- > wire shapes + version bump + tests). Daemon / messenger / agent integration and
10
- > release-note prose are later phases.
11
-
12
- **Status:** DESIGN — approved in shape by the user 2026-06-21. Do **not** implement
13
- yet (writing-plans produces `GROUP_CHAT_PLAN.md` next).
14
-
15
- ---
16
-
17
- ## 0. Decisions locked by the user (2026-06-21)
18
-
19
- 1. **Explicit accept only — no all-at-once.** A group starts empty; the creator
20
- invites existing contacts one at a time; each invitee explicitly accepts before
21
- any address documents change hands.
22
- 2. **Owner-only disclosure invite.** The join offer reveals only the group name and
23
- the owner (creator) — **not** the member list. (Resolves the "A sends B & C each
24
- other's ADs, then B declines" leak: a decliner discloses nothing, and no member
25
- AD is disclosed to a non-acceptor.)
26
- 3. **One-by-one add after accept.** On each acceptance the creator wires the new
27
- member into the mesh: it sends the joiner every existing member's AD and sends
28
- each existing member the joiner's AD.
29
- 4. **Creator/admin-only roster authority.** Only the creator adds/removes members
30
- and is the source of truth for the roster.
31
- 5. **add + remove + leave.** Removal (admin) propagates to all members and to the
32
- removed peer; self-leave propagates to all members. **Neither deletes the
33
- contact** — group membership is a layer *on top of* contacts ("you can add the
34
- contact though").
35
- 6. **Lost-removal repair: bounce + epoch/admin-resync** (not silent ignore). See §5.
36
- 7. **Explicit transactions** (one inbound per event), not a single dispatch inbound.
37
- 8. **Creator cannot leave; it `delete_group`s** (no admin succession in v1).
38
-
39
- ---
40
-
41
- ## 1. What exists today (the primitives we build on)
42
-
43
- All in `a2a_messaging.mm` unless noted. Verified against the tree at core 3.0.
44
-
45
- - **Contacts + peer ADs.** `contacts is (global_id ->> contact_t)` (L80) and
46
- `peer_ads is (global_id ->> t_address_document)` (L99). A peer is *registered*
47
- (its keys usable for an encrypted send) once its self-signed AD has been through
48
- `address_document::process_address_document(ad, TRUE)` — which enforces the
49
- self-signature / proof-of-possession and aborts on a forged document (see
50
- [[process-address-document-semantics]]). `resolve_contact(ref)` (L392) maps a
51
- display name / stringified cid to a cid.
52
- - **1:1 messaging.** `send_message` (L631) rides `encrypted_channel::execute_transaction`
53
- + `send_encrypted_tx`; inbound `receive_message`/`handle_receive_message` (L1430)
54
- validates origin + `check_encrypted_or_abort`, resolves the sender, and delegates
55
- STORAGE to the app via the `on_message_received` hook (L197). The core does wire +
56
- validation + contact resolution; the app owns storage.
57
- - **Bare N-way encrypted send (THE broadcast primitive).** `encrypted_channel::send_encrypted_tx`
58
- is a pure fn returning ONE send action; a single transaction can emit it to N
59
- different targets **bare** (no `execute_transaction`) as long as each target is
60
- `key_storage::is_container_registered` — true for every established contact in
61
- `peer_ads`. Live precedents: `monitor_copy_actions` (L255) and `emit_pair` (L1010).
62
- `execute_transaction` is ONLY for the lazy first-contact handshake and is not
63
- needed (or nestable) for multi-target. (Confirmed finding, [[connect-feature-redesign]].)
64
- - **CP-brokered introduction (the trust model we must NOT reuse).** `introduce` /
65
- `introduce_to_group` (L1042 / L1064) send each party the other's signed AD via
66
- `ingest_connect_descriptor` (L1099). The receiver gate is
67
- `require_cluster_cp_or_abort(sender)` (L375) — it accepts a relayed AD ONLY from
68
- the node's bound/inherited **control plane**. A normal peer therefore *cannot*
69
- introduce its own contacts to each other. Group chat is the **peer/contact-gated**
70
- analogue and needs its own acceptance gate; the CP gate stays untouched (different
71
- trust model).
72
- - **Forced monitoring.** `monitor_copy_actions(direction, peer_cid, date, body)`
73
- (L238) emits one re-encrypted copy of a message to the bound control plane,
74
- self-gating on the hidden `monitoring_proxy`. It is called UNCONDITIONALLY as core
75
- code from the send/recv chokepoints so the app cannot suppress it.
76
- - **State export/import.** `export_core_state`/`import_core_state` (L1488 / L1510)
77
- are composed by each app's `export_state`/`import_state`; import replays every
78
- `peer_ad` through `process_address_document` so channels survive an upgrade.
79
- - **Capabilities.** `a2a_capabilities::self_supports(cap)` (L219) reads the live
80
- manifest. `core.connect` / `core.cluster` are control-plane caps dispatched through
81
- the RR-9 authz chokepoint. **Group chat is user-driven peer messaging, not a
82
- control-plane capability** — so it lives in dedicated transactions (like
83
- `send_message`), NOT the `dispatch` path.
84
-
85
- ---
86
-
87
- ## 2. The model
88
-
89
- ```
90
- creator (admin, authority)
91
- / | \ every edge = a mutual contact
92
- memberA — memberB — memberC (peer_ads both ways)
93
- \________|_________/
94
- full mesh
95
-
96
- group = { chat_id, name, admin_cid, epoch, roster:{cids} } (replicated to each member)
97
- message = bare send_encrypted_tx to every other roster member, tagged {chat_id, epoch}
98
- ```
99
-
100
- - **Roster is a new state layer on top of contacts.** Membership references contact
101
- cids; the ADs themselves live in the shared `a2a_messaging::peer_ads`. Removing a
102
- member or leaving edits only the roster — it NEVER touches `contacts`/`peer_ads`.
103
- - **Mesh, not star.** Because every member is every other member's contact, any
104
- member broadcasts directly (no creator relay → no single point of failure or
105
- surveillance). The creator's only special role is **roster authority** (who may
106
- add/remove); message flow is symmetric peer-to-peer.
107
- - **New library `a2a_group.mm`.** Keeps the 1593-line `a2a_messaging` intact and
108
- gives group chat one clear responsibility, mirroring how `a2a_cluster` is its own
109
- library. It `loads` `a2a_messaging` (reuse `peer_ads`, `contacts`, `resolve_contact`,
110
- the monitoring copy), `encrypted_channel` (the bare send), `address_document(_types)`
111
- (PoP), `current_transaction_info` (origin/envelope), `a2a_protocol` (wire shapes),
112
- `version`.
113
-
114
- ---
115
-
116
- ## 3. v1 flow (create → invite → accept → one-by-one add → broadcast)
117
-
118
- Roles: **Owner/admin** = the creator. **Invitee/joiner** = an existing contact of
119
- the owner. Every hop below is over an **already-established** encrypted channel
120
- (invitees are the owner's contacts; members are mutual contacts), so every send is a
121
- bare `send_encrypted_tx` — no handshake.
122
-
123
- ```
124
- create owner: create_group("trip") -> mint chat_id; roster={owner}; epoch=0
125
-
126
- invite owner ─► invitee : group_invite { chat_id, name, admin_cid=owner } (owner only)
127
- ^ no members disclosed
128
-
129
- accept invitee: respond_to_group_invite(chat_id, accept=true)
130
- invitee ─► owner : group_invite_response { chat_id, accepted=true }
131
- (decline ⇒ accepted=false; NOTHING else is sent, no AD disclosed)
132
-
133
- add owner (on accept) bumps epoch, then:
134
- owner ─► joiner : group_roster_sync { chat_id, members:[{ad,name}…], epoch }
135
- owner ─► each member M≠owner : group_member_add { chat_id, member_ad=joiner_ad, name, epoch }
136
- owner: roster += joiner
137
-
138
- joiner on roster_sync: process_address_document each member AD (PoP) → register any
139
- new contact → roster := members → status=active. Mesh complete for joiner.
140
- member on member_add : PoP joiner AD → register joiner contact → roster += joiner.
141
-
142
- chat any member: send_group_message(chat_id, "hi")
143
- ─► bare send_encrypted_tx to every other roster member
144
- group_message { chat_id, epoch, text, wire_id, reply_to? }
145
- ```
146
-
147
- The owner already holds the joiner's AD (the joiner is its contact), so "add" relays
148
- public material it possesses; the joiner's AD reaches other members **only after the
149
- joiner accepts**. First invite: roster is just `{owner}`, so the joiner's `roster_sync`
150
- carries only the owner's AD; subsequent invites carry the growing roster — the mesh
151
- is built incrementally, one acceptance at a time.
152
-
153
- ---
154
-
155
- ## 4. Roster operations & authority
156
-
157
- **Authority is pinned at join.** Each member stores `admin_cid` (learned from the
158
- `group_invite`, equal to the inviter). All roster-mutating relays —
159
- `group_member_add`, `group_member_remove`, `group_roster_sync` — are honored **only
160
- when `sender == admin_cid`** for that `chat_id`. A non-admin can never alter another
161
- node's roster.
162
-
163
- | Op | Verb | Who | Effect | Propagation |
164
- |----|------|-----|--------|-------------|
165
- | Create | `create_group` | anyone | mint chat_id, roster={me}, admin=me | none (local) |
166
- | Invite | `invite_to_group` | admin | offer, owner-only disclosure | → invitee |
167
- | Accept/decline | `respond_to_group_invite` | invitee | accept ⇒ status `accepting` | → admin |
168
- | Add | (admin handler on accept) | admin | wire joiner into mesh, `epoch++` | → joiner + all members |
169
- | Remove | `remove_from_group` | admin | drop member, `epoch++`; **keep contact** | → all members + removed peer |
170
- | Leave | `leave_group` | member (not admin) | drop group locally; **keep contacts** | → all members (self-assert) |
171
- | Delete | `delete_group` | admin | disband | → all members |
172
- | Resync | `request_group_roster` | member | repair (§5) | → admin → roster_sync back |
173
-
174
- - **Leave / not-member are self-assertions.** They only ever remove the *sender*
175
- from a roster, so they are safely honored from any current roster member (no admin
176
- needed) — you can always evict yourself from others' view.
177
- - **Creator exit = `delete_group`.** `leave_group` aborts for the admin (no
178
- succession in v1); the owner disbands instead.
179
- - **Remove vs contact.** Removal and leave edit the roster only. `contacts`/`peer_ads`
180
- are untouched, so the ex-member remains a normal 1:1 contact (re-addable later).
181
-
182
- ---
183
-
184
- ## 5. Consistency & repair (lost removals/adds)
185
-
186
- `epoch` is a per-group monotonic counter **bumped by the admin on every roster
187
- change** and stamped on every group message. It is a **staleness hint, never a
188
- security control** — authority is the admin pin (§4), so a forged epoch cannot mutate
189
- a roster; at worst it triggers a harmless resync request to the real admin.
190
-
191
- Receiver logic in `receive_group_message(chat_id, from=S, epoch=e)`:
192
-
193
- 1. **I am not a member of `chat_id`** (I left, was removed, or never joined) →
194
- reply `group_not_member { chat_id }` to S and drop the message. Self-assertion
195
- ("drop me"); S removes me from its roster. Loop-free (the reply is a distinct
196
- transaction, never itself a group message). *Heals: I'm out but S didn't get the
197
- removal/leave.*
198
- 2. **I am a member but S is not in my roster** → I must NOT evict S (admin-only).
199
- Reply `group_stale { chat_id, epoch=my_epoch }` and `request_group_roster` from
200
- the admin; drop the message. After the admin's `group_roster_sync` I either learn
201
- S is gone (stays dropped) or learn I missed S's add (S now accepted). *Heals both
202
- a missed remove and a missed add.*
203
- 3. **I am a member and S is in my roster** → accept: app `on_group_message_received`
204
- hook + forced monitoring copy. If `e > my_epoch`, also fire `request_group_roster`
205
- (async self-heal) but still deliver — S is a valid roster member.
206
-
207
- Companion inbounds: `group_not_member` (drop the sender from my roster),
208
- `group_stale` (if I'm behind, request a resync from the admin), and the admin-side
209
- `receive_group_roster_request` (reply `group_roster_sync` if the requester is a
210
- member, else `group_not_member`).
211
-
212
- Net: removals/adds are **eventually consistent and self-healing over the existing
213
- channels**, with the authoritative decision always routed back to the creator — no
214
- signatures, no gossip protocol. Messaging never blocks on repair. (Hardening note:
215
- rate-limit the `group_not_member` bounce per `(sender, chat_id)` to bound a hostile
216
- peer; honest senders self-terminate because the bounce makes them drop the receiver.)
217
-
218
- ---
219
-
220
- ## 6. Wire shapes (`a2a_protocol.mm`)
221
-
222
- Only the OOB-equivalent offer is a fixed metadef; per-event payloads ride as `any`
223
- (forward-compat, exactly like `accept_contact` / `receive_message` today), with their
224
- inner shapes documented.
225
-
226
- ```
227
- // The join offer. Owner-only disclosure: name + owner cid, NO member list, NO ADs.
228
- metadef group_invite_t: (
229
- $chat_id -> global_id, // the group id (minted by the owner via _new_id)
230
- $name -> str, // group display name (metadata only)
231
- $admin_cid -> global_id // the owner/authority; the receiver PINS this
232
- ).
233
-
234
- // Documented `any` payload shapes (carried as $targ on each inbound):
235
- // group_invite_response : { $chat_id -> global_id, $accepted -> bool }
236
- // group_member_add : { $chat_id, $member_ad -> t_address_document, $name -> str, $epoch -> int }
237
- // group_roster_sync : { $chat_id, $epoch -> int,
238
- // $members -> ($member_view)[] where
239
- // $member_view = ($ad -> t_address_document, $name -> str) }
240
- // group_member_remove : { $chat_id, $removed_cid -> global_id, $epoch -> int }
241
- // group_member_leave : { $chat_id }
242
- // group_delete : { $chat_id }
243
- // group_message : { $chat_id, $epoch -> int, $text -> str,
244
- // $wire_id -> str, $reply_to -> reply_ref_t+ }
245
- // group_not_member : { $chat_id } // repair: "drop me"
246
- // group_stale : { $chat_id, $epoch -> int } // repair: epoch hint
247
- // request_group_roster : { $chat_id, $epoch -> int } // repair: pull roster
248
- ```
249
-
250
- `reply_ref_t` (L101) is reused for in-group replies. All ADs travel as the native
251
- `t_address_document` value (no key-list-only reconstruction — the AD is whole and
252
- goes straight through `process_address_document`).
253
-
254
- ---
255
-
256
- ## 7. State (`a2a_group.mm`)
257
-
258
- ```
259
- metadef group_member_t: ($cid -> global_id, $name -> str). // display label; AD ∈ peer_ads
260
- metadef group_t: (
261
- $chat_id -> global_id,
262
- $name -> str,
263
- $admin_cid -> global_id, // pinned authority for this group
264
- $epoch -> int, // last roster epoch I know
265
- $status -> str, // "active" | "invited" | "accepting"
266
- $members -> (global_id ->> group_member_t)
267
- ).
268
- groups is (global_id ->> group_t) = (,). // keyed by chat_id
269
-
270
- // Admin side: invitees I have offered but who have not yet accepted/declined.
271
- // Keyed by chat_id then invitee cid. No secrets.
272
- pending_group_invites is (global_id ->> (global_id ->> bool)) = (,).
273
-
274
- // Monotonic chat_id/epoch helpers: chat_id via _new_id "ours group"; epoch is a
275
- // plain int on group_t bumped by the admin (MUFL has no RNG; this is fine).
276
- ```
277
-
278
- - **No secrets** in any group state → it exports cleanly. `groups` and
279
- `pending_group_invites` are exported via a new `export_group_state` /
280
- `import_group_state` (composed by the app's `export_state`/`import_state`, beside
281
- `export_core_state`). Import needs no special replay: `a2a_messaging::import_core_state`
282
- already re-registers every `peer_ad`, which is what the roster references.
283
- - **Display names** in `group_member_t` are advisory; the only trusted identity is
284
- the AD self-signature already verified into `peer_ads`.
285
-
286
- ---
287
-
288
- ## 8. Transaction-by-transaction spec
289
-
290
- New tx-name consts (library-routed — NEW surfaces, no legacy `::actor::` shims):
291
-
292
- ```
293
- group_invite_tx = "::a2a_group::receive_group_invite".
294
- group_invite_response_tx = "::a2a_group::receive_group_invite_response".
295
- group_member_add_tx = "::a2a_group::receive_group_member_add".
296
- group_roster_sync_tx = "::a2a_group::receive_group_roster_sync".
297
- group_member_remove_tx = "::a2a_group::receive_group_member_remove".
298
- group_member_leave_tx = "::a2a_group::receive_group_member_leave".
299
- group_delete_tx = "::a2a_group::receive_group_delete".
300
- group_message_tx = "::a2a_group::receive_group_message".
301
- group_not_member_tx = "::a2a_group::receive_group_not_member".
302
- group_stale_tx = "::a2a_group::receive_group_stale".
303
- request_group_roster_tx = "::a2a_group::receive_group_roster_request".
304
- ```
305
-
306
- ### 8.1 User transactions (`origin::user`)
307
-
308
- - **`create_group ($name)`** — `chat_id = _new_id "ours group"`;
309
- `groups[chat_id] = {name, admin_cid=me, epoch=0, status="active", members={me:{my_name}}}`.
310
- Return `chat_id`; `_save_state`.
311
- - **`invite_to_group ($chat_id, $contact)`** — admin-gate (`groups[chat_id].admin_cid == me`,
312
- else abort); `invitee = resolve_contact contact` (must be an existing contact);
313
- abort if invitee already a member or already pending; `pending_group_invites[chat_id][invitee]=TRUE`;
314
- bare `send_encrypted_tx invitee {name: group_invite_tx, targ: group_invite_t}`. `_save_state`.
315
- - **`respond_to_group_invite ($chat_id, $accept)`** — require `groups[chat_id].status=="invited"`.
316
- Accept → `status="accepting"`; send admin `{group_invite_response_tx, {chat_id, accepted:TRUE}}`.
317
- Decline → send `{accepted:FALSE}`; `delete groups[chat_id]`. `_save_state`.
318
- - **`send_group_message ($chat_id, $text, $reply_to?)`** — require active membership;
319
- `wire_id`, `date` as in `send_message`; for each roster cid ≠ me emit a bare
320
- `send_encrypted_tx cid {group_message_tx, {chat_id, epoch, text, wire_id, reply_to}}`;
321
- append `on_group_message_sent` hook actions; append the FORCED group monitoring copy
322
- (§9); `_save_state`.
323
- - **`remove_from_group ($chat_id, $member)`** — admin-gate; `m=resolve roster member`;
324
- `epoch++`; `delete members[m]`; broadcast `group_member_remove_tx{chat_id, removed_cid:m, epoch}`
325
- to every remaining member **and** to `m`. `_save_state`.
326
- - **`leave_group ($chat_id)`** — require member; abort if I am the admin ("the owner
327
- disbands with delete_group"); broadcast `group_member_leave_tx{chat_id}` to all
328
- roster members; `delete groups[chat_id]`. `_save_state`.
329
- - **`delete_group ($chat_id)`** — admin-gate; broadcast `group_delete_tx{chat_id}` to
330
- all members; `delete groups[chat_id]`. `_save_state`.
331
- - **`request_group_roster ($chat_id)`** — send admin `{request_group_roster_tx,
332
- {chat_id, epoch}}`. (Also fired internally by the repair gates in §5.)
333
- - **`readonly list_groups`** / **`readonly list_group_members ($chat_id)`**.
334
-
335
- ### 8.2 Inbound transactions (`origin::external`, `check_encrypted_or_abort`)
336
-
337
- Each: `validate_origin_or_abort(external)` → `check_encrypted_or_abort()` →
338
- `sender = envelope.$from`, then:
339
-
340
- - **`receive_group_invite`** — parse `group_invite_t`; abort if `admin_cid != sender`
341
- (the inviter must claim itself as admin); store `groups[chat_id]={name, admin_cid:sender,
342
- epoch:0, status:"invited", members:{}}` (idempotent refresh if already invited);
343
- `_notify_agent($group_invited)`. (No contact added, no AD disclosed.)
344
- - **`receive_group_invite_response`** (admin) — require I am admin + `sender ∈ pending[chat_id]`.
345
- **Accept** → `epoch++`; emit `group_roster_sync` to `sender` (every current member's
346
- AD+name) and `group_member_add{member_ad:peer_ads[sender]}` to each existing member
347
- ≠ me; `members[sender]={contacts[sender].name}`; clear pending; `_notify_agent($group_member_joined)`.
348
- **Decline** → clear pending; `_notify_agent($group_invite_declined)`. `_save_state`.
349
- - **`receive_group_member_add`** — **admin-gate:** `groups[chat_id].admin_cid == sender`,
350
- status ∈ {active, accepting}. `process_address_document(member_ad, TRUE)`; if not a
351
- contact, register `contacts/peer_ads`; `members[member_cid]={name}`; `epoch=max(epoch,e)`;
352
- notify. (Contact-gated add atom: accepted because the relayer is my pinned admin.)
353
- - **`receive_group_roster_sync`** — admin-gate; for each entry `process_address_document(ad,TRUE)`,
354
- register contact if new, set `members`; `epoch=e`; `status="active"`; notify. (Joiner
355
- finalize + repair.)
356
- - **`receive_group_member_remove`** — admin-gate. If `removed_cid == me` → `delete groups[chat_id]`
357
- (keep contacts). Else `delete members[removed_cid]`; `epoch=max(epoch,e)`. Notify.
358
- - **`receive_group_member_leave`** — require `sender ∈ members[chat_id]`; `delete members[sender]`
359
- (self-assertion, no admin needed, no epoch change). Notify.
360
- - **`receive_group_delete`** — admin-gate; `delete groups[chat_id]`. Notify.
361
- - **`receive_group_message`** — apply the §5 gates (not-member → bounce `group_not_member`;
362
- unknown-sender → `group_stale` + `request_group_roster`, drop; valid → `on_group_message_received`
363
- hook + forced monitoring copy + optional async resync if `e>epoch`).
364
- - **`receive_group_not_member`** — if `sender ∈ members[chat_id]` → `delete members[sender]`. Save.
365
- - **`receive_group_stale`** — if `e > my epoch` and I am not the admin → `request_group_roster`. Save.
366
- - **`receive_group_roster_request`** (admin) — require I am admin; if `sender ∈ members`
367
- → reply `group_roster_sync` (full roster, epoch); else reply `group_not_member`.
368
-
369
- ---
370
-
371
- ## 9. Broadcast, storage & monitoring integration
372
-
373
- - **Storage stays app-side.** Two new hooks on `a2a_group::init`, mirroring
374
- `a2a_messaging`: `on_group_message_received ($chat_id,$sender_id,$sender_name,$text,$date,$wire_id,$reply_to)`
375
- and `on_group_message_sent ($chat_id,$text,$date,$wire_id,$reply_to)`. The core does
376
- roster resolution + validation; the app threads history by `chat_id`. (Consumers
377
- also wire the group-event `_notify_agent` payloads into their UX.)
378
- - **Forced monitoring for group traffic.** Group messages must not be a monitoring
379
- hole. Add `a2a_messaging::monitor_group_copy_actions (direction, chat_id, group_name,
380
- date, body)` — a sibling of `monitor_copy_actions` that reads the hidden
381
- `monitoring_proxy` (so it MUST live in `a2a_messaging`) and emits one re-encrypted
382
- copy tagged with group context. `monitoring_copy_t` gains an optional `$chat_id`
383
- (additive). `a2a_group` calls it unconditionally from `send_group_message` and
384
- `receive_group_message` — core code the app cannot suppress. The `a2a_monitoring`
385
- receiver passes the extra field through to its hook unchanged.
386
-
387
- ---
388
-
389
- ## 10. Security analysis & invariants (critic will enforce)
390
-
391
- **Properties:**
392
- - **PoP on every inbound AD.** `group_member_add` / `group_roster_sync` run
393
- `process_address_document(ad, TRUE)` before storing — a forged/inconsistent AD
394
- aborts; a key-derived cid can never be silently overwritten.
395
- - **Roster authority = the pinned admin.** `member_add` / `member_remove` /
396
- `roster_sync` are honored ONLY from `groups[chat_id].admin_cid`. A non-admin contact
397
- cannot add, remove, or resync anyone's roster.
398
- - **Self-assertions only remove the sender.** `leave` / `not_member` are accepted
399
- from any roster member but can only drop *that sender* — never a third party.
400
- - **No disclosure without consent.** A decline (or no response) discloses nothing; a
401
- member's AD reaches the joiner, and the joiner's AD reaches members, ONLY after the
402
- joiner accepts.
403
- - **Membership ≠ contact.** Remove/leave/delete edit `groups` only; `contacts`/`peer_ads`
404
- are never deleted by a group op.
405
- - **`epoch` is advisory.** It drives repair only; it is never an authorization input,
406
- so a forged epoch cannot mutate state (worst case: a harmless resync to the real admin).
407
- - **Forced monitoring covers group messages** (§9) — uniform with 1:1.
408
- - **Bare multi-send is sound.** Every roster member is a registered contact by
409
- construction of the mesh, so `send_encrypted_tx` to each is valid without a handshake.
410
-
411
- **Hard invariants (do not break):**
412
- 1. No `contacts`/`peer_ads` write before `process_address_document(ad, TRUE)` passes.
413
- 2. No roster mutation from a relay whose `sender != admin_cid` (except the
414
- sender-only self-assertions).
415
- 3. A group op never deletes a contact.
416
- 4. `receive_group_message` mutates no group state before its §5 gate decision.
417
- 5. Group state carries no secrets and exports/imports losslessly.
418
-
419
- **Residual trust (documented, unchanged class):** TOFU on the OOB-equivalent first
420
- contact (same as `add_contact` today) and "my admin honestly relays" — bounded by the
421
- admin-only authority and the PoP on every AD. An active admin can add/remove at will
422
- within its own groups; that is the definition of owner authority for v1.
423
-
424
- ---
425
-
426
- ## 11. Backward compatibility & versioning
427
-
428
- **Additive** — a new library, new wire shapes, new transactions, plus one additive
429
- field on `monitoring_copy_t`. No existing wire shape or verification semantics change.
430
- → **`version.mm` 3.0 → 3.1 (MIN).** `config.mufl` exports the new `a2a_group` library;
431
- consumers `load` it and wire the two storage hooks + the group-event notifies. New
432
- inbound names are library-routed, so no `::actor::` shims. `release-notes/3.1.md` per
433
- the existing convention.
434
-
435
- ---
436
-
437
- ## 12. Work breakdown (core mufl only)
438
-
439
- | # | File | Change | Size |
440
- |---|------|--------|------|
441
- | 1 | `a2a_protocol.mm` | Add `group_invite_t`; document the `any` payload shapes (§6). | S |
442
- | 2 | `a2a_messaging.mm` | Add `monitor_group_copy_actions`; add optional `$chat_id` to `monitoring_copy_t`. | S |
443
- | 3 | `a2a_group.mm` (NEW) | State (§7) + `init` (storage hooks) + tx-name consts. | S |
444
- | 4 | `a2a_group.mm` | User trns: create/invite/respond/send/remove/leave/delete/request/list (§8.1). | L |
445
- | 5 | `a2a_group.mm` | Inbound trns: invite/response/add/roster_sync/remove/leave/delete/message/not_member/stale/request (§8.2). | L |
446
- | 6 | `a2a_group.mm` | `export_group_state`/`import_group_state` (§7). | S |
447
- | 7 | `a2a_monitoring.mm` | Pass the optional `$chat_id` through `receive_monitoring_copy` to its hook. | XS |
448
- | 8 | `config.mufl` | Export `a2a_group`. | XS |
449
- | 9 | `version.mm` | `create_version 3 0` → `create_version 3 1` (MIN). | XS |
450
- | 10 | `release-notes/3.1.md` | New note (shipped txns + integration TODO + security notes). | S |
451
- | 11 | (compile) | Clean compile against the toolkit; no consumer wiring ([[qa-toolchain-mufl-core]]). | — |
452
-
453
- ---
454
-
455
- ## 13. Test plan (loopback, per [[qa-toolchain-mufl-core]])
456
-
457
- Extend `tests/test_actor.mu` (load `a2a_group`, wire group storage hooks + `qa_*`
458
- probes) and `tests/test.mjs` (multi-packet loopback, asserting **receiver-side** state).
459
-
460
- 1. **Compile**; `get_version` → 3.1.
461
- 2. **Create + invite + accept (2 members)** — owner creates, invites A; A accepts;
462
- owner roster = {owner, A}; A roster_sync registers owner; A `status=active`.
463
- 3. **Third member, incremental mesh** — owner invites B; B accepts; B's roster_sync
464
- carries owner+A; A gets `member_add(B)`. All three rosters equal; all pairwise
465
- `peer_ads` present (full mesh).
466
- 4. **Owner-only disclosure** — the `group_invite` to B carries no member ADs/names;
467
- a declining invitee's AD never reaches any member.
468
- 5. **Broadcast** — any member `send_group_message`; every other member's
469
- `on_group_message_received` fires with the right `chat_id`; bare multi-send (no
470
- handshake) to N registered contacts.
471
- 6. **Decline** — invitee declines; owner clears pending; no roster change, no AD sent.
472
- 7. **Admin remove** — owner removes A; A's group dropped (A keeps owner/B as
473
- contacts); B drops A from roster; A↔B `peer_ads` retained.
474
- 8. **Self leave** — B leaves; owner+A drop B from roster; contacts retained; admin
475
- `leave_group` aborts.
476
- 9. **Authority** — a non-admin `group_member_add`/`remove`/`roster_sync` is rejected
477
- (admin_cid mismatch); a `group_member_leave`/`not_member` only ever drops the sender.
478
- 10. **PoP** — a `member_add`/`roster_sync` with a stripped/forged AD aborts in
479
- `process_address_document`; nothing registered.
480
- 11. **Repair — bounce** — a removed/left node that receives a `group_message` replies
481
- `group_not_member`; the sender drops it from the roster.
482
- 12. **Repair — epoch/resync** — a member with a stale roster gets an unknown-sender
483
- `group_message` → `group_stale` + `request_group_roster` → admin `roster_sync`
484
- reconciles (missed add appears / missed remove confirmed).
485
- 13. **Delete** — owner `delete_group`; every member drops the group; contacts retained.
486
- 14. **Export/import** — `export_state`→`import_state` preserves `groups` + rosters;
487
- no secrets present; channels still work post-import.
488
- 15. **Monitoring** — with a bound CP, a `send_group_message` emits one forced copy
489
- tagged with `chat_id`; the app cannot suppress it.
490
-
491
- ---
492
-
493
- ## 14. Milestones / sequencing
494
-
495
- - **M0 — Shapes + state + skeleton:** items #1, #3, #9 + `config.mufl`. Compile;
496
- `get_version` → 3.1.
497
- - **M1 — Create/invite/accept/add:** the membership-formation path (create,
498
- invite_to_group, respond, the admin accept handler, member_add, roster_sync) +
499
- tests 2–4, 6, 10.
500
- - **M2 — Broadcast + storage + monitoring:** send/receive_group_message, the hooks,
501
- `monitor_group_copy_actions` (#2, #7) + tests 5, 15.
502
- - **M3 — Remove/leave/delete + repair:** the roster-op + repair inbounds + tests
503
- 7–9, 11–13.
504
- - **M4 — Export/import + release note + critic:** #6, #10 + test 14, critic review
505
- against §10.
506
-
507
- ---
508
-
509
- ## 15. Open decisions (deferred, not v1)
510
-
511
- - **Admin succession / co-admins.** v1 is single-owner; owner exit = `delete_group`.
512
- - **Group key / sender-keys multicast.** v1 fans out per-recipient over existing 1:1
513
- channels (no shared group key, no forward secrecy beyond the 1:1 channels).
514
- - **Signed membership tombstones** (peer-gossipable, admin-offline repair). v1 routes
515
- repair through the live admin (`request_group_roster`); tombstones are the upgrade
516
- if admin-offline healing is later required.
517
- - **Bounce rate-limiting / anti-amplification hardening** beyond the per-pair note in §5.
518
- - **Role-delegated members** (a member that is a delegated role): the AD + chain ride
519
- the same way as in `accept_contact`; v1 treats members as flat identities and may
520
- pin `contact_roots` opportunistically — confirm during M1.
@@ -1,98 +0,0 @@
1
- # Functional Source License, Version 1.1, Apache 2.0 Future License
2
-
3
- ## Abbreviation
4
-
5
- FSL-1.1-Apache-2.0
6
-
7
- ## Notice
8
-
9
- Copyright 2026 ours.network contributors
10
-
11
- ## Terms and Conditions
12
-
13
- ### Licensor ("We")
14
-
15
- The party offering the Software under these Terms and Conditions.
16
-
17
- ### The Software
18
-
19
- The "Software" is each version of the software that we make available under
20
- these Terms and Conditions, as indicated by our inclusion of these Terms and
21
- Conditions with the Software.
22
-
23
- ### License Grant
24
-
25
- Subject to your compliance with this License Grant and the Patents,
26
- Redistribution and Trademark clauses below, we hereby grant you the right to use,
27
- copy, modify, create derivative works, publicly perform, publicly display and
28
- redistribute the Software for any Permitted Purpose identified below.
29
-
30
- ### Permitted Purpose
31
-
32
- A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
- means making the Software available to others in a commercial product or service
34
- that:
35
-
36
- 1. substitutes for the Software;
37
-
38
- 2. substitutes for any other product or service we offer using the Software that
39
- exists as of the date we make the Software available; or
40
-
41
- 3. offers the same or substantially similar functionality as the Software.
42
-
43
- Permitted Purposes specifically include using the Software:
44
-
45
- 1. for your internal use and access;
46
-
47
- 2. for non-commercial education;
48
-
49
- 3. for non-commercial research; and
50
-
51
- 4. in connection with professional services that you provide to a licensee using
52
- the Software in accordance with these Terms and Conditions.
53
-
54
- ### Patents
55
-
56
- To the extent your use for a Permitted Purpose would necessarily infringe our
57
- patents, the license grant above includes a license under our patents. If you
58
- make a claim against any party that the Software infringes or contributes to the
59
- infringement of any patent, then your patent license to the Software ends
60
- immediately.
61
-
62
- ### Redistribution
63
-
64
- The Terms and Conditions apply to all copies, modifications and derivatives of
65
- the Software.
66
-
67
- If you redistribute any copies, modifications or derivatives of the Software, you
68
- must include a copy of or a link to these Terms and Conditions and not remove any
69
- copyright notices provided in or with the Software.
70
-
71
- ### Disclaimer
72
-
73
- THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, INCLUDING
74
- WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
75
- PURPOSE, NON-INFRINGEMENT, OR THAT THE SOFTWARE IS FREE OF DEFECTS. IN NO EVENT
76
- WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE SOFTWARE,
77
- INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF WE HAVE
78
- BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
79
-
80
- ### Grant of Future License
81
-
82
- We hereby irrevocably grant you an additional license to use the Software under
83
- the Apache License, Version 2.0 that is effective on the second anniversary of
84
- the date we make the Software available. On or after that date, you may use the
85
- Software under the Apache License, Version 2.0, in which case the following will
86
- apply:
87
-
88
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
89
- this file except in compliance with the License.
90
-
91
- You may obtain a copy of the License at
92
-
93
- http://www.apache.org/licenses/LICENSE-2.0
94
-
95
- Unless required by applicable law or agreed to in writing, software distributed
96
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
97
- CONDITIONS OF ANY KIND, either express or implied. See the License for the
98
- specific language governing permissions and limitations under the License.