@agentshouse/mdruntime 0.1.0-cc294e382554d → 0.1.0-cc56db96f86ae

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 (125) hide show
  1. package/AGENTS.md +28 -23
  2. package/README.md +9 -8
  3. package/dist/adapter.d.ts +11 -10
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/bootstrap.d.ts.map +1 -1
  6. package/dist/bootstrap.js +60 -29
  7. package/dist/change-set.d.ts.map +1 -1
  8. package/dist/change-set.js +2 -6
  9. package/dist/change.d.ts +31 -1
  10. package/dist/change.d.ts.map +1 -1
  11. package/dist/change.js +10 -1
  12. package/dist/chat/house.d.ts +25 -0
  13. package/dist/chat/house.d.ts.map +1 -0
  14. package/dist/chat/house.js +38 -0
  15. package/dist/chat/input.d.ts +3 -1
  16. package/dist/chat/input.d.ts.map +1 -1
  17. package/dist/chat/input.js +11 -18
  18. package/dist/chat/message.d.ts.map +1 -1
  19. package/dist/chat/message.js +45 -10
  20. package/dist/chat/messages.d.ts +6 -1
  21. package/dist/chat/messages.d.ts.map +1 -1
  22. package/dist/chat/messages.js +14 -11
  23. package/dist/chat/name.d.ts +1 -0
  24. package/dist/chat/name.d.ts.map +1 -1
  25. package/dist/chat/name.js +1 -1
  26. package/dist/chat/opened.d.ts +1 -0
  27. package/dist/chat/opened.d.ts.map +1 -1
  28. package/dist/chat/opened.js +2 -0
  29. package/dist/chat/overlay.d.ts.map +1 -1
  30. package/dist/chat/overlay.js +1 -5
  31. package/dist/chat/parts.d.ts +1 -0
  32. package/dist/chat/parts.d.ts.map +1 -1
  33. package/dist/chat/parts.js +3 -2
  34. package/dist/chat/provider.d.ts +5 -1
  35. package/dist/chat/provider.d.ts.map +1 -1
  36. package/dist/chat/provider.js +58 -77
  37. package/dist/chat/ready.d.ts +4 -1
  38. package/dist/chat/ready.d.ts.map +1 -1
  39. package/dist/chat/ready.js +7 -5
  40. package/dist/chat/room-file.d.ts +8 -0
  41. package/dist/chat/room-file.d.ts.map +1 -0
  42. package/dist/chat/room-file.js +67 -0
  43. package/dist/chat/style.d.ts.map +1 -1
  44. package/dist/chat/style.js +4 -0
  45. package/dist/chat.d.ts +1 -0
  46. package/dist/chat.d.ts.map +1 -1
  47. package/dist/client.d.ts +4 -1
  48. package/dist/client.d.ts.map +1 -1
  49. package/dist/client.js +2 -0
  50. package/dist/collection.d.ts +2 -2
  51. package/dist/collection.d.ts.map +1 -1
  52. package/dist/collection.js +56 -40
  53. package/dist/connection.d.ts +5 -1
  54. package/dist/connection.d.ts.map +1 -1
  55. package/dist/connection.js +723 -158
  56. package/dist/conversation.d.ts +2 -2
  57. package/dist/conversation.d.ts.map +1 -1
  58. package/dist/conversation.js +18 -29
  59. package/dist/digest.d.ts +2 -0
  60. package/dist/digest.d.ts.map +1 -0
  61. package/dist/digest.js +100 -0
  62. package/dist/durability.d.ts +1 -1
  63. package/dist/file.d.ts +2 -10
  64. package/dist/file.d.ts.map +1 -1
  65. package/dist/file.js +3 -120
  66. package/dist/host.d.ts +1 -1
  67. package/dist/host.d.ts.map +1 -1
  68. package/dist/host.js +7 -3
  69. package/dist/index.d.ts +6 -4
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +2 -0
  72. package/dist/memory.d.ts.map +1 -1
  73. package/dist/memory.js +9 -5
  74. package/dist/outcome.d.ts +20 -1
  75. package/dist/outcome.d.ts.map +1 -1
  76. package/dist/outcome.js +22 -0
  77. package/dist/overlay.d.ts +1 -1
  78. package/dist/overlay.d.ts.map +1 -1
  79. package/dist/overlay.js +27 -3
  80. package/dist/query.d.ts +2 -1
  81. package/dist/query.d.ts.map +1 -1
  82. package/dist/query.js +1 -0
  83. package/dist/reach.d.ts +5 -1
  84. package/dist/reach.d.ts.map +1 -1
  85. package/dist/reach.js +144 -39
  86. package/dist/read-side.d.ts +4 -4
  87. package/dist/read-side.d.ts.map +1 -1
  88. package/dist/read-side.js +585 -232
  89. package/dist/readiness.d.ts +1 -1
  90. package/dist/readiness.d.ts.map +1 -1
  91. package/dist/recovery.d.ts +2 -2
  92. package/dist/recovery.d.ts.map +1 -1
  93. package/dist/recovery.js +8 -7
  94. package/dist/refresh.js +8 -8
  95. package/dist/replica.d.ts +1 -2
  96. package/dist/replica.d.ts.map +1 -1
  97. package/dist/replica.js +69 -48
  98. package/dist/room-draft.d.ts +3 -1
  99. package/dist/room-draft.d.ts.map +1 -1
  100. package/dist/room-draft.js +21 -13
  101. package/dist/save.d.ts +43 -7
  102. package/dist/save.d.ts.map +1 -1
  103. package/dist/save.js +329 -77
  104. package/dist/search.d.ts +1 -1
  105. package/dist/search.d.ts.map +1 -1
  106. package/dist/search.js +61 -10
  107. package/dist/shared.d.ts +5 -1
  108. package/dist/shared.d.ts.map +1 -1
  109. package/dist/shared.js +72 -9
  110. package/dist/store.d.ts +8 -13
  111. package/dist/store.d.ts.map +1 -1
  112. package/dist/store.js +189 -230
  113. package/dist/tables.d.ts +181 -0
  114. package/dist/tables.d.ts.map +1 -0
  115. package/dist/tables.js +309 -0
  116. package/dist/turn.d.ts +1 -1
  117. package/dist/turn.d.ts.map +1 -1
  118. package/dist/turn.js +9 -6
  119. package/dist/windows.d.ts +0 -5
  120. package/dist/windows.d.ts.map +1 -1
  121. package/dist/windows.js +0 -9
  122. package/dist/wire.d.ts +8 -0
  123. package/dist/wire.d.ts.map +1 -1
  124. package/dist/wire.js +2 -0
  125. package/package.json +6 -2
