@kumiai/mls 0.3.0 → 0.4.0

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.
@@ -1,14 +1,16 @@
1
1
  import { normalizeDID } from '@kokuin/token';
2
- import { contentTypes, createApplicationMessage, decode, encode, mlsMessageDecoder, mlsMessageEncoder, processMessage as mlsProcessMessage, nodeTypes, senderTypes, wireformats } from 'ts-mls';
2
+ import { contentTypes, createApplicationMessage, decode, encode, mlsExporter, mlsMessageDecoder, mlsMessageEncoder, processMessage as mlsProcessMessage, nodeTypes, senderTypes, wireformats } from 'ts-mls';
3
3
  import { readGroupAnchor } from './anchor.js';
4
4
  import { parseMLSCredentialIdentity } from './credential.js';
5
5
  import { decodeControlEnvelope } from './envelope.js';
6
- import { foldEnvelope } from './envelope-fold.js';
6
+ import { foldEnvelope, GROUP_TYPE_PREFIX } from './envelope-fold.js';
7
+ import { readMessageEpoch } from './group-info.js';
7
8
  import { assertHeadMatches, computeHead, decodeLedgerHead, encodeLedgerHead, extendHead, headsMatch, readLedgerHead, readLedgerHeadExtension } from './head.js';
8
9
  import { ledgerEntryDigest, verifyLedgerEntry } from './ledger.js';
9
10
  import { createMutex } from './mutex.js';
10
11
  import { defaultCommitPolicy, MissingLedgerEntriesError } from './policy.js';
11
12
  import { foldRoster } from './roster.js';
13
+ import { readSenderLeafIndex } from './sender-data.js';
12
14
  /** One serializer per live handle, so its state-mutating operations run one at a
13
15
  * time in issue order. Keyed weakly: the entry is collected with the handle, and
14
16
  * the handle carries no reference back to it. */ const MUTEXES = new WeakMap();
@@ -75,13 +77,42 @@ export function mutexFor(handle) {
75
77
  };
76
78
  }
77
79
  /**
78
- * Read the DID an external-join commit proves control of. An external join is a
80
+ * Narrow a decoded frame to the PrivateMessage fields sender-data decrypt reads, for one
81
+ * content type. Returns undefined for anything that is not a PrivateMessage of that type.
82
+ *
83
+ * The sender-data derivation (RFC 9420 §6.3.2) is content-type-agnostic — the type is one
84
+ * byte of the AAD — so the same read serves a commit's committer and an application
85
+ * message's author.
86
+ */ function readPrivateFrame(decoded, contentType) {
87
+ if (decoded == null || typeof decoded !== 'object') return undefined;
88
+ const frame = decoded;
89
+ if (frame.wireformat !== wireformats.mls_private_message) return undefined;
90
+ const pm = frame.privateMessage;
91
+ if (pm == null || pm.contentType !== contentType) return undefined;
92
+ if (!(pm.groupId instanceof Uint8Array) || typeof pm.epoch !== 'bigint' || !(pm.encryptedSenderData instanceof Uint8Array) || !(pm.ciphertext instanceof Uint8Array)) {
93
+ return undefined;
94
+ }
95
+ return {
96
+ groupId: pm.groupId,
97
+ epoch: pm.epoch,
98
+ contentType: pm.contentType,
99
+ encryptedSenderData: pm.encryptedSenderData,
100
+ ciphertext: pm.ciphertext
101
+ };
102
+ }
103
+ /**
104
+ * Read the DID an external-join commit CLAIMS control of. An external join is a
79
105
  * PublicMessage from a joining non-member (senderType new_member_commit) carrying a
80
106
  * commit; the committer holds no pre-commit leaf, so its DID rides the commit's own
81
107
  * UpdatePath leaf credential. Returns undefined for anything else (keeps the
82
108
  * pre-envelope path). Returns `{ did: undefined }` when the UpdatePath is absent or
83
109
  * the leaf credential does not resolve to a basic-credential DID — cannot be a valid
84
110
  * resync, so the caller rejects it. Narrows structurally.
111
+ *
112
+ * CLAIMS, not proves: this reads the credential and checks no signature, and the
113
+ * credential is a plain field any publisher can write. The DID it yields is the
114
+ * frame's word until {@link GroupHandle.readCommitHeader} has authenticated it, and
115
+ * a caller that reports it unauthenticated hands a forger the choice of committer.
85
116
  */ function readExternalCommit(decoded) {
86
117
  if (decoded == null || typeof decoded !== 'object') return undefined;
87
118
  const frame = decoded;
@@ -113,7 +144,7 @@ export function mutexFor(handle) {
113
144
  }
114
145
  }
