@941design/marmot-engine 0.0.0-stage → 0.2.0-alpha.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.
- package/CHANGELOG.md +477 -0
- package/LICENSE +53 -0
- package/README.md +33 -2
- package/dist/audit/emitter.d.ts +17 -0
- package/dist/audit/emitter.js +30 -0
- package/dist/audit/helpers.d.ts +16 -0
- package/dist/audit/helpers.js +103 -0
- package/dist/audit/index.d.ts +6 -0
- package/dist/audit/index.js +6 -0
- package/dist/audit/recorder.d.ts +13 -0
- package/dist/audit/recorder.js +24 -0
- package/dist/audit/sink.d.ts +16 -0
- package/dist/audit/sink.js +27 -0
- package/dist/audit/types-internal.d.ts +7 -0
- package/dist/audit/types-internal.js +1 -0
- package/dist/audit/types.d.ts +289 -0
- package/dist/audit/types.js +2 -0
- package/dist/core/account-identity-proof.d.ts +165 -0
- package/dist/core/account-identity-proof.js +277 -0
- package/dist/core/application-rumor.d.ts +45 -0
- package/dist/core/application-rumor.js +120 -0
- package/dist/core/auth-service.d.ts +2 -0
- package/dist/core/auth-service.js +52 -0
- package/dist/core/binary.d.ts +142 -0
- package/dist/core/binary.js +363 -0
- package/dist/core/capabilities.d.ts +51 -0
- package/dist/core/capabilities.js +102 -0
- package/dist/core/client-state.d.ts +119 -0
- package/dist/core/client-state.js +226 -0
- package/dist/core/commit-authorization.d.ts +26 -0
- package/dist/core/commit-authorization.js +26 -0
- package/dist/core/components/admin-policy.d.ts +4 -0
- package/dist/core/components/admin-policy.js +69 -0
- package/dist/core/components/agent-text-stream.d.ts +51 -0
- package/dist/core/components/agent-text-stream.js +112 -0
- package/dist/core/components/app-components-list.d.ts +17 -0
- package/dist/core/components/app-components-list.js +35 -0
- package/dist/core/components/avatar-url.d.ts +12 -0
- package/dist/core/components/avatar-url.js +85 -0
- package/dist/core/components/bytes.d.ts +5 -0
- package/dist/core/components/bytes.js +18 -0
- package/dist/core/components/dictionary.d.ts +80 -0
- package/dist/core/components/dictionary.js +175 -0
- package/dist/core/components/disband-validation.d.ts +21 -0
- package/dist/core/components/disband-validation.js +173 -0
- package/dist/core/components/encrypted-media.d.ts +44 -0
- package/dist/core/components/encrypted-media.js +210 -0
- package/dist/core/components/group-lifecycle.d.ts +10 -0
- package/dist/core/components/group-lifecycle.js +32 -0
- package/dist/core/components/group-profile.d.ts +24 -0
- package/dist/core/components/group-profile.js +35 -0
- package/dist/core/components/host-safety.d.ts +9 -0
- package/dist/core/components/host-safety.js +148 -0
- package/dist/core/components/ids.d.ts +93 -0
- package/dist/core/components/ids.js +92 -0
- package/dist/core/components/index.d.ts +14 -0
- package/dist/core/components/index.js +14 -0
- package/dist/core/components/integrity.d.ts +141 -0
- package/dist/core/components/integrity.js +293 -0
- package/dist/core/components/message-retention.d.ts +17 -0
- package/dist/core/components/message-retention.js +26 -0
- package/dist/core/components/nostr-routing.d.ts +8 -0
- package/dist/core/components/nostr-routing.js +92 -0
- package/dist/core/components/url.d.ts +26 -0
- package/dist/core/components/url.js +44 -0
- package/dist/core/convergence-status.d.ts +84 -0
- package/dist/core/convergence-status.js +82 -0
- package/dist/core/convergence.d.ts +567 -0
- package/dist/core/convergence.js +1150 -0
- package/dist/core/credential.d.ts +16 -0
- package/dist/core/credential.js +64 -0
- package/dist/core/default-capabilities.d.ts +9 -0
- package/dist/core/default-capabilities.js +34 -0
- package/dist/core/extensions.d.ts +9 -0
- package/dist/core/extensions.js +5 -0
- package/dist/core/grease.d.ts +2 -0
- package/dist/core/grease.js +6 -0
- package/dist/core/group-event.d.ts +18 -0
- package/dist/core/group-event.js +30 -0
- package/dist/core/group-lifecycle.d.ts +42 -0
- package/dist/core/group-lifecycle.js +66 -0
- package/dist/core/group-members.d.ts +37 -0
- package/dist/core/group-members.js +99 -0
- package/dist/core/group-message-classify.d.ts +42 -0
- package/dist/core/group-message-classify.js +57 -0
- package/dist/core/group-message-crypto.d.ts +53 -0
- package/dist/core/group-message-crypto.js +140 -0
- package/dist/core/group-message.d.ts +5 -0
- package/dist/core/group-message.js +11 -0
- package/dist/core/group.d.ts +56 -0
- package/dist/core/group.js +95 -0
- package/dist/core/inbound.d.ts +102 -0
- package/dist/core/inbound.js +79 -0
- package/dist/core/index.d.ts +29 -0
- package/dist/core/index.js +27 -0
- package/dist/core/key-package-eligibility.d.ts +31 -0
- package/dist/core/key-package-eligibility.js +116 -0
- package/dist/core/key-package-event-decode.d.ts +43 -0
- package/dist/core/key-package-event-decode.js +118 -0
- package/dist/core/key-package-event-delete.d.ts +16 -0
- package/dist/core/key-package-event-delete.js +46 -0
- package/dist/core/key-package-event-encode.d.ts +28 -0
- package/dist/core/key-package-event-encode.js +117 -0
- package/dist/core/key-package-event.d.ts +4 -0
- package/dist/core/key-package-event.js +8 -0
- package/dist/core/key-package.d.ts +66 -0
- package/dist/core/key-package.js +147 -0
- package/dist/core/leaf-succession.d.ts +83 -0
- package/dist/core/leaf-succession.js +97 -0
- package/dist/core/media/canonical.d.ts +34 -0
- package/dist/core/media/canonical.js +57 -0
- package/dist/core/media/crypto.d.ts +79 -0
- package/dist/core/media/crypto.js +215 -0
- package/dist/core/media/imeta.d.ts +33 -0
- package/dist/core/media/imeta.js +188 -0
- package/dist/core/media/locator.d.ts +44 -0
- package/dist/core/media/locator.js +69 -0
- package/dist/core/media/types.d.ts +83 -0
- package/dist/core/media/types.js +12 -0
- package/dist/core/media.d.ts +6 -0
- package/dist/core/media.js +12 -0
- package/dist/core/protocol-profile.d.ts +262 -0
- package/dist/core/protocol-profile.js +535 -0
- package/dist/core/protocol.d.ts +51 -0
- package/dist/core/protocol.js +41 -0
- package/dist/core/relay-lists.d.ts +52 -0
- package/dist/core/relay-lists.js +86 -0
- package/dist/core/retained-history.d.ts +78 -0
- package/dist/core/retained-history.js +59 -0
- package/dist/core/transport.d.ts +43 -0
- package/dist/core/transport.js +21 -0
- package/dist/core/welcome-event.d.ts +61 -0
- package/dist/core/welcome-event.js +116 -0
- package/dist/core/welcome-join.d.ts +155 -0
- package/dist/core/welcome-join.js +243 -0
- package/dist/core/welcome.d.ts +3 -0
- package/dist/core/welcome.js +6 -0
- package/dist/engine/admin-policy.d.ts +75 -0
- package/dist/engine/admin-policy.js +137 -0
- package/dist/engine/auto-committer.d.ts +39 -0
- package/dist/engine/auto-committer.js +42 -0
- package/dist/engine/delivered-payloads.d.ts +61 -0
- package/dist/engine/delivered-payloads.js +84 -0
- package/dist/engine/disband-request.d.ts +41 -0
- package/dist/engine/disband-request.js +86 -0
- package/dist/engine/disband-tombstone.d.ts +14 -0
- package/dist/engine/disband-tombstone.js +66 -0
- package/dist/engine/fork-recovery.d.ts +672 -0
- package/dist/engine/fork-recovery.js +1615 -0
- package/dist/engine/group-engine.d.ts +571 -0
- package/dist/engine/group-engine.js +5134 -0
- package/dist/engine/history-tree.d.ts +232 -0
- package/dist/engine/history-tree.js +651 -0
- package/dist/engine/index.d.ts +16 -0
- package/dist/engine/index.js +15 -0
- package/dist/engine/ingest-disposition.d.ts +5 -0
- package/dist/engine/ingest-disposition.js +63 -0
- package/dist/engine/ingest.d.ts +390 -0
- package/dist/engine/ingest.js +1258 -0
- package/dist/engine/ingestion-pool.d.ts +74 -0
- package/dist/engine/ingestion-pool.js +95 -0
- package/dist/engine/message-dedup.d.ts +16 -0
- package/dist/engine/message-dedup.js +20 -0
- package/dist/engine/own-commit-stamp.d.ts +30 -0
- package/dist/engine/own-commit-stamp.js +71 -0
- package/dist/engine/retained-store.d.ts +79 -0
- package/dist/engine/retained-store.js +133 -0
- package/dist/engine/sender-ratchet.d.ts +50 -0
- package/dist/engine/sender-ratchet.js +196 -0
- package/dist/engine/state-notifications.d.ts +122 -0
- package/dist/engine/state-notifications.js +173 -0
- package/dist/engine/tree-convergence.d.ts +41 -0
- package/dist/engine/tree-convergence.js +90 -0
- package/dist/engine/types.d.ts +366 -0
- package/dist/engine/types.js +14 -0
- package/dist/engine/wire-format.d.ts +77 -0
- package/dist/engine/wire-format.js +120 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1 -0
- package/dist/mls.d.ts +11 -0
- package/dist/mls.js +11 -0
- package/dist/utils/debug.d.ts +3 -0
- package/dist/utils/debug.js +3 -0
- package/dist/utils/encoding.d.ts +38 -0
- package/dist/utils/encoding.js +91 -0
- package/dist/utils/key-value.d.ts +18 -0
- package/dist/utils/key-value.js +2 -0
- package/dist/utils/nostr.d.ts +35 -0
- package/dist/utils/nostr.js +26 -0
- package/dist/utils/relay-url.d.ts +10 -0
- package/dist/utils/relay-url.js +23 -0
- package/dist/utils/tag-cardinality.d.ts +50 -0
- package/dist/utils/tag-cardinality.js +91 -0
- package/dist/utils/timestamp.d.ts +50 -0
- package/dist/utils/timestamp.js +95 -0
- package/dist/version.d.ts +112 -0
- package/dist/version.js +112 -0
- package/package.json +68 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
# @941design/marmot-engine
|
|
2
|
+
|
|
3
|
+
## 0.2.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9659431: The `adminPolicyCallback` factory argument gains an optional `groupContext`: the GroupContext of the state the judged
|
|
8
|
+
message is processed against (for a commit, its parent epoch). The engine passes it on every path that builds the
|
|
9
|
+
callback (ingest, fork recovery, tree replay, witness collection). The vendored rule (`createAdminCommitPolicyCallback`)
|
|
10
|
+
ignores it, so engine behaviour with the default callback is unchanged. An override can now decide against the group
|
|
11
|
+
context of the commit's own epoch, which the ratchet tree alone cannot answer (`@941design/marmot` gates same-account
|
|
12
|
+
commits on `requires0x800d` with it, ADR-023). `ENGINE_STATE_FORMAT` is unchanged.
|
|
13
|
+
- 9659431: Profile-keyed account identity proof (MDK v0.19.0 interop, spec DD-0/DD-7). New in `/core`:
|
|
14
|
+
|
|
15
|
+
- `profileOf(groupContext)` returns `'legacy'`, `'current'` or `{ invalid }`, and `requires0x800d(groupContext)` is
|
|
16
|
+
the protocol-profile seam. A group is Legacy when its `required_capabilities` list `0xf2f1` and its `app_components`
|
|
17
|
+
(`0x0001`) list lacks `0x8009`. It is Current when it is the other way round. Both, neither, or `0x8009` state in the
|
|
18
|
+
GroupContext is invalid.
|
|
19
|
+
- The Current proof codec (`encode`/`decode`/`verifyCurrentAccountIdentityProofForKey`,
|
|
20
|
+
`buildCurrentAccountIdentityProofEvent`, `signCurrentAccountIdentityProof`) uses MDK's byte layout and signed message:
|
|
21
|
+
a 104-byte component `0x8009` (account ‖ created_at u64 BE ‖ BIP-340 signature over the kind-450 Current event).
|
|
22
|
+
- `verifyLeafAccountIdentityProofForProfile` / `checkLeafAccountIdentityProof` accept a leaf only in a single form and
|
|
23
|
+
reject with a typed `AccountIdentityProofFailure` (`both-forms`, `no-proof`, `wrong-form`, `proof-not-advertised`,
|
|
24
|
+
`proof-wrong-length`, `proof-invalid-timestamp`, `proof-account-mismatch`, `proof-signature-invalid`, …).
|
|
25
|
+
- Component ids `ACCOUNT_IDENTITY_PROOF_COMPONENT_ID` (`0x8009`), `GROUP_ENCRYPTED_MEDIA_V2_COMPONENT_ID` (`0x800b`),
|
|
26
|
+
`ACCOUNT_DEVICES_COMPONENT_ID` (`0x800d`) and `PRIVATE_USE_APP_COMPONENT_ID_START`.
|
|
27
|
+
- `generateKeyPackage({ profile: 'current', currentProof })` builds a Current-form KeyPackage, and
|
|
28
|
+
`createGroup` / `createSimpleGroup` take `{ profile: 'current' }` for a Current group. The default stays
|
|
29
|
+
`'legacy'`, and that path is unchanged.
|
|
30
|
+
|
|
31
|
+
Not breaking for anything this library produced before. Legacy KeyPackages, groups, leaves and their event tags are
|
|
32
|
+
byte-identical, and `verifyLeafAccountIdentityProof` (Legacy only) is unchanged. One behaviour change, for Current-form leaves only: `createKeyPackageEvent` derives the `app_components` tag from the
|
|
33
|
+
leaf's own list and emits `mls_extensions` / `mls_proposals` ascending. The tags then exactly match the KeyPackage
|
|
34
|
+
metadata, as MDK v0.19.0 requires. The library re-emits MDK's own published KeyPackage tags byte for byte. Before, the
|
|
35
|
+
`app_components` tag listed `SUPPORTED_APP_COMPONENT_IDS`.
|
|
36
|
+
`ENGINE_STATE_FORMAT` is unchanged, and the state-format ledger entry records why.
|
|
37
|
+
|
|
38
|
+
New Current groups place the application-data dictionary last in the MLS GroupContext. This lets MDK v0.19.0 and the library derive the same epoch keys after routing updates and account-device activation. The migration guide covers earlier experimental Current groups.
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- c470a67: Report the released package version in the engine build identifier.
|
|
43
|
+
- 9659431: Name the vendored engine's true upstream: the README, LICENSE notice, package description and VENDOR.md now all cite https://github.com/marmot-protocol/marmot-ts at commit 50192e117e986d894c16ea1f8922600dc33a0db3 instead of a `dark-matter` branch that the repository does not have. VENDOR.md records when the pin commit was last confirmed reachable and how to check it again.
|
|
44
|
+
- 9659431: Fix a settle check that could stall after its timer fired early. When the settle timer fires before its cutoff on the engine clock, the engine now re-arms it for the remaining time and does not wake the owner too soon. A `driveConvergence()` call before the cutoff also arms the check if no timer is pending. Before this fix, a held disband (or retained input) waited for some unrelated new input. Now it settles from the timers alone, and `group.disbanded` becomes defined without the disband being delivered again. At most one settle timer per group is ever pending.
|
|
45
|
+
|
|
46
|
+
## 0.2.0-alpha.0
|
|
47
|
+
|
|
48
|
+
### Minor Changes
|
|
49
|
+
|
|
50
|
+
- c425a58: The engine stamp stored envelopes are compared against is now a stored-state format, `ENGINE_VERSION = "state.<N>"`
|
|
51
|
+
(`ENGINE_STATE_FORMAT`), instead of a digest of the engine code; the code identity moves to the new `ENGINE_BUILD`.
|
|
52
|
+
Engine changes that leave stored state reading the same (a comment, a read-only accessor) no longer refuse every store;
|
|
53
|
+
`state-format-ledger.json` and a test force a recorded decision on each code change.
|
|
54
|
+
This change itself moves the stamp once: stores written by earlier builds are refused with `storeIncompatible`.
|
|
55
|
+
- 5ee090c: Branch-aware own-leaf fence: a commit of the device's own leaf
|
|
56
|
+
that it cannot open is fenced only whenever the opaque branch could win.
|
|
57
|
+
|
|
58
|
+
Until now a restored device that met a commit of its own leaf it could not process (ts-mls's "No overlap between
|
|
59
|
+
provided private keys and update path", `isLostPathSecretsError`) was fenced at once, wherever it met it. Behind the
|
|
60
|
+
new seam option `MarmotGroupEngineOptions.branchAwareFence` (and `ForkRecovery`'s), off by default and effective only
|
|
61
|
+
together with `equivocationCredit` (with either off every result is byte for byte the previous one), the unreadable
|
|
62
|
+
commit is an *opaque candidate* decided against the processable branches. Its best case `o*` — the candidate's own
|
|
63
|
+
head edge, up to `U` hidden edges below it (`U` is the group's undecryptable count, see below), the hidden credit the
|
|
64
|
+
policy allows and the minimal tiebreak bytes — is scored by the unchanged credited cascade, appended last so an exact
|
|
65
|
+
tie goes to the opaque side; the group is fenced (`unreadable`, carrying a lost-path-secrets error) iff `o*` could
|
|
66
|
+
win, or no processable branch is eligible (a sole member stays fenced). Otherwise the digest is `skipped`
|
|
67
|
+
(`past-epoch`) and held. The decision is taken per digest, at the pool-replay, direct-apply, removal-parent and
|
|
68
|
+
tree-sweep sites alike, and again on every later convergence pass (a later arrival, a larger `U`, a pending own
|
|
69
|
+
commit that confirms), within the rollback horizon (`maxRewindCommits`; leaving it drops the candidate without a
|
|
70
|
+
fence, a pruned parent fences it).
|
|
71
|
+
|
|
72
|
+
- **Conservative hidden-credit policy, pending a decision.** `MarmotGroupEngineOptions.hiddenCreditPolicy` is exactly
|
|
73
|
+
`"conservative"` (the default: the hidden subtree may carry up to `U` credit) or `"anchored-zero"` (an opaque head by
|
|
74
|
+
the device's own leaf, anchored at its parent node, earns no hidden credit there); any other value is a `TypeError`
|
|
75
|
+
at construction while the seam is on, and it is ignored otherwise. The product question which one `@941design/marmot`
|
|
76
|
+
ships is unanswered: under the shipped conservative policy a deliberate attacker's burst from a cloned leaf
|
|
77
|
+
still fences the real device.
|
|
78
|
+
- **The record.** New getter `opaque` and constructor option `opaque` (a `HeldOpaqueRecord`: the held candidates —
|
|
79
|
+
digest, parent tag, epoch, sender, error message, original envelope; at most `MAX_HELD_OPAQUE_CANDIDATES = 16`, the
|
|
80
|
+
overflow fences, candidates sharing a parent node and sender are scored once at their best case — and the
|
|
81
|
+
`undecryptableIds`, `U`), a new object on every change; a malformed record is rejected with `OpaqueRecordInvalid`
|
|
82
|
+
(a `TypeError`). `U` counts the distinct ids of group envelopes that no state the device holds opens and leaves only
|
|
83
|
+
when one decrypts; it is a function of the received set, never of arrival order or `created_at`.
|
|
84
|
+
- **Pure core.** New exports `OpaqueCandidate`, `HiddenCreditPolicy`, `opaqueBestCase`, `opaqueCouldWin` and
|
|
85
|
+
`selectCanonicalBranchWithOpaque`; `ForkResolution` / `AppliedForkResolution` gain `opaqueSkipped` and `opaqueHeld`
|
|
86
|
+
(omitted when empty, never an empty set) and a `skip` outcome now carries the `leafEquivocation` report it used to
|
|
87
|
+
drop.
|
|
88
|
+
- **Batch settle.** `MarmotGroupEngine.ingest(envelopes, { settle?: boolean })`: `settle: false` says more
|
|
89
|
+
envelopes of the caller's batch follow. A deferred call fences nothing that could still be outdone: a could-win
|
|
90
|
+
candidate is held (`skipped`, provisional) at every site, and a call with `settle` unset — an empty `ingest([])`
|
|
91
|
+
suffices — decides it against everything the batch brought. An unavailable parent, an unverified record and a full
|
|
92
|
+
held set still fence at once. The option is ignored with the seam off. `ForkRecovery.resolveFork` takes the
|
|
93
|
+
matching `holdCouldWin` (a deferred replay reports a could-win digest in `opaqueSkipped` with its `opaqueHeld`
|
|
94
|
+
info instead of `fenced`). A decision is therefore taken on the whole batch, whatever the order of the commits in
|
|
95
|
+
it; across separately settled batches it is the whole-batch decision over everything received up to that settle,
|
|
96
|
+
and a fence is terminal.
|
|
97
|
+
- **`send` settles first.** With the seam on, every send path (application message, proposal, commit, self-update,
|
|
98
|
+
invite) first runs the full decision for an open unsettled batch and for any held candidate — the one
|
|
99
|
+
`ingest([])` runs, without the pool passes. A candidate that could win rejects the send with its lost-path-secrets
|
|
100
|
+
error (which a client turns into its fence) and nothing is created. While an own commit is pending nothing is
|
|
101
|
+
decided: a commit or self-update refuses as before, an application message or proposal refuses while a candidate
|
|
102
|
+
is held, and the next send decides. A deferred `ingest` step with a candidate held also postpones the elected auto-commit of pending
|
|
103
|
+
self-removes to the settling call (any later non-deferred ingest covers a batch that never settles). An unsettled batch (a `settle: false` call
|
|
104
|
+
with no settling call after it) is an engine state: only a settling call closes it, and the entry points that act
|
|
105
|
+
(`send`, `driveConvergence`, `reconvergeFromHistory`) decide in full, so an interleaved entry point can fence more,
|
|
106
|
+
never less; the deferral is an explicit argument of the deferred call's own body, never instance state, so an entry point that interleaves — even while the deferred call awaits inside the peeler — decides in full.
|
|
107
|
+
- **Further exports** (the barrels re-export every module, so these are public though meant for the seam's callers
|
|
108
|
+
and tests): `decideOpaqueDrafts` and `OpaqueDraft` (the one per-digest decision both pool replay and the tree-fed
|
|
109
|
+
sites call), `normalizeHiddenCreditPolicy` and `DEFAULT_HIDDEN_CREDIT_POLICY`, `reconstructLostPathSecretsError`
|
|
110
|
+
(a real ts-mls error rebuilt from a record's message, so `isLostPathSecretsError` holds), `OpaqueFromEncrypted`,
|
|
111
|
+
`OpaqueHeldInfo`, the `ForkResolution` / `AppliedForkResolution` keys `opaqueEncrypted` and `opaqueTipEnvelope`,
|
|
112
|
+
the `resolveFork` parameters `undecryptable` (the persisted `U` id set) and `holdCouldWin`, and the optional
|
|
113
|
+
`IngestContext` hooks `decideOpaque`, `holdOpaque`, `opaqueDecided` (and `fencedOpaque` / `releaseOpaque`).
|
|
114
|
+
- **Known limits.** Groups whose history fetch carries envelopes the device can never open — the pre-join history of
|
|
115
|
+
a late joiner, junk — carry a high `U`, which raises every candidate's best case, so such devices fall back to
|
|
116
|
+
today's fence. Live delivery hands the engine one event per call, so a lone own-leaf commit that arrives alone
|
|
117
|
+
(no sibling received yet) is fenced on arrival — sound for what the device has received — and a fence is
|
|
118
|
+
terminal; a history walk that spans several windows decides each window as its own batch. `U` is unbounded in the
|
|
119
|
+
record.
|
|
120
|
+
|
|
121
|
+
Sixteen local patches change engine source, so `PATCHSET_DIGEST` moves `b4c18eea1028b444` → `22af43683e8de310` and
|
|
122
|
+
`ENGINE_VERSION` changes: every store an earlier build wrote is refused (`envelope-mismatch`, surfaced by
|
|
123
|
+
`@941design/marmot` as `storeIncompatible`) and can be recovered by a wipe.
|
|
124
|
+
- **A plain call is a batch of its own.** With the seam on, `ingest(envelopes)` (no `settle` option, envelopes
|
|
125
|
+
present) is `ingest(envelopes, { settle: false })` followed by `ingest([])` by construction: its body runs as a
|
|
126
|
+
deferred step and the same call then settles, so a candidate that the call's own later envelopes outdo is skipped,
|
|
127
|
+
not fenced (it used to be fenced when it sorted after the competing commit). A fenced candidate is therefore first
|
|
128
|
+
reported as the provisional `skipped` and then as `unreadable` within the call. While a batch is open the engine
|
|
129
|
+
also remembers, per held candidate, every envelope it yielded a provisional `skipped` for (duplicate wrappers of the
|
|
130
|
+
commit), and the fence yields `unreadable` for each of them; candidates sharing a parent node and sender fence
|
|
131
|
+
together. This bookkeeping is in memory and batch-scoped (a batch that never settles, or a reload, keeps the
|
|
132
|
+
provisional semantics). With the seam off nothing changes.
|
|
133
|
+
- c9a0364: A pool-replay commit that fork recovery drops for failing the authorization or commit-legality gate now says why. The
|
|
134
|
+
`skipped` (`past-epoch`) result of such a commit carries the new optional `droppedReason`
|
|
135
|
+
(`"admin-policy" | "component-integrity" | "admin-leaf-coupling" | "disband-legality"`, the reason set of a `rejected`
|
|
136
|
+
result): the direct apply path already reported a violation as `rejected`, but the convergence seam yielded the same
|
|
137
|
+
`skipped` as for a commit that merely lost, so a regression on the rewind path showed only as a member silently staying
|
|
138
|
+
active. Additive: `reason` and the disposition are unchanged, an ordinary skip carries no key, and a resolution that
|
|
139
|
+
rejected nothing is unchanged. The violation's diagnostic is logged by the engine (debug), not put on a result. A rewind
|
|
140
|
+
is no longer reported (`processed`) against such a dropped commit: it is yielded `skipped` with its reason, and the rewind
|
|
141
|
+
is attributed to another pool entry.
|
|
142
|
+
|
|
143
|
+
Six local patches change engine source, so `PATCHSET_DIGEST` moves
|
|
144
|
+
(`eee3df5a61b028e2` → `573f46469fecbbcf` → … → `18c5881cacb81c85` with the later patches of this release) and `ENGINE_VERSION` changes: every store an
|
|
145
|
+
earlier build wrote is refused (`envelope-mismatch`, surfaced by `@941design/marmot` as `storeIncompatible`) and can be
|
|
146
|
+
recovered by a wipe.
|
|
147
|
+
- 5141e1a: Device key rotation support: a default-off `selfUpdate` leaf-patch seam, the pure
|
|
148
|
+
`leafKeySuccessions` predicate, and the key-succession lineage of the equivocation credit.
|
|
149
|
+
|
|
150
|
+
**`selfUpdate` leaf patch.** `send({ kind: 'selfUpdate' })` accepts an optional `leafNodePatch` (the `ts-mls`
|
|
151
|
+
`LeafNodePatch` type, re-exported at `@941design/marmot-engine/mls`), forwarded to `createCommit`. A patch carrying a
|
|
152
|
+
`signatureKeyPair` replaces the committer's leaf signature key in the commit's UpdatePath: the commit is signed under the key
|
|
153
|
+
the leaf holds now (receivers verify it against the parent tree), the new leaf is self-signed under the patched key,
|
|
154
|
+
`pending.newState.signaturePrivateKey` is the patched private key (it survives `serializeClientState`), and `engine.state`
|
|
155
|
+
keeps the old key until `confirmPublished`. After the commit is canonical a commit signed under the retired key is refused by
|
|
156
|
+
every member. `extensions` replaces the leaf's whole extension list, so a key rotation swaps the account-identity-proof
|
|
157
|
+
extension in the same commit. A patched signature key that the tree the commit produces would hold twice (the sender's own
|
|
158
|
+
key, another leaf's, a bundled Add's) is refused by `send` before anything is staged; a bundled Remove of the leaf that holds
|
|
159
|
+
it frees it. Authorization, the lifecycle gate and the commit-legality checks are those of the unpatched `selfUpdate`. A
|
|
160
|
+
patched `selfUpdate` may also carry `extraProposals` of Remove kind only (by value, in the same commit as the path rotation),
|
|
161
|
+
so the duplicate-leaf repair is one atomic commit; they are authorized by the engine's `authorizeCommit` seam exactly like a
|
|
162
|
+
`commit` intent's (the default refuses a non-admin's Remove; marmot's same-account seam allows a same-account one) and the
|
|
163
|
+
uniqueness check counts them. Without a patch the call is upstream's.
|
|
164
|
+
|
|
165
|
+
**`leafKeySuccessions(parent, child)`** (`@941design/marmot-engine/core`, with the `LeafKeySuccession` type): the pure, total
|
|
166
|
+
predicate that tells a leaf's signature key replaced in place (a commit whose UpdatePath leaf carries a new key, or a committed
|
|
167
|
+
Update proposal) from the leaf disappearing. A Remove plus an Add of the same account into one index, a different account at
|
|
168
|
+
the index and a blank index are never successions. It is sound only when `child` is exactly one commit after `parent`: over a
|
|
169
|
+
gap, a Remove plus re-Add followed by a self-update reads as a rotation, so call it per edge, never on a tip pair. It is the
|
|
170
|
+
exception removal evidence by key difference needs.
|
|
171
|
+
|
|
172
|
+
**Equivocation credit lineage**, behind the existing `equivocationCredit` flag. A leaf that rotates its own
|
|
173
|
+
signature key kept the credit of the rotation commit but lost that of every later edge, because the key it signs under no longer
|
|
174
|
+
equals the key at the equivocation node; an honest rotated branch could lose to a rival it beats today. Now the keys a leaf is
|
|
175
|
+
credited under, along one candidate path, are extended by the `commit`-source succession of the committing leaf itself and by
|
|
176
|
+
nothing else: a key change by an Update proposal, a Remove plus re-Add, or a missing fact (an unavailable parent or child state)
|
|
177
|
+
earns exactly what it earned. Detection is untouched (a stale clone of the retired key is still a direct equivocation reported
|
|
178
|
+
with the retired key; a lone rotation reports nothing) and so is the branch-aware fence, which reads the same credit.
|
|
179
|
+
`EquivocationCreditInput` gains the optional `successions` map; with the flag off nothing is read and no path is built. The
|
|
180
|
+
three construction sites (pool replay, the tree-fed pass, the removal composition) and the two opaque-fence sites supply the
|
|
181
|
+
facts.
|
|
182
|
+
|
|
183
|
+
**Vendoring.** Six local patches change engine source and `src/core/leaf-succession.ts` is a new
|
|
184
|
+
locally authored file, so `PATCHSET_DIGEST` moves (`18b10c8ce421f728` → `18c5881cacb81c85`), `LOCAL_SOURCE_DIGEST` moves
|
|
185
|
+
(`c69e218dcb54be03` → `75382d7b2da18890`) and `ENGINE_VERSION` changes: every store an earlier build wrote is refused
|
|
186
|
+
(`envelope-mismatch`, surfaced by `@941design/marmot` as `storeIncompatible`) and can be recovered by a wipe.
|
|
187
|
+
- c8cda86: The engine records a `convergence_decision` for an inbound commit it applies in order.
|
|
188
|
+
|
|
189
|
+
Upstream MDK applies every commit through a scheduled convergence pass and records the decision of that pass; this
|
|
190
|
+
engine applied a commit that extends the canonical tip directly and recorded a decision only when a fork was resolved,
|
|
191
|
+
so a consumer reading the audit stream saw the epoch-2 fork decision as a client's latest where MDK's latest is the
|
|
192
|
+
pass of the epoch-3 commit that followed (the MDK vector `cross-route-own-commit-recovery/v1`, known failing until now).
|
|
193
|
+
|
|
194
|
+
- **The event.** An in-order apply of an inbound commit emits `{ type: "convergence_decision", decisive_rule:
|
|
195
|
+
"only_candidate", selected_tip_digest: <the commit's digest>, selected_tip_committer: <the committer's account>,
|
|
196
|
+
selected_fork_epoch: <the parent epoch>, selected_tip_epoch, witness_quorum_met: false, app_witness_score: 0 }`; its
|
|
197
|
+
one candidate carries `commit_ids: [<digest>]` and `commit_count: 1`, which a fork pass's candidates do not. Not
|
|
198
|
+
emitted for a commit that removes the local leaf, for a disband candidate, or for a fork-resolved apply (which
|
|
199
|
+
keeps its own decision), nor for the engine's own commit.
|
|
200
|
+
- **API.** `IngestContext` gains the optional `commitAppliedInOrder(parentState, message, newState, senderLeafIndex)`,
|
|
201
|
+
which `ingestEnvelopes` calls right after `recordCommit`; the engine implements it. A consumer of the audit stream
|
|
202
|
+
sees one more `convergence_decision` per applied commit; `@941design/marmot` reads no audit stream.
|
|
203
|
+
- **Stamp.** Two local patches change engine source, so `PATCHSET_DIGEST` moves (the batch ends at `834029be75954cae`, `22af43683e8de310` before it) and `ENGINE_VERSION` changes: every store an earlier build wrote is refused
|
|
204
|
+
(`envelope-mismatch`, surfaced by `@941design/marmot` as `storeIncompatible`) and can be recovered by a wipe.
|
|
205
|
+
- 0aa122f: Seven types that appear in the signatures of the public API are now importable; the API reference build now fails on any public type that is not exported.
|
|
206
|
+
|
|
207
|
+
- `@941design/marmot-engine/core` exports `OpaqueBounds`, `MediaCryptoFields`, `Rumor` and `ConvergenceStatus`
|
|
208
|
+
together with `convergenceStatuses`, the constant `ConvergenceStatus` is derived from (the whole
|
|
209
|
+
`convergence-status` module is not re-exported).
|
|
210
|
+
- `@941design/marmot-engine/engine` exports `HistoryTreeStore`, `DeferredEntry` and `GenericKeyValueStore`.
|
|
211
|
+
- **Stamp.** Six local patches change engine source, so `PATCHSET_DIGEST` moves (the batch ends at `834029be75954cae`, 22af43683e8de310 before it) and `ENGINE_VERSION` changes: every store an earlier build wrote is refused (`envelope-mismatch`, surfaced by
|
|
212
|
+
`@941design/marmot` as `storeIncompatible`) and can be recovered by a wipe.
|
|
213
|
+
- 2c11e4b: Removal finality: a removal, once it competes with commits by the leaf it
|
|
214
|
+
removes, is no longer undone by depth alone. Behind the new engine option `MarmotGroupEngineOptions.removalFinality`
|
|
215
|
+
(threaded to `ForkRecovery`), off by default and effective only together with `equivocationCredit` (at the opaque fence
|
|
216
|
+
also with `branchAwareFence`); with it off every result is byte for byte the previous one.
|
|
217
|
+
|
|
218
|
+
- **The rule (pure core).** At a *rule node* — a branching node of the candidate tree below which a non-inert removal
|
|
219
|
+
counts, every candidate's tip within `maxRewindCommits` of it (the node-local guard) — a branch's credited edges
|
|
220
|
+
authored by a leaf that a removal on a sibling branch removes earn no *finality* (keyed by leaf index along the
|
|
221
|
+
credited key lineage, so an in-place rotation does not escape it); the entries with the maximal finality are kept,
|
|
222
|
+
and among them a removal head by a non-removed author is preferred before today's ordering. A removal by an author
|
|
223
|
+
anchored at the node in the subtree it heads is inert there (subtree-local inertness). Dead chains up to
|
|
224
|
+
`maxRewindCommits - 1` commits past the removal's parent are decided by the rule; a longer one falls back to today's
|
|
225
|
+
ordering. No new no-winner path; with no non-inert removal the result is unchanged.
|
|
226
|
+
- **New core exports.** `RemovedLeaf`, `CandidatePathEdge.removed` (absent: unknown; `[]`: removes nothing),
|
|
227
|
+
`EquivocationCreditInput.removalFinality`, `CanonicalSelection.decidedByRemoval` (present iff the flag),
|
|
228
|
+
`OpaqueScoringOptions.headEquivocated`, `branchingNodesOf` and `phaseOneNodesOf` (phase 1 is structural — every
|
|
229
|
+
branching node — when the rule is effective).
|
|
230
|
+
- **The four selection sites.** Pool replay, `#reconvergeFromTree`, `#reconvergeWithRemovals` (the removed device's own
|
|
231
|
+
decision, through the virtual `removal:<digest>` edge carrying every leaf the removal removes) and the opaque /
|
|
232
|
+
fence comparator all read per-edge removal facts. `ForkResolution` reports `decisiveRule: "removal_finality"` exactly
|
|
233
|
+
when the rule changed the winner. Facts are derived by `@internal` oracles (`edgeRemovalFactsOf`,
|
|
234
|
+
`opaqueRemovalFactsOf`) and memoised in engine memory only (`#edgeFactMemo`, bounded, never persisted); only an absent
|
|
235
|
+
fact on a removal head sends its node to the previous ordering; a deeper absent fact contributes nothing.
|
|
236
|
+
- **Interop.** A third silent deviation from the Marmot convergence rules / MDK selection (after structural branch
|
|
237
|
+
selection and equivocation credit), valid only in groups whose every member runs this engine with the option on.
|
|
238
|
+
|
|
239
|
+
Four local patches change engine source, so
|
|
240
|
+
`PATCHSET_DIGEST` moves in two steps `18c5881cacb81c85` → `21939d6d69a39e65` (`LOCAL_SOURCE_DIGEST` unchanged) and `ENGINE_VERSION`
|
|
241
|
+
changes: every store an earlier build wrote is refused (`envelope-mismatch`, surfaced by `@941design/marmot` as
|
|
242
|
+
`storeIncompatible`) and can be recovered by a wipe.
|
|
243
|
+
- 73baee0: Close the rewind takeover via a stale leaf snapshot: other-leaf credited depth at equivocation nodes.
|
|
244
|
+
|
|
245
|
+
`@941design/marmot-engine` — a new seam option, off by default (upstream selection, except the sender-attribution change below):
|
|
246
|
+
`MarmotGroupEngineOptions.equivocationCredit` (and `ForkRecovery`'s `equivocationCredit` option). With it on, every
|
|
247
|
+
branch candidate carries its `path` from the fork root (`BranchCandidate.path`, `CandidatePathEdge`), and at an
|
|
248
|
+
equivocation node — a node where one leaf (same index, same leaf signature key) heads one child subtree and also
|
|
249
|
+
authored a commit in another, the cryptographic trace of a restored stale snapshot — that leaf's commits earn nothing
|
|
250
|
+
inside the subtree it heads, and only depth built by leaves that were members at that node counts; a credit tie keeps
|
|
251
|
+
today's ordering. A node whose ratchet-tree facts a site
|
|
252
|
+
cannot resolve falls back to today's ordering on its own, without switching credit off elsewhere. Applied at all three
|
|
253
|
+
selection sites (pool replay, tree-fed re-convergence, re-convergence with removals). New pure core functions
|
|
254
|
+
`equivocationNodesOf` and `selectCanonicalBranchCredited` (types `EquivocationCreditInput`,
|
|
255
|
+
`EquivocationNodeContext`, `LeafEquivocation`, `CanonicalSelection`); `selectCanonicalBranch` takes an optional
|
|
256
|
+
fourth `credit` argument. A direct equivocation — two child commits of one node by one leaf — is reported, whoever
|
|
257
|
+
wins, as the new envelope-less `IngestResult` `{ kind: "leafEquivocation", evidence }` (disposition `accepted`) and
|
|
258
|
+
on `ForkResolution` / `AppliedForkResolution` as `equivocations`; evidence that spans child subtrees only (also the
|
|
259
|
+
shape of an honest lost race re-driven onto the winner) feeds credit but is not reported. `decision.decisiveRule`
|
|
260
|
+
gains `"equivocation_credit"` when credit changed the outcome. New helpers
|
|
261
|
+
`equivocationNodeContextOf` and `senderLeafKeyOf`. Edge senders are framing-independent: the new
|
|
262
|
+
`authenticatedSenderOf(result, message)` takes a commit's sender from its processing result (a `PrivateMessage`'s
|
|
263
|
+
decrypted sender data as a `PublicMessage`'s framing), so a burst framed as `PrivateMessage` is detected and credited
|
|
264
|
+
like any other; `ChainLink` and `RemovalEdge` gain `senderLeafIndex`, `KnownNextState` an optional one, and
|
|
265
|
+
`tipCommitterOf` now takes `(parent, senderLeafIndex)` instead of `(parent, message)` (a breaking signature change
|
|
266
|
+
for direct callers). With the seam off, the seam's only behaviour change is that a `PrivateMessage`-framed tip resolves its
|
|
267
|
+
tip committer. The persisted disband-convergence record carries an optional `senderLeafIndex`. The patch set changed,
|
|
268
|
+
so `ENGINE_VERSION` changes.
|
|
269
|
+
|
|
270
|
+
`@941design/marmot-engine` — ingest now defers a commit framed exactly one epoch ahead of the current epoch as
|
|
271
|
+
`deferred` (`missing_parent`), like one further ahead, instead of handing it to MLS processing where it failed
|
|
272
|
+
membership verification and terminated as `unreadable` (`protocol-core/inbound-processing.md`: a commit missing its
|
|
273
|
+
parent is retryable, never terminal). With `equivocationCredit` on, a credit rewind onto a shallower tip could
|
|
274
|
+
otherwise drop a later commit extending the abandoned branch and leave a member permanently split. The patch set
|
|
275
|
+
changed, so `ENGINE_VERSION` changes.
|
|
276
|
+
|
|
277
|
+
### Patch Changes
|
|
278
|
+
|
|
279
|
+
- 1b6789d: First npm pre-release (alpha) of all four packages.
|
|
280
|
+
- 5794a86: `leafKeySuccessions` is total per leaf instead of per state: a leaf without a byte `signaturePublicKey` contributes no
|
|
281
|
+
succession and no longer erases the genuine rotations at other indices (which removal finality would otherwise read as
|
|
282
|
+
removals). Only reachable with malformed (non-ts-mls) input.
|
|
283
|
+
|
|
284
|
+
`ENGINE_VERSION` moves: `PATCHSET_DIGEST` `21939d6d69a39e65` → `2f0cf69d072f56b5` (a TSDoc-only edit of patch `9l`) and
|
|
285
|
+
`LOCAL_SOURCE_DIGEST` `75382d7b2da18890` → `dda4692d9eb4c034`, so stores written by the previous build are refused as
|
|
286
|
+
`storeIncompatible` (as for every engine change).
|
|
287
|
+
- 85dfd19: Three disband and rewind fixes in the engine:
|
|
288
|
+
|
|
289
|
+
- **Any single admin of a multi-admin group can disband it.** `requestDisband` already carries its own admin-policy
|
|
290
|
+
update (`[actor]`). The commit seam's admin-leaf coupling no longer splices a second update for the other admins
|
|
291
|
+
it removes. Before, that second update made the commit illegal ("exactly one lifecycle and admin-policy
|
|
292
|
+
replacement"), so disband worked only in single-admin groups. Receivers no longer reject such a disband with
|
|
293
|
+
`admin-leaf-coupling` either. `validateCommitLegality` skips the coupling check for a valid disband, because a
|
|
294
|
+
removed receiver's tombstone still carries the parent's admin set.
|
|
295
|
+
- **After a rewind onto a shallower tip, the retained window holds nothing above the new tip.** Equivocation
|
|
296
|
+
credit can cause such a rewind. The new `RetainedHistoryStore.discardAbove(epoch)` drops the abandoned branch's
|
|
297
|
+
states and links, so `retainedStates()` (the cross-epoch media-decrypt candidates) no longer offers that
|
|
298
|
+
branch's keys.
|
|
299
|
+
- **Scheduled disband settlement reports equivocations.** When it settles under `equivocationCredit`,
|
|
300
|
+
`driveConvergence()` now returns the selection's `leafEquivocation` results, also when the disband is
|
|
301
|
+
selected. Before, they were dropped.
|
|
302
|
+
|
|
303
|
+
`ENGINE_VERSION` moves (new `PATCHSET_DIGEST`), so envelopes written by earlier builds are refused
|
|
304
|
+
(`storeIncompatible`); wipe the store by marker to recover.
|
|
305
|
+
- c538b1a: Fence on lost path secrets at the fork-recovery, tree-sweep and re-convergence sites, not only on direct apply.
|
|
306
|
+
Replaying a commit whose `UpdatePath` holds no secret for any key the replaying state carries — ts-mls's
|
|
307
|
+
`InternalError("No overlap between provided private keys and update path")`, raised for a commit of the device's
|
|
308
|
+
own leaf that a restored, older state did not author — is now a first-class outcome:
|
|
309
|
+
|
|
310
|
+
- `isNoOverlapError(error)` is exported from `@941design/marmot-engine/engine`;
|
|
311
|
+
- `ParentResolution` gains `{ kind: "fenced"; cause }`, returned by `resolveCandidateParent` instead of
|
|
312
|
+
`authentication_mismatch`;
|
|
313
|
+
- fork recovery no longer drops such a candidate: it selects no branch (`skip` with `fenced`) and ingest yields a
|
|
314
|
+
terminal `unreadable` carrying the error for that commit, the same result the direct apply path yields;
|
|
315
|
+
- the pool's tree sweep yields that terminal `unreadable` too (and drops the envelope from the pool) instead of
|
|
316
|
+
leaving it pooled;
|
|
317
|
+
- tree-fed re-convergence abandons a winner chain whose link replay raises it (fail closed — every tree edge's child
|
|
318
|
+
state is held, so no transport envelope exists to surface).
|
|
319
|
+
|
|
320
|
+
Previously a restored device whose own commit won a same-epoch race, but was delivered after the competing commit,
|
|
321
|
+
silently forked off instead of being fenced.
|
|
322
|
+
|
|
323
|
+
`ENGINE_VERSION` moves (new `PATCHSET_DIGEST`), so envelopes written by earlier builds are refused
|
|
324
|
+
(`storeIncompatible`); wipe the store by marker to recover.
|
|
325
|
+
- 13a56b8: The branch-aware fence's internal plumbing is marked `@internal` instead of being documented public API: the barrels
|
|
326
|
+
re-export whole modules, so `decideOpaqueDrafts`, `OpaqueFromEncrypted`, `OpaqueHeldInfo`, the test seam
|
|
327
|
+
`selectCanonicalBranchWithOpaque` (with `OpaqueSelection`), the `opaque*` members of `ForkResolution` /
|
|
328
|
+
`AppliedForkResolution`, the `undecryptable` / `undecryptableSaturated` / `holdCouldWin` inputs of
|
|
329
|
+
`ForkRecovery.resolveFork` and the `IngestContext` members the engine fills for the seam (`opaqueDecided`, `decideOpaque`,
|
|
330
|
+
`holdOpaque`, `releaseOpaque`, `fencedOpaque`, `undecryptable`) were listed as public surface. They are excluded from the
|
|
331
|
+
generated documentation (the repo's `excludeInternal`) and may change in any release; they stay importable and typed, so no
|
|
332
|
+
consumer breaks. A test pins the tag on each declaration and the exclusion from a typedoc conversion.
|
|
333
|
+
|
|
334
|
+
Three comment-only local patches still move
|
|
335
|
+
`PATCHSET_DIGEST` (`40a448f66adcaeee` → … → `18c5881cacb81c85` with the other patches of this release) and so `ENGINE_VERSION`, as every patch change must: a store an
|
|
336
|
+
earlier build wrote is refused (`envelope-mismatch`, `storeIncompatible`) and can be recovered by a wipe.
|
|
337
|
+
- fb40ae1: Engine internals: the shared opaque decision (`#holdOrDecide`) no longer carries a branch that could not be reached.
|
|
338
|
+
Since the batch settle a plain ingest is a deferred step plus a settle, so a could-win verdict is provisional only inside a
|
|
339
|
+
deferred step; the non-deferred "other envelopes are still pooled or undecided" computation, the `hold`/`defer` defaults and
|
|
340
|
+
the optional `pending` argument of `IngestContext.decideOpaque` are removed. A verdict taken outside a deferred step is
|
|
341
|
+
final; the only difference from before is on the fail-closed side (a fence instead of a hold), never a skip where a fence
|
|
342
|
+
stood.
|
|
343
|
+
|
|
344
|
+
A local patch pair changes engine source, so `PATCHSET_DIGEST` moves
|
|
345
|
+
(`40a448f66adcaeee` → … → `18c5881cacb81c85` with the other patches of this release) and `ENGINE_VERSION` changes: every store an earlier build wrote is refused
|
|
346
|
+
(`envelope-mismatch`, surfaced by `@941design/marmot` as `storeIncompatible`) and can be recovered by a wipe.
|
|
347
|
+
- 76eeb86: `MarmotGroupEngine.ingest` documents its caller contract: the engine accepts
|
|
348
|
+
any envelope and does not route by group; routing by the transport's group tag (the Nostr `h` tag) is the caller's job
|
|
349
|
+
(`@941design/marmot` does it), so a group's engine should be handed only that group's traffic. An envelope for another
|
|
350
|
+
group cannot be read and is pooled as undecryptable until the pool evicts it, where upstream's engine classes it stale
|
|
351
|
+
at once. The engine deliberately does not filter on the tag: the routing id can rotate through a routing-component
|
|
352
|
+
update, and a filter run ahead of the commits that decide the current id would terminally skip own-group input (an
|
|
353
|
+
early-skip attempt was reverted for that race). Residual: a caller that mixes groups inflates `pendingCount` until
|
|
354
|
+
eviction.
|
|
355
|
+
|
|
356
|
+
- **Stamp.** One doc-only local patch touches engine source,
|
|
357
|
+
so `PATCHSET_DIGEST` moves and the batch of this release ends at `834029be75954cae` (`22af43683e8de310` before it):
|
|
358
|
+
every store an earlier build wrote is refused (`envelope-mismatch`, surfaced by `@941design/marmot` as
|
|
359
|
+
`storeIncompatible`) and can be recovered by a wipe.
|
|
360
|
+
- 72e42b4: `MarmotGroupEngine.removalActor()`: the hex account identity of the committer of the held removal's selected commit
|
|
361
|
+
(`RemovalRecord.commits[0]`), also on a rebuilt engine; `undefined` when none is held or it cannot be resolved. A new
|
|
362
|
+
local patch moves the engine stamp, so stores written by the previous
|
|
363
|
+
build are refused with `storeIncompatible`.
|
|
364
|
+
- 8858e61: A removed admin now accepts its own removal. When another admin removes an admin in one commit (the engine's
|
|
365
|
+
admin-policy splice drops the removed admin from the admin list in the same commit), the removed admin's engine used to
|
|
366
|
+
fail the coupling check on every receive path (rejected `admin-leaf-coupling` inbound; the removal candidate silently
|
|
367
|
+
dropped on the rewind path, when the removal won a fork against the removed admin's own same-epoch commit) and never
|
|
368
|
+
reached the removed-from-group state.
|
|
369
|
+
|
|
370
|
+
- **Cause and fix.** ts-mls hands a receiver the commit removes a tombstone that carries the PARENT group context (its
|
|
371
|
+
admin set) beside the post-commit roster, so the removed admin read itself as an orphan. `validateCommitLegality` now
|
|
372
|
+
takes the resulting admin set for such a receiver from the commit's own last admin-policy (`0x8003`) update. A trailing
|
|
373
|
+
remove operation or undecodable bytes is still the "did not decode" violation, a tombstone commit without an admin-policy
|
|
374
|
+
update keeps the carried-forward check, and every receiver that is not removed is unchanged. A removal whose last
|
|
375
|
+
admin-policy update still lists the removed admin is still rejected on the removed admin and on the other members.
|
|
376
|
+
- **Stamp.** One local patch changes engine source
|
|
377
|
+
, so `PATCHSET_DIGEST` moves (`834029be75954cae` →
|
|
378
|
+
`882f1f81f2f51ee9`) and `ENGINE_VERSION` changes: every store an earlier build wrote is refused (`envelope-mismatch`,
|
|
379
|
+
surfaced by `@941design/marmot` as `storeIncompatible`) and can be recovered by a wipe.
|
|
380
|
+
- 05e238d: A restarted engine keeps the application-witness evidence it had before the restart. Branch convergence weighs a fork
|
|
381
|
+
branch by the application messages delivered on it (`witness_quorum_met`, `app_witness_score`); that evidence was
|
|
382
|
+
resident-only, so a restart between a witness message and the fork resolution turned a witness-selected decision into a
|
|
383
|
+
tip-committer one (upstream MDK re-admits its stored processed application messages for witness scoring).
|
|
384
|
+
|
|
385
|
+
- **What is persisted.** `GroupHistoryTree` now keeps each delivered application message (the MLS message, its epoch and
|
|
386
|
+
delivery state) beside its nodes: `recordWitness` / `witnesses()`, written by `flush()` under
|
|
387
|
+
`<gid>/witness/<digest>` and read back by `GroupHistoryTree.load`. The engine mirrors its delivered-payload ledger into
|
|
388
|
+
the tree (record, prune, drop on a rewind that abandons the branch), so the persisted set follows the
|
|
389
|
+
ledger.
|
|
390
|
+
- **What a reloaded engine does with it.** The messages the ledger does not hold (those delivered before the restart) are
|
|
391
|
+
weighed on every convergence path that weighs witnesses: the tree-fed re-convergence, the removal-convergence pass and the
|
|
392
|
+
pool-replay fork resolution (`ForkRecovery#resolveFork({ witnessMessages })`, `collectMessageWitnessesAt`). An engine that
|
|
393
|
+
was never restarted behaves as before.
|
|
394
|
+
- **Bounded.** Witnesses are pruned from the tip: one counts only above its branch's fork epoch and a fork is resolvable
|
|
395
|
+
only within `maxRewindCommits` (R) of the tip, so those below `tip - 2R` (a rewind can lower the tip by up to R) are
|
|
396
|
+
dropped from memory and the store on every delivery, rewind and engine construction. A record that does not decode on
|
|
397
|
+
load is skipped, never fatal to the tree.
|
|
398
|
+
- **Not yet in `@941design/marmot`.** The client rebuilds its history tree from its retained-window record rather than
|
|
399
|
+
through `GroupHistoryTree.load`, so a client restart does not carry the witnesses yet, and a proof-gate rollback
|
|
400
|
+
(`rebuildEngine`, a fresh tree) drops them too; the engine-level restart keeps them.
|
|
401
|
+
- **Stamp.** Three local patches change engine source, so
|
|
402
|
+
`PATCHSET_DIGEST` moves (`882f1f81f2f51ee9` → `40a448f66adcaeee`, together with the undecryptable-set cap patches of the same release) and `ENGINE_VERSION` changes: every store an earlier
|
|
403
|
+
build wrote is refused (`envelope-mismatch`, surfaced by `@941design/marmot` as `storeIncompatible`) and can be recovered
|
|
404
|
+
by a wipe.
|
|
405
|
+
- cf2115a: Application messages are decoded as strictly as MDK decodes them: a message whose bytes start with U+FEFF, that
|
|
406
|
+
holds malformed UTF-8, or whose strings hold an unpaired surrogate escape, is refused (before, it was accepted here while MDK peers refused it, so members on different
|
|
407
|
+
implementations saw different histories). Avatar `dim`/`thumbhash` hints keep a leading U+FEFF. New conformance
|
|
408
|
+
patches move the engine stamp, so stores written by the previous build are refused with `storeIncompatible`.
|
|
409
|
+
- 780e176: A reload no longer changes what the branch-aware fence decides at the rewind horizon. The engine's history tree keeps every
|
|
410
|
+
node it observed while the rewind window the client persists keeps only the canonical path within `maxRewindCommits` of the
|
|
411
|
+
tip (and the forks off it), so an envelope whose parent lay beyond the horizon was read, and ledgered `skipped`, by an engine
|
|
412
|
+
that never reloaded but counted in the undecryptable set `U` after a reload. With the seam on the tree sweep now reads only
|
|
413
|
+
inside that window for commits (`#rewindWindow`, the same predicate as the persisted window), so both agree. It can only grow `U` (a
|
|
414
|
+
skipped envelope may stay undecryptable, as it already did after a reload), never turn a fence into a skip. Seam off, or an
|
|
415
|
+
unbounded horizon, is unchanged. The reload / rollback invariance tests now include scenarios whose tip stands one epoch
|
|
416
|
+
past the horizon. Application messages and proposals are still read tree-wide.
|
|
417
|
+
|
|
418
|
+
Two local patches change engine source, so `PATCHSET_DIGEST` moves
|
|
419
|
+
(`40a448f66adcaeee` → … → `18c5881cacb81c85` with the other patches of this release) and `ENGINE_VERSION` changes: every store an earlier build wrote is refused
|
|
420
|
+
(`envelope-mismatch`, surfaced by `@941design/marmot` as `storeIncompatible`) and can be recovered by a wipe.
|
|
421
|
+
- 3294d70: **Tree-fed re-convergence no longer reverts a witness-selected branch.** At the end of `ingest`, the history-tree
|
|
422
|
+
pass now weighs the app witnesses delivered on earlier ingests (the delivered-payload ledger), as pool-replay fork
|
|
423
|
+
recovery already did. Before, it saw only the current batch and the ingestion pool. When the witnesses had arrived
|
|
424
|
+
earlier, a branch that pool replay had just kept on witnesses could be switched off by the structural tie-break in
|
|
425
|
+
the same `ingest` call, and the payloads delivered on it were invalidated. A consequence: an equal-depth fork
|
|
426
|
+
sibling or foreign removal no longer outranks a tip that carries a delivered payload. Found by the MDK vector
|
|
427
|
+
`convergence-witness-selected/v1`. Witnesses are cached per history-tree node and envelope, so while a fork stays
|
|
428
|
+
in the tree an `ingest` decrypts only envelopes new to each node rather than the whole ledger again (200 delivered
|
|
429
|
+
payloads: about 10 ms per ingest, against about 750 ms uncached).
|
|
430
|
+
|
|
431
|
+
`ENGINE_VERSION` moves (new `PATCHSET_DIGEST`), so envelopes written by earlier builds are refused
|
|
432
|
+
(`storeIncompatible`); wipe the store by marker to recover.
|
|
433
|
+
- 16ed6ac: `ts-mls` now comes from the npm registry (`npm:@941design/ts-mls@2.0.0-rc.16-941design.1`) instead of
|
|
434
|
+
a git URL, so a default-configured pnpm 10+ install of `@941design/marmot-engine` no longer fails with
|
|
435
|
+
`ERR_PNPM_EXOTIC_SUBDEP`. The MLS code is unchanged: the published build is byte-identical to the
|
|
436
|
+
previous git pin.
|
|
437
|
+
- f7a682f: The branch-aware fence's undecryptable set `U` is bounded, fail-closed. `U` (the ids of group envelopes no held state
|
|
438
|
+
decrypts) is permanent and persisted id by id in `marmot.opaque`, so history a device can never read (before it joined,
|
|
439
|
+
before a restored snapshot's window, junk) filled it for good and the record was rewritten, in full, on every change.
|
|
440
|
+
|
|
441
|
+
- **Cap and saturation.** The engine keeps at most `MAX_UNDECRYPTABLE_IDS` (1,024, about 69 KB of record; per engine
|
|
442
|
+
`maxUndecryptableIds`) ids per group. The id that would exceed the cap saturates `U` instead: the ids are dropped, the
|
|
443
|
+
record carries one flag (`HeldOpaqueRecord.undecryptableSaturated`), and the count is read as unbounded, so every opaque
|
|
444
|
+
candidate fences — today's behaviour for an own-leaf commit, never a skip. It can only turn a skip into a fence: dropping
|
|
445
|
+
ids and keeping a count would undercount hidden edges. Saturation is sticky (a decrypt cannot shrink what is no longer
|
|
446
|
+
tracked; a reload, a prune and the capacity paths keep it) and is persisted and restored with the held candidates.
|
|
447
|
+
- **`@941design/marmot`.** `marmot.opaque` stores and restores the flag (a stored flag that is not `true` is corrupt and
|
|
448
|
+
fences the group), and the proof-gate rollback no longer reads an id missing from a saturated record as a decrypt.
|
|
449
|
+
- **Not done.** Scoping the history fetch so that pre-join and pre-window history never reaches the engine is not part of
|
|
450
|
+
this change: the spec rules a `created_at`-based exclusion out (a publisher chooses its `created_at`, so an excluded
|
|
451
|
+
hidden edge is an undercount), and no sound floor exists today. A restored device that fetched such history still gets
|
|
452
|
+
today's fence for an own-leaf commit once `U` saturates.
|
|
453
|
+
- **Stamp.** Two local patches change engine source, so `PATCHSET_DIGEST` moves (`882f1f81f2f51ee9` →
|
|
454
|
+
`40a448f66adcaeee`) and `ENGINE_VERSION` changes: every store an earlier build wrote is refused (`envelope-mismatch`,
|
|
455
|
+
surfaced by `@941design/marmot` as `storeIncompatible`) and can be recovered by a wipe.
|
|
456
|
+
- 2ab78c6: Marmot text fields keep a leading U+FEFF: `decodeUtf8` no longer strips it as a byte-order mark, so a group name or
|
|
457
|
+
description starting with it reads back exactly (a name of just U+FEFF no longer decodes as empty), as other
|
|
458
|
+
implementations read it. A new local patch moves the engine stamp, so
|
|
459
|
+
stores written by the previous build are refused with `storeIncompatible`.
|
|
460
|
+
- 372aaba: An app-payload witness is credited at the epoch its message was sent in, not at the epoch of the state that decrypted it.
|
|
461
|
+
|
|
462
|
+
`collectWitnessesAt`, shared by pool replay and the tree-fed re-convergence pass, credited every witness at the
|
|
463
|
+
decrypting state's epoch, and `isWitnessEligible` only requires that epoch to be past the fork. A payload sent at or
|
|
464
|
+
before the fork root that a post-root snapshot still decrypts (`historicalReceiverData`) therefore counted as a
|
|
465
|
+
post-fork witness on every post-root node of every candidate path: two such payloads from two senders met the witness
|
|
466
|
+
quorum on pre-fork traffic, and a deeper branch collected more credit from the same message. Reproduced on the tree-fed
|
|
467
|
+
path: two root-epoch payloads delivered after the fork switched the canonical branch from a really-witnessed shallow
|
|
468
|
+
one to a deeper unwitnessed one and retracted what had been delivered on the first. The witness epoch is now the
|
|
469
|
+
message's framed epoch, so a message at or before the fork is not a witness and one message is one credit per epoch.
|
|
470
|
+
Selection can change in the cases above and nowhere else: a witness sent after the fork is credited at its own epoch,
|
|
471
|
+
as before on the node it was sent on.
|
|
472
|
+
|
|
473
|
+
- **Stamp.** One local patch changes engine source, so
|
|
474
|
+
`PATCHSET_DIGEST` moves (the batch ends at `834029be75954cae`, `22af43683e8de310` before it) and `ENGINE_VERSION` changes: every store an earlier
|
|
475
|
+
build wrote is refused (`envelope-mismatch`, surfaced by `@941design/marmot` as `storeIncompatible`) and can be
|
|
476
|
+
recovered by a wipe.
|
|
477
|
+
- Upstream still has the defect; the report is `docs/upstream/marmot-ts-witness-credit-epoch.md`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Markus Rother
|
|
4
|
+
|
|
5
|
+
Vendored portions from marmot-protocol/marmot-ts, commit
|
|
6
|
+
50192e117e986d894c16ea1f8922600dc33a0db3:
|
|
7
|
+
Copyright (c) 2026 Internet Privacy Foundation
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
Portions of this package (src/core, src/engine, src/audit, src/utils) are
|
|
30
|
+
derived from marmot-ts (https://github.com/marmot-protocol/marmot-ts),
|
|
31
|
+
distributed under the following license:
|
|
32
|
+
|
|
33
|
+
MIT License
|
|
34
|
+
|
|
35
|
+
Copyright (c) 2026 Internet Privacy Foundation
|
|
36
|
+
|
|
37
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
38
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
39
|
+
in the Software without restriction, including without limitation the rights
|
|
40
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
41
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
42
|
+
furnished to do so, subject to the following conditions:
|
|
43
|
+
|
|
44
|
+
The above copyright notice and this permission notice shall be included in all
|
|
45
|
+
copies or substantial portions of the Software.
|
|
46
|
+
|
|
47
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
48
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
49
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
50
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
51
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
52
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
53
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@941design/marmot-engine`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The MLS convergence engine behind `@941design/marmot`: the `core`, `engine`
|
|
4
|
+
and `audit` modules of [`marmot-protocol/marmot-ts` at commit
|
|
5
|
+
`50192e117e986d894c16ea1f8922600dc33a0db3`](https://github.com/marmot-protocol/marmot-ts/commit/50192e117e986d894c16ea1f8922600dc33a0db3), ported onto the
|
|
6
|
+
[`ts-mls`](https://github.com/LukaJCB/ts-mls) API and patched locally.
|
|
7
|
+
|
|
8
|
+
Most applications should depend on `@941design/marmot` instead; this package
|
|
9
|
+
is its engine and the single owner of the `ts-mls` dependency.
|
|
10
|
+
|
|
11
|
+
> **Pre-1.0.** Every `0.x` release may break the API. Pin an exact version.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
pnpm add @941design/marmot-engine
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Subpaths
|
|
20
|
+
|
|
21
|
+
There is no root export. Import from one of:
|
|
22
|
+
|
|
23
|
+
| Subpath | Surface |
|
|
24
|
+
| ----------------------------------- | -------------------------------------------------------------------------- |
|
|
25
|
+
| `@941design/marmot-engine/core` | Credentials, key packages, group/welcome events, application-message codec |
|
|
26
|
+
| `@941design/marmot-engine/engine` | `MarmotGroupEngine`, ingest pipeline, retained history, convergence |
|
|
27
|
+
| `@941design/marmot-engine/audit` | Audit sink types and an in-memory implementation |
|
|
28
|
+
| `@941design/marmot-engine/mls` | Re-export of the pinned `ts-mls` surface the engine is built against |
|
|
29
|
+
| `@941design/marmot-engine/version` | The engine's version and stored-state format stamps |
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
MIT — see [`LICENSE`](./LICENSE), which also carries the `marmot-ts` notice
|
|
34
|
+
for the vendored code.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AuditContextOptions, AuditEmitContext, AuditEventContext, AuditEventKind, AuditSink, MarmotAuditEvent } from "./types.js";
|
|
2
|
+
export declare class AuditEmitter implements AuditSink {
|
|
3
|
+
#private;
|
|
4
|
+
readonly context: AuditEmitContext;
|
|
5
|
+
readonly sink: AuditSink;
|
|
6
|
+
constructor(options: AuditContextOptions & {
|
|
7
|
+
sink?: AuditSink;
|
|
8
|
+
});
|
|
9
|
+
record(event: MarmotAuditEvent): void;
|
|
10
|
+
emit(kind: AuditEventKind, options?: {
|
|
11
|
+
groupRef?: string;
|
|
12
|
+
context?: AuditEventContext;
|
|
13
|
+
}): MarmotAuditEvent;
|
|
14
|
+
}
|
|
15
|
+
export declare function createAuditEmitter(options: (AuditContextOptions & {
|
|
16
|
+
sink?: AuditSink;
|
|
17
|
+
}) | undefined): AuditEmitter | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @module @category Audit */
|
|
2
|
+
import { auditNowMs, createAuditEvent } from "./helpers.js";
|
|
3
|
+
import { safeAuditSink } from "./sink.js";
|
|
4
|
+
export class AuditEmitter {
|
|
5
|
+
context;
|
|
6
|
+
sink;
|
|
7
|
+
#seq = 0;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.sink = safeAuditSink(options.sink);
|
|
10
|
+
this.context = {
|
|
11
|
+
engineId: options.engineId,
|
|
12
|
+
accountRef: options.accountRef,
|
|
13
|
+
recorderSessionId: options.recorderSessionId,
|
|
14
|
+
dataMode: options.dataMode ?? "obfuscated_sensitive_data",
|
|
15
|
+
source: options.source,
|
|
16
|
+
now: options.now ?? auditNowMs,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
record(event) {
|
|
20
|
+
this.sink.record(event);
|
|
21
|
+
}
|
|
22
|
+
emit(kind, options) {
|
|
23
|
+
const event = createAuditEvent(this.context, this.#seq++, kind, options);
|
|
24
|
+
this.record(event);
|
|
25
|
+
return event;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function createAuditEmitter(options) {
|
|
29
|
+
return options ? new AuditEmitter(options) : undefined;
|
|
30
|
+
}
|