@real-life/trust-protocol 0.4.0 → 0.6.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.
- package/CHANGELOG.md +137 -0
- package/README.md +91 -24
- package/dist/adapters/vti-mediator.d.ts +36 -8
- package/dist/adapters/vti-mediator.d.ts.map +1 -1
- package/dist/adapters/vti-mediator.js +193 -29
- package/dist/adapters/vti-mediator.js.map +1 -1
- package/dist/codec.d.ts +2 -1
- package/dist/codec.d.ts.map +1 -1
- package/dist/codec.js +75 -26
- package/dist/codec.js.map +1 -1
- package/dist/engine.d.ts +77 -4
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +419 -31
- package/dist/engine.js.map +1 -1
- package/dist/entropy.d.ts +1 -1
- package/dist/entropy.d.ts.map +1 -1
- package/dist/entropy.js +1 -1
- package/dist/entropy.js.map +1 -1
- package/dist/events.d.ts +21 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/holder-api.d.ts +44 -2
- package/dist/holder-api.d.ts.map +1 -1
- package/dist/holder-api.js +40 -5
- package/dist/holder-api.js.map +1 -1
- package/dist/{holder-state-v1.d.ts → holder-state-v3.d.ts} +261 -201
- package/dist/holder-state-v3.d.ts.map +1 -0
- package/dist/holder-state-v3.js +2 -0
- package/dist/holder-state-v3.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/introduction/holder.d.ts.map +1 -1
- package/dist/introduction/holder.js +7 -0
- package/dist/introduction/holder.js.map +1 -1
- package/dist/invariants.d.ts.map +1 -1
- package/dist/invariants.js +70 -0
- package/dist/invariants.js.map +1 -1
- package/dist/membership/holder.d.ts +3 -5
- package/dist/membership/holder.d.ts.map +1 -1
- package/dist/membership/holder.js +165 -88
- package/dist/membership/holder.js.map +1 -1
- package/dist/membership.d.ts +31 -0
- package/dist/membership.d.ts.map +1 -1
- package/dist/membership.js +25 -2
- package/dist/membership.js.map +1 -1
- package/dist/message/holder.d.ts +49 -0
- package/dist/message/holder.d.ts.map +1 -0
- package/dist/message/holder.js +290 -0
- package/dist/message/holder.js.map +1 -0
- package/dist/message.d.ts +43 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +51 -0
- package/dist/message.js.map +1 -0
- package/dist/receive.d.ts +4 -3
- package/dist/receive.d.ts.map +1 -1
- package/dist/receive.js +23 -4
- package/dist/receive.js.map +1 -1
- package/dist/results.d.ts +22 -3
- package/dist/results.d.ts.map +1 -1
- package/dist/results.js.map +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +9 -6
- package/dist/schemas.js.map +1 -1
- package/dist/state.d.ts +88 -14
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +2 -1
- package/dist/state.js.map +1 -1
- package/dist/trust/continuity.d.ts.map +1 -1
- package/dist/trust/continuity.js +7 -1
- package/dist/trust/continuity.js.map +1 -1
- package/dist/trust/entries.d.ts.map +1 -1
- package/dist/trust/entries.js +103 -2
- package/dist/trust/entries.js.map +1 -1
- package/dist/views.d.ts +34 -2
- package/dist/views.d.ts.map +1 -1
- package/dist/views.js +19 -1
- package/dist/views.js.map +1 -1
- package/dist/wire.d.ts +47 -6
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js.map +1 -1
- package/package.json +6 -4
- package/schemas/{holder-state-v1.schema.json → holder-state-v3.schema.json} +300 -12
- package/dist/holder-state-v1.d.ts.map +0 -1
- package/dist/holder-state-v1.js +0 -2
- package/dist/holder-state-v1.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../src/trust/entries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../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AAG,WAUxC,CAAA;AAIF;6BAC6B;AAC7B,wBAAgB,YAAY,CAAE,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAMnF;AA4BD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAE,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,cAAc,EAAE,CAAA;CAAE,GAAG,IAAI,CAetL;AAED,uDAAuD;AACvD,wBAAgB,QAAQ,CAAE,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,cAAc,EAAE,CAAA;CAAE,CA4B3I;AA4BD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAE,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CA8D/G;AAID,wBAAgB,aAAa,CAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CA+BxE"}
|
package/dist/trust/entries.js
CHANGED
|
@@ -1,3 +1,98 @@
|
|
|
1
|
+
// trust/entries — the entries of the deliverable set on the holder (lib
|
|
2
|
+
// Stage 2, PR 4c; Trust Section 2, 6a.1): merge, split, departure, the
|
|
3
|
+
// pending admission that goes with them, and the identity rewrite they
|
|
4
|
+
// need, on HolderState.
|
|
5
|
+
//
|
|
6
|
+
// Rule numbers: bare four-digit numbers are RLTP-TRU (trust-layer.md).
|
|
7
|
+
//
|
|
8
|
+
// What it registers (through trustModule, trust/mapping.ts):
|
|
9
|
+
// commands trust.merge {contactIds} the manual merge of
|
|
10
|
+
// rung 3 (6640): at most one of them holds an entry; human
|
|
11
|
+
// trust.depart {contactId, relationshipId?} departure (2260):
|
|
12
|
+
// the entry id departs the whole entry, an alias the
|
|
13
|
+
// relationship(s) whose identity it is, a relationshipId that
|
|
14
|
+
// one relationship; human
|
|
15
|
+
// duty merge/1 (2230): the persisted continuation of a merge the
|
|
16
|
+
// net (rung 2) or a chaining (2145) made admissible; it runs
|
|
17
|
+
// after the verification commit, as one atomic step
|
|
18
|
+
//
|
|
19
|
+
// The model. An entry is a Contact; its id is the identity of one of its
|
|
20
|
+
// relationships (2100, 2140). A relationship's own identity is its
|
|
21
|
+
// contactId, the contact id it was created under, which stays its identity
|
|
22
|
+
// when it is merged (then an alias of the entry) and which it takes along
|
|
23
|
+
// when it leaves (2090, 2100). A fresh relationship whose tuple a chaining
|
|
24
|
+
// appended to a chain stays as a husk (no tuples, chainedInto = the
|
|
25
|
+
// chain): its contactId is a chain alias of the chain (2090).
|
|
26
|
+
//
|
|
27
|
+
// Choices this file makes where note and spec leave them open:
|
|
28
|
+
// - every merge path but the manual act runs as a merge/1 duty: the
|
|
29
|
+
// verification (or the chaining) commits first, and the duty, run by
|
|
30
|
+
// the next resume before the sweeps, merges in one step (2230). The
|
|
31
|
+
// duty persists its witness (each entry's anchor head and the heads
|
|
32
|
+
// each held as superseded) and runs only while it holds and the binding
|
|
33
|
+
// rule and the one anchor head (6605, 6560) still hold; otherwise it is
|
|
34
|
+
// dropped silently. A verification that admits the merge of the same
|
|
35
|
+
// entries while a duty is open refreshes its witness. The manual merge
|
|
36
|
+
// (6640) involves no verification and merges in its own act
|
|
37
|
+
// - the merged entry's identity: the entry at the earliest position
|
|
38
|
+
// (2140); where none holds one, the identity of the relationship whose
|
|
39
|
+
// active head was created last (2180, entryOrder.heads)
|
|
40
|
+
// - the net (rung 2) runs on every accepted anchor mapping: the incoming
|
|
41
|
+
// relationship against every other entry when it does not lag in its
|
|
42
|
+
// own entry (6550), and, where the entry's
|
|
43
|
+
// anchor head changed, every relationship of another entry against it
|
|
44
|
+
// (6580); all entries that join in one evaluation merge in one duty
|
|
45
|
+
// (2150), taken in position order while they stay mergeable together
|
|
46
|
+
// - the split (2080) applies to the first verified mapping on a
|
|
47
|
+
// relationship of an entry whose other relationships hold an anchor:
|
|
48
|
+
// a relationship without a mapping can share an entry with others only
|
|
49
|
+
// by the manual merge (6640); see the split exception below
|
|
50
|
+
// - "oldest remaining relationship in entry-commit order" (2100): by
|
|
51
|
+
// firstVerified (the commitSeq of its first verification, 2190), never
|
|
52
|
+
// verified ones after, then by the creation of their active heads
|
|
53
|
+
// - departure removes the relationship (and its husks) from the state;
|
|
54
|
+
// its tuples' address keys become tombstones by tick's retention. Its
|
|
55
|
+
// open duties go; its outbox items run to their horizon. An entry
|
|
56
|
+
// removed with it leaves the matches of every accepted star (6160); an
|
|
57
|
+
// entry that keeps relationships keeps its matches, though the anchors
|
|
58
|
+
// behind one may have left with the relationship (a match is not
|
|
59
|
+
// re-tested without the star's key; matches only grow otherwise)
|
|
60
|
+
// - a merge rewrites every holder-local key of the merged ids to the
|
|
61
|
+
// survivor's; a rename (2100) rewrites the remaining entry's keys and
|
|
62
|
+
// the star baselines' members, so a rename alone diverges nothing; the
|
|
63
|
+
// introducer a relationship names (provenance.via) follows both; the
|
|
64
|
+
// stored acks follow through the engine (Applied.renames)
|
|
65
|
+
// - a split (2080) moves a contact reference with the relationship it
|
|
66
|
+
// was made on, never with the entry it was filed under: membership
|
|
67
|
+
// records keep the own rkid of the tuple their prelude went or arrived
|
|
68
|
+
// on (joining preludes and invites, groups' preludes and invitations,
|
|
69
|
+
// the roster entry an invitation became, and as Recipient.via the
|
|
70
|
+
// outbox items and stored acks of documents on a member key), introduction records the own
|
|
71
|
+
// pair label toward the mediator (an offer's pin, the introducer's
|
|
72
|
+
// provenance.viaPin, the voucher mark's memory.vouchedPin); a prompt
|
|
73
|
+
// follows the record it asks about
|
|
74
|
+
// - head rule (b) for the incoming relationship is read by the rationale
|
|
75
|
+
// under 6590 ("only knowledge the committed mapping newly carries
|
|
76
|
+
// connects … stale knowledge … must not create a merge"): (b) is
|
|
77
|
+
// evaluated against the links its entry held before this
|
|
78
|
+
// verification's lineage joined them (6610), while that lineage counts
|
|
79
|
+
// for (a). Read literally after the commit, 6540 would refuse every
|
|
80
|
+
// case 6530 (a) admits by a lineage that extends E's head; the wording
|
|
81
|
+
// of 6540 is a follow-up for Trust 0.32
|
|
82
|
+
// - the split exception: 2080 read literally would split every manual
|
|
83
|
+
// merge of unmapped relationships at the first mapping; open point for
|
|
84
|
+
// Trust 0.32. A relationship whose entry's other relationships hold no
|
|
85
|
+
// anchor yet stays
|
|
86
|
+
//
|
|
87
|
+
// Open point for Trust 0.32: 6540/6580/6590 in the rotation direction;
|
|
88
|
+
// today's behaviour is pinned, not justified normatively. The incoming
|
|
89
|
+
// relationship is joined against the links its entry held before the
|
|
90
|
+
// verification (the 6590 rationale, mergeDutiesAfter), the 6580 direction
|
|
91
|
+
// (an entry's anchor head changed) against the other entry's current
|
|
92
|
+
// links; so a relationship rotating up to a head another entry's lineage
|
|
93
|
+
// extends opens no merge, while the same relationships arriving the other
|
|
94
|
+
// way round can (test/trust-ported.test.mjs, "the other direction").
|
|
95
|
+
import { blockedRel, withBlocked, withoutRelationships } from '../message/holder.js';
|
|
1
96
|
import { CLASSES, anchorSet, classOnToward, conflicts, entryOf, entryRelationships, feeding, findContact, joins, lags, liveRel, newestHeads, newestOf, supersededIn, } from './state.js';
|
|
2
97
|
import { viewDigest } from './star.js';
|
|
3
98
|
import { dropOff, followClasses } from './duties.js';
|
|
@@ -91,7 +186,7 @@ function renameBaselines(t, from, to) {
|
|
|
91
186
|
function promptTuple(state, p) {
|
|
92
187
|
if (p.kind === 'group-invite') {
|
|
93
188
|
const i = Object.values(state.joining.invites).find((x) => x.promptId === p.id);
|
|
94
|
-
return i ? { rkid: i.rkid } : null;
|
|
189
|
+
return i?.rkid !== undefined ? { rkid: i.rkid } : null;
|
|
95
190
|
}
|
|
96
191
|
if (p.kind === 'introduction') {
|
|
97
192
|
if (Object.hasOwn(state.encounter.offers, p.id))
|
|
@@ -321,7 +416,11 @@ export function mergeInto(state, survivor, id, gone, bound) {
|
|
|
321
416
|
settings, groupSettings,
|
|
322
417
|
};
|
|
323
418
|
const renames = [];
|
|
324
|
-
|
|
419
|
+
// a merge sets the block on every relationship of the merged entry where
|
|
420
|
+
// any of them held it (Message Tasks RLTP-MSG-6030)
|
|
421
|
+
const relIds = contacts[id].relIds;
|
|
422
|
+
const blocked = relIds.some((r) => blockedRel(state, r)) ? withBlocked(state.messages.blocked, relIds, true) : state.messages.blocked;
|
|
423
|
+
let next = rewriteIdentity({ ...state, contacts, messages: { ...state.messages, blocked } }, merged, id, { global: true, renames });
|
|
325
424
|
next = { ...next, contacts: { ...next.contacts, [id]: settleHead(next, next.contacts[id]) } };
|
|
326
425
|
// the class duties of the merged settings (2160, 2850, 6410): per
|
|
327
426
|
// relationship against the entry it sent under before (2146)
|
|
@@ -633,6 +732,8 @@ export function depart(state, input, bound) {
|
|
|
633
732
|
};
|
|
634
733
|
// 6160: an accepted star matches the holder's contacts; one that left matches nothing
|
|
635
734
|
next = dropMatches(next, removedIds);
|
|
735
|
+
// the block and the rates of a departed relationship leave with it (Message Tasks 6.1, 4.2)
|
|
736
|
+
next = withoutRelationships(next, [...leaving]);
|
|
636
737
|
const renames = [];
|
|
637
738
|
for (const r of renamed)
|
|
638
739
|
next = rename(next, r.from, r.to, (id) => r.rels.includes(id), renames);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entries.js","sourceRoot":"","sources":["../../src/trust/entries.ts"],"names":[],"mappings":"AAgGA,OAAO,EACL,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,WAA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AAE,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;YAC/J,CAAC;SACoC;QACvC,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;YACvB,KAAK,EAAE,IAAI;YACX,KAAK,CAAE,KAAK,EAAE,EAAE,EAAE,KAAuB;gBACvC,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;gBACjD,IAAI,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,CAAC,SAAS,KAAK,EAAE;oBAAE,MAAM,IAAI,SAAS,CAAC,oDAAoD,CAAC,CAAA;gBACpI,IAAI,CAAC,CAAC,cAAc,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,CAAC,cAAc,KAAK,QAAQ,IAAI,CAAC,CAAC,cAAc,KAAK,EAAE,CAAC;oBAAE,MAAM,IAAI,SAAS,CAAC,yDAAyD,CAAC,CAAA;gBACvL,OAAO,MAAM,CAAC,KAAK,EAAE,CAAgC,EAAE,KAAK,CAAC,CAAA;YAC/D,CAAC;SACqC;KACzC,CAAA;AACH,CAAC","sourcesContent":["// trust/entries — the entries of the deliverable set on the holder (lib\n// Stage 2, PR 4c; Trust Section 2, 6a.1): merge, split, departure, the\n// pending admission that goes with them, and the identity rewrite they\n// need, on HolderState.\n//\n// Rule numbers: bare four-digit numbers are RLTP-TRU (trust-layer.md).\n//\n// What it registers (through trustModule, trust/mapping.ts):\n// commands trust.merge {contactIds} the manual merge of\n// rung 3 (6640): at most one of them holds an entry; human\n// trust.depart {contactId, relationshipId?} departure (2260):\n// the entry id departs the whole entry, an alias the\n// relationship(s) whose identity it is, a relationshipId that\n// one relationship; human\n// duty merge/1 (2230): the persisted continuation of a merge the\n// net (rung 2) or a chaining (2145) made admissible; it runs\n// after the verification commit, as one atomic step\n//\n// The model. An entry is a Contact; its id is the identity of one of its\n// relationships (2100, 2140). A relationship's own identity is its\n// contactId, the contact id it was created under, which stays its identity\n// when it is merged (then an alias of the entry) and which it takes along\n// when it leaves (2090, 2100). A fresh relationship whose tuple a chaining\n// appended to a chain stays as a husk (no tuples, chainedInto = the\n// chain): its contactId is a chain alias of the chain (2090).\n//\n// Choices this file makes where note and spec leave them open:\n// - every merge path but the manual act runs as a merge/1 duty: the\n// verification (or the chaining) commits first, and the duty, run by\n// the next resume before the sweeps, merges in one step (2230). The\n// duty persists its witness (each entry's anchor head and the heads\n// each held as superseded) and runs only while it holds and the binding\n// rule and the one anchor head (6605, 6560) still hold; otherwise it is\n// dropped silently. A verification that admits the merge of the same\n// entries while a duty is open refreshes its witness. The manual merge\n// (6640) involves no verification and merges in its own act\n// - the merged entry's identity: the entry at the earliest position\n// (2140); where none holds one, the identity of the relationship whose\n// active head was created last (2180, entryOrder.heads)\n// - the net (rung 2) runs on every accepted anchor mapping: the incoming\n// relationship against every other entry when it does not lag in its\n// own entry (6550), and, where the entry's\n// anchor head changed, every relationship of another entry against it\n// (6580); all entries that join in one evaluation merge in one duty\n// (2150), taken in position order while they stay mergeable together\n// - the split (2080) applies to the first verified mapping on a\n// relationship of an entry whose other relationships hold an anchor:\n// a relationship without a mapping can share an entry with others only\n// by the manual merge (6640); see the split exception below\n// - \"oldest remaining relationship in entry-commit order\" (2100): by\n// firstVerified (the commitSeq of its first verification, 2190), never\n// verified ones after, then by the creation of their active heads\n// - departure removes the relationship (and its husks) from the state;\n// its tuples' address keys become tombstones by tick's retention. Its\n// open duties go; its outbox items run to their horizon. An entry\n// removed with it leaves the matches of every accepted star (6160); an\n// entry that keeps relationships keeps its matches, though the anchors\n// behind one may have left with the relationship (a match is not\n// re-tested without the star's key; matches only grow otherwise)\n// - a merge rewrites every holder-local key of the merged ids to the\n// survivor's; a rename (2100) rewrites the remaining entry's keys and\n// the star baselines' members, so a rename alone diverges nothing; the\n// introducer a relationship names (provenance.via) follows both; the\n// stored acks follow through the engine (Applied.renames)\n// - a split (2080) moves a contact reference with the relationship it\n// was made on, never with the entry it was filed under: membership\n// records keep the own rkid of the tuple their prelude went or arrived\n// on (joining preludes and invites, groups' preludes and invitations,\n// the roster entry an invitation became, and as Recipient.via the\n// outbox items and stored acks of documents on a member key), introduction records the own\n// pair label toward the mediator (an offer's pin, the introducer's\n// provenance.viaPin, the voucher mark's memory.vouchedPin); a prompt\n// follows the record it asks about\n// - head rule (b) for the incoming relationship is read by the rationale\n// under 6590 (\"only knowledge the committed mapping newly carries\n// connects … stale knowledge … must not create a merge\"): (b) is\n// evaluated against the links its entry held before this\n// verification's lineage joined them (6610), while that lineage counts\n// for (a). Read literally after the commit, 6540 would refuse every\n// case 6530 (a) admits by a lineage that extends E's head; the wording\n// of 6540 is a follow-up for Trust 0.32\n// - the split exception: 2080 read literally would split every manual\n// merge of unmapped relationships at the first mapping; open point for\n// Trust 0.32. A relationship whose entry's other relationships hold no\n// anchor yet stays\n//\n// Open point for Trust 0.32: 6540/6580/6590 in the rotation direction;\n// today's behaviour is pinned, not justified normatively. The incoming\n// relationship is joined against the links its entry held before the\n// verification (the 6590 rationale, mergeDutiesAfter), the 6580 direction\n// (an entry's anchor head changed) against the other entry's current\n// links; so a relationship rotating up to a head another entry's lineage\n// extends opens no merge, while the same relationships arriving the other\n// way round can (test/trust-ported.test.mjs, \"the other direction\").\nimport type { CommandDef, DutyHandler, EventDraft, IdentityRename, Refusal, Applied } from '../engine.js'\nimport type { ClassOnDuty, Contact, Dec, Duty, HolderState, MergeDuty, Prompt, ReissueMappingDuty, Relationship, Setting, StarPair, TrustClass, Tuple } from '../state.js'\nimport {\n CLASSES, anchorSet, classOnToward, conflicts, entryOf, entryRelationships, feeding, findContact, joins, lags, liveRel, newestHeads, newestOf, supersededIn,\n} from './state.js'\nimport { viewDigest } from './star.js'\nimport { dropOff, followClasses } from './duties.js'\nimport { isKnownDuty } from '../codec.js'\nimport { jcs } from '../core.js'\nconst jcsEq = (a: unknown, b: unknown): boolean => jcs(a) === jcs(b)\n\nconst cmp = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0)\nconst cmpDec = (a: Dec, b: Dec): number => { const x = BigInt(a), y = BigInt(b); return x < y ? -1 : x > y ? 1 : 0 }\nconst byPos = (a: Readonly<Contact>, b: Readonly<Contact>): number => cmpDec(a.pos!, b.pos!) || cmp(a.id, b.id)\nconst unique = <T>(xs: Iterable<T>): T[] => [...new Set(xs)]\n\n/** The trust module's entry commands. */\nexport const ENTRY_COMMANDS = Object.freeze({ merge: 'trust.merge', depart: 'trust.depart' } as const)\n\nexport interface TrustMergeInput { contactIds: string[] }\nexport interface TrustDepartInput { contactId: string, relationshipId?: string }\n\n// ── the anchor head and admission ──────────────────────────────────────\n\n/**\n * The entry's anchor head from what its relationships hold (6560): the\n * newest of the heads its feeding relationships hold; among several\n * (a manual merge before its split) the one it holds, else `prefer`, else\n * the smallest. Where a relationship of it feeds another entry (2145), the\n * head only moves forward: with no feeding head, or none beyond it, it\n * stays. With neither, the entry has none.\n */\nexport function settleHead (state: Readonly<HolderState>, c: Readonly<Contact>, prefer: string | null = null): Contact {\n const rels = feeding(state, c)\n const all = entryRelationships(state, c)\n const newest = newestHeads(rels)\n if (!newest.length) {\n if (all.length > rels.length) return c as Contact\n return c.anchorHead === null ? c as Contact : { ...c, anchorHead: null }\n }\n // 2145: a chain of this entry feeds the other one; what the rest feeds\n // never moves the head back — it stays unless a feeding head lies\n // beyond it along the links the entry's relationships hold\n if (all.length > rels.length && c.anchorHead !== null && newestOf([...newest, c.anchorHead], all.flatMap((r) => r.links)).includes(c.anchorHead)) return c as Contact\n const head = newest.length === 1 ? newest[0]\n : c.anchorHead !== null && newest.includes(c.anchorHead) ? c.anchorHead\n : prefer !== null && newest.includes(prefer) ? prefer\n : [...newest].sort(cmp)[0]\n return head === c.anchorHead ? c as Contact : { ...c, anchorHead: head }\n}\n\n/** 2250: pending entries join the set in position order while it has room. */\nexport function admitPending (state: Readonly<HolderState>, bound: bigint): HolderState {\n let admitted = BigInt(Object.values(state.contacts).filter((x) => x.status === 'admitted').length)\n const pending = Object.values(state.contacts).filter((x) => x.status === 'pending' && x.pos !== null).sort(byPos)\n let contacts: HolderState['contacts'] | null = null\n for (const c of pending) {\n if (admitted >= bound) break\n contacts ??= { ...state.contacts }\n contacts[c.id] = { ...c, status: 'admitted' }\n admitted += 1n\n }\n return contacts ? { ...state, contacts } : state as HolderState\n}\n\n// ── the identity rewrite (2100, 2140) ──────────────────────────────────\n\ninterface RewriteOpts {\n /** the relationships whose keys move: their tuples' entryId, their\n * duties, the recipients of their documents; default all */\n rels?: (relId: string) => boolean\n /** also the keys that name the person rather than a relationship: the\n * matches of accepted stars, prompts, the entry ids of merge duties */\n global?: boolean\n /** also the members of the star baselines and in-flight views (a\n * rename: nothing diverges by it) */\n baselines?: boolean\n /** collects the rename for the engine, which follows it in the stored\n * acks (engine.ts Applied.renames) */\n renames?: IdentityRename[]\n}\n\n/** Rename members of one star scope's views, re-sorted and re-digested. */\nfunction renameView (view: StarPair[], from: (id: string) => boolean, to: string): StarPair[] | null {\n if (!view.some((p) => from(p.member))) return null\n return view.map((p) => (from(p.member) ? { ...p, member: to } : p)).sort((a, b) => cmp(a.member, b.member))\n}\n\nfunction renameBaselines (t: Tuple, from: (id: string) => boolean, to: string): Tuple {\n const o = t.starOut\n let changed = false\n let snapshot = o.snapshot\n let snapshotDigest = o.snapshotDigest\n if (snapshot) {\n const v = renameView(snapshot, from, to)\n if (v) { snapshot = v; snapshotDigest = viewDigest(v); changed = true }\n }\n const inflight: typeof o.inflight = {}\n for (const [salt, f] of Object.entries(o.inflight)) {\n const v = renameView(f.view, from, to)\n if (v) { inflight[salt] = { ...f, view: v, viewDigest: viewDigest(v) }; changed = true } else inflight[salt] = f\n }\n return changed ? { ...t, starOut: { ...o, snapshot, snapshotDigest, inflight } } : t\n}\n\n/** The tuple the record a prompt asks about was made on: a group-invite's\n * invite by its own rkid, an introduction's offer or the target's act by\n * its pin toward the mediator; null where none is held (an\n * encounter-confirm names the fresh relationship's own identity). */\nfunction promptTuple (state: Readonly<HolderState>, p: Readonly<Prompt>): { rkid: string } | { label: string } | null {\n if (p.kind === 'group-invite') {\n const i = Object.values(state.joining.invites).find((x) => x.promptId === p.id)\n return i ? { rkid: i.rkid } : null\n }\n if (p.kind === 'introduction') {\n if (Object.hasOwn(state.encounter.offers, p.id)) return { label: state.encounter.offers[p.id].pin }\n const a = Object.values(state.encounter.introductions).find((x) => x.role === 'target' && x.promptId === p.id)\n return a?.pins.mediator !== undefined ? { label: a.pins.mediator } : null\n }\n return null\n}\n\n/**\n * Every holder-local key that resolved through an identity in `ids` now\n * resolves through `to` (2100, 2140), within `opts`: tuples' entryId,\n * duties, the recipients of issued documents, and with `global` the\n * matches of accepted stars and merge duties; and the contact references\n * of the membership and introduction state and of prompts, each with the\n * relationship of the tuple it was made on (2080): by the own rkid it\n * arrived or went on (joining preludes and invites, groups' preludes,\n * invitations and roster) or the own pair label toward the mediator\n * (encounter.offers by their pin, the introducer provenance.via by\n * viaPin, memory.vouchedBy by memory.vouchedPin), a prompt with the\n * record it asks about; one that names no tuple follows with `global`.\n * Contacts are the caller's: their ids\n * and aliases are what the rewrite follows. The stored acks follow\n * through the engine (opts.renames): only the core writes the effect\n * cache, and their sealed envelopes stay as they are. Parts without a\n * change keep their identity.\n */\nexport function rewriteIdentity (state: Readonly<HolderState>, ids: readonly string[], to: string, opts: RewriteOpts = {}): HolderState {\n const from = (x: string): boolean => ids.includes(x)\n const inRel = opts.rels ?? (() => true)\n // the own rkids and pair labels of the tuples within `opts`\n const rkids = new Set<string>(), labels = new Set<string>()\n for (const [id, r] of Object.entries(state.relationships)) {\n if (inRel(id)) for (const t of r.tuples) { rkids.add(t.rkid); labels.add(t.ownPairLabel) }\n }\n const byRkid = (rkid: string | undefined): boolean => (rkid === undefined ? !!opts.global : !opts.rels || rkids.has(rkid))\n const byLabel = (label: unknown): boolean => (typeof label !== 'string' ? !!opts.global : !opts.rels || labels.has(label))\n const re = (x: string | undefined, tied: boolean): boolean => x !== undefined && from(x) && tied\n let relationships: HolderState['relationships'] | null = null\n for (const [id, r] of Object.entries(state.relationships)) {\n const mine = inRel(id)\n let changed = false\n const tuples = r.tuples.map((t) => {\n let x = t\n if (mine && from(t.entryId)) x = { ...x, entryId: to }\n const acc = x.starIn.accepted\n if (opts.global && acc && acc.matches.some(from)) {\n x = { ...x, starIn: { ...x.starIn, accepted: { ...acc, matches: unique(acc.matches.map((m) => (from(m) ? to : m))).sort(cmp) } } }\n }\n if (opts.baselines) x = renameBaselines(x, from, to)\n if (x !== t) changed = true\n return x\n })\n // the introducer with the relationship toward it the act was pinned to\n const provenance = re(r.provenance.via, byLabel(r.provenance.viaPin)) ? { ...r.provenance, via: to } : r.provenance\n if (changed || provenance !== r.provenance) (relationships ??= { ...state.relationships })[id] = { ...r, tuples, provenance }\n }\n opts.renames?.push({ from: [...ids], to, rkids: opts.rels ? [...rkids].sort() : null })\n let duties: HolderState['duties'] | null = null\n for (const [id, d] of Object.entries(state.duties)) {\n if (!isKnownDuty(d)) continue // a kind or version this library does not handle stays as it is\n const x = d as unknown as Record<string, unknown>\n let nd: Duty = d\n if (d.kind === 'merge' && opts.global && Array.isArray(x.entryIds) && (x.entryIds as string[]).some(from)) {\n nd = { ...d, entryIds: unique((x.entryIds as string[]).map((e) => (from(e) ? to : e))).sort(cmp) } as Duty\n } else if (d.kind !== 'merge' && typeof x.contactId === 'string' && from(x.contactId) && (typeof x.relId !== 'string' || inRel(x.relId))) {\n nd = { ...d, contactId: to } as Duty\n }\n if (nd !== d) (duties ??= { ...state.duties })[id] = nd\n }\n // membership, introduction and prompts: each contact reference with the\n // relationship of the tuple it was made on, where it names one (2080)\n let prompts: HolderState['prompts'] | null = null\n for (const [id, p] of Object.entries(state.prompts)) {\n const at = promptTuple(state, p)\n const tied = at === null ? !!opts.global : 'rkid' in at ? byRkid(at.rkid) : byLabel(at.label)\n if (re(p.contactId, tied)) (prompts ??= { ...state.prompts })[id] = { ...p, contactId: to }\n }\n let joining: HolderState['joining'] | null = null\n for (const [k, p] of Object.entries(state.joining.preludes)) {\n if (re(p.contactId, byRkid(p.rkid))) (joining ??= { ...state.joining, preludes: { ...state.joining.preludes } }).preludes[k] = { ...p, contactId: to }\n }\n for (const [k, i] of Object.entries(state.joining.invites)) {\n if (re(i.contactId, byRkid(i.rkid))) {\n joining ??= { ...state.joining, preludes: { ...state.joining.preludes } }\n joining.invites = { ...joining.invites, [k]: { ...i, contactId: to } }\n }\n }\n let groups: HolderState['groups'] | null = null\n for (const [gid, g] of Object.entries(state.groups)) {\n const preludes = Object.fromEntries(Object.entries(g.preludes).map(([k, p]) => [k, re(p.contactId, byRkid(p.rkid)) ? { ...p, contactId: to } : p]))\n const invitations = Object.fromEntries(Object.entries(g.invitations).map(([k, i]) => [k, re(i.contactId, byRkid(i.rkid)) ? { ...i, contactId: to } : i]))\n const roster = Object.fromEntries(Object.entries(g.roster).map(([k, m]) => [k, re(m.contactId, byRkid(m.rkid)) ? { ...m, contactId: to } : m]))\n if (jcsEq(preludes, g.preludes) && jcsEq(invitations, g.invitations) && jcsEq(roster, g.roster)) continue\n ;(groups ??= { ...state.groups })[gid] = { ...g, preludes, invitations, roster }\n }\n let encounter: HolderState['encounter'] | null = null\n for (const [k, o] of Object.entries(state.encounter.offers)) {\n if (re(o.mediatorContactId, byLabel(o.pin))) (encounter ??= { ...state.encounter, offers: { ...state.encounter.offers } }).offers[k] = { ...o, mediatorContactId: to }\n }\n // the voucher mark names the mediator that vouched: it follows the\n // relationship toward that mediator the voucher came on (memory.vouchedPin),\n // not the entry it was filed under\n for (const [id, r] of Object.entries(relationships ?? state.relationships)) {\n const v = r.memory.vouchedBy\n if (typeof v === 'string' && re(v, byLabel(r.memory.vouchedPin))) (relationships ??= { ...state.relationships })[id] = { ...r, memory: { ...r.memory, vouchedBy: to } }\n }\n let outbox: HolderState['outbox'] | null = null\n for (const [d, it] of Object.entries(state.outbox)) {\n // a document on a member key follows the tuple its contact was named through (Recipient.via)\n if (from(it.recipient.contactId) && rkids.has(it.recipient.via ?? it.recipient.rkid)) (outbox ??= { ...state.outbox })[d] = { ...it, recipient: { ...it.recipient, contactId: to } }\n }\n if (!relationships && !duties && !prompts && !outbox && !joining && !groups && !encounter) return state as HolderState\n return {\n ...state,\n ...(relationships ? { relationships } : {}), ...(duties ? { duties } : {}), ...(prompts ? { prompts } : {}), ...(outbox ? { outbox } : {}),\n ...(joining ? { joining } : {}), ...(groups ? { groups } : {}), ...(encounter ? { encounter } : {}),\n }\n}\n\n// ── merge (2140–2180) ──────────────────────────────────────────────────\n\n/** 2160: per class `off` where any held `off`, else `on` where any held\n * `on`, else `default`; per (group, contact) the same, every per-group\n * `on` reset where the merged sealed group star is `off` (5450). */\nexport function mergeSettings (cs: readonly Readonly<Contact>[]): { settings: Record<TrustClass, Setting>, groupSettings: Record<string, Setting> } {\n const pick = (xs: Setting[]): Setting => (xs.includes('off') ? 'off' : xs.includes('on') ? 'on' : 'default')\n const settings = {} as Record<TrustClass, Setting>\n for (const cls of CLASSES) settings[cls] = pick(cs.map((c) => c.settings[cls]))\n const groupSettings: Record<string, Setting> = {}\n for (const g of unique(cs.flatMap((c) => Object.keys(c.groupSettings))).sort(cmp)) {\n const s = pick(cs.map((c) => c.groupSettings[g] ?? 'default'))\n if (s === 'off' || (s === 'on' && settings.sealedGroupStar !== 'off')) groupSettings[g] = s\n }\n return { settings, groupSettings }\n}\n\n/**\n * Whether entries can be one (6605, 6560): no relationship of one holds\n * another binding (or another successor) for an anchor a relationship of\n * another holds, and their anchor heads lie on one chain of the links\n * their relationships hold, so the merged entry has exactly one.\n */\nexport function mergeable (state: Readonly<HolderState>, cs: readonly Readonly<Contact>[]): boolean {\n if (cs.length < 2 || new Set(cs.map((c) => c.id)).size !== cs.length) return false\n const rels = cs.map((c) => entryRelationships(state, c))\n for (let i = 0; i < rels.length; i++) for (let j = i + 1; j < rels.length; j++) if (conflicts(rels[i], rels[j])) return false\n const all = unique(rels.flat())\n const heads = [...cs.map((c) => c.anchorHead), ...all.map((r) => r.heldCounterpartHead)].filter((h): h is string => h !== null)\n return newestOf(heads, all.flatMap((r) => r.links)).length <= 1\n}\n\n/** Where the newest active head among the entries' relationships was created (2180). */\nfunction newestRelationship (state: Readonly<HolderState>, cs: readonly Readonly<Contact>[]): Relationship | undefined {\n let best: Relationship | undefined\n let at = -1\n for (const c of cs) {\n for (const r of entryRelationships(state, c)) {\n const i = state.entryOrder.heads.indexOf(r.id)\n if (i > at) { at = i; best = r }\n }\n }\n return best\n}\n\n/**\n * The atomic merge of entries (2140, 2150, 2160, 2180): one entry at the\n * earliest position under the survivor's identity, the others its\n * aliases; admitted where any was, so `k` admitted ones free `k−1` slots,\n * which the next pending entries take in position order in the same step;\n * every key of a merged id rewritten to the survivor; the anchor head\n * settled (6560). Per-tuple keys stay with their tuples.\n */\nexport function mergeEntries (state: Readonly<HolderState>, cs: readonly Readonly<Contact>[], bound: bigint): Applied & { survivor: string } {\n const withPos = cs.filter((c) => c.pos !== null).sort(byPos)\n let survivor: Readonly<Contact>\n let id: string\n if (withPos.length) { survivor = withPos[0]; id = survivor.id } else {\n const r = newestRelationship(state, cs)\n survivor = (r && cs.find((c) => c.relIds.includes(r.id))) ?? cs[0]\n // the relationship's identity, where it names the survivor (2180)\n id = r && findContact(state, r.contactId)?.id === survivor.id ? r.contactId : survivor.id\n }\n return mergeInto(state, survivor, id, cs.filter((c) => c !== survivor), bound)\n}\n\n/** The merge onto a chosen survivor under identity `id` (its id or one of its aliases). */\nexport function mergeInto (state: Readonly<HolderState>, survivor: Readonly<Contact>, id: string, gone: readonly Readonly<Contact>[], bound: bigint): Applied & { survivor: string } {\n const all = [survivor, ...gone]\n const { settings, groupSettings } = mergeSettings(all)\n const status: Contact['status'] = all.some((c) => c.status === 'admitted') ? 'admitted' : all.some((c) => c.status === 'pending') ? 'pending' : 'none'\n const positioned = all.filter((c) => c.pos !== null).sort(byPos)\n const merged = all.map((c) => c.id).filter((x) => x !== id)\n const contacts = { ...state.contacts }\n for (const c of all) delete contacts[c.id]\n contacts[id] = {\n id, pos: positioned[0]?.pos ?? null, status,\n aliases: unique(all.flatMap((c) => [c.id, ...c.aliases])).filter((x) => x !== id).sort(cmp),\n relIds: unique(all.flatMap((c) => c.relIds)),\n anchorHead: survivor.anchorHead ?? positioned.find((c) => c.anchorHead !== null)?.anchorHead ?? null,\n settings, groupSettings,\n }\n const renames: IdentityRename[] = []\n let next: HolderState = rewriteIdentity({ ...state, contacts }, merged, id, { global: true, renames })\n next = { ...next, contacts: { ...next.contacts, [id]: settleHead(next, next.contacts[id]) } }\n // the class duties of the merged settings (2160, 2850, 6410): per\n // relationship against the entry it sent under before (2146)\n const f = followClasses(state, admitPending(next, bound))\n next = f.state\n return {\n state: next, events: [{ type: 'contact.merged', contactId: id, merged: [...merged].sort(cmp) }],\n ...(f.duties.length ? { duties: f.duties } : {}), renames, survivor: id,\n }\n}\n\n/**\n * The merge duties a commit on `relId` opens (2230): where the\n * relationship stands behind another entry (2145) that is now mergeable\n * with its own, and, with `net`, the convergence net of rung 2 for an\n * accepted anchor mapping (6520–6605). One duty for every entry that\n * joins, in position order while they stay mergeable together (2150).\n */\nexport function mergeDutiesAfter (before: Readonly<HolderState>, after: HolderState, relId: string, opts: { net: boolean }): { state: HolderState, duties: MergeDuty[] } {\n const none = { state: after, duties: [] }\n const rel = after.relationships[relId]\n const E = rel && entryOf(after, rel)\n if (!E || E.pos === null || E.anchorHead === null) return none\n const eRels = entryRelationships(after, E)\n const others = Object.values(after.contacts).filter((x) => x.id !== E.id && x.pos !== null && x.anchorHead !== null).sort(byPos)\n const picked: Contact[] = []\n const take = (x: Contact): void => { if (!picked.includes(x) && mergeable(after, [E, ...picked, x])) picked.push(x) }\n // 2145: the other entry behind this relationship, once comparable and the binding rule admits\n for (const t of rel.tuples) {\n const x = findContact(after, t.entryId)\n if (x && x.id !== E.id && x.pos !== null && x.anchorHead !== null) take(x)\n }\n if (opts.net) {\n // the incoming relationship, where it does not lag in its own entry\n // (6550). Head rule (b) against the knowledge the entry held before\n // this commit: its relationships' links with this relationship's taken\n // from before the 6610 union of this verification. What the mapping\n // newly carries counts for (a) only (the 6590 rationale reading)\n if (rel.heldCounterpartHead === E.anchorHead) {\n const relB = Object.hasOwn(before.relationships, relId) ? before.relationships[relId] : rel\n const own = supersededIn(eRels.map((r) => (r.id === relId ? relB : r)))\n for (const x of others) if (joins(rel, x, entryRelationships(after, x), own)) take(x)\n }\n // 6580: E's anchor head changed — every relationship of another entry against E\n if (findContact(before, E.id)?.anchorHead !== E.anchorHead) {\n for (const x of others) {\n const xs = entryRelationships(after, x)\n if (feeding(after, x).some((r) => r.heldCounterpartHead === x.anchorHead && joins(r, E, eRels, supersededIn(xs)))) take(x)\n }\n }\n }\n if (!picked.length) return none\n const cs = [E, ...picked]\n const ids = cs.map((c) => c.id).sort(cmp)\n const id = 'merge:' + ids.join('|')\n const duty: MergeDuty = { kind: 'merge', v: 1, id, entryIds: ids, relId, witness: witnessOf(after, cs) }\n // a duty open for the same entries takes the new admission's witness\n if (Object.hasOwn(after.duties, id)) return { state: { ...after, duties: { ...after.duties, [id]: { ...after.duties[id], ...duty } as Duty } }, duties: [] }\n return { state: after, duties: [duty] }\n}\n\n/** The heads and superseded sets a merge is admitted against. */\nfunction witnessOf (state: Readonly<HolderState>, cs: readonly Readonly<Contact>[]): MergeDuty['witness'] {\n const heads: Record<string, string> = {}\n const superseded: Record<string, string[]> = {}\n for (const c of cs) heads[c.id] = c.anchorHead!\n for (const y of cs) {\n const sup = supersededIn(entryRelationships(state, y))\n superseded[y.id] = unique(cs.filter((x) => x !== y && sup.has(x.anchorHead!)).map((x) => x.anchorHead!)).sort(cmp)\n }\n return { heads, superseded }\n}\n\n/**\n * Whether the merge a duty was opened for still stands (6540, 6550,\n * 6605): every entry still holds the anchor head it was admitted with, no\n * entry holds another's head as superseded beyond what it did then, the\n * relationship that opened it is still one of theirs, and the entries are\n * mergeable (the binding rule, one anchor head).\n */\nfunction witnessHolds (state: Readonly<HolderState>, d: Readonly<MergeDuty>, cs: readonly Readonly<Contact>[]): boolean {\n const w = d.witness\n if (cs.some((c) => !Object.hasOwn(w.heads, c.id) || c.anchorHead !== w.heads[c.id])) return false\n if (!cs.some((c) => c.relIds.includes(d.relId))) return false\n for (const y of cs) {\n const sup = supersededIn(entryRelationships(state, y))\n for (const x of cs) if (x !== y && sup.has(x.anchorHead!) && !(w.superseded[y.id] ?? []).includes(x.anchorHead!)) return false\n }\n return mergeable(state, cs)\n}\n\n/** merge/1: the merge as one step after the verification commit (2230),\n * re-checked against its witness; where it no longer holds, the duty is\n * dropped without a trace (a later verification may open another). */\nexport const mergeDuty = (bound: bigint): DutyHandler => ({\n v: 1,\n apply (state, duty) {\n const d = duty as MergeDuty\n const cs = unique(d.entryIds.map((x) => findContact(state, x)).filter((c): c is Contact => c !== undefined))\n // the state moved since the commit that opened it: nothing (left) to merge\n if (cs.length < 2 || cs.some((c) => c.pos === null) || !witnessHolds(state, d, cs)) return { state: state as HolderState }\n const r = mergeEntries(state, cs, bound)\n return { state: r.state, ...(r.events ? { events: r.events } : {}), ...(r.duties ? { duties: r.duties } : {}), ...(r.renames ? { renames: r.renames } : {}) }\n },\n})\n\n// ── split (2080–2115) ──────────────────────────────────────────────────\n\n/** The chain aliases of a relationship (2090): the identities of the\n * husks chained into it. */\nexport function chainAliases (state: Readonly<HolderState>, relId: string): string[] {\n const out: string[] = []\n for (const r of Object.values(state.relationships)) {\n if (r.chainedInto === relId) out.push(r.contactId, ...chainAliases(state, r.id))\n }\n return unique(out).sort(cmp)\n}\n\n/** The husks chained into `relId`, transitively. */\nconst husksOf = (state: Readonly<HolderState>, relId: string): string[] =>\n Object.values(state.relationships).filter((r) => r.chainedInto === relId).flatMap((r) => [r.id, ...husksOf(state, r.id)])\n\n/**\n * The identity an entry takes when the relationship whose identity it was\n * leaves (2100): its oldest remaining relationship's in entry-commit order\n * (firstVerified, unverified after, then active-head creation), among those\n * whose identity resolves to this entry; the relationship's id where none\n * does (a relationship behind two entries, 2145).\n */\nfunction oldestIdentity (state: Readonly<HolderState>, c: Readonly<Contact>, remaining: readonly string[], exclude: ReadonlySet<string>): string {\n const heads = state.entryOrder.heads\n const rels = remaining.filter((id) => Object.hasOwn(state.relationships, id)).map((id) => state.relationships[id]).sort((a, b) => {\n if (a.firstVerified !== null && b.firstVerified !== null) { const d = cmpDec(a.firstVerified, b.firstVerified); if (d) return d }\n if ((a.firstVerified === null) !== (b.firstVerified === null)) return a.firstVerified === null ? 1 : -1\n return (heads.indexOf(a.id) - heads.indexOf(b.id)) || cmp(a.id, b.id)\n })\n const own = rels.find((r) => !exclude.has(r.contactId) && (r.contactId === c.id || c.aliases.includes(r.contactId)))\n return own ? own.contactId : rels[0].id\n}\n\n/** The keys of the entry's relationships resolve through its new id (2100). */\nconst rename = (state: HolderState, oldId: string, id: string, rels: (relId: string) => boolean, renames: IdentityRename[]): HolderState =>\n rewriteIdentity(state, [oldId], id, { rels, global: true, baselines: true, renames })\n\n/**\n * 2080: the first verified mapping on `relId`, already in `mid`, leaves it\n * holding no anchor the other relationships of its entry hold, or another\n * binding for one they hold: the split, else null. The entry keeps its\n * position, status, the remaining relationships with their aliases and\n * its settings, frees no slot and settles its anchor head; the leaver\n * takes its identity, its chain aliases and the settings of 2115, and\n * holds no position until the caller's entry commit (2090).\n */\nexport function splitIfUnlinked (before: Readonly<HolderState>, mid: Readonly<HolderState>, relId: string): { state: HolderState, event: EventDraft, renames: IdentityRename[] } | null {\n if (before.relationships[relId]?.heldCounterpartHead !== null) return null\n const rel = mid.relationships[relId]\n const E = entryOf(mid, rel)\n if (!E) return null\n const others = entryRelationships(mid, E).filter((r) => r.id !== relId)\n const holding = others.filter((r) => r.heldCounterpartHead !== null)\n // 2080 read literally would split every manual merge of unmapped\n // relationships at the first mapping; open point for Trust 0.32. Here\n // the relationship stays where the others hold no anchor to contradict\n if (!holding.length) return null\n const mine = anchorSet(rel)\n const shares = holding.some((o) => [...anchorSet(o)].some((a) => mine.has(a)))\n if (shares && !conflicts([rel], others)) return null\n return splitOff(mid, relId)\n}\n\n/** The split of `relId` from its entry (2080–2115). */\nexport function splitOff (state: Readonly<HolderState>, relId: string): { state: HolderState, event: EventDraft, renames: IdentityRename[] } {\n const rel = state.relationships[relId]\n const E = entryOf(state, rel)!\n const identity = rel.contactId\n const chain = chainAliases(state, relId)\n const leaverIds = new Set([identity, ...chain])\n const remaining = E.relIds.filter((id) => id !== relId)\n const eId = leaverIds.has(E.id) ? oldestIdentity(state, E, remaining, leaverIds) : E.id\n // 2115: every class at default, except an `off` of the merged entry, which goes along\n const settings = {} as Record<TrustClass, Setting>\n for (const cls of CLASSES) settings[cls] = E.settings[cls] === 'off' ? 'off' : 'default'\n const groupSettings: Record<string, Setting> = {}\n for (const [g, s] of Object.entries(E.groupSettings)) if (s === 'off') groupSettings[g] = 'off'\n const contacts = { ...state.contacts }\n delete contacts[E.id]\n contacts[eId] = { ...E, id: eId, relIds: remaining, aliases: E.aliases.filter((a) => !leaverIds.has(a) && a !== eId) }\n contacts[identity] = {\n id: identity, pos: null, status: 'none', aliases: chain.filter((a) => a !== identity), relIds: [relId], anchorHead: null, settings, groupSettings,\n }\n // the leaver's keys go to its own entry (2145 entryId, its duties and recipients)\n const renames: IdentityRename[] = []\n let next = rewriteIdentity({ ...state, contacts }, [E.id, ...E.aliases], identity, { rels: (id) => id === relId, renames })\n // the remaining entry's keys that resolved through the old identity (2100)\n if (eId !== E.id) next = rename(next, E.id, eId, (id) => id !== relId, renames)\n next = { ...next, contacts: { ...next.contacts, [eId]: settleHead(next, next.contacts[eId]) } }\n // the leaver's classes start at default (2115): the trusted contacts' classes off with the anchor mapping (6410)\n next = dropOff(next).state\n return { state: next, event: { type: 'contact.split', contactId: eId, leaver: identity, relationshipId: relId }, renames }\n}\n\n// ── departure (2210, 2250, 2260, 5860) ─────────────────────────────────\n\nconst needInput = (x: unknown, name: string): Record<string, unknown> => {\n if (x === null || typeof x !== 'object' || Array.isArray(x)) throw new TypeError(`${name} needs an input object`)\n return x as Record<string, unknown>\n}\n\n/** The matches of every accepted star without the entry ids `ids` (6160). */\nfunction dropMatches (state: HolderState, ids: readonly string[]): HolderState {\n if (!ids.length) return state\n let relationships: HolderState['relationships'] | null = null\n for (const [id, r] of Object.entries(state.relationships)) {\n if (!r.tuples.some((t) => t.starIn.accepted?.matches.some((m) => ids.includes(m)))) continue\n const tuples = r.tuples.map((t) => {\n const acc = t.starIn.accepted\n return acc && acc.matches.some((m) => ids.includes(m)) ? { ...t, starIn: { ...t.starIn, accepted: { ...acc, matches: acc.matches.filter((m) => !ids.includes(m)) } } } : t\n })\n ;(relationships ??= { ...state.relationships })[id] = { ...r, tuples }\n }\n return relationships ? { ...state, relationships } : state\n}\n\n/** The identities of a relationship: its own and its chain aliases. */\nconst identitiesOf = (state: Readonly<HolderState>, relId: string): string[] =>\n [state.relationships[relId].contactId, ...chainAliases(state, relId)]\n\n/**\n * Departure: the relationships leave the state with their husks; an entry\n * left without relationships is removed (pending: 2260; admitted: its\n * slot frees, 2250), one that keeps some drops their aliases, takes a new\n * identity where theirs was its own (2100) and settles its anchor head\n * (2080); pending entries are admitted in position order in the same\n * step, so the set changes once (5860).\n */\nexport function depart (state: Readonly<HolderState>, input: TrustDepartInput, bound: bigint): Applied | Refusal {\n const c = findContact(state, input.contactId)\n if (!c) return { ok: false, code: 'unknown-contact' }\n let relIds: string[]\n if (input.relationshipId !== undefined) {\n if (!c.relIds.includes(input.relationshipId)) return { ok: false, code: 'unknown-contact' }\n relIds = [input.relationshipId]\n } else if (input.contactId !== c.id) {\n relIds = c.relIds.filter((rid) => Object.hasOwn(state.relationships, rid) && identitiesOf(state, rid).includes(input.contactId))\n } else relIds = [...c.relIds]\n const leaving = new Set(relIds.flatMap((rid) => [rid, ...husksOf(state, rid)]))\n const goneIds = new Set([...relIds.flatMap((rid) => (Object.hasOwn(state.relationships, rid) ? identitiesOf(state, rid) : []))])\n if (input.contactId !== c.id && input.relationshipId === undefined) goneIds.add(input.contactId) // an alias without a relationship\n const relationships: HolderState['relationships'] = {}\n for (const [id, r] of Object.entries(state.relationships)) if (!leaving.has(id)) relationships[id] = r\n const contacts: HolderState['contacts'] = {}\n const renamed: Array<{ from: string, to: string, rels: string[] }> = []\n let removed = false\n const removedIds: string[] = []\n for (const x of Object.values(state.contacts)) {\n const rest = x.relIds.filter((id) => !leaving.has(id))\n if (rest.length === x.relIds.length && !x.aliases.some((a) => goneIds.has(a))) { contacts[x.id] = x; continue }\n if (!rest.length) { if (x.id === c.id) removed = true; removedIds.push(x.id); continue }\n const id = goneIds.has(x.id) ? oldestIdentity(state, x, rest, goneIds) : x.id\n if (id !== x.id) renamed.push({ from: x.id, to: id, rels: rest })\n contacts[id] = { ...x, id, relIds: rest, aliases: x.aliases.filter((a) => !goneIds.has(a) && a !== id) }\n }\n const duties: HolderState['duties'] = {}\n for (const [id, d] of Object.entries(state.duties)) {\n const relOf = (d as { relId?: unknown }).relId\n // a duty of a kind (or version) this library does not know is kept as it is\n if (typeof relOf === 'string' && leaving.has(relOf) && d.kind !== 'merge' && isKnownDuty(d)) continue\n duties[id] = d\n }\n const rotations: HolderState['rotations'] = {}\n for (const [id, r] of Object.entries(state.rotations)) {\n rotations[id] = Object.keys(r.awaitHead).some((k) => leaving.has(k))\n ? { ...r, awaitHead: Object.fromEntries(Object.entries(r.awaitHead).filter(([k]) => !leaving.has(k))) }\n : r\n }\n let next: HolderState = {\n ...state, relationships, contacts, duties, rotations,\n entryOrder: { ...state.entryOrder, heads: state.entryOrder.heads.filter((id) => !leaving.has(id)) },\n }\n // 6160: an accepted star matches the holder's contacts; one that left matches nothing\n next = dropMatches(next, removedIds)\n const renames: IdentityRename[] = []\n for (const r of renamed) next = rename(next, r.from, r.to, (id) => r.rels.includes(id), renames)\n for (const x of Object.values(next.contacts)) {\n const s = settleHead(next, x)\n if (s !== x) next = { ...next, contacts: { ...next.contacts, [x.id]: s } }\n }\n // 2850: a relationship that ceased to lag with the departure gets the classes on for it\n const f = followClasses(state, admitPending(next, bound))\n next = f.state\n return {\n ...(f.duties.length ? { duties: f.duties } : {}),\n state: next, events: [{ type: 'contact.departed', contactId: c.id, relationshipIds: relIds.filter((id) => Object.hasOwn(state.relationships, id)).sort(cmp), removed }],\n ...(renames.length ? { renames } : {}),\n }\n}\n\n// ── the commands ───────────────────────────────────────────────────────\n\nexport function entryCommands (bound: bigint): Record<string, CommandDef> {\n return {\n // rung 3: the manual merge (6640)\n [ENTRY_COMMANDS.merge]: {\n human: true,\n apply (state, _p, input: TrustMergeInput) {\n const i = needInput(input, ENTRY_COMMANDS.merge)\n if (!Array.isArray(i.contactIds) || i.contactIds.some((x) => typeof x !== 'string' || x === '')) throw new TypeError('trust.merge: contactIds must be non-empty strings')\n const cs: Contact[] = []\n for (const x of i.contactIds as string[]) {\n const c = findContact(state, x)\n if (!c) return { ok: false, code: 'unknown-contact' }\n if (!cs.includes(c)) cs.push(c)\n }\n if (cs.length < 2) return { state: state as HolderState }\n if (cs.filter((c) => c.pos !== null).length > 1) return { ok: false, code: 'not-mergeable', ref: 'RLTP-TRU-6640' }\n if (!mergeable(state, cs)) return { ok: false, code: 'not-mergeable', ref: 'RLTP-TRU-6605' }\n const r = mergeEntries(state, cs, bound)\n return { state: r.state, ...(r.events ? { events: r.events } : {}), ...(r.duties ? { duties: r.duties } : {}), ...(r.renames ? { renames: r.renames } : {}) }\n },\n } satisfies CommandDef<TrustMergeInput>,\n [ENTRY_COMMANDS.depart]: {\n human: true,\n apply (state, _p, input: TrustDepartInput) {\n const i = needInput(input, ENTRY_COMMANDS.depart)\n if (typeof i.contactId !== 'string' || i.contactId === '') throw new TypeError('trust.depart: contactId must be a non-empty string')\n if (i.relationshipId !== undefined && (typeof i.relationshipId !== 'string' || i.relationshipId === '')) throw new TypeError('trust.depart: relationshipId must be a non-empty string')\n return depart(state, i as unknown as TrustDepartInput, bound)\n },\n } satisfies CommandDef<TrustDepartInput>,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"entries.js","sourceRoot":"","sources":["../../src/trust/entries.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,uEAAuE;AACvE,uEAAuE;AACvE,wBAAwB;AACxB,EAAE;AACF,uEAAuE;AACvE,EAAE;AACF,6DAA6D;AAC7D,yEAAyE;AACzE,yEAAyE;AACzE,4EAA4E;AAC5E,mEAAmE;AACnE,4EAA4E;AAC5E,wCAAwC;AACxC,wEAAwE;AACxE,yEAAyE;AACzE,gEAAgE;AAChE,EAAE;AACF,yEAAyE;AACzE,mEAAmE;AACnE,2EAA2E;AAC3E,0EAA0E;AAC1E,2EAA2E;AAC3E,oEAAoE;AACpE,8DAA8D;AAC9D,EAAE;AACF,+DAA+D;AAC/D,sEAAsE;AACtE,yEAAyE;AACzE,wEAAwE;AACxE,wEAAwE;AACxE,4EAA4E;AAC5E,4EAA4E;AAC5E,yEAAyE;AACzE,2EAA2E;AAC3E,gEAAgE;AAChE,sEAAsE;AACtE,2EAA2E;AAC3E,4DAA4D;AAC5D,2EAA2E;AAC3E,yEAAyE;AACzE,+CAA+C;AAC/C,0EAA0E;AAC1E,wEAAwE;AACxE,yEAAyE;AACzE,kEAAkE;AAClE,yEAAyE;AACzE,2EAA2E;AAC3E,gEAAgE;AAChE,uEAAuE;AACvE,2EAA2E;AAC3E,sEAAsE;AACtE,yEAAyE;AACzE,0EAA0E;AAC1E,sEAAsE;AACtE,2EAA2E;AAC3E,2EAA2E;AAC3E,qEAAqE;AACrE,qEAAqE;AACrE,uEAAuE;AACvE,0EAA0E;AAC1E,2EAA2E;AAC3E,yEAAyE;AACzE,8DAA8D;AAC9D,wEAAwE;AACxE,uEAAuE;AACvE,2EAA2E;AAC3E,0EAA0E;AAC1E,sEAAsE;AACtE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AC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;YAC/J,CAAC;SACoC;QACvC,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;YACvB,KAAK,EAAE,IAAI;YACX,KAAK,CAAE,KAAK,EAAE,EAAE,EAAE,KAAuB;gBACvC,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;gBACjD,IAAI,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,CAAC,SAAS,KAAK,EAAE;oBAAE,MAAM,IAAI,SAAS,CAAC,oDAAoD,CAAC,CAAA;gBACpI,IAAI,CAAC,CAAC,cAAc,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,CAAC,cAAc,KAAK,QAAQ,IAAI,CAAC,CAAC,cAAc,KAAK,EAAE,CAAC;oBAAE,MAAM,IAAI,SAAS,CAAC,yDAAyD,CAAC,CAAA;gBACvL,OAAO,MAAM,CAAC,KAAK,EAAE,CAAgC,EAAE,KAAK,CAAC,CAAA;YAC/D,CAAC;SACqC;KACzC,CAAA;AACH,CAAC","sourcesContent":["// trust/entries — the entries of the deliverable set on the holder (lib\n// Stage 2, PR 4c; Trust Section 2, 6a.1): merge, split, departure, the\n// pending admission that goes with them, and the identity rewrite they\n// need, on HolderState.\n//\n// Rule numbers: bare four-digit numbers are RLTP-TRU (trust-layer.md).\n//\n// What it registers (through trustModule, trust/mapping.ts):\n// commands trust.merge {contactIds} the manual merge of\n// rung 3 (6640): at most one of them holds an entry; human\n// trust.depart {contactId, relationshipId?} departure (2260):\n// the entry id departs the whole entry, an alias the\n// relationship(s) whose identity it is, a relationshipId that\n// one relationship; human\n// duty merge/1 (2230): the persisted continuation of a merge the\n// net (rung 2) or a chaining (2145) made admissible; it runs\n// after the verification commit, as one atomic step\n//\n// The model. An entry is a Contact; its id is the identity of one of its\n// relationships (2100, 2140). A relationship's own identity is its\n// contactId, the contact id it was created under, which stays its identity\n// when it is merged (then an alias of the entry) and which it takes along\n// when it leaves (2090, 2100). A fresh relationship whose tuple a chaining\n// appended to a chain stays as a husk (no tuples, chainedInto = the\n// chain): its contactId is a chain alias of the chain (2090).\n//\n// Choices this file makes where note and spec leave them open:\n// - every merge path but the manual act runs as a merge/1 duty: the\n// verification (or the chaining) commits first, and the duty, run by\n// the next resume before the sweeps, merges in one step (2230). The\n// duty persists its witness (each entry's anchor head and the heads\n// each held as superseded) and runs only while it holds and the binding\n// rule and the one anchor head (6605, 6560) still hold; otherwise it is\n// dropped silently. A verification that admits the merge of the same\n// entries while a duty is open refreshes its witness. The manual merge\n// (6640) involves no verification and merges in its own act\n// - the merged entry's identity: the entry at the earliest position\n// (2140); where none holds one, the identity of the relationship whose\n// active head was created last (2180, entryOrder.heads)\n// - the net (rung 2) runs on every accepted anchor mapping: the incoming\n// relationship against every other entry when it does not lag in its\n// own entry (6550), and, where the entry's\n// anchor head changed, every relationship of another entry against it\n// (6580); all entries that join in one evaluation merge in one duty\n// (2150), taken in position order while they stay mergeable together\n// - the split (2080) applies to the first verified mapping on a\n// relationship of an entry whose other relationships hold an anchor:\n// a relationship without a mapping can share an entry with others only\n// by the manual merge (6640); see the split exception below\n// - \"oldest remaining relationship in entry-commit order\" (2100): by\n// firstVerified (the commitSeq of its first verification, 2190), never\n// verified ones after, then by the creation of their active heads\n// - departure removes the relationship (and its husks) from the state;\n// its tuples' address keys become tombstones by tick's retention. Its\n// open duties go; its outbox items run to their horizon. An entry\n// removed with it leaves the matches of every accepted star (6160); an\n// entry that keeps relationships keeps its matches, though the anchors\n// behind one may have left with the relationship (a match is not\n// re-tested without the star's key; matches only grow otherwise)\n// - a merge rewrites every holder-local key of the merged ids to the\n// survivor's; a rename (2100) rewrites the remaining entry's keys and\n// the star baselines' members, so a rename alone diverges nothing; the\n// introducer a relationship names (provenance.via) follows both; the\n// stored acks follow through the engine (Applied.renames)\n// - a split (2080) moves a contact reference with the relationship it\n// was made on, never with the entry it was filed under: membership\n// records keep the own rkid of the tuple their prelude went or arrived\n// on (joining preludes and invites, groups' preludes and invitations,\n// the roster entry an invitation became, and as Recipient.via the\n// outbox items and stored acks of documents on a member key), introduction records the own\n// pair label toward the mediator (an offer's pin, the introducer's\n// provenance.viaPin, the voucher mark's memory.vouchedPin); a prompt\n// follows the record it asks about\n// - head rule (b) for the incoming relationship is read by the rationale\n// under 6590 (\"only knowledge the committed mapping newly carries\n// connects … stale knowledge … must not create a merge\"): (b) is\n// evaluated against the links its entry held before this\n// verification's lineage joined them (6610), while that lineage counts\n// for (a). Read literally after the commit, 6540 would refuse every\n// case 6530 (a) admits by a lineage that extends E's head; the wording\n// of 6540 is a follow-up for Trust 0.32\n// - the split exception: 2080 read literally would split every manual\n// merge of unmapped relationships at the first mapping; open point for\n// Trust 0.32. A relationship whose entry's other relationships hold no\n// anchor yet stays\n//\n// Open point for Trust 0.32: 6540/6580/6590 in the rotation direction;\n// today's behaviour is pinned, not justified normatively. The incoming\n// relationship is joined against the links its entry held before the\n// verification (the 6590 rationale, mergeDutiesAfter), the 6580 direction\n// (an entry's anchor head changed) against the other entry's current\n// links; so a relationship rotating up to a head another entry's lineage\n// extends opens no merge, while the same relationships arriving the other\n// way round can (test/trust-ported.test.mjs, \"the other direction\").\nimport { blockedRel, withBlocked, withoutRelationships } from '../message/holder.js'\nimport type { CommandDef, DutyHandler, EventDraft, IdentityRename, Refusal, Applied } from '../engine.js'\nimport type { ClassOnDuty, Contact, Dec, Duty, HolderState, MergeDuty, Prompt, ReissueMappingDuty, Relationship, Setting, StarPair, TrustClass, Tuple } from '../state.js'\nimport {\n CLASSES, anchorSet, classOnToward, conflicts, entryOf, entryRelationships, feeding, findContact, joins, lags, liveRel, newestHeads, newestOf, supersededIn,\n} from './state.js'\nimport { viewDigest } from './star.js'\nimport { dropOff, followClasses } from './duties.js'\nimport { isKnownDuty } from '../codec.js'\nimport { jcs } from '../core.js'\nconst jcsEq = (a: unknown, b: unknown): boolean => jcs(a) === jcs(b)\n\nconst cmp = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0)\nconst cmpDec = (a: Dec, b: Dec): number => { const x = BigInt(a), y = BigInt(b); return x < y ? -1 : x > y ? 1 : 0 }\nconst byPos = (a: Readonly<Contact>, b: Readonly<Contact>): number => cmpDec(a.pos!, b.pos!) || cmp(a.id, b.id)\nconst unique = <T>(xs: Iterable<T>): T[] => [...new Set(xs)]\n\n/** The trust module's entry commands. */\nexport const ENTRY_COMMANDS = Object.freeze({ merge: 'trust.merge', depart: 'trust.depart' } as const)\n\nexport interface TrustMergeInput { contactIds: string[] }\nexport interface TrustDepartInput { contactId: string, relationshipId?: string }\n\n// ── the anchor head and admission ──────────────────────────────────────\n\n/**\n * The entry's anchor head from what its relationships hold (6560): the\n * newest of the heads its feeding relationships hold; among several\n * (a manual merge before its split) the one it holds, else `prefer`, else\n * the smallest. Where a relationship of it feeds another entry (2145), the\n * head only moves forward: with no feeding head, or none beyond it, it\n * stays. With neither, the entry has none.\n */\nexport function settleHead (state: Readonly<HolderState>, c: Readonly<Contact>, prefer: string | null = null): Contact {\n const rels = feeding(state, c)\n const all = entryRelationships(state, c)\n const newest = newestHeads(rels)\n if (!newest.length) {\n if (all.length > rels.length) return c as Contact\n return c.anchorHead === null ? c as Contact : { ...c, anchorHead: null }\n }\n // 2145: a chain of this entry feeds the other one; what the rest feeds\n // never moves the head back — it stays unless a feeding head lies\n // beyond it along the links the entry's relationships hold\n if (all.length > rels.length && c.anchorHead !== null && newestOf([...newest, c.anchorHead], all.flatMap((r) => r.links)).includes(c.anchorHead)) return c as Contact\n const head = newest.length === 1 ? newest[0]\n : c.anchorHead !== null && newest.includes(c.anchorHead) ? c.anchorHead\n : prefer !== null && newest.includes(prefer) ? prefer\n : [...newest].sort(cmp)[0]\n return head === c.anchorHead ? c as Contact : { ...c, anchorHead: head }\n}\n\n/** 2250: pending entries join the set in position order while it has room. */\nexport function admitPending (state: Readonly<HolderState>, bound: bigint): HolderState {\n let admitted = BigInt(Object.values(state.contacts).filter((x) => x.status === 'admitted').length)\n const pending = Object.values(state.contacts).filter((x) => x.status === 'pending' && x.pos !== null).sort(byPos)\n let contacts: HolderState['contacts'] | null = null\n for (const c of pending) {\n if (admitted >= bound) break\n contacts ??= { ...state.contacts }\n contacts[c.id] = { ...c, status: 'admitted' }\n admitted += 1n\n }\n return contacts ? { ...state, contacts } : state as HolderState\n}\n\n// ── the identity rewrite (2100, 2140) ──────────────────────────────────\n\ninterface RewriteOpts {\n /** the relationships whose keys move: their tuples' entryId, their\n * duties, the recipients of their documents; default all */\n rels?: (relId: string) => boolean\n /** also the keys that name the person rather than a relationship: the\n * matches of accepted stars, prompts, the entry ids of merge duties */\n global?: boolean\n /** also the members of the star baselines and in-flight views (a\n * rename: nothing diverges by it) */\n baselines?: boolean\n /** collects the rename for the engine, which follows it in the stored\n * acks (engine.ts Applied.renames) */\n renames?: IdentityRename[]\n}\n\n/** Rename members of one star scope's views, re-sorted and re-digested. */\nfunction renameView (view: StarPair[], from: (id: string) => boolean, to: string): StarPair[] | null {\n if (!view.some((p) => from(p.member))) return null\n return view.map((p) => (from(p.member) ? { ...p, member: to } : p)).sort((a, b) => cmp(a.member, b.member))\n}\n\nfunction renameBaselines (t: Tuple, from: (id: string) => boolean, to: string): Tuple {\n const o = t.starOut\n let changed = false\n let snapshot = o.snapshot\n let snapshotDigest = o.snapshotDigest\n if (snapshot) {\n const v = renameView(snapshot, from, to)\n if (v) { snapshot = v; snapshotDigest = viewDigest(v); changed = true }\n }\n const inflight: typeof o.inflight = {}\n for (const [salt, f] of Object.entries(o.inflight)) {\n const v = renameView(f.view, from, to)\n if (v) { inflight[salt] = { ...f, view: v, viewDigest: viewDigest(v) }; changed = true } else inflight[salt] = f\n }\n return changed ? { ...t, starOut: { ...o, snapshot, snapshotDigest, inflight } } : t\n}\n\n/** The tuple the record a prompt asks about was made on: a group-invite's\n * invite by its own rkid, an introduction's offer or the target's act by\n * its pin toward the mediator; null where none is held (an\n * encounter-confirm names the fresh relationship's own identity). */\nfunction promptTuple (state: Readonly<HolderState>, p: Readonly<Prompt>): { rkid: string } | { label: string } | null {\n if (p.kind === 'group-invite') {\n const i = Object.values(state.joining.invites).find((x) => x.promptId === p.id)\n return i?.rkid !== undefined ? { rkid: i.rkid } : null\n }\n if (p.kind === 'introduction') {\n if (Object.hasOwn(state.encounter.offers, p.id)) return { label: state.encounter.offers[p.id].pin }\n const a = Object.values(state.encounter.introductions).find((x) => x.role === 'target' && x.promptId === p.id)\n return a?.pins.mediator !== undefined ? { label: a.pins.mediator } : null\n }\n return null\n}\n\n/**\n * Every holder-local key that resolved through an identity in `ids` now\n * resolves through `to` (2100, 2140), within `opts`: tuples' entryId,\n * duties, the recipients of issued documents, and with `global` the\n * matches of accepted stars and merge duties; and the contact references\n * of the membership and introduction state and of prompts, each with the\n * relationship of the tuple it was made on (2080): by the own rkid it\n * arrived or went on (joining preludes and invites, groups' preludes,\n * invitations and roster) or the own pair label toward the mediator\n * (encounter.offers by their pin, the introducer provenance.via by\n * viaPin, memory.vouchedBy by memory.vouchedPin), a prompt with the\n * record it asks about; one that names no tuple follows with `global`.\n * Contacts are the caller's: their ids\n * and aliases are what the rewrite follows. The stored acks follow\n * through the engine (opts.renames): only the core writes the effect\n * cache, and their sealed envelopes stay as they are. Parts without a\n * change keep their identity.\n */\nexport function rewriteIdentity (state: Readonly<HolderState>, ids: readonly string[], to: string, opts: RewriteOpts = {}): HolderState {\n const from = (x: string): boolean => ids.includes(x)\n const inRel = opts.rels ?? (() => true)\n // the own rkids and pair labels of the tuples within `opts`\n const rkids = new Set<string>(), labels = new Set<string>()\n for (const [id, r] of Object.entries(state.relationships)) {\n if (inRel(id)) for (const t of r.tuples) { rkids.add(t.rkid); labels.add(t.ownPairLabel) }\n }\n const byRkid = (rkid: string | undefined): boolean => (rkid === undefined ? !!opts.global : !opts.rels || rkids.has(rkid))\n const byLabel = (label: unknown): boolean => (typeof label !== 'string' ? !!opts.global : !opts.rels || labels.has(label))\n const re = (x: string | undefined, tied: boolean): boolean => x !== undefined && from(x) && tied\n let relationships: HolderState['relationships'] | null = null\n for (const [id, r] of Object.entries(state.relationships)) {\n const mine = inRel(id)\n let changed = false\n const tuples = r.tuples.map((t) => {\n let x = t\n if (mine && from(t.entryId)) x = { ...x, entryId: to }\n const acc = x.starIn.accepted\n if (opts.global && acc && acc.matches.some(from)) {\n x = { ...x, starIn: { ...x.starIn, accepted: { ...acc, matches: unique(acc.matches.map((m) => (from(m) ? to : m))).sort(cmp) } } }\n }\n if (opts.baselines) x = renameBaselines(x, from, to)\n if (x !== t) changed = true\n return x\n })\n // the introducer with the relationship toward it the act was pinned to\n const provenance = re(r.provenance.via, byLabel(r.provenance.viaPin)) ? { ...r.provenance, via: to } : r.provenance\n if (changed || provenance !== r.provenance) (relationships ??= { ...state.relationships })[id] = { ...r, tuples, provenance }\n }\n opts.renames?.push({ from: [...ids], to, rkids: opts.rels ? [...rkids].sort() : null })\n let duties: HolderState['duties'] | null = null\n for (const [id, d] of Object.entries(state.duties)) {\n if (!isKnownDuty(d)) continue // a kind or version this library does not handle stays as it is\n const x = d as unknown as Record<string, unknown>\n let nd: Duty = d\n if (d.kind === 'merge' && opts.global && Array.isArray(x.entryIds) && (x.entryIds as string[]).some(from)) {\n nd = { ...d, entryIds: unique((x.entryIds as string[]).map((e) => (from(e) ? to : e))).sort(cmp) } as Duty\n } else if (d.kind !== 'merge' && typeof x.contactId === 'string' && from(x.contactId) && (typeof x.relId !== 'string' || inRel(x.relId))) {\n nd = { ...d, contactId: to } as Duty\n }\n if (nd !== d) (duties ??= { ...state.duties })[id] = nd\n }\n // membership, introduction and prompts: each contact reference with the\n // relationship of the tuple it was made on, where it names one (2080)\n let prompts: HolderState['prompts'] | null = null\n for (const [id, p] of Object.entries(state.prompts)) {\n const at = promptTuple(state, p)\n const tied = at === null ? !!opts.global : 'rkid' in at ? byRkid(at.rkid) : byLabel(at.label)\n if (re(p.contactId, tied)) (prompts ??= { ...state.prompts })[id] = { ...p, contactId: to }\n }\n let joining: HolderState['joining'] | null = null\n for (const [k, p] of Object.entries(state.joining.preludes)) {\n if (re(p.contactId, byRkid(p.rkid))) (joining ??= { ...state.joining, preludes: { ...state.joining.preludes } }).preludes[k] = { ...p, contactId: to }\n }\n for (const [k, i] of Object.entries(state.joining.invites)) {\n if (re(i.contactId, byRkid(i.rkid))) {\n joining ??= { ...state.joining, preludes: { ...state.joining.preludes } }\n joining.invites = { ...joining.invites, [k]: { ...i, contactId: to } }\n }\n }\n let groups: HolderState['groups'] | null = null\n for (const [gid, g] of Object.entries(state.groups)) {\n const preludes = Object.fromEntries(Object.entries(g.preludes).map(([k, p]) => [k, re(p.contactId, byRkid(p.rkid)) ? { ...p, contactId: to } : p]))\n const invitations = Object.fromEntries(Object.entries(g.invitations).map(([k, i]) => [k, re(i.contactId, byRkid(i.rkid)) ? { ...i, contactId: to } : i]))\n const roster = Object.fromEntries(Object.entries(g.roster).map(([k, m]) => [k, re(m.contactId, byRkid(m.rkid)) ? { ...m, contactId: to } : m]))\n if (jcsEq(preludes, g.preludes) && jcsEq(invitations, g.invitations) && jcsEq(roster, g.roster)) continue\n ;(groups ??= { ...state.groups })[gid] = { ...g, preludes, invitations, roster }\n }\n let encounter: HolderState['encounter'] | null = null\n for (const [k, o] of Object.entries(state.encounter.offers)) {\n if (re(o.mediatorContactId, byLabel(o.pin))) (encounter ??= { ...state.encounter, offers: { ...state.encounter.offers } }).offers[k] = { ...o, mediatorContactId: to }\n }\n // the voucher mark names the mediator that vouched: it follows the\n // relationship toward that mediator the voucher came on (memory.vouchedPin),\n // not the entry it was filed under\n for (const [id, r] of Object.entries(relationships ?? state.relationships)) {\n const v = r.memory.vouchedBy\n if (typeof v === 'string' && re(v, byLabel(r.memory.vouchedPin))) (relationships ??= { ...state.relationships })[id] = { ...r, memory: { ...r.memory, vouchedBy: to } }\n }\n let outbox: HolderState['outbox'] | null = null\n for (const [d, it] of Object.entries(state.outbox)) {\n // a document on a member key follows the tuple its contact was named through (Recipient.via)\n if (from(it.recipient.contactId) && rkids.has(it.recipient.via ?? it.recipient.rkid)) (outbox ??= { ...state.outbox })[d] = { ...it, recipient: { ...it.recipient, contactId: to } }\n }\n if (!relationships && !duties && !prompts && !outbox && !joining && !groups && !encounter) return state as HolderState\n return {\n ...state,\n ...(relationships ? { relationships } : {}), ...(duties ? { duties } : {}), ...(prompts ? { prompts } : {}), ...(outbox ? { outbox } : {}),\n ...(joining ? { joining } : {}), ...(groups ? { groups } : {}), ...(encounter ? { encounter } : {}),\n }\n}\n\n// ── merge (2140–2180) ──────────────────────────────────────────────────\n\n/** 2160: per class `off` where any held `off`, else `on` where any held\n * `on`, else `default`; per (group, contact) the same, every per-group\n * `on` reset where the merged sealed group star is `off` (5450). */\nexport function mergeSettings (cs: readonly Readonly<Contact>[]): { settings: Record<TrustClass, Setting>, groupSettings: Record<string, Setting> } {\n const pick = (xs: Setting[]): Setting => (xs.includes('off') ? 'off' : xs.includes('on') ? 'on' : 'default')\n const settings = {} as Record<TrustClass, Setting>\n for (const cls of CLASSES) settings[cls] = pick(cs.map((c) => c.settings[cls]))\n const groupSettings: Record<string, Setting> = {}\n for (const g of unique(cs.flatMap((c) => Object.keys(c.groupSettings))).sort(cmp)) {\n const s = pick(cs.map((c) => c.groupSettings[g] ?? 'default'))\n if (s === 'off' || (s === 'on' && settings.sealedGroupStar !== 'off')) groupSettings[g] = s\n }\n return { settings, groupSettings }\n}\n\n/**\n * Whether entries can be one (6605, 6560): no relationship of one holds\n * another binding (or another successor) for an anchor a relationship of\n * another holds, and their anchor heads lie on one chain of the links\n * their relationships hold, so the merged entry has exactly one.\n */\nexport function mergeable (state: Readonly<HolderState>, cs: readonly Readonly<Contact>[]): boolean {\n if (cs.length < 2 || new Set(cs.map((c) => c.id)).size !== cs.length) return false\n const rels = cs.map((c) => entryRelationships(state, c))\n for (let i = 0; i < rels.length; i++) for (let j = i + 1; j < rels.length; j++) if (conflicts(rels[i], rels[j])) return false\n const all = unique(rels.flat())\n const heads = [...cs.map((c) => c.anchorHead), ...all.map((r) => r.heldCounterpartHead)].filter((h): h is string => h !== null)\n return newestOf(heads, all.flatMap((r) => r.links)).length <= 1\n}\n\n/** Where the newest active head among the entries' relationships was created (2180). */\nfunction newestRelationship (state: Readonly<HolderState>, cs: readonly Readonly<Contact>[]): Relationship | undefined {\n let best: Relationship | undefined\n let at = -1\n for (const c of cs) {\n for (const r of entryRelationships(state, c)) {\n const i = state.entryOrder.heads.indexOf(r.id)\n if (i > at) { at = i; best = r }\n }\n }\n return best\n}\n\n/**\n * The atomic merge of entries (2140, 2150, 2160, 2180): one entry at the\n * earliest position under the survivor's identity, the others its\n * aliases; admitted where any was, so `k` admitted ones free `k−1` slots,\n * which the next pending entries take in position order in the same step;\n * every key of a merged id rewritten to the survivor; the anchor head\n * settled (6560). Per-tuple keys stay with their tuples.\n */\nexport function mergeEntries (state: Readonly<HolderState>, cs: readonly Readonly<Contact>[], bound: bigint): Applied & { survivor: string } {\n const withPos = cs.filter((c) => c.pos !== null).sort(byPos)\n let survivor: Readonly<Contact>\n let id: string\n if (withPos.length) { survivor = withPos[0]; id = survivor.id } else {\n const r = newestRelationship(state, cs)\n survivor = (r && cs.find((c) => c.relIds.includes(r.id))) ?? cs[0]\n // the relationship's identity, where it names the survivor (2180)\n id = r && findContact(state, r.contactId)?.id === survivor.id ? r.contactId : survivor.id\n }\n return mergeInto(state, survivor, id, cs.filter((c) => c !== survivor), bound)\n}\n\n/** The merge onto a chosen survivor under identity `id` (its id or one of its aliases). */\nexport function mergeInto (state: Readonly<HolderState>, survivor: Readonly<Contact>, id: string, gone: readonly Readonly<Contact>[], bound: bigint): Applied & { survivor: string } {\n const all = [survivor, ...gone]\n const { settings, groupSettings } = mergeSettings(all)\n const status: Contact['status'] = all.some((c) => c.status === 'admitted') ? 'admitted' : all.some((c) => c.status === 'pending') ? 'pending' : 'none'\n const positioned = all.filter((c) => c.pos !== null).sort(byPos)\n const merged = all.map((c) => c.id).filter((x) => x !== id)\n const contacts = { ...state.contacts }\n for (const c of all) delete contacts[c.id]\n contacts[id] = {\n id, pos: positioned[0]?.pos ?? null, status,\n aliases: unique(all.flatMap((c) => [c.id, ...c.aliases])).filter((x) => x !== id).sort(cmp),\n relIds: unique(all.flatMap((c) => c.relIds)),\n anchorHead: survivor.anchorHead ?? positioned.find((c) => c.anchorHead !== null)?.anchorHead ?? null,\n settings, groupSettings,\n }\n const renames: IdentityRename[] = []\n // a merge sets the block on every relationship of the merged entry where\n // any of them held it (Message Tasks RLTP-MSG-6030)\n const relIds = contacts[id].relIds\n const blocked = relIds.some((r) => blockedRel(state, r)) ? withBlocked(state.messages.blocked, relIds, true) : state.messages.blocked\n let next: HolderState = rewriteIdentity({ ...state, contacts, messages: { ...state.messages, blocked } }, merged, id, { global: true, renames })\n next = { ...next, contacts: { ...next.contacts, [id]: settleHead(next, next.contacts[id]) } }\n // the class duties of the merged settings (2160, 2850, 6410): per\n // relationship against the entry it sent under before (2146)\n const f = followClasses(state, admitPending(next, bound))\n next = f.state\n return {\n state: next, events: [{ type: 'contact.merged', contactId: id, merged: [...merged].sort(cmp) }],\n ...(f.duties.length ? { duties: f.duties } : {}), renames, survivor: id,\n }\n}\n\n/**\n * The merge duties a commit on `relId` opens (2230): where the\n * relationship stands behind another entry (2145) that is now mergeable\n * with its own, and, with `net`, the convergence net of rung 2 for an\n * accepted anchor mapping (6520–6605). One duty for every entry that\n * joins, in position order while they stay mergeable together (2150).\n */\nexport function mergeDutiesAfter (before: Readonly<HolderState>, after: HolderState, relId: string, opts: { net: boolean }): { state: HolderState, duties: MergeDuty[] } {\n const none = { state: after, duties: [] }\n const rel = after.relationships[relId]\n const E = rel && entryOf(after, rel)\n if (!E || E.pos === null || E.anchorHead === null) return none\n const eRels = entryRelationships(after, E)\n const others = Object.values(after.contacts).filter((x) => x.id !== E.id && x.pos !== null && x.anchorHead !== null).sort(byPos)\n const picked: Contact[] = []\n const take = (x: Contact): void => { if (!picked.includes(x) && mergeable(after, [E, ...picked, x])) picked.push(x) }\n // 2145: the other entry behind this relationship, once comparable and the binding rule admits\n for (const t of rel.tuples) {\n const x = findContact(after, t.entryId)\n if (x && x.id !== E.id && x.pos !== null && x.anchorHead !== null) take(x)\n }\n if (opts.net) {\n // the incoming relationship, where it does not lag in its own entry\n // (6550). Head rule (b) against the knowledge the entry held before\n // this commit: its relationships' links with this relationship's taken\n // from before the 6610 union of this verification. What the mapping\n // newly carries counts for (a) only (the 6590 rationale reading)\n if (rel.heldCounterpartHead === E.anchorHead) {\n const relB = Object.hasOwn(before.relationships, relId) ? before.relationships[relId] : rel\n const own = supersededIn(eRels.map((r) => (r.id === relId ? relB : r)))\n for (const x of others) if (joins(rel, x, entryRelationships(after, x), own)) take(x)\n }\n // 6580: E's anchor head changed — every relationship of another entry against E\n if (findContact(before, E.id)?.anchorHead !== E.anchorHead) {\n for (const x of others) {\n const xs = entryRelationships(after, x)\n if (feeding(after, x).some((r) => r.heldCounterpartHead === x.anchorHead && joins(r, E, eRels, supersededIn(xs)))) take(x)\n }\n }\n }\n if (!picked.length) return none\n const cs = [E, ...picked]\n const ids = cs.map((c) => c.id).sort(cmp)\n const id = 'merge:' + ids.join('|')\n const duty: MergeDuty = { kind: 'merge', v: 1, id, entryIds: ids, relId, witness: witnessOf(after, cs) }\n // a duty open for the same entries takes the new admission's witness\n if (Object.hasOwn(after.duties, id)) return { state: { ...after, duties: { ...after.duties, [id]: { ...after.duties[id], ...duty } as Duty } }, duties: [] }\n return { state: after, duties: [duty] }\n}\n\n/** The heads and superseded sets a merge is admitted against. */\nfunction witnessOf (state: Readonly<HolderState>, cs: readonly Readonly<Contact>[]): MergeDuty['witness'] {\n const heads: Record<string, string> = {}\n const superseded: Record<string, string[]> = {}\n for (const c of cs) heads[c.id] = c.anchorHead!\n for (const y of cs) {\n const sup = supersededIn(entryRelationships(state, y))\n superseded[y.id] = unique(cs.filter((x) => x !== y && sup.has(x.anchorHead!)).map((x) => x.anchorHead!)).sort(cmp)\n }\n return { heads, superseded }\n}\n\n/**\n * Whether the merge a duty was opened for still stands (6540, 6550,\n * 6605): every entry still holds the anchor head it was admitted with, no\n * entry holds another's head as superseded beyond what it did then, the\n * relationship that opened it is still one of theirs, and the entries are\n * mergeable (the binding rule, one anchor head).\n */\nfunction witnessHolds (state: Readonly<HolderState>, d: Readonly<MergeDuty>, cs: readonly Readonly<Contact>[]): boolean {\n const w = d.witness\n if (cs.some((c) => !Object.hasOwn(w.heads, c.id) || c.anchorHead !== w.heads[c.id])) return false\n if (!cs.some((c) => c.relIds.includes(d.relId))) return false\n for (const y of cs) {\n const sup = supersededIn(entryRelationships(state, y))\n for (const x of cs) if (x !== y && sup.has(x.anchorHead!) && !(w.superseded[y.id] ?? []).includes(x.anchorHead!)) return false\n }\n return mergeable(state, cs)\n}\n\n/** merge/1: the merge as one step after the verification commit (2230),\n * re-checked against its witness; where it no longer holds, the duty is\n * dropped without a trace (a later verification may open another). */\nexport const mergeDuty = (bound: bigint): DutyHandler => ({\n v: 1,\n apply (state, duty) {\n const d = duty as MergeDuty\n const cs = unique(d.entryIds.map((x) => findContact(state, x)).filter((c): c is Contact => c !== undefined))\n // the state moved since the commit that opened it: nothing (left) to merge\n if (cs.length < 2 || cs.some((c) => c.pos === null) || !witnessHolds(state, d, cs)) return { state: state as HolderState }\n const r = mergeEntries(state, cs, bound)\n return { state: r.state, ...(r.events ? { events: r.events } : {}), ...(r.duties ? { duties: r.duties } : {}), ...(r.renames ? { renames: r.renames } : {}) }\n },\n})\n\n// ── split (2080–2115) ──────────────────────────────────────────────────\n\n/** The chain aliases of a relationship (2090): the identities of the\n * husks chained into it. */\nexport function chainAliases (state: Readonly<HolderState>, relId: string): string[] {\n const out: string[] = []\n for (const r of Object.values(state.relationships)) {\n if (r.chainedInto === relId) out.push(r.contactId, ...chainAliases(state, r.id))\n }\n return unique(out).sort(cmp)\n}\n\n/** The husks chained into `relId`, transitively. */\nconst husksOf = (state: Readonly<HolderState>, relId: string): string[] =>\n Object.values(state.relationships).filter((r) => r.chainedInto === relId).flatMap((r) => [r.id, ...husksOf(state, r.id)])\n\n/**\n * The identity an entry takes when the relationship whose identity it was\n * leaves (2100): its oldest remaining relationship's in entry-commit order\n * (firstVerified, unverified after, then active-head creation), among those\n * whose identity resolves to this entry; the relationship's id where none\n * does (a relationship behind two entries, 2145).\n */\nfunction oldestIdentity (state: Readonly<HolderState>, c: Readonly<Contact>, remaining: readonly string[], exclude: ReadonlySet<string>): string {\n const heads = state.entryOrder.heads\n const rels = remaining.filter((id) => Object.hasOwn(state.relationships, id)).map((id) => state.relationships[id]).sort((a, b) => {\n if (a.firstVerified !== null && b.firstVerified !== null) { const d = cmpDec(a.firstVerified, b.firstVerified); if (d) return d }\n if ((a.firstVerified === null) !== (b.firstVerified === null)) return a.firstVerified === null ? 1 : -1\n return (heads.indexOf(a.id) - heads.indexOf(b.id)) || cmp(a.id, b.id)\n })\n const own = rels.find((r) => !exclude.has(r.contactId) && (r.contactId === c.id || c.aliases.includes(r.contactId)))\n return own ? own.contactId : rels[0].id\n}\n\n/** The keys of the entry's relationships resolve through its new id (2100). */\nconst rename = (state: HolderState, oldId: string, id: string, rels: (relId: string) => boolean, renames: IdentityRename[]): HolderState =>\n rewriteIdentity(state, [oldId], id, { rels, global: true, baselines: true, renames })\n\n/**\n * 2080: the first verified mapping on `relId`, already in `mid`, leaves it\n * holding no anchor the other relationships of its entry hold, or another\n * binding for one they hold: the split, else null. The entry keeps its\n * position, status, the remaining relationships with their aliases and\n * its settings, frees no slot and settles its anchor head; the leaver\n * takes its identity, its chain aliases and the settings of 2115, and\n * holds no position until the caller's entry commit (2090).\n */\nexport function splitIfUnlinked (before: Readonly<HolderState>, mid: Readonly<HolderState>, relId: string): { state: HolderState, event: EventDraft, renames: IdentityRename[] } | null {\n if (before.relationships[relId]?.heldCounterpartHead !== null) return null\n const rel = mid.relationships[relId]\n const E = entryOf(mid, rel)\n if (!E) return null\n const others = entryRelationships(mid, E).filter((r) => r.id !== relId)\n const holding = others.filter((r) => r.heldCounterpartHead !== null)\n // 2080 read literally would split every manual merge of unmapped\n // relationships at the first mapping; open point for Trust 0.32. Here\n // the relationship stays where the others hold no anchor to contradict\n if (!holding.length) return null\n const mine = anchorSet(rel)\n const shares = holding.some((o) => [...anchorSet(o)].some((a) => mine.has(a)))\n if (shares && !conflicts([rel], others)) return null\n return splitOff(mid, relId)\n}\n\n/** The split of `relId` from its entry (2080–2115). */\nexport function splitOff (state: Readonly<HolderState>, relId: string): { state: HolderState, event: EventDraft, renames: IdentityRename[] } {\n const rel = state.relationships[relId]\n const E = entryOf(state, rel)!\n const identity = rel.contactId\n const chain = chainAliases(state, relId)\n const leaverIds = new Set([identity, ...chain])\n const remaining = E.relIds.filter((id) => id !== relId)\n const eId = leaverIds.has(E.id) ? oldestIdentity(state, E, remaining, leaverIds) : E.id\n // 2115: every class at default, except an `off` of the merged entry, which goes along\n const settings = {} as Record<TrustClass, Setting>\n for (const cls of CLASSES) settings[cls] = E.settings[cls] === 'off' ? 'off' : 'default'\n const groupSettings: Record<string, Setting> = {}\n for (const [g, s] of Object.entries(E.groupSettings)) if (s === 'off') groupSettings[g] = 'off'\n const contacts = { ...state.contacts }\n delete contacts[E.id]\n contacts[eId] = { ...E, id: eId, relIds: remaining, aliases: E.aliases.filter((a) => !leaverIds.has(a) && a !== eId) }\n contacts[identity] = {\n id: identity, pos: null, status: 'none', aliases: chain.filter((a) => a !== identity), relIds: [relId], anchorHead: null, settings, groupSettings,\n }\n // the leaver's keys go to its own entry (2145 entryId, its duties and recipients)\n const renames: IdentityRename[] = []\n let next = rewriteIdentity({ ...state, contacts }, [E.id, ...E.aliases], identity, { rels: (id) => id === relId, renames })\n // the remaining entry's keys that resolved through the old identity (2100)\n if (eId !== E.id) next = rename(next, E.id, eId, (id) => id !== relId, renames)\n next = { ...next, contacts: { ...next.contacts, [eId]: settleHead(next, next.contacts[eId]) } }\n // the leaver's classes start at default (2115): the trusted contacts' classes off with the anchor mapping (6410)\n next = dropOff(next).state\n return { state: next, event: { type: 'contact.split', contactId: eId, leaver: identity, relationshipId: relId }, renames }\n}\n\n// ── departure (2210, 2250, 2260, 5860) ─────────────────────────────────\n\nconst needInput = (x: unknown, name: string): Record<string, unknown> => {\n if (x === null || typeof x !== 'object' || Array.isArray(x)) throw new TypeError(`${name} needs an input object`)\n return x as Record<string, unknown>\n}\n\n/** The matches of every accepted star without the entry ids `ids` (6160). */\nfunction dropMatches (state: HolderState, ids: readonly string[]): HolderState {\n if (!ids.length) return state\n let relationships: HolderState['relationships'] | null = null\n for (const [id, r] of Object.entries(state.relationships)) {\n if (!r.tuples.some((t) => t.starIn.accepted?.matches.some((m) => ids.includes(m)))) continue\n const tuples = r.tuples.map((t) => {\n const acc = t.starIn.accepted\n return acc && acc.matches.some((m) => ids.includes(m)) ? { ...t, starIn: { ...t.starIn, accepted: { ...acc, matches: acc.matches.filter((m) => !ids.includes(m)) } } } : t\n })\n ;(relationships ??= { ...state.relationships })[id] = { ...r, tuples }\n }\n return relationships ? { ...state, relationships } : state\n}\n\n/** The identities of a relationship: its own and its chain aliases. */\nconst identitiesOf = (state: Readonly<HolderState>, relId: string): string[] =>\n [state.relationships[relId].contactId, ...chainAliases(state, relId)]\n\n/**\n * Departure: the relationships leave the state with their husks; an entry\n * left without relationships is removed (pending: 2260; admitted: its\n * slot frees, 2250), one that keeps some drops their aliases, takes a new\n * identity where theirs was its own (2100) and settles its anchor head\n * (2080); pending entries are admitted in position order in the same\n * step, so the set changes once (5860).\n */\nexport function depart (state: Readonly<HolderState>, input: TrustDepartInput, bound: bigint): Applied | Refusal {\n const c = findContact(state, input.contactId)\n if (!c) return { ok: false, code: 'unknown-contact' }\n let relIds: string[]\n if (input.relationshipId !== undefined) {\n if (!c.relIds.includes(input.relationshipId)) return { ok: false, code: 'unknown-contact' }\n relIds = [input.relationshipId]\n } else if (input.contactId !== c.id) {\n relIds = c.relIds.filter((rid) => Object.hasOwn(state.relationships, rid) && identitiesOf(state, rid).includes(input.contactId))\n } else relIds = [...c.relIds]\n const leaving = new Set(relIds.flatMap((rid) => [rid, ...husksOf(state, rid)]))\n const goneIds = new Set([...relIds.flatMap((rid) => (Object.hasOwn(state.relationships, rid) ? identitiesOf(state, rid) : []))])\n if (input.contactId !== c.id && input.relationshipId === undefined) goneIds.add(input.contactId) // an alias without a relationship\n const relationships: HolderState['relationships'] = {}\n for (const [id, r] of Object.entries(state.relationships)) if (!leaving.has(id)) relationships[id] = r\n const contacts: HolderState['contacts'] = {}\n const renamed: Array<{ from: string, to: string, rels: string[] }> = []\n let removed = false\n const removedIds: string[] = []\n for (const x of Object.values(state.contacts)) {\n const rest = x.relIds.filter((id) => !leaving.has(id))\n if (rest.length === x.relIds.length && !x.aliases.some((a) => goneIds.has(a))) { contacts[x.id] = x; continue }\n if (!rest.length) { if (x.id === c.id) removed = true; removedIds.push(x.id); continue }\n const id = goneIds.has(x.id) ? oldestIdentity(state, x, rest, goneIds) : x.id\n if (id !== x.id) renamed.push({ from: x.id, to: id, rels: rest })\n contacts[id] = { ...x, id, relIds: rest, aliases: x.aliases.filter((a) => !goneIds.has(a) && a !== id) }\n }\n const duties: HolderState['duties'] = {}\n for (const [id, d] of Object.entries(state.duties)) {\n const relOf = (d as { relId?: unknown }).relId\n // a duty of a kind (or version) this library does not know is kept as it is\n if (typeof relOf === 'string' && leaving.has(relOf) && d.kind !== 'merge' && isKnownDuty(d)) continue\n duties[id] = d\n }\n const rotations: HolderState['rotations'] = {}\n for (const [id, r] of Object.entries(state.rotations)) {\n rotations[id] = Object.keys(r.awaitHead).some((k) => leaving.has(k))\n ? { ...r, awaitHead: Object.fromEntries(Object.entries(r.awaitHead).filter(([k]) => !leaving.has(k))) }\n : r\n }\n let next: HolderState = {\n ...state, relationships, contacts, duties, rotations,\n entryOrder: { ...state.entryOrder, heads: state.entryOrder.heads.filter((id) => !leaving.has(id)) },\n }\n // 6160: an accepted star matches the holder's contacts; one that left matches nothing\n next = dropMatches(next, removedIds)\n // the block and the rates of a departed relationship leave with it (Message Tasks 6.1, 4.2)\n next = withoutRelationships(next, [...leaving])\n const renames: IdentityRename[] = []\n for (const r of renamed) next = rename(next, r.from, r.to, (id) => r.rels.includes(id), renames)\n for (const x of Object.values(next.contacts)) {\n const s = settleHead(next, x)\n if (s !== x) next = { ...next, contacts: { ...next.contacts, [x.id]: s } }\n }\n // 2850: a relationship that ceased to lag with the departure gets the classes on for it\n const f = followClasses(state, admitPending(next, bound))\n next = f.state\n return {\n ...(f.duties.length ? { duties: f.duties } : {}),\n state: next, events: [{ type: 'contact.departed', contactId: c.id, relationshipIds: relIds.filter((id) => Object.hasOwn(state.relationships, id)).sort(cmp), removed }],\n ...(renames.length ? { renames } : {}),\n }\n}\n\n// ── the commands ───────────────────────────────────────────────────────\n\nexport function entryCommands (bound: bigint): Record<string, CommandDef> {\n return {\n // rung 3: the manual merge (6640)\n [ENTRY_COMMANDS.merge]: {\n human: true,\n apply (state, _p, input: TrustMergeInput) {\n const i = needInput(input, ENTRY_COMMANDS.merge)\n if (!Array.isArray(i.contactIds) || i.contactIds.some((x) => typeof x !== 'string' || x === '')) throw new TypeError('trust.merge: contactIds must be non-empty strings')\n const cs: Contact[] = []\n for (const x of i.contactIds as string[]) {\n const c = findContact(state, x)\n if (!c) return { ok: false, code: 'unknown-contact' }\n if (!cs.includes(c)) cs.push(c)\n }\n if (cs.length < 2) return { state: state as HolderState }\n if (cs.filter((c) => c.pos !== null).length > 1) return { ok: false, code: 'not-mergeable', ref: 'RLTP-TRU-6640' }\n if (!mergeable(state, cs)) return { ok: false, code: 'not-mergeable', ref: 'RLTP-TRU-6605' }\n const r = mergeEntries(state, cs, bound)\n return { state: r.state, ...(r.events ? { events: r.events } : {}), ...(r.duties ? { duties: r.duties } : {}), ...(r.renames ? { renames: r.renames } : {}) }\n },\n } satisfies CommandDef<TrustMergeInput>,\n [ENTRY_COMMANDS.depart]: {\n human: true,\n apply (state, _p, input: TrustDepartInput) {\n const i = needInput(input, ENTRY_COMMANDS.depart)\n if (typeof i.contactId !== 'string' || i.contactId === '') throw new TypeError('trust.depart: contactId must be a non-empty string')\n if (i.relationshipId !== undefined && (typeof i.relationshipId !== 'string' || i.relationshipId === '')) throw new TypeError('trust.depart: relationshipId must be a non-empty string')\n return depart(state, i as unknown as TrustDepartInput, bound)\n },\n } satisfies CommandDef<TrustDepartInput>,\n }\n}\n"]}
|