@cello-protocol/daemon 0.0.161 → 0.0.163

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 (65) hide show
  1. package/dist/daemon.js +15 -5
  2. package/dist/daemon.js.map +1 -1
  3. package/dist/document-ack-inbound.d.ts +8 -1
  4. package/dist/document-ack-inbound.d.ts.map +1 -1
  5. package/dist/document-ack-inbound.js +31 -8
  6. package/dist/document-ack-inbound.js.map +1 -1
  7. package/dist/document-amendment-store.d.ts +72 -0
  8. package/dist/document-amendment-store.d.ts.map +1 -0
  9. package/dist/document-amendment-store.js +151 -0
  10. package/dist/document-amendment-store.js.map +1 -0
  11. package/dist/document-control-notifier.d.ts +29 -0
  12. package/dist/document-control-notifier.d.ts.map +1 -1
  13. package/dist/document-control-notifier.js +62 -6
  14. package/dist/document-control-notifier.js.map +1 -1
  15. package/dist/document-delivery-transport.d.ts +2 -1
  16. package/dist/document-delivery-transport.d.ts.map +1 -1
  17. package/dist/document-delivery-transport.js +1 -1
  18. package/dist/document-delivery-transport.js.map +1 -1
  19. package/dist/document-delivery.d.ts +6 -1
  20. package/dist/document-delivery.d.ts.map +1 -1
  21. package/dist/document-delivery.js +167 -201
  22. package/dist/document-delivery.js.map +1 -1
  23. package/dist/document-frame-router.d.ts +15 -1
  24. package/dist/document-frame-router.d.ts.map +1 -1
  25. package/dist/document-frame-router.js +22 -1
  26. package/dist/document-frame-router.js.map +1 -1
  27. package/dist/document-gate.js +1 -1
  28. package/dist/document-gate.js.map +1 -1
  29. package/dist/document-handlers.d.ts.map +1 -1
  30. package/dist/document-handlers.js +649 -5
  31. package/dist/document-handlers.js.map +1 -1
  32. package/dist/document-handshake.d.ts +13 -0
  33. package/dist/document-handshake.d.ts.map +1 -1
  34. package/dist/document-handshake.js +24 -0
  35. package/dist/document-handshake.js.map +1 -1
  36. package/dist/document-inbound.d.ts +12 -0
  37. package/dist/document-inbound.d.ts.map +1 -1
  38. package/dist/document-inbound.js +141 -10
  39. package/dist/document-inbound.js.map +1 -1
  40. package/dist/document-join-store.d.ts +80 -0
  41. package/dist/document-join-store.d.ts.map +1 -0
  42. package/dist/document-join-store.js +197 -0
  43. package/dist/document-join-store.js.map +1 -0
  44. package/dist/document-layer.d.ts +52 -2
  45. package/dist/document-layer.d.ts.map +1 -1
  46. package/dist/document-layer.js +457 -12
  47. package/dist/document-layer.js.map +1 -1
  48. package/dist/document-lifecycle.d.ts +32 -1
  49. package/dist/document-lifecycle.d.ts.map +1 -1
  50. package/dist/document-lifecycle.js +88 -20
  51. package/dist/document-lifecycle.js.map +1 -1
  52. package/dist/document-publish.d.ts +7 -0
  53. package/dist/document-publish.d.ts.map +1 -1
  54. package/dist/document-publish.js +20 -4
  55. package/dist/document-publish.js.map +1 -1
  56. package/dist/document-rejection.js +1 -1
  57. package/dist/document-rejection.js.map +1 -1
  58. package/dist/document-store.d.ts +97 -4
  59. package/dist/document-store.d.ts.map +1 -1
  60. package/dist/document-store.js +335 -21
  61. package/dist/document-store.js.map +1 -1
  62. package/dist/vocabulary.d.ts.map +1 -1
  63. package/dist/vocabulary.js +2 -0
  64. package/dist/vocabulary.js.map +1 -1
  65. package/package.json +5 -5