115
146
  /**
116
- * Project a held ledger into the roster. foldRoster drops every non-`group.role`
147
+ * Project a held ledger into the roster. foldRoster drops every non-`kumiai.role`
117
148
  * entry by type, so the mixed-type log is fed in whole. Replayed in order, repeats
118
149
  * and all: a claim re-enacted at a later position must undo what came between.
119
150
  */ function foldLedgerRoster(ledger, anchor, groupID) {
@@ -328,6 +359,9 @@ export function mutexFor(handle) {
328
359
  verified
329
360
  });
330
361
  }
362
+ // What this bootstrap ADDS, in log order, minus the reserved `kumiai.*` types the fold
363
+ // consumes itself — the same rule the commit path surfaces by.
364
+ const surfaced = log.filter(({ entryID, verified })=>!this.#entryBodies.has(entryID) && !verified.entry.type.startsWith(GROUP_TYPE_PREFIX)).map(({ verified })=>verified);
331
365
  this.#ledger = log;
332
366
  this.#entryBodies = new Map(log.map(({ entryID, token, verified })=>[
333
367
  entryID,
@@ -337,6 +371,15 @@ export function mutexFor(handle) {
337
371
  }
338
372
  ]));
339
373
  this.#roster = foldLedgerRoster(log, this.#anchor, this.groupID);
374
+ // SURFACED HERE TOO, not only on the commit path. A heal is how a peer that missed commits
375
+ // catches up — it rejoins, gathers the whole ledger, and lands here — so a bootstrap that
376
+ // said nothing left a host consuming `onLedgerEntries` as an event stream permanently
377
+ // unaware of everything enacted while it was away. The state was right and the host was
378
+ // never told, which is the worst of both.
379
+ //
380
+ // Deduped against what this handle already held, so a peer bootstrapping over a partial
381
+ // ledger is not re-notified of entries it has already seen.
382
+ if (surfaced.length > 0) this.#onLedgerEntries?.(surfaced);
340
383
  });
341
384
  }
