@agentshouse/mdruntime 0.1.0-c95464765b116 → 0.1.0-c969b8dee6cc8

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 (99) hide show
  1. package/AGENTS.md +238 -233
  2. package/README.md +8 -8
  3. package/dist/adapter.d.ts +20 -6
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/bootstrap.d.ts +2 -1
  6. package/dist/bootstrap.d.ts.map +1 -1
  7. package/dist/bootstrap.js +4 -0
  8. package/dist/change-set.d.ts.map +1 -1
  9. package/dist/change-set.js +2 -1
  10. package/dist/chat/earlier.d.ts +10 -0
  11. package/dist/chat/earlier.d.ts.map +1 -0
  12. package/dist/chat/earlier.js +54 -0
  13. package/dist/chat/kit.js +1 -1
  14. package/dist/chat/list.d.ts.map +1 -1
  15. package/dist/chat/list.js +39 -3
  16. package/dist/chat/provider.d.ts +1 -1
  17. package/dist/chat/provider.d.ts.map +1 -1
  18. package/dist/chat/provider.js +35 -27
  19. package/dist/chat/question.d.ts +1 -1
  20. package/dist/chat/question.d.ts.map +1 -1
  21. package/dist/chat/question.js +7 -18
  22. package/dist/chat/style.js +1 -1
  23. package/dist/client.d.ts +7 -2
  24. package/dist/client.d.ts.map +1 -1
  25. package/dist/client.js +16 -5
  26. package/dist/connection.d.ts +13 -3
  27. package/dist/connection.d.ts.map +1 -1
  28. package/dist/connection.js +417 -107
  29. package/dist/conversation.d.ts +7 -0
  30. package/dist/conversation.d.ts.map +1 -1
  31. package/dist/conversation.js +206 -48
  32. package/dist/entry.d.ts.map +1 -1
  33. package/dist/entry.js +1 -1
  34. package/dist/host.d.ts +8 -3
  35. package/dist/host.d.ts.map +1 -1
  36. package/dist/host.js +58 -6
  37. package/dist/index.d.ts +6 -5
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +1 -0
  40. package/dist/memory.d.ts +6 -1
  41. package/dist/memory.d.ts.map +1 -1
  42. package/dist/memory.js +20 -5
  43. package/dist/model.d.ts +3 -2
  44. package/dist/model.d.ts.map +1 -1
  45. package/dist/model.js +1 -1
  46. package/dist/observation.d.ts +2 -0
  47. package/dist/observation.d.ts.map +1 -1
  48. package/dist/observation.js +9 -3
  49. package/dist/outcome.d.ts +8 -2
  50. package/dist/outcome.d.ts.map +1 -1
  51. package/dist/outcome.js +3 -0
  52. package/dist/overlay.d.ts +1 -0
  53. package/dist/overlay.d.ts.map +1 -1
  54. package/dist/overlay.js +27 -3
  55. package/dist/query.d.ts +29 -2
  56. package/dist/query.d.ts.map +1 -1
  57. package/dist/query.js +36 -7
  58. package/dist/reach.d.ts +1 -2
  59. package/dist/reach.d.ts.map +1 -1
  60. package/dist/reach.js +17 -4
  61. package/dist/react.d.ts +3 -3
  62. package/dist/react.d.ts.map +1 -1
  63. package/dist/react.js +7 -17
  64. package/dist/read-side.d.ts.map +1 -1
  65. package/dist/read-side.js +176 -48
  66. package/dist/reads.d.ts +11 -0
  67. package/dist/reads.d.ts.map +1 -0
  68. package/dist/reads.js +98 -0
  69. package/dist/refresh.d.ts +4 -4
  70. package/dist/refresh.d.ts.map +1 -1
  71. package/dist/refresh.js +6 -0
  72. package/dist/replica.d.ts +5 -1
  73. package/dist/replica.d.ts.map +1 -1
  74. package/dist/replica.js +30 -5
  75. package/dist/room-draft.d.ts +13 -1
  76. package/dist/room-draft.d.ts.map +1 -1
  77. package/dist/room-draft.js +2 -2
  78. package/dist/rows.d.ts +3 -1
  79. package/dist/rows.d.ts.map +1 -1
  80. package/dist/rows.js +8 -1
  81. package/dist/save.d.ts +1 -0
  82. package/dist/save.d.ts.map +1 -1
  83. package/dist/save.js +17 -1
  84. package/dist/search.d.ts +28 -7
  85. package/dist/search.d.ts.map +1 -1
  86. package/dist/search.js +89 -7
  87. package/dist/seed.d.ts +16 -0
  88. package/dist/seed.d.ts.map +1 -0
  89. package/dist/seed.js +75 -0
  90. package/dist/store.d.ts +20 -5
  91. package/dist/store.d.ts.map +1 -1
  92. package/dist/store.js +58 -18
  93. package/dist/windows.d.ts +26 -0
  94. package/dist/windows.d.ts.map +1 -0
  95. package/dist/windows.js +93 -0
  96. package/dist/wire.d.ts +16 -0
  97. package/dist/wire.d.ts.map +1 -1
  98. package/dist/wire.js +4 -0
  99. package/package.json +2 -2
