@ours.network/tg-connector 0.1.1 → 0.1.3

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 (33) hide show
  1. package/README.md +62 -0
  2. package/dist/cli.js +35 -2
  3. package/dist/connector.js +105 -7
  4. package/dist/mufl_code/2DA1D5F860E42C605D92F1E24E2466C70EFDDBF057BBCBA52F0ECC639EFCA387.muflo +0 -0
  5. package/dist/mufl_code/core/CLUSTER_API.md +640 -0
  6. package/dist/mufl_code/core/CLUSTER_CONTRACT.md +121 -0
  7. package/dist/mufl_code/core/CLUSTER_INTRODUCTION_PLAN.md +200 -0
  8. package/dist/mufl_code/core/CONFIGURATION_DESIGN.md +35 -0
  9. package/dist/mufl_code/core/CONFIGURATION_PLAN.md +394 -0
  10. package/dist/mufl_code/core/DEVELOPMENT.md +168 -0
  11. package/dist/mufl_code/core/EPHEMERAL_INVITE_PLAN.md +465 -0
  12. package/dist/mufl_code/core/GROUP_CHAT_DESIGN.md +520 -0
  13. package/dist/mufl_code/core/LICENSE +98 -0
  14. package/dist/mufl_code/core/README.md +76 -0
  15. package/dist/mufl_code/core/a2a_capabilities.mm +350 -0
  16. package/dist/mufl_code/core/a2a_cluster.mm +601 -0
  17. package/dist/mufl_code/core/a2a_control.mm +89 -0
  18. package/dist/mufl_code/core/a2a_messaging.mm +2103 -0
  19. package/dist/mufl_code/core/a2a_monitoring.mm +94 -0
  20. package/dist/mufl_code/core/a2a_protocol.mm +231 -0
  21. package/dist/mufl_code/core/config.mufl +26 -0
  22. package/dist/mufl_code/core/release-notes/2.0.md +268 -0
  23. package/dist/mufl_code/core/release-notes/2.1.md +92 -0
  24. package/dist/mufl_code/core/release-notes/2.2.md +94 -0
  25. package/dist/mufl_code/core/release-notes/3.0.md +162 -0
  26. package/dist/mufl_code/core/release-notes/3.1.md +43 -0
  27. package/dist/mufl_code/core/release-notes/README.md +32 -0
  28. package/dist/mufl_code/core/tests/README.md +66 -0
  29. package/dist/mufl_code/core/tests/run.sh +67 -0
  30. package/dist/mufl_code/core/tests/test.mjs +467 -0
  31. package/dist/mufl_code/core/tests/test_actor.mu +287 -0
  32. package/dist/mufl_code/core/version.mm +24 -0
  33. package/package.json +4 -2
