@cello-protocol/protocol-types 0.0.54 → 0.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/document-amendment.d.ts +27 -22
  2. package/dist/document-amendment.d.ts.map +1 -1
  3. package/dist/document-amendment.js +63 -181
  4. package/dist/document-amendment.js.map +1 -1
  5. package/dist/document-derive.d.ts +96 -0
  6. package/dist/document-derive.d.ts.map +1 -0
  7. package/dist/document-derive.js +605 -0
  8. package/dist/document-derive.js.map +1 -0
  9. package/dist/document-envelope.d.ts +18 -8
  10. package/dist/document-envelope.d.ts.map +1 -1
  11. package/dist/document-envelope.js +35 -19
  12. package/dist/document-envelope.js.map +1 -1
  13. package/dist/document-governance.d.ts +1 -1
  14. package/dist/document-governance.d.ts.map +1 -1
  15. package/dist/document-governance.js +41 -6
  16. package/dist/document-governance.js.map +1 -1
  17. package/dist/document-proposal.d.ts +6 -0
  18. package/dist/document-proposal.d.ts.map +1 -1
  19. package/dist/document-proposal.js +21 -0
  20. package/dist/document-proposal.js.map +1 -1
  21. package/dist/document-reconcile.d.ts +100 -0
  22. package/dist/document-reconcile.d.ts.map +1 -0
  23. package/dist/document-reconcile.js +197 -0
  24. package/dist/document-reconcile.js.map +1 -0
  25. package/dist/index.d.ts +9 -11
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +6 -6
  28. package/dist/index.js.map +1 -1
  29. package/package.json +2 -2
  30. package/dist/document-ack.d.ts +0 -111
  31. package/dist/document-ack.d.ts.map +0 -1
  32. package/dist/document-ack.js +0 -228
  33. package/dist/document-ack.js.map +0 -1
  34. package/dist/document-control.d.ts +0 -74
  35. package/dist/document-control.d.ts.map +0 -1
  36. package/dist/document-control.js +0 -174
  37. package/dist/document-control.js.map +0 -1
  38. package/dist/document-join-answer.d.ts +0 -34
  39. package/dist/document-join-answer.d.ts.map +0 -1
  40. package/dist/document-join-answer.js +0 -100
  41. package/dist/document-join-answer.js.map +0 -1
  42. package/dist/document-join.d.ts +0 -83
  43. package/dist/document-join.d.ts.map +0 -1
  44. package/dist/document-join.js +0 -225
  45. package/dist/document-join.js.map +0 -1