package/dist/read-side.js CHANGED
@@ -2,6 +2,7 @@ import { and, BasicIndex, configureIndexDevMode, count, createCollection, create
2
2
  import { ARRAY_INDEX, parse, pointerSegments } from '@agentshouse/mdmodel';
3
3
  import { documentKey } from './rows.js';
4
4
  import { after, inUnits, ROW_WEIGHT } from './turn.js';
5
+ import { beyond, cursorOf, MAXIMUM_WINDOW, windowed } from './windows.js';
5
6
  function every(expressions) {
6
7
  const [first, second, ...rest] = expressions;
7
8
  return second === undefined ? first : and(first, second, ...rest);
@@ -59,10 +60,12 @@ function reached(reach, room, document) {
59
60
  ? []
60
61
  : [or(inArray(room, [...reach.rooms]), inArray(document, [...reach.documents]))];
61
62
  }
62
- function scoped(scope, row, rooms, reach) {
63
+ function scoped(scope, row, rooms, reach, paths = null, folder = null) {
63
64
  return every([
64
65
  eq(row.kind, 'document'),
65
66
  ...(rooms === null ? [] : [inArray(row.room, [...rooms])]),
67
+ ...(paths === null ? [] : [inArray(row.path, [...paths])]),
68
+ ...(folder === null ? [] : [eq(row.folder, folder)]),
66
69
  ...reached(reach, row.room, row.key),
67
70
  ...(scope.types === null ? [] : [inArray(row.type, [...scope.types])]),
68
71
  ...(scope.pathPrefix === null ? [] : [inArray(scope.pathPrefix, row.directories)]),
@@ -90,7 +93,7 @@ function related(q, rows, scope, field, kept, reach) {
90
93
  }
91
94
  function filtered(q, rows, plan) {
92
95
  const from = q.from({ d: rows });
93
- let query = narrowed(from.where(({ d }) => scoped(plan.root, d, plan.rooms, plan.reach)), plan.root.where, 'd');
96
+ let query = narrowed(from.where(({ d }) => scoped(plan.root, d, plan.rooms, plan.reach, plan.paths, plan.folder)), plan.root.where, 'd');
94
97
  if (plan.hop !== null) {
95
98
  const hop = related(q, rows, plan.hop, plan.hop.field, 'source', plan.reach);
96
99
  query = query.innerJoin({ h: hop }, ({ d, h }) => eq(d.key, h.key));
@@ -104,25 +107,56 @@ function filtered(q, rows, plan) {
104
107
  function bodied(shape) {
105
108
  return shape.sections !== null || shape.preamble || shape.markdown;
106
109
  }
110
+ function orderingOf(options) {
111
+ const collated = options.stringSort === 'locale';
112
+ return {
113
+ direction: options.direction,
114
+ nulls: options.nulls ?? 'first',
115
+ stringSort: options.stringSort ?? 'locale',
116
+ locale: collated ? options.locale : undefined,
117
+ localeOptions: collated
118
+ ? options.localeOptions
119
+ : undefined,
120
+ };
121
+ }
122
+ function storedValue(key, row) {
123
+ return key.of === 'field' ? row.values[key.field] : row[key.of];
124
+ }
125
+ function documentOrder(shape) {
126
+ return shape.orderBy.map(({ options }) => orderingOf(options));
127
+ }
128
+ function documentCursor(shape, row) {
129
+ return cursorOf([
130
+ ...shape.orderBy.map((_, index) => row[`order${index}`]),
131
+ documentKey(row.room, row.path),
132
+ ]);
133
+ }
107
134
  function documents(q, rows, plan, shape) {
108
135
  let query = filtered(q, rows, plan);
136
+ const cursor = plan.after?.values ?? null;
137
+ if (cursor !== null) {
138
+ const orderings = documentOrder(shape);
139
+ query = query.fn.where(({ d }) => beyond([...shape.orderBy.map(({ key }) => storedValue(key, d)), d.key], cursor, orderings));
140
+ }
109
141
  for (const { key, options } of shape.orderBy) {
110
142
  query = query.orderBy(({ d }) => keyed(key, d), options);
111
143
  }
112
- if (shape.orderBy.length === 0 && plan.limit !== null) {
144
+ if (shape.orderBy.length > 0 || plan.limit !== null || plan.after !== null) {
113
145
  query = query.orderBy(({ d }) => d.key, { stringSort: 'lexical' });
114
146
  }
115
147
  if (plan.limit !== null)
116
- query = query.limit(plan.limit);
148
+ query = query.limit(plan.limit + 1);
117
149
  return query.select(({ d }) => ({
118
150
  room: d.room,
119
151
  path: d.path,
120
152
  type: d.type,
121
153
  binary: d.binary,
154
+ ...Object.fromEntries(shape.orderBy.map(({ key }, index) => [`order${index}`, keyed(key, d)])),
122
155
  ...(shape.fields === null ? {} : { fields: d.fields }),
123
156
  ...(bodied(shape) ? { text: d.text } : {}),
124
157
  ...(shape.backlinks ? { backlinks: toArray(backlinked(q, rows, d, plan.reach)) } : {}),
125
158
  ...(shape.change ? { change: d.change } : {}),
159
+ ...(shape.fileId ? { fileId: d.fileId } : {}),
126
160
  }));
127
161
  }
128
162
  function backlinked(q, rows, document, reach) {
@@ -133,15 +167,13 @@ function backlinked(q, rows, document, reach) {
133
167
  .orderBy(({ r }) => r.field, { stringSort: 'lexical' })
134
168
  .select(({ r }) => ({ path: r.path, type: r.type, field: r.field }));
135
169
  }
136
- function groups(q, stage, shape, limit) {
170
+ function groups(q, stage, shape) {
137
171
  const keys = shape.groupBy.map((_, index) => `key${index}`);
138
172
  const from = q.from({ m: stage });
139
173
  let query = from.groupBy(({ m }) => keys.map((key) => m[key]));
140
174
  for (const { by, direction } of shape.orderBy) {
141
175
  query = query.orderBy(({ m }) => (by === 'count' ? count(m.key) : m[keys[by]]), direction);
142
176
  }
143
- if (limit !== null && shape.orderBy.length > 0)
144
- query = query.limit(limit);
145
177
  return query.select(({ m }) => ({
146
178
  ...Object.fromEntries(keys.map((key) => [key, m[key]])),
147
179
  count: count(m.key),
@@ -151,15 +183,27 @@ function built(rows, plan) {
151
183
  const shape = plan.shape;
152
184
  if (shape.kind === 'documents') {
153
185
  const collection = live((q) => documents(q, rows, plan, shape));
154
- return { live: collection, dispose: () => void collection.cleanup() };
186
+ const count = plan.total
187
+ ? live((q) => filtered(q, rows, plan).select(({ d }) => ({ key: d.key })))
188
+ : null;
189
+ return {
190
+ live: collection,
191
+ count,
192
+ dispose: () => {
193
+ void collection.cleanup();
194
+ if (count !== null)
195
+ void count.cleanup();
196
+ },
197
+ };
155
198
  }
156
199
  const stage = live((q) => filtered(q, rows, plan).select(({ d }) => ({
157
200
  key: d.key,
158
201
  ...Object.fromEntries(shape.groupBy.map((key, index) => [`key${index}`, keyed(key, d)])),
159
202
  })));
160
- const collection = live((q) => groups(q, stage, shape, plan.limit));
203
+ const collection = live((q) => groups(q, stage, shape));
161
204
  return {
162
205
  live: collection,
206
+ count: null,
163
207
  dispose: () => {
164
208
  void collection.cleanup();
165
209
  void stage.cleanup();
@@ -239,6 +283,7 @@ function documentOf(key, row, shape, bodies) {
239
283
  room: row.room,
240
284
  path: row.path,
241
285
  ...(binary === null ? {} : { binaryFile: binary }),
286
+ ...(shape.fileId ? { fileId: row.fileId } : {}),
242
287
  };
243
288
  }
244
289
  const body = bodied(shape) ? bodyOf(row, key, bodies) : null;
@@ -260,33 +305,74 @@ function documentOf(key, row, shape, bodies) {
260
305
  ...(shape.markdown && body !== null ? { markdown: body.content } : {}),
261
306
  ...(shape.backlinks
262
307
  ? {
263
- backlinks: row.backlinks.map(({ path, type, field }) => ({ path, type, field })),
308
+ backlinks: row.backlinks
309
+ .slice(0, MAXIMUM_WINDOW)
310
+ .map(({ path, type, field }) => ({ path, type, field })),
264
311
  }
265
312
  : {}),
266
313
  ...(shape.change ? { change: row.change } : {}),
314
+ ...(shape.fileId ? { fileId: row.fileId } : {}),
267
315
  };
268
316
  }
269
317
  function weight(row) {
270
318
  return ROW_WEIGHT + (typeof row?.text === 'string' ? row.text.length : 0);
271
319
  }
272
- function rowsOfPlan(plan, entries, bodies, each = (row) => row) {
320
+ function groupValues(shape, [key, row]) {
321
+ return [...shape.orderBy.map(({ by }) => (by === 'count' ? row.count : row[`key${by}`])), key];
322
+ }
323
+ function groupOrder(shape) {
324
+ return shape.orderBy.map(({ direction }) => ({
325
+ direction,
326
+ nulls: 'first',
327
+ stringSort: 'locale',
328
+ locale: undefined,
329
+ localeOptions: undefined,
330
+ }));
331
+ }
332
+ function windowOf(plan, entries, total) {
333
+ const shape = plan.shape;
334
+ if (shape.kind === 'documents') {
335
+ return {
336
+ ...windowed(entries, plan.limit, plan.after?.text, ([, row]) => documentCursor(shape, row)),
337
+ total,
338
+ };
339
+ }
340
+ const cursor = plan.after?.values ?? null;
341
+ const orderings = groupOrder(shape);
342
+ const following = cursor === null
343
+ ? entries
344
+ : entries.filter((entry) => beyond(groupValues(shape, entry), cursor, orderings));
345
+ return {
346
+ ...windowed(following, plan.limit, plan.after?.text, (entry) => cursorOf(groupValues(shape, entry))),
347
+ total: plan.total ? entries.length : undefined,
348
+ };
349
+ }
350
+ function framed(rows, { next, total }) {
351
+ return {
352
+ ...rows,
353
+ ...(next === undefined ? {} : { next }),
354
+ ...(total === undefined ? {} : { total }),
355
+ };
356
+ }
357
+ function rowsOfPlan(plan, entries, total, bodies, each = (row) => row) {
273
358
  const shape = plan.shape;
359
+ const { kept, ...window } = windowOf(plan, entries, total);
360
+ const keys = kept.map(([key]) => key);
274
361
  if (shape.kind === 'documents') {
275
362
  const documents = [];
276
- return after(inUnits(entries, ([key, row]) => {
363
+ return after(inUnits(kept, ([key, row]) => {
277
364
  documents.push(each(documentOf(key, row, shape, bodies)));
278
365
  return weight(row);
279
- }), () => ({ rows: { documents }, keys: entries.map(([key]) => key) }));
366
+ }), () => ({ rows: framed({ documents }, window), keys, ...window }));
280
367
  }
281
- const bounded = shape.orderBy.length === 0 && plan.limit !== null ? entries.slice(0, plan.limit) : entries;
282
368
  const groups = [];
283
- return after(inUnits(bounded, ([, row]) => {
369
+ return after(inUnits(kept, ([, row]) => {
284
370
  groups.push(each({
285
371
  key: shape.groupBy.map((_, index) => row[`key${index}`]),
286
372
  count: row.count,
287
373
  }));
288
374
  return ROW_WEIGHT;
289
- }), () => ({ rows: { groups }, keys: bounded.map(([key]) => key) }));
375
+ }), () => ({ rows: framed({ groups }, window), keys, ...window }));
290
376
  }
291
377
  export function reconciled(previous, next) {
292
378
  const before = previous.result;
@@ -311,13 +397,16 @@ export function reconciled(previous, next) {
311
397
  const removed = previous.keys.filter((key) => !present.has(key));
312
398
  const moved = reordered(previous.keys, next.keys, present);
313
399
  const covered = !deepEquals(before.coverage, after.coverage);
314
- if (changed.length === 0 && removed.length === 0 && !moved && !covered)
400
+ const framing = reframed(before, after);
401
+ if (changed.length === 0 && removed.length === 0 && !moved && !covered && framing === null) {
315
402
  return null;
403
+ }
404
+ const window = { next: after.next, total: after.total };
316
405
  return {
317
406
  keyed: {
318
407
  result: 'groups' in after
319
- ? { groups: rows, coverage: after.coverage }
320
- : { documents: rows, coverage: after.coverage },
408
+ ? framed({ groups: rows, coverage: after.coverage }, window)
409
+ : framed({ documents: rows, coverage: after.coverage }, window),
321
410
  keys: next.keys,
322
411
  },
323
412
  message: {
@@ -325,9 +414,17 @@ export function reconciled(previous, next) {
325
414
  removed,
326
415
  order: moved ? next.keys : null,
327
416
  ...(covered ? { coverage: after.coverage } : {}),
417
+ ...framing,
328
418
  },
329
419
  };
330
420
  }
421
+ function reframed(before, after) {
422
+ const next = before.next === after.next ? {} : { next: after.next ?? null };
423
+ const total = before.total === after.total || after.total === undefined ? {} : { total: after.total };
424
+ return Object.keys(next).length === 0 && Object.keys(total).length === 0
425
+ ? null
426
+ : { ...next, ...total };
427
+ }
331
428
  function reordered(previous, next, present) {
332
429
  let at = 0;
333
430
  for (const key of previous) {
@@ -376,8 +473,11 @@ export function createReadSide() {
376
473
  return;
377
474
  entry.rows.set(key, row);
378
475
  }
476
+ function counted(entry) {
477
+ return entry.built.count === null ? undefined : entry.built.count.size;
478
+ }
379
479
  function rebuilt(entry) {
380
- return after(rowsOfPlan(entry.plan, [...entry.built.live.entries()], entry.bodies), ({ rows: found, keys }) => {
480
+ return after(rowsOfPlan(entry.plan, [...entry.built.live.entries()], counted(entry), entry.bodies), ({ rows: found, keys, next, total }) => {
381
481
  const present = new Set(keys);
382
482
  for (const key of [...entry.rows.keys()])
383
483
  if (!present.has(key))
@@ -387,32 +487,34 @@ export function createReadSide() {
387
487
  entry.bodies.delete(key);
388
488
  }
389
489
  keys.forEach((key, index) => kept(entry, key, rowAt(found, index)));
390
- return keys;
490
+ return { keys, next, total };
391
491
  });
392
492
  }
393
493
  function refreshed(entry, dirty) {
394
494
  const shape = entry.plan.shape;
395
- const keys = [...entry.built.live.keys()];
396
- const named = new Set([...dirty, ...keys.filter((key) => !entry.rows.has(key))]);
397
- const values = [...named].map((key) => [key, entry.built.live.get(key)]);
495
+ const { kept: inWindow, next, total, } = windowOf(entry.plan, [...entry.built.live.entries()], counted(entry));
496
+ const keys = inWindow.map(([key]) => key);
497
+ const present = new Set(keys);
498
+ for (const key of [...entry.rows.keys()]) {
499
+ if (present.has(key))
500
+ continue;
501
+ entry.rows.delete(key);
502
+ entry.bodies.delete(key);
503
+ }
504
+ const values = inWindow.filter(([key]) => dirty.has(key) || !entry.rows.has(key));
398
505
  const done = inUnits(values, ([key, value]) => {
399
- if (value !== undefined)
400
- kept(entry, key, documentOf(key, value, shape, entry.bodies));
401
- else {
402
- entry.rows.delete(key);
403
- entry.bodies.delete(key);
404
- }
506
+ kept(entry, key, documentOf(key, value, shape, entry.bodies));
405
507
  return weight(value);
406
508
  });
407
- return after(done, () => keys);
509
+ return after(done, () => ({ keys, next, total }));
408
510
  }
409
- function current(entry, keys, coverage) {
410
- const found = keys.map((key) => entry.rows.get(key));
511
+ function current(entry, found, coverage) {
512
+ const rows = found.keys.map((key) => entry.rows.get(key));
411
513
  return {
412
514
  result: entry.plan.shape.kind === 'groups'
413
- ? { groups: found, coverage }
414
- : { documents: found, coverage },
415
- keys,
515
+ ? framed({ groups: rows, coverage }, found)
516
+ : framed({ documents: rows, coverage }, found),
517
+ keys: found.keys,
416
518
  };
417
519
  }
418
520
  function delivered(entry, next) {
@@ -448,12 +550,12 @@ export function createReadSide() {
448
550
  const dirty = entry.dirty;
449
551
  entry.dirty = new Set();
450
552
  entry.whole = false;
451
- const keys = whole ? rebuilt(entry) : refreshed(entry, dirty);
452
- if (keys instanceof Promise) {
453
- void keys
454
- .then((found) => {
553
+ const found = whole ? rebuilt(entry) : refreshed(entry, dirty);
554
+ if (found instanceof Promise) {
555
+ void found
556
+ .then((window) => {
455
557
  if (entry.listeners.size > 0)
456
- delivered(entry, current(entry, found, cover.coverage));
558
+ delivered(entry, current(entry, window, cover.coverage));
457
559
  run(entry);
458
560
  })
459
561
  .catch(() => {
@@ -461,7 +563,7 @@ export function createReadSide() {
461
563
  });
462
564
  return;
463
565
  }
464
- delivered(entry, current(entry, keys, cover.coverage));
566
+ delivered(entry, current(entry, found, cover.coverage));
465
567
  }
466
568
  entry.running = false;
467
569
  }
@@ -517,12 +619,14 @@ export function createReadSide() {
517
619
  },
518
620
  recover,
519
621
  async query(plan, at) {
520
- const { live: collection, dispose } = built(rows, plan);
622
+ const { live: collection, count, dispose } = built(rows, plan);
521
623
  try {
522
624
  await collection.toArrayWhenReady();
625
+ if (count !== null)
626
+ await count.toArrayWhenReady();
523
627
  const entries = [...collection.entries()];
524
628
  const held = at();
525
- const found = await rowsOfPlan(plan, entries, null, structuredClone);
629
+ const found = await rowsOfPlan(plan, entries, count?.size, null, structuredClone);
526
630
  return { rows: found.rows, at: held };
527
631
  }
528
632
  finally {
@@ -543,13 +647,16 @@ export function createReadSide() {
543
647
  fresh: new Set(),
544
648
  ready: new Set(),
545
649
  subscription: null,
650
+ counting: null,
546
651
  whole: true,
547
652
  dirty: new Set(),
548
653
  stale: false,
549
654
  running: false,
550
655
  };
551
656
  created.built.live.on('status:change', ({ status }) => {
552
- if (status === 'cleaned-up' && created.listeners.size === 0)
657
+ if (status !== 'cleaned-up' || created.listeners.size > 0)
658
+ return;
659
+ if (shared.get(identity) === created)
553
660
  shared.delete(identity);
554
661
  });
555
662
  shared.set(identity, created);
@@ -557,7 +664,14 @@ export function createReadSide() {
557
664
  }
558
665
  const observed = entry;
559
666
  observed.listeners.add(deliverTo);
560
- observed.built.live.onFirstReady(() => {
667
+ const ready = (then) => observed.built.live.onFirstReady(() => observed.built.count === null ? then() : observed.built.count.onFirstReady(then));
668
+ const settled = () => {
669
+ if (observed.built.count === null)
670
+ wake(observed);
671
+ else
672
+ queueMicrotask(() => wake(observed));
673
+ };
674
+ ready(() => {
561
675
  if (!observed.listeners.has(deliverTo))
562
676
  return;
563
677
  observed.fresh.add(deliverTo);
@@ -569,8 +683,13 @@ export function createReadSide() {
569
683
  else
570
684
  for (const { key } of changes)
571
685
  observed.dirty.add(key);
572
- wake(observed);
686
+ settled();
573
687
  }, { includeInitialState: false });
688
+ observed.counting =
689
+ observed.built.count?.subscribeChanges(() => {
690
+ observed.stale = true;
691
+ settled();
692
+ }, { includeInitialState: false }) ?? null;
574
693
  }
575
694
  wake(observed);
576
695
  });
@@ -581,11 +700,16 @@ export function createReadSide() {
581
700
  return;
582
701
  observed.subscription?.unsubscribe();
583
702
  observed.subscription = null;
703
+ observed.counting?.unsubscribe();
704
+ observed.counting = null;
584
705
  observed.result = undefined;
585
706
  observed.rows.clear();
586
707
  observed.bodies.clear();
587
708
  observed.dirty.clear();
588
709
  observed.whole = true;
710
+ if (shared.get(identity) === observed)
711
+ shared.delete(identity);
712
+ observed.built.dispose();
589
713
  };
590
714
  },
591
715
  room(room) {
@@ -601,6 +725,7 @@ export function createReadSide() {
601
725
  entry.fresh.clear();
602
726
  entry.ready.clear();
603
727
  entry.subscription?.unsubscribe();
728
+ entry.counting?.unsubscribe();
604
729
  entry.built.dispose();
605
730
  }
606
731
  shared.clear();
@@ -625,13 +750,16 @@ function changedFrom(previous, next) {
625
750
  const removed = previous.keys.filter((key) => !present.has(key));
626
751
  const moved = reordered(previous.keys, next.keys, present);
627
752
  const covered = !deepEquals(before.coverage, after.coverage);
628
- if (changed.length === 0 && removed.length === 0 && !moved && !covered)
753
+ const framing = reframed(before, after);
754
+ if (changed.length === 0 && removed.length === 0 && !moved && !covered && framing === null) {
629
755
  return null;
756
+ }
630
757
  return {
631
758
  changed,
632
759
  removed,
633
760
  order: moved ? next.keys : null,
634
761
  ...(covered ? { coverage: after.coverage } : {}),
762
+ ...framing,
635
763
  };
636
764
  }
637
765
  function rowAt(rows, index) {
@@ -0,0 +1,11 @@
1
+ import type { Adapter } from './adapter.js';
2
+ import type { Reads } from './bootstrap.js';
3
+ export type DoorReads = Reads & {
4
+ carried(locator: string): number;
5
+ finished(locator: string, turn: number): void;
6
+ opened(): void;
7
+ applied(): void;
8
+ lost(): void;
9
+ };
10
+ export declare function doorReads(adapter: Adapter, declaration: (locator: string) => unknown, generation: () => number): DoorReads;
11
+ //# sourceMappingURL=reads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reads.d.ts","sourceRoot":"","sources":["../src/reads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAOR,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG;IAC9B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;IAChB,IAAI,IAAI,IAAI,CAAC;CACd,CAAC;AAiCF,wBAAgB,SAAS,CACvB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,EACzC,UAAU,EAAE,MAAM,MAAM,GACvB,SAAS,CA0FX"}
package/dist/reads.js ADDED
@@ -0,0 +1,98 @@
1
+ function declaredAs(declaration) {
2
+ if (declaration === null || typeof declaration !== 'object')
3
+ return declaration;
4
+ const { roomVersion: _version, ...declared } = declaration;
5
+ return declared;
6
+ }
7
+ function sameHeld(one, other) {
8
+ return one?.documents === other?.documents && one?.revisions === other?.revisions;
9
+ }
10
+ function failed(answer) {
11
+ return answer?.kind === 'transport-uncertainty';
12
+ }
13
+ function continues(answer) {
14
+ const page = answer;
15
+ return page?.kind === 'net-advancement' && page.pageToken !== undefined;
16
+ }
17
+ export function doorReads(adapter, declaration, generation) {
18
+ const reading = new Map();
19
+ const taken = new Map();
20
+ let carrying = false;
21
+ function joined(read, authorization, request, ask) {
22
+ const key = `${read} ${request.locator} ${request.pageToken ?? ''}`;
23
+ const { held, ...named } = request;
24
+ const asked = JSON.stringify([declaredAs(declaration(request.locator)), named]);
25
+ const asking = generation();
26
+ const current = reading.get(key);
27
+ if (current !== undefined &&
28
+ current.authorization === authorization &&
29
+ current.asked === asked &&
30
+ sameHeld(current.held, held) &&
31
+ (!current.settled || current.holder < asking)) {
32
+ if (current.settled && !current.continued)
33
+ reading.delete(key);
34
+ else
35
+ current.holder = Math.max(current.holder, asking);
36
+ if (current.from === asking)
37
+ return current.answer;
38
+ const again = () => joined(read, authorization, request, ask);
39
+ return current.answer.then((answer) => {
40
+ if (failed(answer))
41
+ return again();
42
+ taken.set(request.locator, (taken.get(request.locator) ?? 0) + 1);
43
+ return answer;
44
+ }, again);
45
+ }
46
+ const answer = ask();
47
+ const sent = {
48
+ locator: request.locator,
49
+ authorization,
50
+ asked,
51
+ held,
52
+ answer,
53
+ from: asking,
54
+ holder: asking,
55
+ settled: false,
56
+ continued: false,
57
+ };
58
+ reading.set(key, sent);
59
+ const settled = (result, kept) => {
60
+ sent.settled = true;
61
+ sent.continued = kept && read === 'refresh' && continues(result);
62
+ if (reading.get(key) !== sent)
63
+ return;
64
+ const live = sent.holder === generation();
65
+ if (!kept || (live ? !sent.continued : !carrying))
66
+ reading.delete(key);
67
+ };
68
+ answer.then((result) => settled(result, !failed(result)), () => settled(null, false));
69
+ return answer;
70
+ }
71
+ return {
72
+ bootstrap: (authorization, request) => joined('bootstrap', authorization, request, () => adapter.bootstrap(authorization, request)),
73
+ refresh: (authorization, request) => joined('refresh', authorization, request, () => adapter.refresh(authorization, request)),
74
+ reached: (locator, roomVersion, target) => adapter.reached(locator, roomVersion, target),
75
+ carried: (locator) => taken.get(locator) ?? 0,
76
+ finished(locator, turn) {
77
+ for (const [key, held] of reading) {
78
+ if (held.locator !== locator || !held.settled || held.holder !== turn)
79
+ continue;
80
+ if (turn === generation() || !carrying)
81
+ reading.delete(key);
82
+ }
83
+ },
84
+ opened() {
85
+ carrying = true;
86
+ },
87
+ applied() {
88
+ carrying = false;
89
+ for (const [key, held] of reading) {
90
+ if (held.settled && held.holder !== generation())
91
+ reading.delete(key);
92
+ }
93
+ },
94
+ lost() {
95
+ reading.clear();
96
+ },
97
+ };
98
+ }
package/dist/refresh.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Adapter, AdapterFailure, Authorization, RetryableRefusal } from './adapter.js';
2
- import type { Remodel } from './bootstrap.js';
1
+ import type { AdapterFailure, Authorization, RetryableRefusal } from './adapter.js';
2
+ import type { Reads, Remodel } from './bootstrap.js';
3
3
  import { type ConfirmedLayer } from './replica.js';
4
4
  import type { ReplicaRecord } from './store.js';
5
5
  import { type Refused, type Unconfirmed } from './transfer.js';
@@ -19,6 +19,6 @@ export type RefreshOutcome = {
19
19
  } | {
20
20
  kind: 'beyond-horizon';
21
21
  } | RetryableRefusal | Unconfirmed | Refused | AdapterFailure;
22
- export declare function advancement(adapter: Adapter, authorization: Authorization, held: ReplicaRecord, remodel: Remodel, continuing: () => boolean): Promise<Advancement>;
23
- export declare function refreshRoom(adapter: Adapter, authorization: Authorization, confirmed: ConfirmedLayer, remodel: Remodel, continuing: () => boolean): Promise<RefreshOutcome>;
22
+ export declare function advancement(adapter: Reads, authorization: Authorization, held: ReplicaRecord, remodel: Remodel, continuing: () => boolean): Promise<Advancement>;
23
+ export declare function refreshRoom(adapter: Reads, authorization: Authorization, confirmed: ConfirmedLayer, remodel: Remodel, continuing: () => boolean): Promise<RefreshOutcome>;
24
24
  //# sourceMappingURL=refresh.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../src/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,aAAa,EAEb,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,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AgB,CAAC;AACrD,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAe,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B,gBAAgB,GAChB,WAAW,GACX,cAAc,CAAC;AAEnB,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B,gBAAgB,GAChB,WAAW,GACX,OAAO,GACP,cAAc,CAAC;AAEnB,wBAAsB,WAAW,CAC/B,OAAO,EAAE,KAAK,EACd,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,GACxB,OAAO,CAAC,WAAW,CAAC,CA8EtB;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,KAAK,EACd,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,GACxB,OAAO,CAAC,cAAc,CAAC,CAKzB"}
package/dist/refresh.js CHANGED
@@ -19,27 +19,32 @@ export async function advancement(adapter, authorization, held, remodel, continu
19
19
  });
20
20
  const documents = drafted(held.documents);
21
21
  const revisions = drafted(held.revisions);
22
+ const fileIds = drafted(held.fileIds);
22
23
  const changes = drafted(held.changes);
23
24
  const written = drafted(held.written);
24
25
  const binaries = drafted(held.binaries);
25
26
  const stage = (page) => {
26
27
  for (const path of Object.keys(page.documents)) {
27
28
  delete binaries[path];
29
+ delete fileIds[path];
28
30
  delete changes[path];
29
31
  written[path] = roomVersion;
30
32
  }
31
33
  for (const path of Object.keys(page.binaryFiles)) {
32
34
  delete documents[path];
35
+ delete fileIds[path];
33
36
  delete changes[path];
34
37
  delete written[path];
35
38
  }
36
39
  Object.assign(documents, page.documents);
37
40
  Object.assign(binaries, acceptedBinaries(page.binaryFiles));
38
41
  Object.assign(revisions, page.revisions);
42
+ Object.assign(fileIds, page.fileIds);
39
43
  Object.assign(changes, page.changes);
40
44
  for (const path of page.removals) {
41
45
  delete documents[path];
42
46
  delete revisions[path];
47
+ delete fileIds[path];
43
48
  delete changes[path];
44
49
  delete written[path];
45
50
  delete binaries[path];
@@ -75,6 +80,7 @@ export async function advancement(adapter, authorization, held, remodel, continu
75
80
  documents: settled(documents),
76
81
  binaries: settled(binaries),
77
82
  revisions: settled(revisions),
83
+ fileIds: settled(fileIds),
78
84
  changes: settled(changes),
79
85
  written: settled(written),
80
86
  },
package/dist/replica.d.ts CHANGED
@@ -41,6 +41,10 @@ type Accepted = Extract<MutationResult, {
41
41
  export declare function applyReturned(confirmed: ConfirmedLayer, submitted: ChangeBatch, accepted: Accepted, roomVersion: string, writtenAt: string): Staged;
42
42
  export declare function replicaOf(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], previous?: Replica): Replica;
43
43
  export declare function landed(batch: ChangeBatch, confirmed: ConfirmedLayer, current?: Readonly<Record<string, string>>): boolean;
44
- export declare function withdrawals(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean, local: boolean): readonly ChangeBatch[];
44
+ export type Standing = {
45
+ readonly withdrawn: readonly ChangeBatch[];
46
+ readonly kept: readonly ChangeBatch[];
47
+ };
48
+ export declare function standing(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean, local: boolean): Standing;
45
49
  export {};
46
50
  //# sourceMappingURL=replica.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,WAAW,EAAqB,MAAM,aAAa,CAAC;AACnG,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAML,KAAK,KAAK,EACX,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG;IACjC,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,GAAG,OAAO,CAAC;AAE7E,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,cAAc,CAAC;IAC1B,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9B,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;CAC/B,CAAC;AAEF,KAAK,UAAU,GAAG;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,KAAK,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,WAAW,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,WAAW,CAQhE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