@@ -95,14 +95,15 @@ export class DocumentDelivery {
95
95
  * unreachable peer must not stop delivery to every other peer, which is precisely the "works
96
96
  * only when all nodes are healthy" shape the project forbids.
97
97
  */
98
- async tick(ownerAgentId, peerFor, nowMs, opts = {}) {
99
- // NO RE-ENTRY. Nothing marks a row in-flight until its outcome lands, so a `deliver` slower
100
- // than the tick interval a dial to a distant peer is exactly that would have the next tick
101
- // return the same rows and dial again: two autonomous sessions and two seals for one envelope,
102
- // and the loser's markAcked returning false, which logs as if the PEER had redelivered an ack.
98
+ /**
99
+ * One pass over what is due, PER (document, holder). Returns counts rather than throwing on a
100
+ * per-target failure: one unreachable HOLDER must not stop delivery to any other — the same
101
+ * "works only when all nodes are healthy" shape the project forbids, now per holder.
102
+ */
103
+ async tick(ownerAgentId, holdersFor, nowMs, opts = {}) {
103
104
  if (this.#inFlight)
104
105
  return this.#inFlight;
105
- const run = this.#run(ownerAgentId, peerFor, nowMs, opts);
106
+ const run = this.#run(ownerAgentId, holdersFor, nowMs, opts);
106
107
  this.#inFlight = run;
107
108
  try {
108
109
  return await run;
@@ -111,239 +112,204 @@ export class DocumentDelivery {
111
112
  this.#inFlight = null;
112
113
  }
113
114
  }
114
- async #run(ownerAgentId, peerFor, nowMs, opts) {
115
- // THE PASS BUDGET. Spent down by every envelope that opens its own session and waits for an
116
- // ack; once it is gone the rest of the pass delivers without waiting rather than stalling
117
- // behind whoever exhausted it. See DELIVERY_ACK_GRACE_BUDGET_MS.
115
+ async #run(ownerAgentId, holdersFor, nowMs, opts) {
118
116
  let graceBudgetRemainingMs = DELIVERY_ACK_GRACE_BUDGET_MS;
119
- // Minted once per pass and threaded through every event, so an operator can tie a failure back
120
- // to the lookup that preceded it and the session that carried it. Delivery is precisely the
121
- // async multi-step flow the convention exists for: lookup, dial, deliver, ack — across ticks
122
- // and across restarts.
123
117
  const correlationId = opts.correlationId ?? `dlv-${ownerAgentId.slice(0, 8)}-${nowMs}`;
124
- // OUR sender id on the wire, which M14-D5 makes the pubkey hex rather than the owner key.
125
- // Passing the owner key here returned nothing pending and every published update sat in the log
126
- // undelivered, with no error on any path.
127
- const pending = this.#store.pendingDeliveries(ownerAgentId, nowMs, opts.senderAgentId);
118
+ const senderAgentId = opts.senderAgentId ?? ownerAgentId;
119
+ // LEGACY bilateral rows gain their per-holder twin before anything is read idempotent
120
+ // insurance, journaled (Entry 14): pre-fan-out backlogs are near-empty at alpha.
121
+ this.#store.backfillBilateralDeliveries(ownerAgentId, senderAgentId, nowMs);
122
+ const pending = this.#store.pendingHolderDeliveries(ownerAgentId, nowMs);
128
123
  const result = {
129
124
  attempted: 0, delivered: 0, sent: 0, rejected: 0, deferred: 0, failed: 0,
130
125
  };
131
- // Group by document so one reachability lookup serves every pending envelope for that peer.
132
- // Per-envelope lookups would multiply directory traffic by the size of the backlog, which is
133
- // largest exactly when the peer has been away longest.
126
+ // Grouped (document, holder): one derivation and one reachability probe serve every pending
127
+ // envelope for that pair.
134
128
  const byDocument = new Map();
135
- for (const e of pending) {
136
- const list = byDocument.get(e.documentId);
129
+ for (const p of pending) {
130
+ let holders = byDocument.get(p.documentId);
131
+ if (!holders) {
132
+ holders = new Map();
133
+ byDocument.set(p.documentId, holders);
134
+ }
135
+ const list = holders.get(p.holderAgentId);
137
136
  if (list)
138
- list.push(e);
137
+ list.push(p);
139
138
  else
140
- byDocument.set(e.documentId, [e]);
139
+ holders.set(p.holderAgentId, [p]);
141
140
  }
142
- for (const [documentId, envelopes] of byDocument) {
143
- const peerAgentId = peerFor(documentId);
144
- if (peerAgentId === null) {
145
- // No peer means the document row is gone or malformed, which is NOT transientso it goes
146
- // straight to the cap rather than climbing to it, and crucially it is SCHEDULED. Skipping
147
- // the schedule made this the one exit that never self-corrects: the rows stayed due on
148
- // every tick forever, emitting an error line each time, and — because the pending window
149
- // is ordered and bounded — they filled it and starved every other document. The operator's
150
- // work on an unrelated document would silently never leave the machine, with the only
151
- // signal being an error naming a different one.
152
- this.#logger.error("document.delivery.no_peer", {
141
+ for (const [documentId, holderGroups] of byDocument) {
142
+ const currentHolders = holdersFor(documentId);
143
+ if (currentHolders === null) {
144
+ // The document row is gone or its chain does not deriveNOT transient. Scheduled at
145
+ // the cap so the rows never starve anything, exactly the old no_peer discipline.
146
+ this.#logger.error("document.delivery.no_holders", {
153
147
  documentId,
154
- pending: envelopes.length,
148
+ pending: [...holderGroups.values()].reduce((n, l) => n + l.length, 0),
155
149
  correlationId,
156
150
  });
157
- for (const e of envelopes) {
158
- this.#store.recordDeliveryAttempt(ownerAgentId, documentId, e.envelopeHash, nowMs + DELIVERY_UNRESOLVABLE_RETRY_MS);
151
+ for (const [holder, rows] of holderGroups) {
152
+ for (const r of rows) {
153
+ this.#store.scheduleHolderRetry(ownerAgentId, documentId, r.envelope.envelopeHash, holder, nowMs + DELIVERY_UNRESOLVABLE_RETRY_MS);
154
+ }
155
+ result.failed += rows.length;
159
156
  }
160
- result.failed += envelopes.length;
161
157
  continue;
162
158
  }
163
- let reach;
164
- try {
165
- reach = await this.#transport.isPeerReachable(peerAgentId, correlationId);
166
- }
167
- catch (err) {
168
- // A FAILED LOOKUP IS NOT AN OFFLINE PEER. Recording it as "away" would report a directory
169
- // outage to the operator as their collaborator being absent — an error substituted for a
170
- // different error, and one that sends them to ask the wrong person.
171
- this.#logger.warn("document.delivery.lookup_failed", {
172
- documentId,
173
- peerAgentId,
174
- correlationId,
175
- reason: err instanceof Error ? err.message : String(err),
176
- });
177
- this.#defer(ownerAgentId, documentId, envelopes, nowMs);
178
- result.deferred += envelopes.length;
179
- continue;
180
- }
181
- if (!reach.reachable) {
182
- // The unknown-agent case is announced AGAINST THE DOCUMENT, not in a separate line that
183
- // cannot be joined to it. "This address does not resolve" and "your collaborator stepped
184
- // away" are different things to tell an operator, and the second is what they saw for both.
185
- this.#logger.info(reach.unknownAgent ? "document.delivery.peer_unknown" : "document.delivery.peer_unreachable", { documentId, peerAgentId, pending: envelopes.length, correlationId });
186
- this.#defer(ownerAgentId, documentId, envelopes, nowMs);
187
- result.deferred += envelopes.length;
188
- continue;
189
- }
190
- for (const envelope of envelopes) {
191
- result.attempted += 1;
192
- // CLAIM THE ROW BEFORE DIALING. Scheduling only on the outcome leaves the row due for the
193
- // whole duration of the dial, and leaves it due FOREVER if the daemon dies mid-dial. The
194
- // claim is corrected below when the outcome lands.
195
- const attempts = this.#store.recordDeliveryAttempt(ownerAgentId, documentId, envelope.envelopeHash, nowMs + backoffFor(envelope.attempts ?? 0));
196
- let outcome;
197
- const graceStartedAt = Date.now();
198
- try {
199
- outcome = await this.#transport.deliver({
200
- peerAgentId,
201
- documentId,
202
- envelope,
203
- // WHAT IS LEFT OF THE PASS BUDGET, never a fresh allowance. One unresponsive peer can
204
- // exhaust it, and then every later envelope in the sweep is delivered without a wait
205
- // rather than the sweep stalling behind it.
206
- ackGraceMs: Math.max(0, graceBudgetRemainingMs),
207
- // Per DOCUMENT. One hint applied to every envelope in the pass refused every OTHER
208
- // document's delivery — their peer's active sessions cannot contain this document's
209
- // session — so an unrelated update failed and backed off, citing a session the
210
- // operator never associated with it.
211
- sessionHint: opts.sessionHints?.get(documentId),
212
- correlationId,
159
+ const currentSet = new Set(currentHolders);
160
+ for (const [holderAgentId, rows] of holderGroups) {
161
+ // A holder the arrangement no longer includes — removed, or never derivable — is
162
+ // RETIRED, announced: our decision, not evidence about them (DOD-MP-REMOVE-1's
163
+ // delivery-stop clause, generalized per holder).
164
+ if (!currentSet.has(holderAgentId) ||
165
+ this.#store.memberRemoved(ownerAgentId, documentId, holderAgentId).removed) {
166
+ const retiredHashes = this.#store.abandonHolderDeliveries(ownerAgentId, documentId, holderAgentId, nowMs);
167
+ for (const hash of retiredHashes) {
168
+ this.#store.reconcileEnvelopeSettlement(ownerAgentId, documentId, hash, nowMs);
169
+ }
170
+ this.#logger.info("document.delivery.peer_removed", {
171
+ documentId, holderAgentId, retired: retiredHashes.length, correlationId,
213
172
  });
173
+ continue;
174
+ }
175
+ let reach;
176
+ try {
177
+ reach = await this.#transport.isPeerReachable(holderAgentId, correlationId);
214
178
  }
215
179
  catch (err) {
216
- // A THROW IS A FAILURE, never a success. Wrapped here rather than left to propagate so
217
- // one envelope's transport fault does not abandon the rest of the backlog mid-pass.
218
- outcome = {
219
- ok: false,
220
- reason: "document_delivery_threw",
221
- detail: err instanceof Error ? err.message : String(err),
222
- };
180
+ // A FAILED LOOKUP IS NOT AN OFFLINE HOLDER deferred, per holder, without an attempt.
181
+ this.#logger.warn("document.delivery.lookup_failed", {
182
+ documentId, holderAgentId, correlationId,
183
+ reason: err instanceof Error ? err.message : String(err),
184
+ });
185
+ for (const r of rows) {
186
+ // Deferrals ESCALATE the schedule (an offline holder must not be redialed at full
187
+ // rate forever) without touching the SENDS ceiling — waiting is not sending.
188
+ this.#store.recordHolderAttempt(ownerAgentId, documentId, r.envelope.envelopeHash, holderAgentId, nowMs + backoffFor(r.attempts));
189
+ }
190
+ result.deferred += rows.length;
191
+ continue;
223
192
  }
224
- finally {
225
- // SPEND WHAT THE CALL ACTUALLY TOOK, not the allowance it was offered. The dial and the
226
- // seal share the same await and cannot be timed apart from here, so the whole call is
227
- // charged the conservative direction, since it can only exhaust the budget sooner,
228
- // never let one envelope overrun it.
229
- graceBudgetRemainingMs -= Date.now() - graceStartedAt;
193
+ if (!reach.reachable) {
194
+ this.#logger.info(reach.unknownAgent ? "document.delivery.peer_unknown" : "document.delivery.peer_unreachable", { documentId, holderAgentId, pending: rows.length, correlationId });
195
+ for (const r of rows) {
196
+ this.#store.recordHolderAttempt(ownerAgentId, documentId, r.envelope.envelopeHash, holderAgentId, nowMs + backoffFor(r.attempts));
197
+ }
198
+ result.deferred += rows.length;
199
+ continue;
230
200
  }
231
- if (outcome.ok && outcome.admitted === null) {
232
- // IN FLIGHT. The content left and the peer has not answered.
233
- this.#store.markDelivered(ownerAgentId, documentId, envelope.envelopeHash, nowMs);
234
- // PARKED IS NOT DELIVERED, and scheduling them alike cost ten minutes per parked update.
235
- //
236
- // The ack timeout answers "how long do I wait for an ANSWER", and it is the right question
237
- // for content that reached the peer. Parked content did not reach them — the relay took it
238
- // because the session had no live counterparty — so the question is the one the ordinary
239
- // backoff answers: how long before trying again. Ten minutes for a peer who is online and
240
- // simply moved to another session is a stall the operator reads as a broken document.
241
- //
242
- // Caught by the no-chat enforcer flipping red when unrelated edits shifted timing by
243
- // milliseconds: the update parked onto a session the peer had just left, and the next
244
- // attempt was outside any window a person would wait.
245
- const parked = outcome.parked;
246
- this.#store.recordDeliveryAttempt(ownerAgentId, documentId, envelope.envelopeHash, nowMs + (parked ? backoffFor(envelope.attempts ?? 0) : DELIVERY_ACK_TIMEOUT_MS));
247
- this.#logger.info("document.delivery.sent", {
248
- documentId,
249
- envelopeHash: envelope.envelopeHash,
250
- sessionId: outcome.sessionId,
251
- sessionOpened: outcome.sessionOpened,
252
- unackedSends: attempts,
253
- correlationId,
254
- });
255
- result.sent += 1;
256
- if (attempts >= DELIVERY_MAX_UNACKED_SENDS) {
257
- // A peer that will never answer must stop being a transient. Otherwise this envelope is
258
- // re-sent forever and looks, in the log and in `list`, exactly like one about to land.
259
- //
260
- // AND IT DID, because setting the status was never what stopped it. The selection above
261
- // is `pendingDeliveries`, which filters on `acked_at IS NULL` and reads no status at
262
- // all — so `stalled` changed what the surface SAID and nothing about what the worker
263
- // DID. Every subsequent tick re-entered this branch, re-set the same status, and sent
264
- // again. Measured on the operator's daemon: `sends: 74` against a documented cap of 5,
265
- // while both the log line and the comment above claimed publishing had stopped.
266
- //
267
- // Retiring the envelope is what actually stops it — and it is retired as ABANDONED,
268
- // not as acked. `markAcked` was the first spelling and it was wrong: `acked_at` means
269
- // "the peer's daemon answered", so reusing it made `withdraw` tell the operator "your
270
- // peer holds it, so it cannot be withdrawn" about an envelope the peer may never have
271
- // seen. Giving up is our decision; it is not evidence about them.
272
- this.#store.setDocumentStatus(ownerAgentId, documentId, "stalled");
273
- this.#store.markAbandoned(ownerAgentId, documentId, envelope.envelopeHash, nowMs);
274
- this.#logger.error("document.delivery.unacked_limit", {
201
+ for (const row of rows) {
202
+ const envelope = row.envelope;
203
+ result.attempted += 1;
204
+ // CLAIM THE ROW BEFORE DIALING due-forever-on-crash-mid-dial is the same hazard it
205
+ // always was, per holder now.
206
+ this.#store.recordHolderAttempt(ownerAgentId, documentId, envelope.envelopeHash, holderAgentId, nowMs + backoffFor(row.attempts));
207
+ let outcome;
208
+ const graceStartedAt = Date.now();
209
+ try {
210
+ outcome = await this.#transport.deliver({
211
+ peerAgentId: holderAgentId,
275
212
  documentId,
276
- envelopeHash: envelope.envelopeHash,
277
- sends: attempts,
213
+ envelope,
214
+ ackGraceMs: Math.max(0, graceBudgetRemainingMs),
215
+ sessionHint: opts.sessionHints?.get(documentId),
278
216
  correlationId,
279
- // WHAT WAS OBSERVED, not a guess about whose fault it is. This said "Their client may
280
- // not support shared documents yet" — an assertion about the PEER'S SOFTWARE for a
281
- // failure whose measured cause was our own teardown deleting an ack that had already
282
- // arrived and been verified. An exit-point label presented as a diagnosis, and it
283
- // sent the one operator who hit it looking at the wrong machine.
284
- //
285
- // Both named events are ours and are upstream of this line, so the operator has
286
- // somewhere to go before concluding anything about the counterparty.
287
- detail: `this update has been delivered ${attempts} times without the peer's daemon ever ` +
288
- `confirming it — the document has stopped publishing and this update will not be ` +
289
- `retried. The cause may be local: check document.delivery.ack_grace_expired and ` +
290
- `session.content.held.discarded for this session before concluding the peer's ` +
291
- `client is at fault.`,
292
217
  });
293
218
  }
294
- }
295
- else if (outcome.ok) {
296
- // ACK = the peer's daemon ANSWERED, admitted or not. A rejection is an ack for delivery
297
- // purposes (§3.2's 0x05): the peer has decided, so there is nothing left to retry, and
298
- // retrying would re-trigger their gate and their retry counter until the document stalls
299
- // for reasons the operator cannot see. Supersession is REJECT-1's job, not the worker's.
300
- const first = this.#store.markAcked(ownerAgentId, documentId, envelope.envelopeHash, nowMs);
301
- this.#logger.info("document.delivery.session", {
302
- documentId,
303
- sessionId: outcome.sessionId,
304
- opened: outcome.sessionOpened,
305
- correlationId,
306
- });
307
- if (outcome.admitted) {
308
- this.#logger.info("document.delivery.acked", {
219
+ catch (err) {
220
+ outcome = {
221
+ ok: false,
222
+ reason: "document_delivery_threw",
223
+ detail: err instanceof Error ? err.message : String(err),
224
+ };
225
+ }
226
+ finally {
227
+ graceBudgetRemainingMs -= Date.now() - graceStartedAt;
228
+ }
229
+ if (outcome.ok && outcome.admitted === null) {
230
+ // IN FLIGHT for THIS holder. Parked and live sends want DIFFERENT retry schedules,
231
+ // but both LEFT the machine — the sent-vs-never-left surface counts either (review
232
+ // M7: reporting relay-parked content as "never left" mislabels a delivery that the
233
+ // relay is holding for them).
234
+ this.#store.markHolderDelivered(ownerAgentId, documentId, envelope.envelopeHash, holderAgentId, nowMs);
235
+ const sends = this.#store.recordHolderSend(ownerAgentId, documentId, envelope.envelopeHash, holderAgentId);
236
+ this.#store.scheduleHolderRetry(ownerAgentId, documentId, envelope.envelopeHash, holderAgentId, nowMs + (outcome.parked ? backoffFor(row.attempts) : DELIVERY_ACK_TIMEOUT_MS));
237
+ this.#logger.info("document.delivery.sent", {
309
238
  documentId,
310
239
  envelopeHash: envelope.envelopeHash,
240
+ holderAgentId,
311
241
  sessionId: outcome.sessionId,
312
- firstAck: first,
242
+ sessionOpened: outcome.sessionOpened,
243
+ unackedSends: sends,
313
244
  correlationId,
314
245
  });
315
- result.delivered += 1;
246
+ result.sent += 1;
247
+ if (sends >= DELIVERY_MAX_UNACKED_SENDS) {
248
+ // THIS HOLDER is exhausted — retired, announced, and only theirs. The document
249
+ // stalls ONLY when every current holder is exhausted: one silent peer stopping a
250
+ // living collaboration is the exact availability failure the milestone forbids.
251
+ this.#store.abandonSingleHolderDelivery(ownerAgentId, documentId, envelope.envelopeHash, holderAgentId, nowMs);
252
+ this.#store.reconcileEnvelopeSettlement(ownerAgentId, documentId, envelope.envelopeHash, nowMs);
253
+ this.#logger.error("document.delivery.unacked_limit", {
254
+ documentId,
255
+ envelopeHash: envelope.envelopeHash,
256
+ holderAgentId,
257
+ sends,
258
+ correlationId,
259
+ detail: `this update has been delivered ${sends} times to this holder without their ` +
260
+ `daemon ever confirming it — delivery TO THEM is retired; every other holder ` +
261
+ `is unaffected. Check document.delivery.ack_grace_expired, ` +
262
+ `session.content.held.discarded, and whether their daemon has yet received ` +
263
+ `the amendment that added you (their log would show ` +
264
+ `document.inbound.sender_unknown_epoch_ahead) before concluding their client ` +
265
+ `is at fault.`,
266
+ });
267
+ const allExhausted = currentHolders
268
+ .filter((h) => h !== senderAgentId)
269
+ .every((h) => !this.#store.holderHasPending(ownerAgentId, documentId, h));
270
+ if (allExhausted) {
271
+ this.#store.setDocumentStatus(ownerAgentId, documentId, "stalled");
272
+ this.#logger.error("document.delivery.stalled_all_holders", {
273
+ documentId, correlationId,
274
+ });
275
+ }
276
+ }
277
+ }
278
+ else if (outcome.ok) {
279
+ const first = this.#store.ackHolderDelivery(ownerAgentId, documentId, envelope.envelopeHash, holderAgentId, nowMs);
280
+ // The envelope-level record follows the ONE terminal rule (review M3).
281
+ this.#store.reconcileEnvelopeSettlement(ownerAgentId, documentId, envelope.envelopeHash, nowMs);
282
+ this.#logger.info("document.delivery.session", {
283
+ documentId, holderAgentId, sessionId: outcome.sessionId,
284
+ opened: outcome.sessionOpened, correlationId,
285
+ });
286
+ if (outcome.admitted) {
287
+ this.#logger.info("document.delivery.acked", {
288
+ documentId, envelopeHash: envelope.envelopeHash, holderAgentId,
289
+ sessionId: outcome.sessionId, firstAck: first, correlationId,
290
+ });
291
+ result.delivered += 1;
292
+ }
293
+ else {
294
+ this.#logger.warn("document.delivery.rejected", {
295
+ documentId, envelopeHash: envelope.envelopeHash, holderAgentId,
296
+ sessionId: outcome.sessionId, reason: outcome.rejectionReason, correlationId,
297
+ });
298
+ result.rejected += 1;
299
+ }
316
300
  }