@@ -0,0 +1,92 @@
1
+ # core 2.1 — Cluster CP-introduction
2
+
3
+ **Version 2.1 · MIN (additive) · One root↔CP bind enrolls a whole cluster; the
4
+ CP then introduces child components across clusters with zero per-child
5
+ ceremony and zero application logic.**
6
+
7
+ > **STATUS: prose pending.** This is the architecture stub for the 2.1 release
8
+ > note. The structure + transaction list below are authoritative for the change
9
+ > shipped on `feat/cluster-introduction`; the full narrative write-up is the
10
+ > next round (per the implementation plan, §5). Implemented + compiles clean;
11
+ > founder approval gates the merge to `main` (see *Security notes*).
12
+
13
+ ## What shipped
14
+
15
+ Core-side protocol support for **CP-brokered cluster introductions**. A root
16
+ binds a control plane (CP) once; that single bind:
17
+
18
+ - registers the CP as the manager of the root's whole cluster (CP side), and
19
+ - lets every child of the root **inherit** the root-signed CP binding so the
20
+ child accepts the CP's introductions locally, with no per-child bind ceremony.
21
+
22
+ The CP can then introduce child components of *different* roots to each other
23
+ (the existing root-agnostic `introduce` / `introduce_to_group`); the introduced
24
+ parties do fresh end-to-end DH, so the CP never holds their channel keys.
25
+
26
+ Application logic required is still just the `core.connect` boolean — everything
27
+ else is identity-hierarchy + control-plane material the host/daemon manages.
28
+
29
+ This is **additive**: the legacy direct-bind introduction path (a node that ran
30
+ its own 6-digit proxy bind) is unchanged and still accepts introductions.
31
+
32
+ ## New/changed transactions (`a2a_messaging.mm`)
33
+
34
+ - **`manage_root($root_cid)`** — host-fired (CP side). Records that this control
35
+ plane manages a root (`managed_roots` set). The authorization half of
36
+ enrollment: a child enrolls only if its delegation chain resolves to a root
37
+ here. Idempotent.
38
+ - **`set_root_cp_binding($binding)`** — host-fired. Stores the root-signed CP
39
+ binding (`root_cp_binding`), verified against the node's own root identity
40
+ before storage. Fills the long-standing gap (the binding was restored on
41
+ import but never settable). It then rides the existing invite / state-push
42
+ paths down to the root's roles.
43
+ - **`enroll_delegated_node`** — external inbound (CP side). A root relays one of
44
+ its children's signed address document + delegation chain; the CP verifies
45
+ **(1)** the authenticated sender *is* the root in the chain, **(2)** that root
46
+ is in `managed_roots`, **(3)** `verify_peer_delegation` chains the child to it,
47
+ and re-checks the child AD self-signature (proof-of-possession). On success it
48
+ stores `peer_ads`/`contacts`/`contact_roots`. Idempotent.
49
+ - **`require_cluster_cp_or_abort`** (helper) replaces `require_bound_cp_or_abort`
50
+ in `ingest_connect_descriptor`'s relay gate. Additive: accepts **either** a
51
+ legacy direct bind (`monitoring_proxy == sender`) **or** an inherited cluster
52
+ CP (sender is the CP the node's root designated, re-verified locally against
53
+ the pinned `root_ad` keys — including the `cid_cp` pin — on every call).
54
+ - `managed_roots` threaded through `export_core_state` / `import_core_state`
55
+ (optional; pre-2.1 exports default to empty).
56
+ - `version.mm`: `2.0 → 2.1`.
57
+
58
+ `a2a_protocol.mm` is unchanged — the existing hierarchy/attestation shapes and
59
+ verifiers (`delegation_cert_t`/`verify_peer_delegation`,
60
+ `root_cp_binding_t`/`verify_root_cp_binding`, `cp_attestation_t`) were already
61
+ sufficient.
62
+
63
+ ## Integration TODO for consumers (later phases, NOT in this change)
64
+
65
+ - **MCP daemon** (`ours-mcp/packages/core`): at root-bind, relay each
66
+ subagent's AD to the CP via `enroll_delegated_node`; call `manage_root` for the
67
+ bound root; push `root_cp_binding` to roles via the role-spawn state push; run
68
+ the `get_manifest` `core.connect` pre-check before calling `introduce`.
69
+ - **Control-plane / messenger**: UX for the cluster-introduction flow.
70
+ - **Monitoring inheritance** is deliberately **NOT** changed here: a root bind
71
+ does **not** auto-copy all roles' traffic to the CP. That is a governance
72
+ decision (it would change the monitoring guarantee's semantics) and is parked
73
+ unless explicitly approved.
74
+ - **Recursive delegation** (N-level trees) is parked; the enrollment + gate are
75
+ written so a later chain-walk could slot in, but flat 2-level is all that ships.
76
+
77
+ ## Security notes
78
+
79
+ - This change **promotes the previously non-enforcing governance-attestation
80
+ layer** (`root_cp_binding` / `cp_attestation` / invite-threading) to an
81
+ **enforcing** authorization role gating introductions. The crypto is sound —
82
+ root-signed, domain-separated, locally pinned via `root_ad` — and the residual
83
+ trust (the host honestly distributes `root_ad` / `root_cp_binding` to its
84
+ roles) is the same honesty class as the existing monitoring self-assertion
85
+ limit. **The promotion decision is the founder's**; implemented on a branch,
86
+ not merged to `main` until signed off.
87
+ - Invariants preserved: the node-side capability gate (`self_supports(core.connect)`)
88
+ stays authoritative; `enroll_delegated_node` rejects a child of an unmanaged
89
+ root (and a relayer that is not the root); `require_cluster_cp_or_abort`
90
+ re-verifies the binding against the pinned `root_ad` keys (and `cid_cp`) every
91
+ call; the `process_address_document(peer_ad, TRUE)` self-signature re-check
92
+ stays in `ingest`.
@@ -0,0 +1,94 @@
1
+ # core 2.2 — Cluster root-side producers
2
+
3
+ **Version 2.2 · MIN (additive) · The root-side PRODUCER half of cluster
4
+ CP-introduction: a root can now MINT its CP binding, push it to its roles, and
5
+ RELAY its children to the control plane. Completes the loop core 2.1 left to
6
+ "later phases".**
7
+
8
+ ## What shipped
9
+
10
+ core 2.1 shipped the cluster RECEIVER + ACCEPT side (`manage_root`, the
11
+ `enroll_delegated_node` handler, the `set_root_cp_binding` store,
12
+ `require_cluster_cp_or_abort`, and `$rpb` propagation) but deferred the
13
+ root-side PRODUCERS to consumer integration — and no transaction existed to
14
+ (a) mint the root-signed `root_cp_binding` or (b) emit the enrollment relay to
15
+ the CP. The managed/root side therefore could not actually drive enrollment.
16
+ core 2.2 adds those producers, all additive and root-side:
17
+
18
+ - A root **mints** its §3c CP binding (`sign_root_cp_binding`) — self-signing
19
+ `{context_tag, root_cid, cid_cp}` via the same key path as delegation certs.
20
+ - The daemon stores it on the root AND pushes the same blob to each role;
21
+ `set_root_cp_binding` is widened so a role verifies its **inherited** binding
22
+ against its pinned `root_ad` (the accept gate's own keys + verifier), letting a
23
+ role hold the edge with zero ceremony.
24
+ - A root **relays** each child's signed AD + delegation chain to the bound CP
25
+ (`relay_enroll_delegated_node`), driving the existing CP-side
26
+ `enroll_delegated_node` handler — one root bind enrolls the whole cluster.
27
+
28
+ No CP-side or node-accept-side behaviour changed; the legacy direct-bind path is
29
+ untouched.
30
+
31
+ ## New/changed transactions (`a2a_messaging.mm`)
32
+
33
+ - **`sign_root_cp_binding($proxy)`** — NEW, host-fired, ROOT only, STATELESS.
34
+ Resolves `$proxy` to the CP's container id, builds
35
+ `root_cp_binding_core_t{version 1, context_tag "ours:cp-attestation:v1",
36
+ root_cid=self, cid_cp}`, root-signs it via `key_storage::default_sign` over
37
+ `_value_id`, and returns the signed blob (+ `cid_cp`). Mirrors
38
+ `sign_delegation`. Aborts if not a root (`delegation_cert != NIL`).
39
+ - **`set_root_cp_binding($binding)`** — CHANGED (additive verify-path widening),
40
+ now DUAL-MODE. ROOT (`delegation_cert == NIL`): verify the binding against the
41
+ node's own identity — unchanged from 2.1. ROLE (`delegation_cert != NIL`):
42
+ verify the INHERITED binding against the pinned `root_ad` — rejecting any edge
43
+ not signed by the role's own root. Fails CLOSED. This is a NEW, tightly-gated
44
+ acceptance, not a narrowing: in 2.1 the role path always aborted (it
45
+ own-identity-verified a root-signed edge, which can never match), so 2.2 newly
46
+ accepts root-signed inherited bindings a role could not store before. The root
47
+ path is byte-unchanged; no pre-existing accept path is loosened.
48
+ - **`relay_enroll_delegated_node($proxy, $child_ad, $delegation_cert,
49
+ $root_profile)`** — NEW, host-fired, ROOT only. Resolves `$proxy` to the bound
50
+ CP and sends an encrypted `enroll_delegated_node` relay carrying
51
+ `{$child_ad (AD value), $delegation_cert (blob), $root_profile (blob)}` —
52
+ field-for-field matching `handle_enroll_delegated_node`. Returns the relay
53
+ target + child container id. Aborts if not a root.
54
+ - **`version.mm`**: `2.1 → 2.2`.
55
+
56
+ `a2a_protocol.mm` is unchanged — `root_cp_binding_t` / `verify_root_cp_binding` /
57
+ `cp_attestation_context_tag` and the delegation verifiers were already
58
+ sufficient.
59
+
60
+ ## Integration TODO for consumers (MCP daemon)
61
+
62
+ - At root↔CP bind: `sign_root_cp_binding(cp)` then `set_root_cp_binding(blob)` on
63
+ the root; push the same blob to each role via `set_root_cp_binding` (role path,
64
+ `root_ad`-verified).
65
+ - For each child: `relay_enroll_delegated_node(cp, child_ad, cert, root_profile)`.
66
+ - `manage_root` / `introduce` / `introduce_to_group` and the `get_manifest`
67
+ `core.connect` pre-check stay CP-side (messenger), unchanged.
68
+ - The child container id the CP keys on is `child_ad.identity.container_id`; the
69
+ daemon must source it from ONE place and keep it byte-consistent with the cid it
70
+ advertises elsewhere (e.g. `list_agents`).
71
+
72
+ ## Security notes
73
+
74
+ - These are PRODUCERS, not new enforcement. The root signs its OWN governance
75
+ edge with the same key it uses for delegation certs; the relay is an
76
+ authenticated root→CP send over the existing bound channel; and the CP handler's
77
+ three checks (sender is the child's root, that root is managed, the delegation
78
+ chain verifies + AD proof-of-possession) are unchanged. No trust-model change
79
+ beyond making the 2.1 layer usable from the root side.
80
+ - `set_root_cp_binding` EXTENDS the verify semantics of the
81
+ governance-attestation enforcement layer: a role now stores an inherited edge,
82
+ verified against its pinned `root_ad` (`binding.root_cid` == `root_ad`'s
83
+ container id; signature under the domain-separated `context_tag`; `cid_cp`
84
+ integrity via the signed core record). The role path is a NEW acceptance, not a
85
+ narrowing: in 2.1 a role's `set_root_cp_binding` always aborted (own-identity
86
+ verify of a root-signed edge can never match), so 2.2 newly accepts root-signed
87
+ inherited bindings the role could not store before — tightly gated to edges
88
+ signed by the role's own root, matching the accept gate's trust. The root path
89
+ is byte-unchanged. Additive (MIN); no pre-existing accept path is loosened.
90
+ - Like core 2.1's promotion of the governance-attestation layer to an ENFORCING
91
+ role, this change rides the **founder promotion gate**: implemented on a branch
92
+ (`feat/cluster-root-producers`), NOT merged to `main` until signed off. The
93
+ producers further activate that enforcing layer (roles can now inherit and
94
+ accept CP introductions end-to-end), so founder visibility applies.
@@ -0,0 +1,162 @@
1
+ # core 3.0 — Ephemeral-key slim invite
2
+
3
+ **Version 3.0 · MAJ (breaking) · The fat, identity-bearing invite is replaced by
4
+ a slim invite that carries only an ephemeral encryption pubkey; both parties'
5
+ address documents (and, for roles, the delegation chain) are exchanged over a
6
+ two-message encrypted hop after redemption instead of riding in the invite.**
7
+
8
+ ## What shipped
9
+
10
+ Invites no longer disclose identity. A core-3.0 invite (`invite_eph_t`,
11
+ `a2a_protocol.mm`) carries only `{ invite_id, inviter_container_id, inviter_name,
12
+ ephemeral_encryption_pubkey, scheme_id }` — **no public-key list, no
13
+ self-signatures, no delegation cert, no root profile.** The inviter's (and, for a
14
+ delegated role, the responder's) full address document + chain travel **inside a
15
+ box** on a two-message redeem hop, only to a party that has proven liveness by
16
+ round-tripping the invite.
17
+
18
+ The redeem flow is **1 out-of-band invite + 2 on-wire messages** (down from the
19
+ old ≈4-message ECDH handshake + accept):
20
+
21
+ ```
22
+ (OOB) inviter ──► responder : invite_eph_t { invite_id, inviter_cid, name, eph_pub, scheme }
23
+ leg 1 responder ──► inviter : submit_invite_response (BARE send; box → inviter eph_pub)
24
+ leg 3 inviter ──► responder : complete_invite (BARE send; box → responder eph_pub)
25
+ ```
26
+
27
+ Both legs are **bare boxed sends** (`_crypto_encrypt_message` to the
28
+ counterparty's ephemeral public key — the `authorize_packet` idiom,
29
+ `encrypted_channel.mm:118-124`); `encrypted_channel` is **untouched** and resumes
30
+ for all post-contact `send_message` traffic once both sides are registered.
31
+
32
+ The invite is structurally minimal — 5 public fields, no key list / cert / root
33
+ profile — so its **size floor is the post-quantum ephemeral public key** (measured
34
+ ~921 bytes raw, dominated by that key). The dramatic reduction is **vs role
35
+ invites**, which previously embedded the root's entire key list + profile + the
36
+ delegation chain; a flat invite shrinks too, but the win is largest for roles.
37
+
38
+ > **Why leg 3 is a bare box, not `encrypted_channel`.** At leg 3 the responder has
39
+ > not yet registered the inviter, so an `encrypted_channel::send_encrypted_tx`
40
+ > reply is undecryptable receiver-side — the responder cannot resolve the inviter's
41
+ > source key (`key_storage.mm:291` "Unknown source key for message decryption",
42
+ > reproduced in loopback). Boxing to the responder's **real** long-term key is also
43
+ > impossible: the stdlib never exposes a raw long-term encryption private key. So
44
+ > leg 3 boxes to the responder's **ephemeral** public key (carried in leg 1); the
45
+ > responder keeps its ephemeral private key until leg 3 to open it. This corrects
46
+ > the plan's original "leg 3 via encrypted_channel / box to the real key" wording.
47
+
48
+ After leg 3 both sides hold the other's verified AD + contact + (optional) root
49
+ linkage — symmetric to the pre-3.0 end state.
50
+
51
+ **Disclosure order flips:** the responder now discloses its identity first (boxed
52
+ to the inviter's ephemeral key). This is inherent — moving the identity bulk off
53
+ the OOB channel forces recipient-first disclosure — and is neutral under the
54
+ OOB-trust model (see *Security notes*).
55
+
56
+ ## New/changed transactions (`a2a_messaging.mm`)
57
+
58
+ - **`generate_invite($name)`** — unchanged signature; now mints the slim
59
+ `invite_eph_t` via the reworked `mint_eph_invite` (was `mint_invite`). Generates
60
+ a per-invite ephemeral encryption keypair: the public half ships in the invite,
61
+ the private half is stored in the new hidden `pending_invite_keys`.
62
+ - **`add_contact($invite, $name?)` → LEG 1 (responder).** Parses the slim invite,
63
+ generates a one-shot responder ephemeral keypair, boxes its identity bundle
64
+ (`{ad, cert?, root_profile?, cp_binding?, invite_id}`) to the invite's ephemeral
65
+ pubkey, and **bare-sends** `submit_invite_response`. Records `pending_redemptions`
66
+ (chosen name + expected inviter cid) and keeps the responder ephemeral private
67
+ key in the new hidden `pending_redemption_keys`. The contact is **pending** here;
68
+ it finalizes on leg 3. Returns `$resp_eph_pub` (already-public wire material) so a
69
+ caller can correlate the outstanding redemption.
70
+ - **`submit_invite_response` (NEW, library-routed) → LEG 2 (inviter).** Inbound,
71
+ bare box. Gates in order — pending-invite lookup → box decrypt → cid-bind
72
+ (`AD.container_id == envelope.from`) → `process_address_document(ad, TRUE)` (PoP
73
+ self-sig) → optional delegation-chain verification — **then** registers the
74
+ responder and **single-use consumes both** `pending_invites` and
75
+ `pending_invite_keys`. Replies leg 3 as a bare box to the responder's ephemeral
76
+ pubkey. Deliberately does **not** `check_encrypted_or_abort` (the box is the
77
+ protection).
78
+ - **`complete_invite` (NEW, library-routed) → LEG 3 (responder).** Inbound, bare
79
+ box. Gates — pending-redemption lookup → inviter-cid pin (`from == expected
80
+ inviter`) → box decrypt with the kept responder ephemeral key → cid-bind →
81
+ `process_address_document(ad, TRUE)` → optional chain — **then** registers the
82
+ inviter and clears **both** `pending_redemptions` and `pending_redemption_keys`.
83
+ Also bare (no `check_encrypted_or_abort`).
84
+
85
+ State (`a2a_messaging.mm`): `pending_invites` changed from `(global_id ->> str)` to
86
+ `(global_id ->> pending_invite_t)` (`{assigned, eph_pub, scheme}`); new hidden,
87
+ **non-exported** `pending_invite_keys` and `pending_redemption_keys` (ephemeral
88
+ private keys); new `pending_redemptions` (`{inviter_cid, inviter_name,
89
+ custom_name}`).
90
+
91
+ ## Breaking changes
92
+
93
+ - **Invite format + redemption flow changed; old fat invites are NOT redeemable
94
+ on 3.0, and 3.0 invites are NOT redeemable by pre-3.0 clients.** Invites are
95
+ short-lived artifacts; re-issue them after upgrading. (Clean break, plan §7
96
+ option A.)
97
+ - **Removed:** `a2a_protocol::invite_t`, `a2a_protocol::invite_role_t`,
98
+ `a2a_protocol::rebuild_peer_address_document`, and the old offline-redeem
99
+ `add_contact` body. (`accept_contact`/`handle_accept_contact` are retained as a
100
+ legacy inbound handler; they are no longer reachable from the 3.0 redeem path.)
101
+ - **Outstanding invites do not survive a daemon restart** (see *Security notes* —
102
+ this is by design, fail-closed).
103
+
104
+ ## Integration TODO for consumers (later phases — NOT in this core-only change)
105
+
106
+ - `add_contact` is now **asynchronous**: it returns a *pending* status; the contact
107
+ finalizes when leg 3 arrives. Consumers that treated `add_contact`'s return as
108
+ "contact added" must instead surface completion on the leg-3 `notify_agent`
109
+ (`$contact_added`) event. The inviter's confirmation arrives via the leg-2
110
+ `$contact_accepted` event.
111
+ - No new `::actor::` shim is required: `submit_invite_response` / `complete_invite`
112
+ are library-routed (`::a2a_messaging::…`), like `ingest_connect_descriptor`.
113
+ - The slim invite blob is much smaller; consumer compression/transport is
114
+ unaffected (the blob is still an opaque bin).
115
+ - Re-issue any outstanding invites after the upgrade.
116
+
117
+ ## Security notes
118
+
119
+ - **Identity pin is unchanged.** Both legs enforce `received_AD.container_id ==
120
+ envelope.from` **and** `process_address_document(ad, TRUE)` (proof-of-possession
121
+ self-signature) before storing or trusting any AD — identical to the pre-3.0
122
+ `handle_accept_contact` gate. Pin strength still tracks the planned `container_id`
123
+ key-derivation; neither improved nor regressed.
124
+ - **No registration before all gates pass (INV-5).** Neither leg writes
125
+ `contacts`/`peer_ads`/`contact_roots` until lookup → decrypt → cid-bind → PoP →
126
+ chain all pass. A failed gate mutates nothing.
127
+ - **Single-use.** The first valid leg 2 consumes both inviter stores
128
+ (`pending_invites` + `pending_invite_keys`); the first valid leg 3 consumes both
129
+ responder stores. A replayed or invalid leg consumes nothing.
130
+ - **Reduced disclosure / smaller blast radius.** An intercepted invite leaks only
131
+ `{eph_pub, cid, name}` — no keys, no root profile, no org chain. A leaked invite
132
+ forces an active, single-use round-trip (revealing the attacker's own cid) rather
133
+ than being passive total identity exposure.
134
+ - **Ephemeral secret at rest, and restart-transience BY DESIGN.** The per-invite
135
+ ephemeral private keys live in `pending_invite_keys` / `pending_redemption_keys`,
136
+ which are `hidden` **and never added to `export_core_state` (INV-4)**. The export
137
+ blob is the host's persistence boundary (`export_state` → disk → `import_state`),
138
+ so an outstanding invite/redemption **does not survive a daemon restart** between
139
+ legs — it fails closed (the next leg aborts on the missing key; no contact is
140
+ silently formed). Treat invites as **session/process-transient**; re-issue after a
141
+ restart.
142
+ - **`AdaptValue.Serialize` corrupts raw secret keys — LANDMINE.** Empirically (M0
143
+ spike), a raw `secretkey_encrypt` round-tripped through the SDK
144
+ `AdaptValue.Serialize()` / `ParseValue()` path (the host's `export_state` →
145
+ on-disk blob, `index.ts:1296`) comes back **present-but-unusable** (decrypt
146
+ aborts "crypto box failed"). It DOES round-trip faithfully through mufl's own
147
+ `_write`/`_read`. This is a second, independent reason the ephemeral secret stores
148
+ must never be placed in `export_core_state`: doing so would both leak the secret
149
+ AND yield a corrupt, silently-failing key on reload. Do not "fix" restart-survival
150
+ by adding these stores to the export.
151
+ - **Eph-key TTL — RECOMMENDED, NOT implemented in this change.** Bounding the
152
+ at-rest-secret window and stale-invite growth wants an expiry sweep over
153
+ `pending_invites`/`pending_invite_keys` (and the responder stores). It needs a
154
+ time source + a sweep hook and is deferred (plan §10). Until then, the stores are
155
+ bounded only by single-use consumption and restart-transience.
156
+ - **Leg 1 is an unauthenticated bare inbound.** Anyone holding a leaked invite can
157
+ spam `submit_invite_response`, each forcing one decrypt attempt; it aborts cheaply
158
+ on the lookup / box-open / cid-bind, mutates no state before the gates, and the
159
+ first valid one consumes the invite. Bounded DoS; documented, accepted.
160
+ - **MITM exposure unchanged.** Both designs are TOFU rooted in the OOB invite
161
+ channel; an active OOB attacker can substitute the whole invite either way, and
162
+ the defense is the same (verify the cid you pinned, out of band).
@@ -0,0 +1,43 @@
1
+ # core 3.1 — File transfer (`send_file` / `receive_file`)
2
+
3
+ **Version 3.1 · MIN (additive) · A first-class file-transfer transaction pair,
4
+ separate from `send_message`. Files and text are always distinct messages: to
5
+ send a file with a caption, an agent sends two transactions.**
6
+
7
+ ## What shipped
8
+
9
+ `send_file _:($contact, $filename, $mime?, $data, $reply_to?)` mirrors
10
+ `send_message` exactly but on its own path: it resolves the contact, stamps a
11
+ `wire_id`, and sends the file (`filename` + optional `mime` + `bin` bytes) over
12
+ `encrypted_channel` to the new library-routed inbound `::a2a_messaging::receive_file`.
13
+ The receiver validates + resolves the sender and hands the file to the app via a
14
+ new `on_file_received` storage hook; the sender side fires `on_file_sent`. Both
15
+ hooks are injected through `a2a_messaging::init`, identical in shape to the
16
+ message hooks. The app owns file storage — the core stores nothing.
17
+
18
+ ## One shared `wire_id` namespace
19
+
20
+ A file's `wire_id` is stamped from the SAME `_new_id` namespace as a message's, so
21
+ `reply_ref_t` (unchanged) works across kinds: a `send_message` can `reply_to` a
22
+ file, and a `send_file` can be a reply to a message, out of the box.
23
+
24
+ ## Monitoring
25
+
26
+ `send_file` / `receive_file` emit the same FORCED monitoring copy as messages,
27
+ self-gating on the bound control plane — but the body is **metadata only**:
28
+ `[file] <name> (<mime>, <N> B)`. The control plane learns a file moved and its
29
+ metadata, never the bytes (`monitoring_copy_t.$body` stays `str`).
30
+ When the sender omits the mime type, the `<mime>` field renders empty (e.g. `[file] notes.txt (, 12 B)`).
31
+
32
+ ## Out of scope (YAGNI)
33
+
34
+ No chunking / streaming / resumable transfer, no content-type validation or dedup,
35
+ no attachment-on-message style. One `send_file` = one whole file in one transaction.
36
+
37
+ ## Consumer coordination
38
+
39
+ `a2a_messaging::init` gains two parameters (`$on_file_received`, `$on_file_sent`).
40
+ Consumers (agent packet, web messenger) must add these two hooks to their `init`
41
+ call when adopting core 3.1 — the same kind of coordinated, version-gated change as
42
+ any prior core signature bump. This repo's QA actor (`tests/test_actor.mu`) is
43
+ updated accordingly.
@@ -0,0 +1,32 @@
1
+ # ours mufl core — release notes
2
+
3
+ One note file per **core version**, where the version is the `MAJ.MIN` reported
4
+ by `version::get_core_version` (`version.mm`). This replaces the single
5
+ `RELEASE_NOTES_core_config.md` that previously covered a whole range (1.10→2.0);
6
+ that file is now `2.0.md` (the 2.0 lineage record), unchanged in content.
7
+
8
+ ## Versions (newest first)
9
+
10
+ | Core | Bump | Summary |
11
+ |------|------|---------|
12
+ | [3.0](3.0.md) | MAJ (breaking) | **Ephemeral-key slim invite** — the fat identity-bearing invite is replaced by a slim `invite_eph_t` (ephemeral encryption pubkey + cid + name + scheme only); both address documents + the delegation chain move to a two-message **bare boxed** redeem hop (legs 1/2/3). Removes `invite_t` / `invite_role_t` / `rebuild_peer_address_document` + the old `add_contact` body. Per-invite ephemeral secrets are `hidden` + never exported → outstanding invites are restart-transient (fail-closed). |
13
+ | [2.2](2.2.md) | MIN (additive) | **Cluster root-side producers** — the root half core 2.1 deferred: a root mints its CP binding (`sign_root_cp_binding`), pushes it to roles (`set_root_cp_binding` widened to verify a role's inherited binding against its pinned `root_ad`), and relays children to the CP (`relay_enroll_delegated_node`). Additive; legacy paths untouched. |
14
+ | [2.1](2.1.md) | MIN (additive) | **Cluster CP-introduction** — one root↔CP bind enrolls a whole cluster; children inherit the root's CP binding and accept CP introductions with zero per-child ceremony. New `manage_root`, `set_root_cp_binding`, `enroll_delegated_node`; `ingest` gate widened (additive). |
15
+ | [2.0](2.0.md) | MAJ (breaking) | Configuration / control-plane lineage (1.10→2.0): forced monitoring (B1), opaque control-plane config (B3), and the **radically simplified** `core.connect` introduction (B2) — SAS / CP-signed-intro / `connect_descriptor_t` removed. |
16
+
17
+ ## Convention
18
+
19
+ - **Filename** = the core version string `MAJ.MIN.md`, matching
20
+ `version::get_core_version` for the change.
21
+ - **Every `MAJ`/`MIN` bump in `version.mm` REQUIRES a matching
22
+ `release-notes/<version>.md` in the same change** — a reviewer checklist item.
23
+ A version bump with no matching note (or a note with no bump) is a review block.
24
+ - Each note opens with a **header line** stating the version, the bump type
25
+ (`MAJ` breaking / `MIN` additive) and a one-line summary, then these sections:
26
+ - **What shipped**
27
+ - **New/changed transactions**
28
+ - **Breaking changes** (only if `MAJ`)
29
+ - **Integration TODO for consumers**
30
+ - **Security notes**
31
+ - This `README.md` carries the version table above, **newest first**, one line
32
+ each. Add a row in the same change that adds the note.
@@ -0,0 +1,66 @@
1
+ # core 3.0 ephemeral-invite — loopback test suite
2
+
3
+ End-to-end behavioural tests for the slim ephemeral-key invite + two-message boxed
4
+ redeem (legs 1/2/3) shipped in core 3.0 (`release-notes/3.0.md`).
5
+
6
+ The core repo is pure mufl libraries with no standalone build, so these tests run
7
+ through a small **self-contained test actor** (`test_actor.mu`) that loads the
8
+ shared core and supplies the minimum host wiring (storage hooks, a tiny inbox, the
9
+ identity-hierarchy helpers, export/import wrappers) plus `qa_*` probe transactions
10
+ the driver uses to inject adversarial inputs and read state. **No consumer/daemon
11
+ source is vendored** — the actor is derived locally for this repo.
12
+
13
+ ## Files
14
+
15
+ - **`test_actor.mu`** — the derived test actor (pure mufl; compiles against this
16
+ repo's `core/` via the toolkit).
17
+ - **`test.mjs`** — the loopback driver: spins up multiple packets on one broker and
18
+ runs the scenarios, asserting **receiver-side state** (not just send emission).
19
+ - **`run.sh`** — builds a throwaway harness, compiles, boots a local broker, runs
20
+ the driver. Exit 0 = all green.
21
+
22
+ ## Prerequisites (external to this repo)
23
+
24
+ 1. **ADAPT toolkit** — the `mufl-compile` binary + `mufl_stdlib` / `meta` /
25
+ `transactions` (default root `…/adapt-toolkit`).
26
+ 2. **`@adapt-toolkit` Node SDK** — from any consumer checkout's `node_modules`
27
+ (e.g. `ours-mcp/node_modules`); used only to drive packets in the loopback.
28
+ 3. **`dev-broker.mjs`** — the local relay launcher (ships in `ours-mcp/scripts`).
29
+
30
+ Node 18+ (tested on v20).
31
+
32
+ ## Run
33
+
34
+ ```sh
35
+ ./tests/run.sh
36
+ # or override paths:
37
+ ADAPT_TOOLKIT=/path/to/adapt-toolkit \
38
+ OURS_SDK_NODE_MODULES=/path/to/ours-mcp/node_modules \
39
+ DEV_BROKER=/path/to/ours-mcp/scripts/dev-broker.mjs \
40
+ PORT=9799 ./tests/run.sh
41
+ ```
42
+
43
+ The SDK's leak-tracker prints `###`/`Leak for AdaptValue` lines at exit and inbound
44
+ aborts surface as `EVAL_ERROR` on stderr — both are expected noise (the adversarial
45
+ scenarios deliberately trigger aborts; `run.sh` forwards only the meaningful
46
+ `inbound rejected` lines). The verdict is the final `SCORECARD` + exit code.
47
+
48
+ ## Scenarios asserted (10 scenarios, 36 assertions)
49
+
50
+ | # | Scenario | What it proves |
51
+ |---|----------|----------------|
52
+ | T1 | happy-flat | leg-2 consumes the invite + registers the responder; **leg-3 receiver-side**: the responder decrypts the boxed leg-3 with its kept eph priv and registers the inviter; both `list_contacts` show the other; `send_message` round-trips **both** directions over `encrypted_channel`. |
53
+ | T2 | happy-role | both sides are delegated roles; the delegation chain verifies and `contact_roots` is pinned on **both** legs. |
54
+ | T3 | single-use | a 2nd leg-1 for the same `invite_id` aborts (`already-redeemed`); inviter state unchanged. |
55
+ | T4 | invalid-then-valid | a bad box aborts at decrypt and does **not** consume the invite; a subsequent valid redeem then consumes it. |
56
+ | T5 | tamper | a tampered box aborts and mutates **no** state. |
57
+ | T6 | cid-bind leg-2 | a boxed AD whose `container_id` ≠ sender aborts; nothing registered/consumed. |
58
+ | T7 | PoP leg-2 | an AD with stripped self-signatures aborts in `process_address_document`. |
59
+ | T8 | leg-3 gates | unexpected-inviter (sender ≠ pinned cid), cid-bind leg-3, and PoP leg-3 each abort and register nothing. |
60
+ | T9 | export-secrecy | `export_core_state` contains **neither** `pending_invite_keys` **nor** `pending_redemption_keys`; `pending_invites` carries only public `{assigned, eph_pub, scheme}` (INV-4). |
61
+ | T10 | import migration | `export_state`→`import_state` preserves contacts/peer_ads and resets `pending_invites` (plan §4.4). |
62
+
63
+ Hard invariants exercised: **INV-5** (no `contacts`/`peer_ads`/`contact_roots`
64
+ write before lookup → decrypt → cid-bind → PoP → chain) on both legs; **single-use**
65
+ consumes both per-side ephemeral stores; **INV-4** (ephemeral secrets never
66
+ exported).
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+ # Loopback test runner for the core-3.0 ephemeral-invite suite.
3
+ #
4
+ # The core repo is pure mufl libraries; running a behavioural test needs (a) the
5
+ # ADAPT toolkit compiler + stdlib, and (b) the @adapt-toolkit Node SDK + a dev
6
+ # broker to actually execute packets. Both are external to this repo. This script
7
+ # builds a throwaway harness dir, compiles the self-contained test actor against
8
+ # THIS repo's core, boots a local broker, and runs the driver.
9
+ #
10
+ # Override any path via env:
11
+ # ADAPT_TOOLKIT toolkit root (has build.linux.release/mufl-compile, mufl_stdlib, meta, transactions)
12
+ # OURS_SDK_NODE_MODULES a node_modules dir containing @adapt-toolkit (e.g. an ours-mcp checkout's)
13
+ # DEV_BROKER path to dev-broker.mjs (ships in ours-mcp/scripts)
14
+ # PORT broker port (default 9799)
15
+ set -u
16
+ HERE=$(cd "$(dirname "$0")" && pwd)
17
+ CORE_DIR=$(cd "$HERE/.." && pwd)
18
+ AT=${ADAPT_TOOLKIT:-/home/shakhvit/work/adapt/adapt-toolkit}
19
+ SDK_NM=${OURS_SDK_NODE_MODULES:-/home/shakhvit/work/adapt/ours/ours-mcp/node_modules}
20
+ DEV_BROKER=${DEV_BROKER:-/home/shakhvit/work/adapt/ours/ours-mcp/scripts/dev-broker.mjs}
21
+ PORT=${PORT:-9799}
22
+ COMPILE="$AT/build.linux.release/mufl-compile"
23
+
24
+ for p in "$COMPILE" "$AT/mufl_stdlib" "$SDK_NM/@adapt-toolkit" "$DEV_BROKER"; do
25
+ [ -e "$p" ] || { echo "MISSING: $p (set ADAPT_TOOLKIT / OURS_SDK_NODE_MODULES / DEV_BROKER)"; exit 2; }
26
+ done
27
+
28
+ BUILD=$(mktemp -d)
29
+ trap 'rm -rf "$BUILD"' EXIT
30
+ mkdir -p "$BUILD/core"
31
+ cp "$CORE_DIR"/*.mm "$CORE_DIR"/config.mufl "$BUILD/core/"
32
+ cp "$HERE/test_actor.mu" "$HERE/test.mjs" "$BUILD/"
33
+ # SDK 0.6.x (adapt #77) runs ::protocol_container::init_my_ipd on every packet
34
+ # during broker registration — the harness needs the same stub the consumers
35
+ # ship. Prefer a checkout-local copy; fall back to the ours-mcp one.
36
+ PC_STUB=${PROTOCOL_CONTAINER_MM:-/home/shakhvit/work/adapt/ours.network/ours-mcp/packages/core/mufl_code/protocol_container.mm}
37
+ [ -e "$PC_STUB" ] || { echo "MISSING: $PC_STUB (set PROTOCOL_CONTAINER_MM)"; exit 2; }
38
+ cp "$PC_STUB" "$BUILD/protocol_container.mm"
39
+ ln -sfn "$SDK_NM" "$BUILD/node_modules"
40
+ # Top-level compile config: merge the stdlib with this repo's core (the core/ subdir).
41
+ cat > "$BUILD/config.mufl" <<'CFG'
42
+ config script
43
+ {
44
+ stdlib_config = (config_load #$MUFL_STDLIB_PATH).
45
+ core_config = (config_load #"core").
46
+ (
47
+ $imports -> ( $libraries -> (stdlib_config $exports $libraries)'(core_config $exports $libraries)'($protocol_container -> #"protocol_container.mm"), ),
48
+ $exports -> ( $libraries -> (,), $applications -> (,) )
49
+ ).
50
+ }
51
+ CFG
52
+
53
+ cd "$BUILD"
54
+ echo "compiling test actor against $CORE_DIR core…"
55
+ MUFL_STDLIB_PATH="$AT/mufl_stdlib" "$COMPILE" -mp "$AT/meta" -mp "$AT/transactions" test_actor.mu 2>&1 \
56
+ | grep -vE "Unused symbol|browser_attestation|identity_proof_document_impl" | tail -4
57
+ ls ./*.muflo >/dev/null 2>&1 || { echo "COMPILE FAILED"; exit 1; }
58
+
59
+ node "$DEV_BROKER" --host 127.0.0.1 --port "$PORT" --test_mode >broker.log 2>&1 &
60
+ BPID=$!
61
+ sleep 2.5
62
+ kill -0 "$BPID" 2>/dev/null || { echo "BROKER FAILED TO START:"; cat broker.log; exit 3; }
63
+
64
+ BROKER_URL="ws://127.0.0.1:$PORT" node test.mjs 2> >(grep -E 'inbound rejected|DRIVER ERR' >&2)
65
+ RC=$?
66
+ kill "$BPID" 2>/dev/null
67
+ exit $RC