342
385
  get memberCount() {
@@ -375,12 +418,51 @@ export function mutexFor(handle) {
375
418
  * order. Leaves whose credential identity fails to parse are skipped (like
376
419
  * findMemberLeafIndex). Reflects current #state — call before and after
377
420
  * processMessage to diff a commit's membership change.
421
+ *
422
+ * The diff sees MEMBERSHIP, and only membership: an Add, a Remove, or both in
423
+ * one commit (compare as a set — a count misses that last case). It does NOT
424
+ * see an external-commit REJOIN by a member the group still holds. That member
425
+ * keeps its id, so the id set is unchanged; and its leaf index is unchanged
426
+ * too, because a resync blanks the member's old leaf and the new leaf then
427
+ * takes the leftmost blank — the one just blanked (RFC 9420 §12.4.3.2). No
428
+ * field of this result moves, and no before/after diff of it can be made to.
429
+ * A caller that must detect a rejoin reads the COMMIT instead — an external
430
+ * commit is structurally one: a public message from a non-member carrying a
431
+ * commit, recognizable from its own bytes before it is applied, and carrying
432
+ * its committer's id in its own UpdatePath leaf. That is the read
433
+ * {@link readCommitHeader} already makes internally to resolve such a
434
+ * committer, and it does not surface the fact today.
378
435
  */ listMembers() {
379
436
  return [
380
437
  ...this.#iterateMembers()
381
438
  ];
382
439
  }
383
440
  /**
441
+ * The MLS exporter (RFC 9420 §8.5): a secret derived from THIS EPOCH's exporter secret,
442
+ * a label and a context. Every member at the epoch derives the same bytes; a member at
443
+ * any other epoch derives different ones, and cannot reach this epoch's from what it holds.
444
+ *
445
+ * That per-epoch property is the point, and it is the only thing that cuts a removed member
446
+ * off from anything keyed on it. A removed member keeps every exporter secret it ever held
447
+ * and every value it ever derived, and epoch numbers are a counter it can enumerate — so a
448
+ * consumer deriving a rotating name (an app-lane topic, say) must feed it from HERE and never
449
+ * from a lifelong group secret, which would rotate onto a name the removed member walks
450
+ * straight back onto.
451
+ *
452
+ * Non-mutating and consumes no ratchet key: the exporter secret is epoch-level. A handle a
453
+ * commit has superseded exports its own pre-commit epoch's secret, which is a feature — a
454
+ * reader opening a retained frame needs the secret of the epoch that frame was sealed at.
455
+ *
456
+ * DELIBERATELY NOT MUTEX-WRAPPED, unlike its neighbours, and two things depend on that. A
457
+ * consumer resolving a commit's ledger entries is called from INSIDE `processMessage`, which
458
+ * holds the mutex — so taking it here would deadlock every commit-apply. And `#state` is
459
+ * replaced only after resolution returns, so a read from in there sees the PRE-commit epoch's
460
+ * exporter secret, which is the epoch the blob being opened was sealed under. Both are silent
461
+ * consequences of this method's plainness; wrapping it "for consistency" breaks both.
462
+ */ async exportSecret(label, context, length = 32) {
463
+ return await mlsExporter(this.#state.keySchedule.exporterSecret, label, context, length, this.#context.cipherSuite);
464
+ }
465
+ /**
384
466
  * Encrypt an application message for the group at this handle's current epoch,
385
467
  * returning framed wire bytes. A handle a commit has already superseded (see
386
468
  * {@link commitInvite}, {@link removeMember}, {@link commitLedgerEntries}) must not
@@ -399,6 +481,57 @@ export function mutexFor(handle) {
399
481
  });
400
482
  }
401
483
  /**
484
+ * Open an application message sealed for the group and recover WHO SENT IT — the
485
+ * counterpart to {@link encrypt}, and the read half of the group's application lane.
486
+ *
487
+ * Throws for bytes this handle cannot open, which for an application message means
488
+ * ANY epoch but its own: MLS ratchets forward, so a frame sealed below this handle's
489
+ * epoch is gone and one sealed above it has not arrived yet. That is ordinary control
490
+ * flow for a caller walking a retained log full of frames from epochs it does not hold
491
+ * — it is how a frame says "not mine" — and such a caller must not read the throw as
492
+ * corruption. Use {@link readMessageEpoch} to tell those two cases apart before trying.
493
+ *
494
+ * WHY THE SENDER IS AUTHENTICATED and not merely claimed: the leaf index comes from the
495
+ * message's sender-data, encrypted under this epoch's sender-data secret, and the
496
+ * message body then opens only under the ratchet key derived at THAT leaf. A frame
497
+ * naming a leaf it was not sealed at does not open, so a sender that survives to be
498
+ * returned is one the AEAD has vouched for. The leaf is resolved to a DID against this
499
+ * handle's own ratchet tree, never from anything the frame carries.
500
+ *
501
+ * `senderDID` is absent only when the authenticated leaf holds no parsable credential —
502
+ * absent means "I cannot name the author", never "there is no author".
503
+ *
504
+ * ts-mls's own `processMessage` returns an application message's plaintext WITHOUT any
505
+ * sender, which is why this exists rather than delegating.
506
+ */ async decrypt(message) {
507
+ const decoded = decode(mlsMessageDecoder, message);
508
+ if (decoded == null) throw new Error('decrypt: failed to decode MLSMessage');
509
+ return mutexFor(this).run(async ()=>{
510
+ const pm = readPrivateFrame(decoded, contentTypes.application);
511
+ if (pm == null) throw new Error('decrypt: not a PrivateMessage application frame');
512
+ // Read the sender BEFORE opening: the sender-data secret is epoch-level and this
513
+ // consumes no ratchet key, so a frame that then fails to open has cost nothing.
514
+ const leafIndex = await readSenderLeafIndex(this.#context, this.#state.keySchedule.senderDataSecret, pm);
515
+ const result = await mlsProcessMessage({
516
+ context: this.#context,
517
+ state: this.#state,
518
+ message: decoded
519
+ });
520
+ this.#state = result.newState;
521
+ zeroAll(result.consumed);
522
+ if (result.kind !== 'applicationMessage') {
523
+ throw new Error('decrypt: frame was not an application message');
524
+ }
525
+ const senderDID = leafIndex == null ? undefined : this.#didOfLeaf(leafIndex);
526
+ return {
527
+ payload: result.message,
528
+ ...senderDID != null && {
529
+ senderDID
530
+ }
531
+ };
532
+ });
533
+ }
534
+ /**
402
535
  * The async pre-pass feeding the synchronous ts-mls commit callback, run before
403
536
  * mlsProcessMessage. For anything that is not a PrivateMessage commit it just
404
537
  * resolves the caller policy, wraps it for rejected-proposal capture, and applies
@@ -541,6 +674,156 @@ export function mutexFor(handle) {
541
674
  };
542
675
  }
543
676
  /**
677
+ * Does this external commit carry a signature that verifies as its own UpdatePath leaf's?
678
+ *
679
+ * An external commit is self-signed: the key that signed it is the `signaturePublicKey` of the
680
+ * same UpdatePath leaf whose credential names the committer. So a verified signature binds the
681
+ * two — whoever authored these bytes held the key of the leaf claiming that DID — and an
682
+ * unverified one means the credential is a field somebody wrote, nothing more.
683
+ *
684
+ * WHAT IT REQUIRES, and why the answer is only ever available at this handle's own epoch.
685
+ * MLS binds the full GroupContext into the signed FramedContentTBS for a new_member_commit
686
+ * sender, so verifying needs the group context the signer signed against: group id, epoch, tree
687
+ * hash, confirmed transcript hash, extensions. This handle holds exactly one — its current
688
+ * epoch's. It holds none for an epoch AHEAD of it, which no peer can, and that is not a gap
689
+ * this check can close: a peer that has fallen behind holds nothing to check the group's future
690
+ * with. So a commit framed anywhere but here answers false, and the caller reports no committer
691
+ * rather than an unauthenticated one.
692
+ *
693
+ * WHAT IT DOES NOT ESTABLISH. Possession of a key is not permission to use it: a verified
694
+ * signature says "the holder of that leaf key authored these bytes", never "this member may
695
+ * rejoin". And it is a property of the bytes, not of their delivery — a GENUINE external commit
696
+ * captured and re-published verifies exactly as it did the first time.
697
+ *
698
+ * Implemented by asking the MLS library to process the message with a callback that refuses it,
699
+ * which runs the real verification and stops before anything is applied. Deliberately not a
700
+ * reimplementation: a check that verified less than the apply path does would pass frames the
701
+ * apply path rejects, and the two must not drift. Non-mutating — the refusal returns this same
702
+ * state, and the result is discarded either way. Any throw is a "no": the library raises on a
703
+ * bad signature, on an epoch that is not this one, and on a malformed frame, and none of those
704
+ * is an authenticated committer.
705
+ */ async #externalCommitAuthenticates(decoded) {
706
+ try {
707
+ const result = await mlsProcessMessage({
708
+ context: this.#context,
709
+ state: this.#state,
710
+ message: decoded,
711
+ callback: ()=>'reject'
712
+ });
713
+ // Zeroed rather than assumed empty: the refusal path hands back nothing to retire today,
714
+ // and this must not become a way to leak retired key material if that ever changes.
715
+ zeroAll(result.consumed);
716
+ return result.kind === 'newState' && result.actionTaken === 'reject';
717
+ } catch {
718
+ return false;
719
+ }
720
+ }
721
+ /** The DID at a ratchet-tree leaf index, or undefined if that leaf is empty/unparsable. */ #didOfLeaf(leafIndex) {
722
+ for (const member of this.#iterateMembers()){
723
+ if (member.leafIndex === leafIndex) return member.id;
724
+ }
725
+ return undefined;
726
+ }
727
+ /**
728
+ * Read what a Commit says about itself against this handle, WITHOUT advancing state.
729
+ *
730
+ * **`null` means "these bytes are not a Commit" and nothing else.** It does not mean "a
731
+ * Commit I could not read": callers file `null` as poison and step over it, so answering it
732
+ * for a Commit this handle merely cannot authenticate would make a reader treat every commit
733
+ * framed away from its own epoch as garbage — including the ones that say it fell behind.
734
+ *
735
+ * The two facts the header carries are NOT equally available, and the return type says so:
736
+ * - `epoch` is in the message's CLEARTEXT ({@link readMessageEpoch}). Keyless, so it is
737
+ * readable for a Commit framed at any epoch — and unauthenticated, so it is the
738
+ * publisher's word and may only be used to decide what to try.
739
+ * - `committerDID` needs the epoch's sender-data secret. A member commit (PrivateMessage)
740
+ * has its committer encrypted under it: decrypt to the sender leaf index and resolve that
741
+ * against this handle's ratchet tree — the same leaf->DID the commit policy sees as
742
+ * `didOfLeaf(senderLeafIndex)`. Both the secret and the tree are THIS epoch's, so the
743
+ * committer resolves only for a Commit framed where this handle stands, and is ABSENT
744
+ * otherwise. Absent is "I cannot vouch for the author", never "there is no author": a
745
+ * caller must not substitute an unauthenticated one.
746
+ *
747
+ * An external commit needs no epoch secret and no tree lookup — it is a public message and its
748
+ * committer's DID rides its own UpdatePath leaf (see {@link readExternalCommit}), which is also
749
+ * what makes it recognizable as external. It is NOT exempt from authentication. The credential
750
+ * carrying that DID is a plain field, so it is returned only once the commit's own self-signed
751
+ * signature verifies, and it is ABSENT otherwise — the same rule the member path follows, for
752
+ * the same reason. Verifiable only at this handle's own epoch, since MLS binds the GroupContext
753
+ * into what an external commit signs; a commit framed elsewhere reports no committer.
754
+ *
755
+ * `external: true` is reported either way: it is read from the wireformat and sender type, both
756
+ * cleartext, so it is as available as the epoch and says nothing about who authored the frame.
757
+ *
758
+ * Runs on the handle mutex so the epoch secret, tree, and epoch are one snapshot against a
759
+ * concurrent processMessage. Non-mutating: sender-data decrypt is epoch-level and consumes
760
+ * no per-message key. Async only because the KDF and AEAD are.
761
+ */ async readCommitHeader(commit) {
762
+ return mutexFor(this).run(async ()=>{
763
+ let decoded;
764
+ try {
765
+ decoded = decode(mlsMessageDecoder, commit);
766
+ } catch {
767
+ // ts-mls `decode` throws CodecError on malformed/truncated frames; the contract is
768
+ // "null for bytes that are not a Commit", and the lane treats null as poison (advance
769
+ // the cursor, never retry). An unguarded throw would instead wedge the commit lane on
770
+ // this frame forever. Mirrors readMessageEpoch, which guards this same decode.
771
+ return null;
772
+ }
773
+ if (decoded == null) return null;
774
+ const epoch = readMessageEpoch(commit);
775
+ if (epoch == null) return null;
776
+ // External-join commit: the committer holds no pre-commit leaf, so its DID rides the
777
+ // commit's own UpdatePath leaf. No tree lookup, no sender-data decrypt.
778
+ //
779
+ // `external: true` is reported, not just consumed to find the committer: a resync rejoin
780
+ // is invisible to every before/after diff a caller could run — it changes no member DID
781
+ // (the roster already held it) and no occupied leaf index (the new leaf lands on the
782
+ // leftmost blank, which is the one the resync just blanked). A caller that must know the
783
+ // group's membership shifted has no other way to see it, so the fact is surfaced here
784
+ // rather than discarded. Absent means a member commit.
785
+ const external = readExternalCommit(decoded);
786
+ if (external != null) {
787
+ // It IS a commit, so it gets a header even when the leaf credential will not parse to a
788
+ // DID and even when the signature will not verify — the epoch is readable and the
789
+ // caller's epoch rows are entitled to it. Only the committer goes missing.
790
+ //
791
+ // The signature is checkable only where this handle holds the GroupContext the commit's
792
+ // signature is bound to, which is the epoch this handle stands at. A commit framed
793
+ // anywhere else comes back with no committer — indistinguishable, from here, from a
794
+ // forgery, and treated as one.
795
+ const authentic = external.did != null && await this.#externalCommitAuthenticates(decoded);
796
+ return {
797
+ epoch,
798
+ external: true,
799
+ ...authentic && {
800
+ committerDID: external.did
801
+ }
802
+ };
803
+ }
804
+ const pm = readPrivateFrame(decoded, contentTypes.commit);
805
+ // The ONLY "not a Commit" verdict on this path, and the only thing `null` is for: the
806
+ // frame is not a PrivateMessage of contentType commit. Both of those fields are cleartext,
807
+ // so this verdict needs no key and is the same at every epoch.
808
+ if (pm == null) return null;
809
+ // From here the bytes ARE a commit, and every exit carries its epoch. The committer is
810
+ // what may be missing: sender-data is sealed under the epoch secret this handle holds
811
+ // right now, so a commit framed at any other epoch decrypts to nothing, and a leaf this
812
+ // tree does not hold resolves to nobody. Neither is a reason to call the frame garbage.
813
+ const leafIndex = await readSenderLeafIndex(this.#context, this.#state.keySchedule.senderDataSecret, pm);
814
+ if (leafIndex == null) return {
815
+ epoch
816
+ };
817
+ const committerDID = this.#didOfLeaf(leafIndex);
818
+ return committerDID == null ? {
819
+ epoch
820
+ } : {
821
+ epoch,
822
+ committerDID
823
+ };
824
+ });
825
+ }
826
+ /**
544
827
  * Process a received MLS message (Commit, Proposal, or application). Accepts
545
828
  * wire-form bytes (preferred, e.g. from commitInvite/removeMember) or a pre-decoded
546
829
  * ts-mls object (legacy). Param widens to `unknown` because `Uint8Array | unknown`
@@ -17,9 +17,6 @@ export type ProcessWelcomeParams = {
17
17
  ratchetTree?: unknown;
18
18
  options?: GroupOptions;
19
19
  };
20
- /**
21
- * Process a Welcome message to join a group.
22
- */
23
20
  export declare function processWelcome(params: ProcessWelcomeParams): Promise<ProcessWelcomeResult>;
24
21
  export type ProcessWelcomeOnceParams = ProcessWelcomeParams & {
25
22
  /** The group ids this member already holds a handle for. */
@@ -7,9 +7,7 @@ import { GroupHandle } from './group-handle.js';
7
7
  import { assertHeadMatches, computeHead, readLedgerHead } from './head.js';
8
8
  import { ledgerEntryDigest, verifyLedgerEntry } from './ledger.js';
9
9
  import { ROLE_ENTRY_TYPE } from './roster.js';
10
- /**
11
- * Process a Welcome message to join a group.
12
- */ export async function processWelcome(params) {
10
+ export async function processWelcome(params) {
13
11
  const { identity, invite, welcome, keyPackageBundle, ratchetTree, options } = params;
14
12
  const cache = options?.cache ?? createInMemoryDIDCache();
15
13
  const context = await resolveMlsContext(options);
package/lib/policy.d.ts CHANGED
@@ -1,29 +1,26 @@
1
1
  import type { GroupContextExtension, IncomingMessageAction, ProposalWithSender } from 'ts-mls';
2
2
  import type { RosterState } from './roster.js';
3
3
  /**
4
- * Everything the receiving-side gate needs, resolved by the caller. Pure: no
5
- * group handle, no I/O. `didOfLeaf` maps a pre-commit ratchet-tree leaf index to
6
- * its member DID (undefined for an empty or unresolvable leaf).
7
- * `currentExtensions` is the pre-commit GroupContext extension list, the baseline
8
- * the group-context-extensions rule pins. `externalCommitDID` is the DID resolved
9
- * from an external commit's UpdatePath leaf (precomputed by the caller); undefined
10
- * for a non-external commit.
4
+ * Everything the receiving-side gate needs, resolved by the caller. Pure: no group handle, no
5
+ * I/O. `didOfLeaf` maps a pre-commit leaf index to its member DID (undefined if unresolvable).
6
+ * `currentExtensions` is the pre-commit extension list the group-context-extensions rule pins
7
+ * against. `externalCommitDID` is the DID resolved from an external commit's UpdatePath leaf
8
+ * (precomputed by the caller); undefined for a non-external commit.
11
9
  */
12
10
  export type CommitPolicyContext = {
13
- /** Roster before this commit applies. Judges every proposal sender's authority:
14
- * a promotion riding this same commit does not grant its subject commit authority. */
11
+ /** Roster before the commit. Judges every sender's authority — a promotion riding this same
12
+ * commit doesn't grant its subject commit authority. */
15
13
  baseRoster: RosterState;
16
- /** Roster after foldEnvelope applies this commit's group.role entries. Judges the
17
- * removed target: a Remove of a leaf still `admin` here carried no demotion and is rejected. */
14
+ /** Roster after foldEnvelope applies this commit's kumiai.role entries. Judges the removed
15
+ * target: a Remove of a leaf still `admin` here carried no demotion and is rejected. */
18
16
  candidateRoster: RosterState;
19
17
  didOfLeaf: (leafIndex: number) => string | undefined;
20
- /** The pre-commit GroupContext extension list. A group_context_extensions commit
21
- * may change nothing in it but the ledger_head entry. */
18
+ /** The pre-commit GroupContext extension list. A group_context_extensions commit may change
19
+ * nothing in it but the ledger_head entry. */
22
20
  currentExtensions: Array<GroupContextExtension>;
23
- /** The head extension bytes this commit must install: the current head extended by
24
- * the commit's envelope entry ids, in envelope order. Equals the current head when
25
- * the commit enacts nothing, so a commit that moves the head without enacting
26
- * anything is rejected too. */
21
+ /** The head extension bytes this commit must install: the current head extended by the
22
+ * commit's envelope entry ids, in order. Equals the current head when the commit enacts
23
+ * nothing, so a commit that moves the head without enacting anything is rejected too. */
27
24
  expectedHeadExtensionData: Uint8Array;
28
25
  /** Whether the commit's envelope names any entries. */
29
26
  commitEnactsEntries: boolean;
@@ -39,28 +36,24 @@ type IncomingMessage = {
39
36
  proposal: ProposalWithSender;
40
37
  };
41
38
  /**
42
- * Pure receiving-side commit policy. Given the resolved context, decides whether
43
- * an incoming commit or standalone proposal is admissible. Never throws.
39
+ * Pure receiving-side commit policy: given the resolved context, decides whether an incoming
40
+ * commit or standalone proposal is admissible. Never throws.
44
41
  *
45
- * Per proposal the effective sender is the proposal's own `senderLeafIndex` when
46
- * present, else the committer's — a commit may carry by-reference proposals
47
- * authored by other members, so checking only the committer would let an admin
48
- * launder a member's Remove. A commit is accepted only when every proposal
49
- * passes its row; the first failing proposal rejects the whole commit. A commit
50
- * with no proposals is a key rotation any member may make. When any proposal is
51
- * an `external_init`, the whole commit is judged by the external-init rule rather
52
- * than the per-proposal loop.
42
+ * Per proposal, the effective sender is its own `senderLeafIndex` if present, else the
43
+ * committer's — a commit may carry by-reference proposals from other members, so checking only
44
+ * the committer would let an admin launder a member's Remove. Every proposal must pass its row
45
+ * or the whole commit rejects; no proposals is a key rotation any member may make. An
46
+ * `external_init` anywhere routes the whole commit to the external-init rule instead of the
47
+ * per-proposal loop.
53
48
  *
54
- * One rule is not a proposal's own: a commit that enacts ledger entries must carry
55
- * a group-context-extensions proposal, or it would enact entries without moving the
56
- * head, and the head would stop covering the ledger.
49
+ * One rule isn't a proposal's own: a commit enacting ledger entries must carry a
50
+ * group-context-extensions proposal, or entries would be enacted without moving the head.
57
51
  */
58
52
  export declare function defaultCommitPolicy(incoming: IncomingMessage, context: CommitPolicyContext): IncomingMessageAction;
59
53
  /**
60
- * Thrown by the caller's resolver path when the entry bodies an envelope names
61
- * cannot be resolved from the ledger. Carries the unresolved ids. Defined here
62
- * because it belongs to the commit-policy resolution boundary, but it is never
63
- * thrown by {@link defaultCommitPolicy}, which is pure and total.
54
+ * Thrown by the caller's resolver when an envelope names entry ids the ledger can't resolve.
55
+ * Belongs to the commit-policy resolution boundary, but {@link defaultCommitPolicy} itself is
56
+ * pure and total, and never throws it.
64
57
  */
65
58
  export declare class MissingLedgerEntriesError extends Error {
66
59
  #private;