317
301
  else {
318
- this.#logger.warn("document.delivery.rejected", {
319
- documentId,
320
- envelopeHash: envelope.envelopeHash,
321
- sessionId: outcome.sessionId,
322
- reason: outcome.rejectionReason,
302
+ this.#logger.warn("document.delivery.failed", {
303
+ documentId, envelopeHash: envelope.envelopeHash, holderAgentId,
304
+ reason: outcome.reason, detail: outcome.detail, attempts: row.attempts + 1,
323
305
  correlationId,
324
306
  });
325
- result.rejected += 1;
307
+ result.failed += 1;
326
308
  }
327
309
  }
328
- else {
329
- this.#logger.warn("document.delivery.failed", {
330
- documentId,
331
- envelopeHash: envelope.envelopeHash,
332
- reason: outcome.reason,
333
- detail: outcome.detail,
334
- attempts,
335
- correlationId,
336
- });
337
- result.failed += 1;
338
- }
339
310
  }
340
311
  }
341
312
  return result;
342
313
  }
343
- #defer(ownerAgentId, documentId, envelopes, nowMs) {
344
- for (const e of envelopes) {
345
- this.#store.recordDeliveryAttempt(ownerAgentId, documentId, e.envelopeHash, nowMs + backoffFor(e.attempts ?? 0));
346
- }
347
- }
348
314
  }