@@ -0,0 +1,605 @@
1
+ /**
2
+ * SYNC-P1 — the causal derivation. ONE derivation of a document's state for every holder: the
3
+ * fold over the entry DAG in a deterministic total order. Same entry set → same state, everywhere,
4
+ * always. This file replaces the linear epoch replay; the fold rules are M14B Build Journal
5
+ * Entries 48–49 (SYNC-G2's finding plus its admin-floor addendum).
6
+ *
7
+ * The total order is Kahn's topological sort refined by ascending entry hash — a pure function of
8
+ * the entry SET. The hash tie-break resolves only what is semantically arbitrary (which property
9
+ * value wins). It never resolves authority: causal concurrency is author-claimable (a modified
10
+ * daemon backdates its parents at will), so any rule where a concurrent act could beat a removal
11
+ * would make removal defeatable. Hence the fold rules:
12
+ *
13
+ * F1. A non-removal entry takes effect iff it validates against the folded state at its position
14
+ * AND it is not concurrent with an ancestor-valid removal of its author.
15
+ * F2. A removal is judged at its OWN ancestors (the state derived from its ancestor closure) and
16
+ * is exempt from F1's concurrency void — the exemption is what keeps mutual removals from
17
+ * being circular. At fold position it is void only by the admin floor: a removal that would
18
+ * leave zero admins does not take effect.
19
+ * F3. Content admissibility is R20's (ancestor-based) and is NOT this module's concern.
20
+ * F4. A void entry stays in the linearization — history, not refusal — and contributes nothing.
21
+ */
22
+ import { documentAmendmentHash, MAX_DOCUMENT_HOLDERS, AMENDABLE_PROPERTIES, AMENDMENT_SUBJECT_KIND, } from "./document-amendment.js";
23
+ import { collectionStatus } from "./document-multisig.js";
24
+ import { DOCUMENT_FEATURE_VERSION } from "./document-proposal.js";
25
+ /**
26
+ * SYNC-G1 — the derivation AT a named governance frontier: the fold restricted to the ancestor
27
+ * closure of `frontierHashes`. This is what content admissibility rules on (R20/R30): was the
28
+ * envelope's author a participant in the world its signed `governance_parents` name? Judged
29
+ * from the named ancestors alone — the same bounded backdating concession Entry 48 accepted
30
+ * for governance: a lying daemon admits exactly what an honest holder AT THAT POSITION could
31
+ * have authored, and the fold's removal dominance keeps it out of governance regardless.
32
+ *
33
+ * A frontier hash not present in `entries` is the caller's signal to reconcile first — this
34
+ * function reports it rather than guessing (`missing`).
35
+ */
36
+ export function deriveDocumentStateAt(genesis, entries, frontierHashes, policy, verify) {
37
+ const byHash = new Map(entries.map((env) => [
38
+ Buffer.from(documentAmendmentHash(env.body)).toString("hex"),
39
+ env,
40
+ ]));
41
+ const missing = frontierHashes.filter((h) => !byHash.has(h));
42
+ if (missing.length > 0) {
43
+ return {
44
+ ok: false,
45
+ reason: `derive_frontier_missing: ${missing.length} of the named governance ancestors are not ` +
46
+ `held — reconcile before ruling`,
47
+ missing,
48
+ };
49
+ }
50
+ const wanted = new Set();
51
+ const queue = [...frontierHashes];
52
+ while (queue.length > 0) {
53
+ const h = queue.pop();
54
+ if (wanted.has(h))
55
+ continue;
56
+ wanted.add(h);
57
+ const env = byHash.get(h);
58
+ if (env)
59
+ queue.push(...env.body.parents);
60
+ }
61
+ const subset = entries.filter((env) => wanted.has(Buffer.from(documentAmendmentHash(env.body)).toString("hex")));
62
+ return deriveDocumentState(genesis, subset, policy, verify);
63
+ }
64
+ /**
65
+ * The STATE-INDEPENDENT admission check — what an inbound path may refuse outright, because no
66
+ * future entry can ever make it good: the collection must bind to this entry, the claimed author
67
+ * must be in the required set, and every claimed signature must verify. Everything else — subject
68
+ * semantics, policy, concurrency — is the fold's ruling, and a fold-void entry is still HISTORY
69
+ * (F4): it must be stored and shared, never bounced at the door, or two holders end up holding
70
+ * different sets.
71
+ */
72
+ export function checkEntryAdmissible(env, verify) {
73
+ const body = env.body;
74
+ if (!env.collection.required_signers.includes(body.author_agent_id)) {
75
+ return {
76
+ ok: false,
77
+ reason: `entry_author_not_required: the claimed author ${body.author_agent_id} is not in the ` +
78
+ `collection's required set — accountability is signed, not asserted`,
79
+ };
80
+ }
81
+ if (env.collection.document_id !== body.document_id) {
82
+ return {
83
+ ok: false,
84
+ reason: `amendment_collection_document_mismatch: collection names ${env.collection.document_id}`,
85
+ };
86
+ }
87
+ if (env.collection.subject_kind !== AMENDMENT_SUBJECT_KIND) {
88
+ return {
89
+ ok: false,
90
+ reason: `amendment_collection_kind: collection signs "${env.collection.subject_kind}", not an amendment`,
91
+ };
92
+ }
93
+ const expected = documentAmendmentHash(body);
94
+ if (Buffer.compare(env.collection.subject_hash, expected) !== 0) {
95
+ return {
96
+ ok: false,
97
+ reason: "amendment_collection_subject_mismatch: the collection signs a different entry than the " +
98
+ "one it rides with",
99
+ };
100
+ }
101
+ const status = collectionStatus(env.collection, verify);
102
+ if (!status.complete) {
103
+ return {
104
+ ok: false,
105
+ reason: `amendment_collection_incomplete: missing [${status.missing.join(", ")}], invalid ` +
106
+ `[${status.invalidSigners.join(", ")}], unknown [${status.unknown.join(", ")}], ` +
107
+ `duplicate [${status.duplicates.join(", ")}]`,
108
+ };
109
+ }
110
+ return { ok: true };
111
+ }
112
+ function isRemoval(kind) {
113
+ return kind === "remove_holder" || kind === "remove_admin";
114
+ }
115
+ export function deriveDocumentState(genesis, entries, policy, verify) {
116
+ // ── Genesis — document-level refusals ───────────────────────────────────────────────────────
117
+ // R21/R22: the proposer's signature on the proposal IS their consent; the peer is INVITED
118
+ // until their own consent entry applies. Declared admin power activates with participation —
119
+ // a declared-admin peer is briefly powerless, which self-resolves at their consent.
120
+ const genesisParticipants = new Set([genesis.proposerAgentId]);
121
+ const genesisInvited = new Set(genesis.peerAgentId === genesis.proposerAgentId ? [] : [genesis.peerAgentId]);
122
+ const declaredGenesisAdmins = new Set(genesis.adminSet);
123
+ if (declaredGenesisAdmins.size === 0) {
124
+ return {
125
+ ok: false,
126
+ reason: "arrangement_admin_set_empty: a document with no admins can never be amended — the " +
127
+ "creation flow must name at least one",
128
+ };
129
+ }
130
+ for (const admin of declaredGenesisAdmins) {
131
+ if (admin !== genesis.proposerAgentId && admin !== genesis.peerAgentId) {
132
+ return {
133
+ ok: false,
134
+ reason: `arrangement_admin_not_participant: ${admin} holds admin power but is not a genesis ` +
135
+ `party — admins are always holders`,
136
+ };
137
+ }
138
+ }
139
+ const genesisAdmins = new Set([...declaredGenesisAdmins].filter((id) => genesisParticipants.has(id)));
140
+ // ── Index by hash (exact duplicates collapse — idempotence is free) ─────────────────────────
141
+ const byHash = new Map();
142
+ for (const env of entries) {
143
+ byHash.set(Buffer.from(documentAmendmentHash(env.body)).toString("hex"), env);
144
+ }
145
+ // ── Exclusion: only entries whose FULL ancestry is present participate (R14 defensively) ────
146
+ const includedMemo = new Map();
147
+ function isIncluded(hash) {
148
+ const known = includedMemo.get(hash);
149
+ if (known !== undefined)
150
+ return known;
151
+ const env = byHash.get(hash);
152
+ if (env === undefined) {
153
+ includedMemo.set(hash, false);
154
+ return false;
155
+ }
156
+ // Mark in-progress false to break cycles (a hash cycle is unconstructable for honest SHA-256
157
+ // entries, but the walk must not hang on a crafted set).
158
+ includedMemo.set(hash, false);
159
+ const ok = env.body.parents.every((p) => isIncluded(p));
160
+ includedMemo.set(hash, ok);
161
+ return ok;
162
+ }
163
+ const included = new Map();
164
+ const excluded = [];
165
+ for (const hash of byHash.keys()) {
166
+ if (isIncluded(hash)) {
167
+ included.set(hash, byHash.get(hash));
168
+ }
169
+ else {
170
+ excluded.push({
171
+ hash,
172
+ reason: "entry_ancestry_incomplete: a named parent (or one of its ancestors) is not held — " +
173
+ "the entry is held out, never applied on a guess",
174
+ });
175
+ }
176
+ }
177
+ // ── Ancestor closures (memoized) ────────────────────────────────────────────────────────────
178
+ const closureMemo = new Map();
179
+ function closure(hash) {
180
+ const known = closureMemo.get(hash);
181
+ if (known !== undefined)
182
+ return known;
183
+ const out = new Set();
184
+ closureMemo.set(hash, out);
185
+ const env = included.get(hash);
186
+ if (env) {
187
+ for (const p of env.body.parents) {
188
+ out.add(p);
189
+ for (const g of closure(p))
190
+ out.add(g);
191
+ }
192
+ }
193
+ return out;
194
+ }
195
+ // ── The deterministic total order: Kahn, ready set by ascending hash ────────────────────────
196
+ function linearize(subset) {
197
+ const pending = new Set(subset);
198
+ const done = new Set();
199
+ const order = [];
200
+ while (pending.size > 0) {
201
+ let next = null;
202
+ for (const hash of pending) {
203
+ const env = included.get(hash);
204
+ const ready = env.body.parents.every((p) => done.has(p) || !subset.has(p));
205
+ if (ready && (next === null || hash < next))
206
+ next = hash;
207
+ }
208
+ // Unreachable for included entries (ancestry is complete), kept as a loud invariant.
209
+ if (next === null)
210
+ throw new Error("entry_linearize_stuck: no ready entry in a nonempty set");
211
+ order.push(next);
212
+ pending.delete(next);
213
+ done.add(next);
214
+ }
215
+ return order;
216
+ }
217
+ // ── Per-entry checks that need no state ─────────────────────────────────────────────────────
218
+ function structuralVoid(env, hash) {
219
+ const body = env.body;
220
+ if (body.document_id !== genesis.documentId) {
221
+ return `entry_wrong_document: names ${body.document_id}, deriving ${genesis.documentId}`;
222
+ }
223
+ if (!env.collection.required_signers.includes(body.author_agent_id)) {
224
+ return (`entry_author_not_required: the claimed author ${body.author_agent_id} is not in the ` +
225
+ `collection's required set — accountability is signed, not asserted`);
226
+ }
227
+ if (env.collection.document_id !== body.document_id) {
228
+ return `amendment_collection_document_mismatch: collection names ${env.collection.document_id}`;
229
+ }
230
+ if (env.collection.subject_kind !== AMENDMENT_SUBJECT_KIND) {
231
+ return `amendment_collection_kind: collection signs "${env.collection.subject_kind}", not an amendment`;
232
+ }
233
+ const expected = documentAmendmentHash(body);
234
+ if (Buffer.compare(env.collection.subject_hash, expected) !== 0) {
235
+ return ("amendment_collection_subject_mismatch: the collection signs a different entry than the " +
236
+ "one it rides with");
237
+ }
238
+ if (body.author_seq > 1) {
239
+ // The author's previous entry must be among the ANCESTORS — a direct parent is the common
240
+ // case, but authoring on a frontier that already causally contains your own last entry is
241
+ // the normal shape of concurrent work.
242
+ const ancestors = closure(hash);
243
+ let prevOwn = false;
244
+ for (const p of ancestors) {
245
+ const parent = included.get(p);
246
+ if (parent !== undefined &&
247
+ parent.body.author_agent_id === body.author_agent_id &&
248
+ parent.body.author_seq === body.author_seq - 1) {
249
+ prevOwn = true;
250
+ break;
251
+ }
252
+ }
253
+ if (!prevOwn) {
254
+ return (`entry_own_chain_broken: seq ${body.author_seq} by ${body.author_agent_id} is not ` +
255
+ `causally after that author's seq ${body.author_seq - 1} — an author's own entries ` +
256
+ `form a chain`);
257
+ }
258
+ }
259
+ return null;
260
+ }
261
+ /** Subject semantics + policy + completeness against a given state. Null = takes effect. */
262
+ function effectVoid(env, state) {
263
+ const body = env.body;
264
+ const subject = body.subject_agent_id;
265
+ if (body.state_hash !== null && state.properties["assurance_tier"] !== "attested") {
266
+ return (`amendment_state_hash_tier: carries a canonical state hash but the document's tier is ` +
267
+ `${JSON.stringify(state.properties["assurance_tier"] ?? null)} — only "attested" (Tier 2) ` +
268
+ `defines that slot`);
269
+ }
270
+ switch (body.kind) {
271
+ case "add_holder": {
272
+ if (subject === null)
273
+ return `amendment_subject_required: add_holder names nobody`;
274
+ if (state.participants.has(subject)) {
275
+ return `amendment_subject_already_holder: ${subject} already holds this document`;
276
+ }
277
+ if (state.invited.has(subject)) {
278
+ return `amendment_subject_already_invited: ${subject} already holds an open invitation`;
279
+ }
280
+ // Invited seats ARE seats — counting only consented holders would let over-inviting
281
+ // smuggle a 21st past the door.
282
+ const admitted = state.participants.size + state.invited.size;
283
+ if (admitted + 1 > MAX_DOCUMENT_HOLDERS) {
284
+ return (`amendment_holder_cap: admitting ${subject} would make ${admitted + 1} admitted ` +
285
+ `seats and the cap is ${MAX_DOCUMENT_HOLDERS} (D5)`);
286
+ }
287
+ break;
288
+ }
289
+ case "consent": {
290
+ if (subject === null)
291
+ return `amendment_subject_required: consent names nobody`;
292
+ if (body.author_agent_id !== subject) {
293
+ return (`entry_consent_not_subject: a consent is the subject's own act — authored by ` +
294
+ `${body.author_agent_id}, names ${subject}`);
295
+ }
296
+ if (!state.invited.has(subject)) {
297
+ return (`amendment_subject_not_invited: ${subject} has no open invitation to answer at this ` +
298
+ `position`);
299
+ }
300
+ const expected = `${String(state.properties["assurance_tier"])}/${DOCUMENT_FEATURE_VERSION}`;
301
+ const claimed_to = body.property_change?.key === "consents_to" ? String(body.property_change.value) : null;
302
+ if (claimed_to !== expected) {
303
+ return (`entry_consents_to_mismatch: the consent claims "${claimed_to ?? "nothing"}" and ` +
304
+ `this document is "${expected}" — what was agreed to must be what stands (R22)`);
305
+ }
306
+ break;
307
+ }
308
+ case "refuse_join": {
309
+ if (subject === null)
310
+ return `amendment_subject_required: refuse_join names nobody`;
311
+ if (body.author_agent_id !== subject) {
312
+ return (`entry_consent_not_subject: a refusal is the subject's own act — authored by ` +
313
+ `${body.author_agent_id}, names ${subject}`);
314
+ }
315
+ if (!state.invited.has(subject)) {
316
+ return (`amendment_subject_not_invited: ${subject} has no open invitation to refuse at this ` +
317
+ `position`);
318
+ }
319
+ break;
320
+ }
321
+ case "close": {
322
+ if (subject === null)
323
+ return `amendment_subject_required: close names nobody`;
324
+ if (body.author_agent_id !== subject) {
325
+ return (`entry_consent_not_subject: a close is the closer's own act — authored by ` +
326
+ `${body.author_agent_id}, names ${subject}`);
327
+ }
328
+ if (!state.participants.has(subject)) {
329
+ return `amendment_subject_not_holder: ${subject} has no seat to close from`;
330
+ }
331
+ break;
332
+ }
333
+ case "kill": {
334
+ if (subject === null)
335
+ return `amendment_subject_required: kill names nobody`;
336
+ if (body.author_agent_id !== subject) {
337
+ return (`entry_consent_not_subject: a kill is the admin's own act — authored by ` +
338
+ `${body.author_agent_id}, names ${subject}`);
339
+ }
340
+ break;
341
+ }
342
+ case "remove_holder": {
343
+ if (subject === null)
344
+ return `amendment_subject_required: remove_holder names nobody`;
345
+ // An INVITED seat is removable too — that is invitation retraction (P3): an admin takes
346
+ // back an unanswered offer, and a consent concurrent with the retraction is void under
347
+ // the same removal-dominance every other authority conflict follows.
348
+ if (!state.participants.has(subject) && !state.invited.has(subject)) {
349
+ return `amendment_subject_not_holder: ${subject} neither holds this document nor holds an invitation to it`;
350
+ }
351
+ break;
352
+ }
353
+ case "promote_admin": {
354
+ if (subject === null)
355
+ return `amendment_subject_required: promote_admin names nobody`;
356
+ if (!state.participants.has(subject)) {
357
+ return `amendment_subject_not_holder: ${subject} does not hold this document`;
358
+ }
359
+ if (state.admins.has(subject)) {
360
+ return `amendment_subject_already_admin: ${subject} is already an admin`;
361
+ }
362
+ break;
363
+ }
364
+ case "remove_admin": {
365
+ if (subject === null)
366
+ return `amendment_subject_required: remove_admin names nobody`;
367
+ if (!state.admins.has(subject)) {
368
+ return `amendment_subject_not_admin: ${subject} holds no admin power to remove`;
369
+ }
370
+ break;
371
+ }
372
+ case "change_property": {
373
+ if (subject !== null) {
374
+ return `amendment_subject_forbidden: change_property is about the document, not a holder`;
375
+ }
376
+ if (body.property_change === null) {
377
+ return `amendment_property_missing: change_property carries no change`;
378
+ }
379
+ if (!AMENDABLE_PROPERTIES.has(body.property_change.key)) {
380
+ return (`amendment_property_not_amendable: "${body.property_change.key}" is not amendable — ` +
381
+ `the amendable set is {${[...AMENDABLE_PROPERTIES].join(", ")}}`);
382
+ }
383
+ break;
384
+ }
385
+ }
386
+ const verdict = policy(body.kind, subject, state, env.collection.required_signers);
387
+ if (!verdict.ok)
388
+ return verdict.reason;
389
+ const status = collectionStatus(env.collection, verify);
390
+ if (!status.complete) {
391
+ return (`amendment_collection_incomplete: missing [${status.missing.join(", ")}], invalid ` +
392
+ `[${status.invalidSigners.join(", ")}], unknown [${status.unknown.join(", ")}], ` +
393
+ `duplicate [${status.duplicates.join(", ")}]`);
394
+ }
395
+ return null;
396
+ }
397
+ function apply(env, state) {
398
+ const body = env.body;
399
+ switch (body.kind) {
400
+ case "add_holder":
401
+ state.invited.add(body.subject_agent_id);
402
+ break;
403
+ case "consent":
404
+ state.invited.delete(body.subject_agent_id);
405
+ state.participants.add(body.subject_agent_id);
406
+ // A declared genesis admin's power arrives WITH their participation (R21) — unless a
407
+ // removal already spent the grant (F6): the re-admitted return as plain holders.
408
+ if (declaredGenesisAdmins.has(body.subject_agent_id) &&
409
+ !state.spentDeclaredAdmins.has(body.subject_agent_id)) {
410
+ state.admins.add(body.subject_agent_id);
411
+ }
412
+ break;
413
+ case "refuse_join":
414
+ state.invited.delete(body.subject_agent_id);
415
+ break;
416
+ case "close":
417
+ state.closes.add(body.subject_agent_id);
418
+ break;
419
+ case "kill":
420
+ state.killed = true;
421
+ break;
422
+ case "remove_holder":
423
+ state.participants.delete(body.subject_agent_id);
424
+ state.invited.delete(body.subject_agent_id);
425
+ // Their agreement is spent with their seat: a re-admitted holder returns to a document
426
+ // that WAITS on them again, instead of one their old tenure's close silently settles.
427
+ state.closes.delete(body.subject_agent_id);
428
+ if (state.admins.has(body.subject_agent_id)) {
429
+ state.spentDeclaredAdmins.add(body.subject_agent_id);
430
+ }
431
+ state.admins.delete(body.subject_agent_id);
432
+ break;
433
+ case "promote_admin":
434
+ state.admins.add(body.subject_agent_id);
435
+ break;
436
+ case "remove_admin":
437
+ state.spentDeclaredAdmins.add(body.subject_agent_id);
438
+ state.admins.delete(body.subject_agent_id);
439
+ break;
440
+ case "change_property":
441
+ state.properties[body.property_change.key] = body.property_change.value;
442
+ break;
443
+ }
444
+ }
445
+ // ── F2: is a removal valid at its OWN ancestors? Memoized; recursion strictly shrinks. ──────
446
+ const removalVerdictMemo = new Map();
447
+ function removalValidAtAncestors(hash) {
448
+ const known = removalVerdictMemo.get(hash);
449
+ if (known !== undefined)
450
+ return known;
451
+ const env = included.get(hash);
452
+ const ancestorState = foldSubset(closure(hash)).state;
453
+ const reason = effectVoid(env, ancestorState);
454
+ const verdict = { ok: reason === null, reason };
455
+ removalVerdictMemo.set(hash, verdict);
456
+ return verdict;
457
+ }
458
+ /**
459
+ * F1's concurrency void: an ancestor-valid removal of this author, CONCURRENT with this entry —
460
+ * neither is an ancestor of the other. An entry the removers had seen stands; an entry authored
461
+ * AFTER the removal (removal among its ancestors) is not concurrent either — it is the
462
+ * fold-position state's question, which fails safe: without a re-admission the author is no
463
+ * longer a participant there and the act voids on its own merits, while after a legitimate
464
+ * re-admission it must take effect (the Entry 48 re-admission promise).
465
+ *
466
+ * RULED (M14B Entry 51, review F3): this check consults ancestor-validity, NOT the admin
467
+ * floor — so in the all-admins-remove-each-other race, the floor-voided removal still voids
468
+ * its victim's concurrent non-removal acts. Deterministic on every holder, err-on-the-safe
469
+ * side (the removal was pairwise legitimate), and the alternative needs a second fold pass
470
+ * for a case that takes every admin co-signing against every other to construct.
471
+ */
472
+ function concurrentRemovalOf(subset, entryHash, author) {
473
+ for (const other of subset) {
474
+ if (other === entryHash)
475
+ continue;
476
+ const env = included.get(other);
477
+ if (!isRemoval(env.body.kind))
478
+ continue;
479
+ if (env.body.subject_agent_id !== author)
480
+ continue;
481
+ if (!structuralOk(other))
482
+ continue;
483
+ if (!removalValidAtAncestors(other).ok)
484
+ continue;
485
+ if (closure(other).has(entryHash))
486
+ continue; // the removers had seen it — it stands
487
+ if (closure(entryHash).has(other))
488
+ continue; // authored after the removal — not concurrent
489
+ return other;
490
+ }
491
+ return null;
492
+ }
493
+ const structuralMemo = new Map();
494
+ function structuralOk(hash) {
495
+ let cached = structuralMemo.get(hash);
496
+ if (cached === undefined) {
497
+ cached = structuralVoid(included.get(hash), hash);
498
+ structuralMemo.set(hash, cached);
499
+ }
500
+ return cached === null;
501
+ }
502
+ // ── The fold — one function, used for the full set and (recursively) for ancestor subsets ───
503
+ function foldSubset(subset) {
504
+ const state = {
505
+ participants: new Set(genesisParticipants),
506
+ invited: new Set(genesisInvited),
507
+ admins: new Set(genesisAdmins),
508
+ spentDeclaredAdmins: new Set(),
509
+ closes: new Set(),
510
+ killed: false,
511
+ properties: { ...genesis.properties },
512
+ };
513
+ const order = linearize(subset);
514
+ const voids = [];
515
+ for (const hash of order) {
516
+ const env = included.get(hash);
517
+ const structural = structuralMemo.get(hash) ?? structuralVoid(env, hash);
518
+ structuralMemo.set(hash, structural);
519
+ if (structural !== null) {
520
+ voids.push({ hash, reason: structural });
521
+ continue;
522
+ }
523
+ if (isRemoval(env.body.kind)) {
524
+ const verdict = removalValidAtAncestors(hash);
525
+ if (!verdict.ok) {
526
+ voids.push({ hash, reason: verdict.reason });
527
+ continue;
528
+ }
529
+ // The admin floor (Entry 49): a removal that would empty the admin set is void HERE, at
530
+ // its fold position — the one check a removal answers to fold state.
531
+ const subject = env.body.subject_agent_id;
532
+ const wouldEmptyAdmins = state.admins.has(subject) && state.admins.size === 1;
533
+ if (wouldEmptyAdmins) {
534
+ voids.push({
535
+ hash,
536
+ reason: `entry_admin_floor: removing ${subject} at this position would leave the document ` +
537
+ `with no admins — it could never be amended again`,
538
+ });
539
+ continue;
540
+ }
541
+ // Idempotence at fold position: the subject may already be gone (a concurrent duplicate
542
+ // removal). Nothing to do is not a conflict.
543
+ apply(env, state);
544
+ continue;
545
+ }
546
+ const removal = concurrentRemovalOf(subset, hash, env.body.author_agent_id);
547
+ if (removal !== null) {
548
+ voids.push({
549
+ hash,
550
+ reason: `entry_void_concurrent_removal: authored by ${env.body.author_agent_id} concurrently ` +
551
+ `with their own removal (${removal}) — a removed party's concurrent authority does ` +
552
+ `not stand`,
553
+ });
554
+ continue;
555
+ }
556
+ const ineffective = effectVoid(env, state);
557
+ if (ineffective !== null) {
558
+ voids.push({ hash, reason: ineffective });
559
+ continue;
560
+ }
561
+ apply(env, state);
562
+ }
563
+ return { state, order, voids };
564
+ }
565
+ const allIncluded = new Set(included.keys());
566
+ const { state, order, voids } = foldSubset(allIncluded);
567
+ // ── Derived views for the surface and the authoring path ────────────────────────────────────
568
+ const namedAsParent = new Set();
569
+ for (const env of included.values()) {
570
+ for (const p of env.body.parents)
571
+ namedAsParent.add(p);
572
+ }
573
+ const frontier = [...included.keys()].filter((h) => !namedAsParent.has(h)).sort();
574
+ const authorSeqs = new Map();
575
+ for (const env of included.values()) {
576
+ const author = env.body.author_agent_id;
577
+ const seq = env.body.author_seq;
578
+ if ((authorSeqs.get(author) ?? 0) < seq)
579
+ authorSeqs.set(author, seq);
580
+ }
581
+ return {
582
+ ok: true,
583
+ state: {
584
+ participants: state.participants,
585
+ invited: state.invited,
586
+ admins: state.admins,
587
+ ended: state.killed
588
+ ? "killed"
589
+ : state.participants.size > 0 &&
590
+ state.invited.size === 0 &&
591
+ [...state.participants].every((participant) => state.closes.has(participant))
592
+ ? "closed"
593
+ : null,
594
+ closedBy: state.closes,
595
+ properties: state.properties,
596
+ order,
597
+ frontier,
598
+ voids,
599
+ excluded,
600
+ authorSeqs,
601
+ interimLastHash: order.length > 0 ? order[order.length - 1] : null,
602
+ },
603
+ };
604
+ }
605
+ //# sourceMappingURL=document-derive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-derive.js","sourceRoot":"","sources":["../src/document-derive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,GAIvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAiClE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAA2B,EAC3B,OAA6C,EAC7C,cAAiC,EACjC,MAAoB,EACpB,MAAgB;IAEhB,MAAM,MAAM,GAAG,IAAI,GAAG,CACpB,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;QACnB,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC5D,GAAG;KACJ,CAAC,CACH,CAAC;IACF,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO;YACL,E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