package/dist/save.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { definitionOf } from './model.js';
2
- import { apply, ATTACHMENT, links, parse, pointerSegments, references, relative, relativize, retarget, serialize, target, } from '@agentshouse/mdmodel';
3
- import { immutable, queuedFile, departure, } from './change.js';
2
+ import { apply, ARRAY_INDEX, ATTACHMENT, links, parse, pointerSegments, references, relative, relativize, retarget, roomReferences, serialize, target, } from '@agentshouse/mdmodel';
3
+ import { immutable, leaving, queuedFile, departure, } from './change.js';
4
4
  import { available, changedCleanly, collectionOf, documentsOf, governing, referring, validateCollection, } from './collection.js';
5
5
  import { changeBatchIdentity } from './identity.js';
6
6
  import { overlaying } from './overlay.js';
7
7
  import { covered, normalize } from './paths.js';
8
- import { differences } from './shared.js';
9
- import { finished, ROW_WEIGHT, stepped } from './turn.js';
8
+ import { differences, sorting } from './shared.js';
9
+ import { ROW_WEIGHT, stepped } from './turn.js';
10
10
  function refuse(code, file, location) {
11
11
  return {
12
12
  kind: 'refused',
@@ -143,12 +143,13 @@ function* rewrites(changes, visible) {
143
143
  return { kind: 'changes', changes };
144
144
  const merged = [...changes];
145
145
  const added = [];
146
- for (const [path, document] of documentsOf(visible.collection)) {
146
+ for (const [path, document] of yield* documentsOf(visible.collection)) {
147
147
  if (settled.has(path))
148
148
  continue;
149
149
  const moved = moves.get(path) ?? path;
150
150
  const definition = definitionOf(governing(visible.collection.composition, path), document.type);
151
- added.push(...repointed(document, definition, path, moved, moves, settled));
151
+ const repointing = repointed(document, definition, path, moved, moves, settled);
152
+ added.push(...repointing);
152
153
  const own = parts.get(path) ?? [];
153
154
  const relinked = relinks(path, moved, edited(document, own.map((index) => merged[index])), moves);
154
155
  if (relinked.kind === 'refused')
@@ -175,7 +176,9 @@ function* rewrites(changes, visible) {
175
176
  else
176
177
  merged[index] = change;
177
178
  }
178
- yield ROW_WEIGHT + visible.collection.text[path].length;
179
+ const text = visible.collection.text[path].length;
180
+ const rewritten = repointing.length > 0 || relinked.changes.length > 0;
181
+ yield ROW_WEIGHT + text + (rewritten ? text : 0);
179
182
  }
180
183
  return {
181
184
  kind: 'changes',
@@ -199,6 +202,75 @@ export function* providerRewritten(batch, visible) {
199
202
  ...(yield* anticipated(batch.changes, batch.preconditions, rewritten.changes, visible)),
200
203
  };
201
204
  }
205
+ function crossed(document, definition, path, to) {
206
+ const changes = [];
207
+ for (const link of links(document, path)) {
208
+ const written = to(link.target, link.href);
209
+ if (written !== undefined)
210
+ changes.push({ kind: 'link', href: link.href, to: written });
211
+ }
212
+ for (const { pointer, value } of definition === undefined
213
+ ? []
214
+ : references(document, definition)) {
215
+ const named = target(path, value);
216
+ const written = named === null ? undefined : to(named, value);
217
+ if (written !== undefined) {
218
+ changes.push({ kind: 'reference', pointer, value: retarget(value, written), prior: value });
219
+ }
220
+ }
221
+ return changes;
222
+ }
223
+ function rewritten(path, document, changes) {
224
+ if (changes.length === 0)
225
+ return [];
226
+ const applied = apply(document, changes);
227
+ if (applied.outcome !== 'applied')
228
+ return [];
229
+ const after = applied.document;
230
+ if (document.type === undefined)
231
+ return [{ kind: 'replace', path, content: serialize(after) }];
232
+ const names = new Set(changes.flatMap((change) => change.kind === 'reference' ? [pointerSegments(change.pointer)[0] ?? ''] : []));
233
+ return [
234
+ ...[...names].map((name) => ({ kind: 'field', path, name, value: after.fields[name] })),
235
+ ...bodies(path, document, after),
236
+ ];
237
+ }
238
+ function roomPathOf(handle, path) {
239
+ return `/rooms/${handle}/${path}`;
240
+ }
241
+ export function* leavingRewritten(batch, visible) {
242
+ const between = batch.between;
243
+ if (between === undefined)
244
+ return batch;
245
+ const moved = new Map(between.moves.map(({ path, to }) => [path, roomPathOf(between.destination.handle, to)]));
246
+ const derived = [];
247
+ for (const [path, document] of yield* documentsOf(visible.collection)) {
248
+ if (moved.has(path))
249
+ continue;
250
+ const definition = definitionOf(governing(visible.collection.composition, path), document.type);
251
+ derived.push(...rewritten(path, document, crossed(document, definition, path, (named) => moved.get(named))));
252
+ yield ROW_WEIGHT + visible.collection.text[path].length;
253
+ }
254
+ if (derived.length === 0)
255
+ return batch;
256
+ return {
257
+ ...batch,
258
+ changes: [...derived, ...batch.changes],
259
+ preconditions: [...(yield* preconditionsOf(derived, visible, [])), ...batch.preconditions],
260
+ };
261
+ }
262
+ export function rewriting(batch, locator) {
263
+ return leaving(batch, locator) || batch.changes.some((change) => change.kind === 'move');
264
+ }
265
+ export function* effectiveIn(batch, locator, visible) {
266
+ return leaving(batch, locator)
267
+ ? yield* leavingRewritten(batch, visible)
268
+ : yield* providerRewritten(batch, visible);
269
+ }
270
+ function* chained(...sets) {
271
+ for (const set of sets)
272
+ yield* set;
273
+ }
202
274
  function* incoming(collection, removed, candidates) {
203
275
  const found = new Map();
204
276
  const note = (target, file) => {
@@ -209,13 +281,19 @@ function* incoming(collection, removed, candidates) {
209
281
  found.set(target, referrers);
210
282
  };
211
283
  const read = function* (paths) {
212
- for (const path of [...new Set(paths)].sort()) {
284
+ const seen = new Set();
285
+ for (const path of paths) {
286
+ if (seen.has(path))
287
+ continue;
288
+ seen.add(path);
213
289
  const document = collection.document(path);
214
290
  if (document !== undefined)
215
291
  yield [path, document];
216
292
  }
217
293
  };
218
- for (const [path, document] of candidates === null ? documentsOf(collection) : read(candidates)) {
294
+ for (const [path, document] of candidates === null
295
+ ? yield* documentsOf(collection)
296
+ : read(candidates)) {
219
297
  const definition = definitionOf(governing(collection.composition, path), document.type);
220
298
  for (const { value, to } of definition === undefined ? [] : references(document, definition)) {
221
299
  if (to.includes(ATTACHMENT))
@@ -226,7 +304,7 @@ function* incoming(collection, removed, candidates) {
226
304
  }
227
305
  yield ROW_WEIGHT + collection.text[path].length;
228
306
  }
229
- const [first] = [...found.keys()].sort();
307
+ const [first] = yield* sorting(found.keys());
230
308
  if (first === undefined)
231
309
  return null;
232
310
  const every = new Set();
@@ -239,14 +317,14 @@ function* incoming(collection, removed, candidates) {
239
317
  code: 'referenced-missing-file',
240
318
  retryable: false,
241
319
  file: first,
242
- referrers: [...every].sort(),
320
+ referrers: yield* sorting(every),
243
321
  },
244
322
  };
245
323
  }
246
324
  function affected(change) {
247
325
  return change.kind === 'move' ? [change.path, change.to] : [change.path];
248
326
  }
249
- function guard(changes, input) {
327
+ function guard(changes, input, removing) {
250
328
  const overridden = new Map();
251
329
  const existing = {
252
330
  has: (path) => overridden.get(path) ??
@@ -262,11 +340,11 @@ function guard(changes, input) {
262
340
  if (covered(input.providerOwnedPaths, normalized)) {
263
341
  return refuse('provider-owned-path', normalized);
264
342
  }
265
- const operation = change.kind === 'remove' ? 'delete' : 'write';
343
+ const operation = change.kind === 'remove' ? removing : 'write';
266
344
  if (!input.local && !covered(input.operations[operation], normalized))
267
345
  return refuse(`${operation}-grant`, normalized);
268
346
  }
269
- if (change.kind === 'create') {
347
+ if (change.kind === 'create' || change.kind === 'arrival') {
270
348
  if (existing.has(change.path))
271
349
  return refuse('path-collision', change.path);
272
350
  existing.add(change.path);
@@ -326,7 +404,7 @@ export function queuedDocuments(queue) {
326
404
  const paths = new Set();
327
405
  for (const batch of queue) {
328
406
  for (const change of batch.changes) {
329
- if (change.kind === 'binary')
407
+ if (change.kind === 'binary' || (change.kind === 'arrival' && !('content' in change)))
330
408
  continue;
331
409
  if (change.kind === 'remove')
332
410
  paths.delete(change.path);
@@ -417,7 +495,10 @@ function depth(path) {
417
495
  function* exceeding(limits, changes, effective, resulting) {
418
496
  const written = effective.map((change) => (change.kind === 'move' ? change.to : change.path));
419
497
  const created = changes
420
- .filter((change) => change.kind === 'create' || change.kind === 'move' || change.kind === 'binary')
498
+ .filter((change) => change.kind === 'create' ||
499
+ change.kind === 'move' ||
500
+ change.kind === 'binary' ||
501
+ change.kind === 'arrival')
421
502
  .map((change) => (change.kind === 'move' ? change.to : change.path));
422
503
  for (const limit of limits) {
423
504
  const value = limit.value;
@@ -506,7 +587,7 @@ function relativeChanges(input) {
506
587
  function* unmodeledType(collection, composition) {
507
588
  if (available(composition))
508
589
  return false;
509
- for (const [path, document] of documentsOf(collection)) {
590
+ for (const [path, document] of yield* documentsOf(collection)) {
510
591
  if (document.type !== undefined &&
511
592
  document.type !== 'any' &&
512
593
  governing(composition, path).status === 'unavailable')
@@ -617,8 +698,8 @@ function folded(changes, change, appending, deferred) {
617
698
  changes.push(change);
618
699
  return 'appended';
619
700
  }
620
- function relinked(batch, move, before, after, appending) {
621
- const derived = finished(rewrites([move], after));
701
+ function* relinked(batch, move, before, after, appending) {
702
+ const derived = yield* rewrites([move], after);
622
703
  if (derived.kind === 'refused')
623
704
  return derived;
624
705
  const changes = [...batch.changes];
@@ -645,6 +726,7 @@ function relinked(batch, move, before, after, appending) {
645
726
  if (!changed)
646
727
  return { kind: 'relinked', batch };
647
728
  const held = new Set(batch.preconditions.map(identity));
729
+ const added = yield* preconditionsOf(appended, before, []);
648
730
  return {
649
731
  kind: 'relinked',
650
732
  batch: immutable({
@@ -653,7 +735,7 @@ function relinked(batch, move, before, after, appending) {
653
735
  changes,
654
736
  preconditions: [
655
737
  ...batch.preconditions,
656
- ...finished(preconditionsOf(appended, before, [])).filter((precondition) => !held.has(identity(precondition))),
738
+ ...added.filter((precondition) => !held.has(identity(precondition))),
657
739
  ],
658
740
  }),
659
741
  };
@@ -699,7 +781,7 @@ function withdrawnFile(batch, change, at) {
699
781
  ];
700
782
  return immutable({ ...batch, id: changeBatchIdentity(), changes, preconditions });
701
783
  }
702
- export function requeued(queue, changes, visible, changeable, state) {
784
+ export function* requeuing(queue, changes, visible, changeable, state) {
703
785
  const next = [...queue];
704
786
  const origins = new Map();
705
787
  const withdrawn = new Map();
@@ -722,19 +804,19 @@ export function requeued(queue, changes, visible, changeable, state) {
722
804
  return unqueueable(change.path);
723
805
  const following = next.slice(index);
724
806
  const rebuilt = [];
725
- let before = change.kind === 'move' ? state(next.slice(0, index)) : visible;
807
+ let before = change.kind === 'move' ? yield* state(next.slice(0, index)) : visible;
726
808
  for (const [offset, batch] of following.entries()) {
727
809
  let current = batch;
728
810
  if (change.kind === 'move') {
729
- const after = state(next.slice(0, index + offset + 1));
811
+ const after = yield* state(next.slice(0, index + offset + 1));
730
812
  const appending = offset === 0 && created(batch, queuedFile(batch, change.path, held.localId));
731
- const relinking = relinked(batch, change, before, after, appending);
813
+ const relinking = yield* relinked(batch, change, before, after, appending);
732
814
  if (relinking.kind === 'refused')
733
815
  return relinking;
734
816
  current = relinking.batch;
735
817
  before = after;
736
818
  }
737
- if (current !== batch && !open(batch))
819
+ if (current !== batch && (!open(batch) || batch.between !== undefined))
738
820
  return unqueueable(change.path);
739
821
  rebuilt.push(offset === 0
740
822
  ? withdrawnFile(current, change, queuedFile(current, change.path, held.localId))
@@ -804,67 +886,46 @@ export function joined(queue, owner, extra) {
804
886
  });
805
887
  return { kind: 'joined', batch, queue: queue.map((item) => (item === owner ? batch : item)) };
806
888
  }
807
- export function limitedIn(queue, batch, limits, state) {
889
+ export function* limiting(queue, batch, limits, state) {
808
890
  const at = queue.indexOf(batch);
809
- const limited = finished(exceeding(limits, batch.changes, finished(providerRewritten(batch, state(queue.slice(0, at)))).changes, state(queue.slice(0, at + 1))));
891
+ const rewritten = yield* providerRewritten(batch, yield* state(queue.slice(0, at)));
892
+ const limited = yield* exceeding(limits, batch.changes, rewritten.changes, yield* state(queue.slice(0, at + 1)));
810
893
  return limited?.kind === 'refused' ? limited.refusal : null;
811
894
  }
812
- function* batching(input) {
813
- const changes = relativeChanges(input);
814
- const structural = changes.find((change) => change.kind === 'move' || change.kind === 'remove');
815
- if (structural !== undefined &&
816
- (yield* unmodeledType(input.visible.collection, input.composition)))
817
- return refuse('model-unavailable', structural.path);
818
- if (changes.length === 0)
819
- return refuse('no-change');
820
- const rewritten = yield* rewrites(changes, input.visible);
821
- if (rewritten.kind === 'refused')
822
- return rewritten;
823
- const refusal = guard(changes, input);
824
- if (refusal !== null)
825
- return refusal;
826
- const preconditions = yield* preconditionsOf(changes, input.visible, input.bases);
827
- const predicted = yield* anticipated(changes, preconditions, rewritten.changes, input.visible);
828
- const resulting = yield* overlaying(input.visible, [
829
- { id: '', baseRoomVersion: input.baseRoomVersion, ...predicted },
830
- ]);
831
- const clean = input.clean !== undefined && available(input.composition) ? input.clean : null;
832
- const removed = new Set(changes.filter((change) => change.kind === 'remove').map((change) => change.path));
895
+ function typedText(content) {
896
+ if (content === undefined)
897
+ return false;
898
+ const parsed = parse(content);
899
+ return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';
900
+ }
901
+ function* judging(visible, resulting, composition, clean, removed, touched) {
833
902
  if (removed.size > 0) {
834
- const referrers = clean === null ? null : referring(clean, input.composition, removed);
835
- const referenced = yield* incoming(collectionOf(resulting.documents, input.composition), removed, clean === null || referrers === null
903
+ const referrers = clean === null ? null : yield* referring(clean, composition, removed);
904
+ const referenced = yield* incoming(collectionOf(resulting.documents, composition), removed, clean === null || referrers === null
836
905
  ? null
837
- : [...referrers, ...(yield* differences(clean.text, resulting.documents))]);
906
+ : chained(referrers, yield* differences(clean.text, resulting.documents)));
838
907
  if (referenced !== null)
839
908
  return referenced;
840
909
  }
841
- const typed = (content) => {
842
- if (content === undefined)
843
- return false;
844
- const parsed = parse(content);
845
- return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';
846
- };
847
- const touched = [...new Set(predicted.changes.flatMap(affected))];
848
910
  const typedPaths = [];
849
911
  for (const path of touched) {
850
- const before = input.visible.documents[path];
912
+ const before = visible.documents[path];
851
913
  const after = resulting.documents[path];
852
- if (typed(before) || typed(after))
914
+ if (typedText(before) || typedText(after))
853
915
  typedPaths.push(path);
854
916
  yield ROW_WEIGHT + (before?.length ?? 0) + (after?.length ?? 0);
855
917
  }
856
- const needsModel = typedPaths.length > 0;
857
- const withoutModel = typedPaths.find((path) => governing(input.composition, path).status === 'unavailable');
918
+ const withoutModel = typedPaths.find((path) => governing(composition, path).status === 'unavailable');
858
919
  if (withoutModel !== undefined)
859
920
  return refuse('model-unavailable', withoutModel);
860
921
  const verdict = clean !== null &&
861
- (yield* changedCleanly({ text: resulting.documents, binaries: resulting.binaries }, clean, input.composition))
922
+ (yield* changedCleanly({ text: resulting.documents, binaries: resulting.binaries }, clean, composition))
862
923
  ? { verdict: 'accept' }
863
- : yield* validateCollection(needsModel
924
+ : yield* validateCollection(typedPaths.length > 0
864
925
  ? resulting.documents
865
926
  : Object.fromEntries(touched.flatMap((path) => resulting.documents[path] === undefined
866
927
  ? []
867
- : [[path, resulting.documents[path]]])), Object.keys(resulting.binaries), input.composition);
928
+ : [[path, resulting.documents[path]]])), Object.keys(resulting.binaries), composition);
868
929
  if (verdict.verdict === 'refuse') {
869
930
  return {
870
931
  kind: 'refused',
@@ -877,12 +938,94 @@ function* batching(input) {
877
938
  },
878
939
  };
879
940
  }
941
+ return {
942
+ kind: 'judged',
943
+ validated: typedPaths
944
+ .map((path) => governing(composition, path))
945
+ .find((model) => model.status !== 'unavailable'),
946
+ };
947
+ }
948
+ function placed(reference) {
949
+ const key = roomPathOf(reference.handle, reference.path);
950
+ if (reference.kind === 'link')
951
+ return `link ${key}`;
952
+ if (reference.kind === 'item')
953
+ return `section ${reference.section} ${key}`;
954
+ const pointer = reference.pointer
955
+ .split('/')
956
+ .map((segment) => (ARRAY_INDEX.test(segment) ? '-' : segment))
957
+ .join('/');
958
+ return `field ${pointer} ${key}`;
959
+ }
960
+ function roomReferencesIn(path, content, composition) {
961
+ if (content === undefined)
962
+ return [];
963
+ const parsed = parse(content, path);
964
+ if (!parsed.ok)
965
+ return [];
966
+ return roomReferences(path, content, definitionOf(governing(composition, path), parsed.document.type));
967
+ }
968
+ function* admittedRooms(changes, visible, resulting, composition) {
969
+ const from = new Map();
970
+ for (const [index, change] of changes.entries()) {
971
+ if (change.kind === 'move')
972
+ from.set(change.to, departure(changes, index));
973
+ }
974
+ for (const path of [...new Set(changes.flatMap(affected))].sort()) {
975
+ const now = resulting.documents[path];
976
+ if (now === undefined)
977
+ continue;
978
+ const held = new Set(roomReferencesIn(path, visible.documents[from.get(path) ?? path], composition).map(placed));
979
+ for (const reference of roomReferencesIn(path, now, composition)) {
980
+ if (reference.kind === 'link' || reference.crossRoom === true)
981
+ continue;
982
+ if (held.has(placed(reference)))
983
+ continue;
984
+ return refuse('unresolved-reference', path, reference.kind === 'field' ? reference.pointer : reference.section);
985
+ }
986
+ yield ROW_WEIGHT + now.length;
987
+ }
988
+ return null;
989
+ }
990
+ function validationOf(validated) {
991
+ return validated === undefined
992
+ ? {}
993
+ : {
994
+ validation: {
995
+ identity: validated.snapshot.identity,
996
+ version: validated.snapshot.version,
997
+ source: validated.status,
998
+ },
999
+ };
1000
+ }
1001
+ function* batching(input) {
1002
+ const changes = relativeChanges(input);
1003
+ const structural = changes.find((change) => change.kind === 'move' || change.kind === 'remove');
1004
+ if (structural !== undefined &&
1005
+ (yield* unmodeledType(input.visible.collection, input.composition)))
1006
+ return refuse('model-unavailable', structural.path);
1007
+ if (changes.length === 0)
1008
+ return refuse('no-change');
1009
+ const rewritten = yield* rewrites(changes, input.visible);
1010
+ if (rewritten.kind === 'refused')
1011
+ return rewritten;
1012
+ const refusal = guard(changes, input, 'delete');
1013
+ if (refusal !== null)
1014
+ return refusal;
1015
+ const preconditions = yield* preconditionsOf(changes, input.visible, input.bases);
1016
+ const predicted = yield* anticipated(changes, preconditions, rewritten.changes, input.visible);
1017
+ const resulting = yield* overlaying(input.visible, [
1018
+ { id: '', baseRoomVersion: input.baseRoomVersion, ...predicted },
1019
+ ]);
1020
+ const judged = yield* judging(input.visible, resulting, input.composition, input.clean !== undefined && available(input.composition) ? input.clean : null, new Set(changes.filter((change) => change.kind === 'remove').map((change) => change.path)), [...new Set(predicted.changes.flatMap(affected))]);
1021
+ if (judged.kind === 'refused')
1022
+ return judged;
1023
+ const crossing = yield* admittedRooms(changes, input.visible, resulting, input.composition);
1024
+ if (crossing !== null)
1025
+ return crossing;
880
1026
  const limited = yield* exceeding(input.providerLimits, changes, predicted.changes, resulting);
881
1027
  if (limited !== null)
882
1028
  return limited;
883
- const validated = typedPaths
884
- .map((path) => governing(input.composition, path))
885
- .find((model) => model.status !== 'unavailable');
886
1029
  return {
887
1030
  kind: 'batch',
888
1031
  batch: immutable({
@@ -891,18 +1034,127 @@ function* batching(input) {
891
1034
  changes,
892
1035
  preconditions,
893
1036
  ...(input.writtenBy === undefined ? {} : { writtenBy: input.writtenBy }),
894
- ...(validated === undefined
895
- ? {}
896
- : {
897
- validation: {
898
- identity: validated.snapshot.identity,
899
- version: validated.snapshot.version,
900
- source: validated.status,
901
- },
902
- }),
1037
+ ...validationOf(judged.validated),
903
1038
  }),
904
1039
  };
905
1040
  }
1041
+ export const MOVE_DOCUMENTS = 'move-documents';
1042
+ function heldAt(visible, path) {
1043
+ return visible.documents[path] !== undefined || visible.binaries[path] !== undefined;
1044
+ }
1045
+ function arrivingText(path, to, source, moved) {
1046
+ const content = source.visible.documents[path];
1047
+ const document = source.visible.collection.document(path);
1048
+ if (document === undefined)
1049
+ return content;
1050
+ const definition = definitionOf(governing(source.composition, path), document.type);
1051
+ const changes = crossed(document, definition, path, (named, href) => {
1052
+ const at = moved.get(named);
1053
+ if (at !== undefined)
1054
+ return target(to, href) === at ? undefined : relative(to, at);
1055
+ return heldAt(source.visible, named) ? roomPathOf(source.handle, named) : undefined;
1056
+ });
1057
+ if (changes.length === 0)
1058
+ return content;
1059
+ const applied = apply(document, changes);
1060
+ return applied.outcome === 'applied' ? serialize(applied.document) : content;
1061
+ }
1062
+ function arrivalOf({ path, to }, source, moved) {
1063
+ const { documents, revisions, fileIds, changes, binaries } = source.visible;
1064
+ const kept = {
1065
+ ...(fileIds[path] === undefined ? {} : { fileId: fileIds[path] }),
1066
+ ...(changes[path] === undefined ? {} : { change: changes[path] }),
1067
+ };
1068
+ const heads = {
1069
+ ...(revisions[path] === undefined ? {} : { revision: revisions[path] }),
1070
+ ...kept,
1071
+ };
1072
+ const binary = binaries[path];
1073
+ if (binary?.state === 'accepted') {
1074
+ const { fileRef, byteLength, mediaType, sha256 } = binary;
1075
+ return {
1076
+ kind: 'arrival',
1077
+ path: to,
1078
+ binary: { fileRef, byteLength, mediaType, sha256 },
1079
+ ...heads,
1080
+ };
1081
+ }
1082
+ const content = arrivingText(path, to, source, moved);
1083
+ return {
1084
+ kind: 'arrival',
1085
+ path: to,
1086
+ content,
1087
+ ...(content === documents[path] ? heads : kept),
1088
+ };
1089
+ }
1090
+ function* moving(input) {
1091
+ const { source, destination, moves } = input;
1092
+ if (moves.length === 0)
1093
+ return refuse('no-change');
1094
+ const removals = moves.map(({ path }) => ({ kind: 'remove', path }));
1095
+ const leaves = guard(removals, { ...source, local: input.local, bases: [] }, 'write');
1096
+ if (leaves !== null)
1097
+ return leaves;
1098
+ const uploading = moves.find(({ path }) => source.visible.binaries[path]?.state === 'pending');
1099
+ if (uploading !== undefined)
1100
+ return refuse('unknown-revision', uploading.path);
1101
+ const moved = new Map(moves.map(({ path, to }) => [path, to]));
1102
+ const arrivals = moves.map((move) => arrivalOf(move, source, moved));
1103
+ const arrives = guard(arrivals, { ...destination, local: input.local, bases: [] }, 'write');
1104
+ if (arrives !== null)
1105
+ return arrives;
1106
+ const bound = input.providerLimits.find((limit) => limit.name === MOVE_DOCUMENTS)?.value;
1107
+ if (typeof bound === 'number' && moves.length > bound) {
1108
+ return refuse('provider-limit', undefined, MOVE_DOCUMENTS);
1109
+ }
1110
+ if (yield* unmodeledType(source.visible.collection, source.composition)) {
1111
+ return refuse('model-unavailable', moves[0].path);
1112
+ }
1113
+ const id = changeBatchIdentity();
1114
+ const between = {
1115
+ source: { room: source.room, baseRoomVersion: source.baseRoomVersion },
1116
+ destination: {
1117
+ room: destination.room,
1118
+ baseRoomVersion: destination.baseRoomVersion,
1119
+ handle: destination.handle,
1120
+ },
1121
+ moves,
1122
+ };
1123
+ const written = input.writtenBy === undefined ? {} : { writtenBy: input.writtenBy };
1124
+ const leavingBatch = {
1125
+ id,
1126
+ baseRoomVersion: source.baseRoomVersion,
1127
+ changes: removals,
1128
+ preconditions: moves.map(({ path }) => existence(source.visible, path)),
1129
+ ...written,
1130
+ between,
1131
+ };
1132
+ const effective = yield* leavingRewritten(leavingBatch, source.visible);
1133
+ const left = yield* overlaying(source.visible, [effective]);
1134
+ const sourceJudged = yield* judging(source.visible, left, source.composition, available(source.composition) ? source.clean : null, new Set(moves.map(({ path }) => path)), [...new Set(effective.changes.map((change) => change.path))]);
1135
+ if (sourceJudged.kind === 'refused')
1136
+ return sourceJudged;
1137
+ const arrivingBatch = {
1138
+ id,
1139
+ baseRoomVersion: destination.baseRoomVersion,
1140
+ changes: arrivals,
1141
+ preconditions: moves.map(({ to }) => ({ kind: 'absent', path: to })),
1142
+ ...written,
1143
+ between,
1144
+ };
1145
+ const arrived = yield* overlaying(destination.visible, [arrivingBatch]);
1146
+ const destinationJudged = yield* judging(destination.visible, arrived, destination.composition, available(destination.composition) ? destination.clean : null, new Set(), moves.map(({ to }) => to));
1147
+ if (destinationJudged.kind === 'refused')
1148
+ return destinationJudged;
1149
+ const limited = (yield* exceeding(input.providerLimits, removals, effective.changes, left)) ??
1150
+ (yield* exceeding(input.providerLimits, arrivals, arrivals, arrived));
1151
+ if (limited !== null)
1152
+ return limited;
1153
+ return { kind: 'moved', leaving: immutable(leavingBatch), arriving: immutable(arrivingBatch) };
1154
+ }
1155
+ export function buildMove(input) {
1156
+ return stepped(moving(input));
1157
+ }
906
1158
  export function buildBatch(input) {
907
1159
  return stepped(batching(input));
908
1160
  }
package/dist/search.d.ts CHANGED
@@ -71,7 +71,7 @@ export type SearchedMessage = {
71
71
  text: string;
72
72
  };
73
73
  export type SearchSource = {
74
- room(room: string): readonly string[];
74
+ room(room: string): Iterable<string>;
75
75
  document(room: string, path: string): SearchedDocument | null;
76
76
  };
77
77
  type HitCursor = readonly [number, string, string] | readonly [] | null;
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAKtC,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;AAE7E,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;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