349
315
  //# sourceMappingURL=document-delivery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"document-delivery.js","sourceRoot":"","sources":["../src/document-delivery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAgHH;;;;;;;;;;;GAWG;AACH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC;AAEnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAU,CAAC;AACrF,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAE3F;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AAE/D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,uBAAuB,CAAC;AAEtE,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC5E,OAAO,mBAAmB,CAAC,GAAG,CAAE,CAAC;AACnC,CAAC;AAaD,MAAM,OAAO,gBAAgB;IAClB,MAAM,CAAgB;IACtB,UAAU,CAA4B;IACtC,OAAO,CAAS;IACzB,SAAS,GAAuC,IAAI,CAAC;IAErD,YAAY,KAAoB,EAAE,SAAoC,EAAE,MAAc;QACpF,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB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YAAY,EAAE,aAAa;4BAC9D,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,GAAG,CAAC;4BAC1E,aAAa;yBACd,CAAC,CAAC;wBACH,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;oBACrB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -76,7 +76,7 @@ import type { Logger } from "./types.js";
76
76
  * message and fires the doorbell exactly as before. Nothing about the conversation path changes.
77
77
  */
78
78
  /** Every document frame kind that can arrive on the session channel. */
79
- export type DocumentFrameKind = "update" | "ack" | "proposal" | "rejection" | "proposal_ack" | "control";
79
+ export type DocumentFrameKind = "update" | "ack" | "proposal" | "rejection" | "proposal_ack" | "control" | "join_offer" | "join_answer" | "amendment";
80
80
  export type FrameRouting = {
81
81
  consumed: false;
82
82
  } | {
@@ -122,6 +122,20 @@ export interface DocumentFrameRouterDeps {
122
122
  * with nothing on their screen explaining why.
123
123
  */
124
124
  recordControl(ownerAgentId: string, wire: Uint8Array, nowMs: number): void;
125
+ /**
126
+ * M14B / DOD-MP-JOIN-1 — an admin's offer to a third party. Validated (the invitee REPLAYS the
127
+ * carried bytes) and recorded — pending or refused-with-reason, never dropped.
128
+ */
129
+ recordJoinOffer(ownerAgentId: string, wire: Uint8Array, nowMs: number): void;
130
+ /** The invitee's signed answer to an offer we authored. Settle-once. */
131
+ recordJoinAnswer(ownerAgentId: string, wire: Uint8Array, nowMs: number): void;
132
+ /**
133
+ * An amendment reaching an EXISTING holder — validated against our own chain
134
+ * (validate-before-append) and appended, so our derived participant set does not silently
135
+ * diverge from the amender's (§7-1's hazard). Best-effort delivery at P1; the inbound epoch
136
+ * gate makes a missed one loud.
137
+ */
138
+ recordAmendment(ownerAgentId: string, wire: Uint8Array, nowMs: number): void;
125
139
  /**
126
140
  * Tell the sender what happened to their envelope — admitted or refused, both of which SETTLE it.
127
141
  *
@@ -1 +1 @@
1
- {"version":3,"file":"document-frame-router.d.ts","sourceRoot":"","sources":["../src/document-frame-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAWH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;GAKG;AACH,wEAAwE;AACxE,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,KAAK,GACL,UAAU,GACV,WAAW,GACX,cAAc,GACd,SAAS,CAAC;AAEd,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,EAAE,KAAK,CAAA;CAAE,GACnB;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IAAE,QAAQ,EAAE,KAAK,CAAA;CAAE,GACnB;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAEhD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,kBAAkB,CAAC;IAC/B;;;;;OAKG;IACH,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5E,wEAAwE;IACxE,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAA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,MAAM;IACpB,+FAA+F;IAC/F,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE;QACP,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,OAAO,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,aAAa,EAAE,MAAM,CAAC;KACvB,GACA,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB;;;;;;;;;;;;;;;;OAgBG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,mBAAmB;;gBAKlB,IAAI,EAAE,uBAAuB;IAIzC;;;;;;;OAOG;IACH;;;;;;OAMG;IACH,SAAS,CACP,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,GACpB,mBAAmB;IA2EtB,oGAAoG;IAC9F,KAAK,CACT,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,YAAY,CAAC;CAuKzB;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,QAAkB,CAAC"}
@@ -66,7 +66,7 @@
66
66
  *
67
67
  * The guard must never again be described as what makes hostile input safe. It was, and it was not.
68
68
  */
69
- import { decodeCbor, decodeDocumentUpdateEnvelope, decodeDocumentAck, decodeDocumentProposal, decodeDocumentRejection, decodeDocumentProposalAck, decodeDocumentControl, } from "@cello-protocol/protocol-types";
69
+ import { decodeCbor, decodeDocumentUpdateEnvelope, decodeDocumentAck, decodeDocumentProposal, decodeDocumentRejection, decodeDocumentProposalAck, decodeDocumentControl, decodeDocumentJoinOffer, decodeDocumentJoinAnswer, decodeDocumentAmendment, } from "@cello-protocol/protocol-types";
70
70
  export class DocumentFrameRouter {
71
71
  #d;
72
72
  /** One promise chain per owning agent — the serialization point. See `#enqueue`. */
@@ -295,6 +295,18 @@ export class DocumentFrameRouter {
295
295
  this.#d.recordControl(ownerAgentId, content, nowMs);
296
296
  return { consumed: true, kind, ok: true };
297
297
  }
298
+ if (kind === "join_offer") {
299
+ this.#d.recordJoinOffer(ownerAgentId, content, nowMs);
300
+ return { consumed: true, kind, ok: true };
301
+ }
302
+ if (kind === "join_answer") {
303
+ this.#d.recordJoinAnswer(ownerAgentId, content, nowMs);
304
+ return { consumed: true, kind, ok: true };
305
+ }
306
+ if (kind === "amendment") {
307
+ this.#d.recordAmendment(ownerAgentId, content, nowMs);
308
+ return { consumed: true, kind, ok: true };
309
+ }
298
310
  const res = this.#d.ackInbound.receive(ownerAgentId, content, nowMs, correlationId);
299
311
  return { consumed: true, kind, ok: res.ok, reason: res.ok ? undefined : res.reason };
300
312
  }
@@ -415,6 +427,15 @@ function classify(content) {
415
427
  case "document_control":
416
428
  decodeDocumentControl(content);
417
429
  return "control";
430
+ case "document_join_offer":
431
+ decodeDocumentJoinOffer(content);
432
+ return "join_offer";
433
+ case "document_join_answer":
434
+ decodeDocumentJoinAnswer(content);
435
+ return "join_answer";
436
+ case "document_amendment":
437
+ decodeDocumentAmendment(content);
438
+ return "amendment";
418
439
  default:
419
440
  // A frame type this build does not know. Reported by the caller rather than silently
420
441
  // treated as conversation — see `routeSync`.