@agentshouse/mdruntime 0.1.0-c26d7e158e11b → 0.1.0-c27d511fb284d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -19
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +32 -22
- package/dist/act-lanes.d.ts +11 -14
- package/dist/act-lanes.d.ts.map +1 -1
- package/dist/act-lanes.js +53 -5
- package/dist/actions.d.ts +1 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +135 -55
- package/dist/adapter.d.ts +136 -29
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -7
- package/dist/{binary.d.ts → attachment.d.ts} +8 -4
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +15 -0
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +347 -0
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +6 -2
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +3 -0
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +2 -4
- package/dist/client.d.ts +21 -15
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +29 -57
- package/dist/collection.d.ts +6 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -9
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +4 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +88 -44
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +15 -14
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +20 -9
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +18 -8
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +20 -7
- package/dist/conversation.d.ts +30 -12
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +256 -180
- package/dist/declaration.js +3 -3
- package/dist/discovery.d.ts +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +30 -8
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +2 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +25 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +111 -34
- package/dist/expectation.d.ts +25 -14
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +51 -20
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -1
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +6 -4
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/host.d.ts +7 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +78 -32
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +102 -0
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +21 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -7
- package/dist/install.d.ts +9 -3
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +44 -46
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +40 -29
- package/dist/listing.d.ts +24 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +50 -21
- package/dist/live.d.ts +19 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +94 -36
- package/dist/loaded.d.ts +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -0
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +4 -3
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +2 -3
- package/dist/media.d.ts +19 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +181 -34
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +66 -22
- package/dist/messages.d.ts +17 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +29 -10
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +10 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +5 -8
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +206 -69
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opened.d.ts +5 -5
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +20 -10
- package/dist/outcome.d.ts +30 -13
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +21 -6
- package/dist/overlay.d.ts +21 -7
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +112 -39
- package/dist/parts.d.ts +4 -9
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -15
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +198 -87
- package/dist/presence.d.ts +8 -2
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +24 -13
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +133 -73
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +1 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -8
- package/dist/queue.d.ts +2 -2
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +73 -48
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +164 -39
- package/dist/react.d.ts +10 -11
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +22 -4
- package/dist/readiness.d.ts +23 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +18 -10
- package/dist/reads.d.ts +1 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +17 -6
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +1 -3
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +5 -5
- package/dist/room-draft.d.ts +31 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +262 -36
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +12 -7
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +11 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +24 -10
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +5 -4
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +105 -124
- package/dist/saves.d.ts +7 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +107 -57
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- package/dist/selector.d.ts +3 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +22 -0
- package/dist/shown.d.ts +5 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +79 -43
- package/dist/socket/lanes.d.ts +10 -3
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +29 -6
- package/dist/socket/session.d.ts +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +3 -3
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +3 -9
- package/dist/source.d.ts +7 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +15 -2
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +30 -8
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +70 -26
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store.d.ts +15 -10
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +12 -5
- package/dist/stored.d.ts +41 -16
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +215 -57
- package/dist/surface.d.ts +14 -8
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +59 -27
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +52 -35
- package/dist/tables.d.ts +28 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +95 -326
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +3 -4
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +50 -10
- package/dist/wire.d.ts +39 -16
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +21 -14
- package/package.json +4 -4
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/queue.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
2
2
|
import { leaving as leavingIn, partnerOf } from './change.js';
|
|
3
3
|
import { composedOf, definitionsAt } from './collection.js';
|
|
4
|
+
import { declared } from './declaration.js';
|
|
4
5
|
import { runtimeError } from './failure.js';
|
|
5
6
|
import { roomDraftRevision } from './identity.js';
|
|
6
7
|
import { landed, movedBy, overlayOf, replaying, slicing, slicingWith, standing, storedRecord, touchedBy, } from './replica.js';
|
|
7
|
-
import { returnedBy, returnedInto } from './room-draft.js';
|
|
8
|
+
import { joinedOver, marksOver, returnedBy, returnedInto, } from './room-draft.js';
|
|
8
9
|
import { documentKey } from './rows.js';
|
|
9
10
|
import { stepped } from './turn.js';
|
|
10
11
|
export function withdrawable(states) {
|
|
@@ -37,25 +38,39 @@ async function landedWhole(store, record, batch, confirmedLayer, current) {
|
|
|
37
38
|
return false;
|
|
38
39
|
return landed(half, await sliceAt(store, other.record, 'confirmed', [half]), store.composed(other.record));
|
|
39
40
|
}
|
|
40
|
-
async function returnedDrafts(store, locator, work, leaving, composition) {
|
|
41
|
+
async function returnedDrafts(store, locator, work, leaving, composition, visible) {
|
|
41
42
|
const written = new Map();
|
|
42
43
|
for (const { batch, returned } of leaving) {
|
|
43
44
|
if (returned === null || batch.between?.destination.room === locator)
|
|
44
45
|
continue;
|
|
45
46
|
for (const saved of work.states.get(batch.id)?.drafts ?? []) {
|
|
46
47
|
const existing = written.get(saved.path) ?? (await store.draft(locator, saved.path));
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
const parts = returnedInto(existing?.parts, saved.parts, composition === undefined ? undefined : definitionsAt(composition, saved.path));
|
|
49
|
+
const record = parts === null
|
|
50
|
+
? { ...existing, returned }
|
|
51
|
+
: {
|
|
52
|
+
locator,
|
|
53
|
+
path: saved.path,
|
|
54
|
+
revision: roomDraftRevision(),
|
|
55
|
+
parts,
|
|
56
|
+
marks: existing?.marks ?? {},
|
|
57
|
+
returned,
|
|
58
|
+
};
|
|
59
|
+
const join = visible === undefined ? null : joinedOver(record.parts, record.marks, saved.path, visible);
|
|
60
|
+
written.set(saved.path, join === null ? record : { ...record, ...join, revision: roomDraftRevision() });
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
return written;
|
|
57
64
|
}
|
|
58
|
-
|
|
65
|
+
function unheldComposition({ store, presence }, locator) {
|
|
66
|
+
const model = presence.unheldModel(locator);
|
|
67
|
+
const listed = presence.room(locator);
|
|
68
|
+
if (model === null || listed === undefined)
|
|
69
|
+
return undefined;
|
|
70
|
+
return store.composed({ model, declaration: declared(listed) });
|
|
71
|
+
}
|
|
72
|
+
async function carriedBack(runtime, locator, unlanded, written) {
|
|
73
|
+
const { store } = runtime;
|
|
59
74
|
const back = new Map();
|
|
60
75
|
const taken = [];
|
|
61
76
|
for (const batch of unlanded) {
|
|
@@ -74,12 +89,17 @@ async function carriedBack(store, locator, unlanded, written) {
|
|
|
74
89
|
const [into, key] = source === locator ? [written, path] : [back, documentKey(source, path)];
|
|
75
90
|
const existing = into.get(key) ?? (await store.draft(source, path));
|
|
76
91
|
const held = await store.record(source);
|
|
92
|
+
const composition = held === undefined ? unheldComposition(runtime, source) : store.composed(held);
|
|
93
|
+
const parts = returnedInto(existing?.parts, record.parts, composition === undefined ? undefined : definitionsAt(composition, path));
|
|
94
|
+
if (parts === null)
|
|
95
|
+
continue;
|
|
77
96
|
taken.push({ locator: destination, path: to });
|
|
78
97
|
into.set(key, {
|
|
79
98
|
locator: source,
|
|
80
99
|
path,
|
|
81
100
|
revision: roomDraftRevision(),
|
|
82
|
-
parts
|
|
101
|
+
parts,
|
|
102
|
+
marks: marksOver(existing?.marks ?? {}, record.marks),
|
|
83
103
|
returned: existing?.returned ?? null,
|
|
84
104
|
});
|
|
85
105
|
}
|
|
@@ -156,7 +176,7 @@ async function together(runtime, local, settlements) {
|
|
|
156
176
|
return mergeChangeSets(all.map((one) => one.apply(answer)));
|
|
157
177
|
}
|
|
158
178
|
async function settlement(runtime, local, locator, work, record, queue, settling = {}) {
|
|
159
|
-
const { store,
|
|
179
|
+
const { store, localSaves } = runtime;
|
|
160
180
|
const before = work.replica;
|
|
161
181
|
const view = settling.view ?? 'confirmed';
|
|
162
182
|
const previousQueue = work.queue;
|
|
@@ -165,37 +185,47 @@ async function settlement(runtime, local, locator, work, record, queue, settling
|
|
|
165
185
|
...(before !== undefined && before.record.key === record.key ? before.overlaid : []),
|
|
166
186
|
...(overrides?.set.map(({ path }) => path) ?? []),
|
|
167
187
|
...(overrides?.removed ?? []),
|
|
188
|
+
...[...work.states.values()].flatMap(({ drafts }) => drafts.map(({ path }) => path)),
|
|
168
189
|
]);
|
|
169
190
|
const confirmedLayer = overrides === undefined
|
|
170
191
|
? read
|
|
171
192
|
: await stepped(slicingWith(read, overrides.set, overrides.removed));
|
|
172
193
|
const composition = store.composed(record);
|
|
173
194
|
const shown = queue.filter((batch) => {
|
|
174
|
-
const held = store.
|
|
195
|
+
const held = store.conflicted.of(locator, batch.id);
|
|
175
196
|
return (held !== undefined &&
|
|
176
|
-
Object.entries(held).some(([path, revision]) => confirmedLayer.revisions[path] !== revision));
|
|
197
|
+
Object.entries(held.revisions).some(([path, revision]) => confirmedLayer.revisions[path] !== revision));
|
|
177
198
|
});
|
|
178
199
|
const unshown = queue.filter((batch) => !shown.includes(batch));
|
|
179
200
|
const { withdrawn, kept } = await stepped(standing(confirmedLayer, unshown, withdrawable(work.states), localSaves, locator, composition));
|
|
180
201
|
const founded = kept.filter((batch) => !unshown.includes(batch));
|
|
181
202
|
const queueChanged = kept.length !== previousQueue.length || founded.length > 0;
|
|
182
|
-
const unqueued = shown.map((batch) =>
|
|
203
|
+
const unqueued = shown.map((batch) => {
|
|
204
|
+
const { returned } = store.conflicted.of(locator, batch.id);
|
|
205
|
+
return {
|
|
206
|
+
batch,
|
|
207
|
+
returned: returned === null || landed(batch, confirmedLayer, composition) ? null : returned,
|
|
208
|
+
};
|
|
209
|
+
});
|
|
183
210
|
for (const batch of withdrawn) {
|
|
184
|
-
|
|
211
|
+
const held = await landedWhole(store, record, batch, confirmedLayer);
|
|
212
|
+
unqueued.push({ batch, returned: held ? null : returnedBy() });
|
|
185
213
|
}
|
|
186
214
|
const returning = [
|
|
187
|
-
...[...unqueued].reverse().map(({ batch,
|
|
215
|
+
...[...unqueued].reverse().map(({ batch, returned }) => ({
|
|
188
216
|
batch,
|
|
189
|
-
returned: localSaves
|
|
217
|
+
returned: localSaves ? null : returned,
|
|
190
218
|
})),
|
|
191
219
|
...(settling.leaving ?? []),
|
|
192
220
|
];
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
|
|
221
|
+
const replayedLayer = await replayed(store, record, confirmedLayer, kept);
|
|
222
|
+
const written = await returnedDrafts(store, locator, work, returning, composition, replayedLayer.visible);
|
|
223
|
+
const carried = await carriedBack(runtime, locator, [
|
|
224
|
+
...[...unqueued]
|
|
225
|
+
.reverse()
|
|
226
|
+
.flatMap(({ batch, returned }) => (returned === null ? [] : [batch])),
|
|
196
227
|
...(settling.leaving ?? []).flatMap(({ batch, returned }) => returned === null ? [] : [batch]),
|
|
197
228
|
], written);
|
|
198
|
-
const replayedLayer = await replayed(store, record, confirmedLayer, kept);
|
|
199
229
|
const { overlay } = await overlayDiff(record, before, replayedLayer.visible, replayedLayer.touched);
|
|
200
230
|
const commit = {
|
|
201
231
|
rooms: [
|
|
@@ -232,13 +262,9 @@ async function settlement(runtime, local, locator, work, record, queue, settling
|
|
|
232
262
|
apply: (answer) => {
|
|
233
263
|
for (const batch of previousQueue) {
|
|
234
264
|
if (!staying.has(batch.id))
|
|
235
|
-
store.
|
|
265
|
+
store.conflicted.drop(locator, batch.id);
|
|
236
266
|
}
|
|
237
267
|
const drafts = [...written.keys(), ...carried.taken];
|
|
238
|
-
for (const { batch, landed: held } of unqueued) {
|
|
239
|
-
const outcome = localSaves ? 'dropped' : held ? 'landed' : 'withdrawn';
|
|
240
|
-
journal.record(`outcome ${locator} ${batch.id} ${outcome}`);
|
|
241
|
-
}
|
|
242
268
|
const changed = answer.changed[locator];
|
|
243
269
|
if (settling.commit?.published !== undefined ||
|
|
244
270
|
settling.commit?.refreshed === true ||
|
|
@@ -260,29 +286,20 @@ async function settlement(runtime, local, locator, work, record, queue, settling
|
|
|
260
286
|
};
|
|
261
287
|
}
|
|
262
288
|
async function unpairing(runtime, local, locator, batches) {
|
|
263
|
-
const { store,
|
|
289
|
+
const { store, localSaves } = runtime;
|
|
264
290
|
const ids = new Set(batches.map(({ id }) => id));
|
|
265
291
|
const leaving = batches.map((batch) => ({
|
|
266
292
|
batch,
|
|
267
293
|
returned: !localSaves && leavingIn(batch, locator) ? returnedBy() : null,
|
|
268
294
|
}));
|
|
269
|
-
const outcome = localSaves ? 'dropped' : 'unpaired';
|
|
270
295
|
const work = await store.work(locator);
|
|
271
296
|
const current = work.replica;
|
|
272
297
|
if (current !== undefined) {
|
|
273
|
-
|
|
274
|
-
return {
|
|
275
|
-
...settled,
|
|
276
|
-
apply(answer) {
|
|
277
|
-
for (const batch of batches)
|
|
278
|
-
journal.record(`outcome ${locator} ${batch.id} ${outcome}`);
|
|
279
|
-
return settled.apply(answer);
|
|
280
|
-
},
|
|
281
|
-
};
|
|
298
|
+
return settlement(runtime, local, locator, work, current.record, current.queue.filter((one) => !ids.has(one.id)), { leaving });
|
|
282
299
|
}
|
|
283
300
|
const queue = work.queue.filter((one) => !ids.has(one.id));
|
|
284
|
-
const written = await returnedDrafts(store, locator, work, leaving, undefined);
|
|
285
|
-
const carried = await carriedBack(
|
|
301
|
+
const written = await returnedDrafts(store, locator, work, leaving, unheldComposition(runtime, locator), undefined);
|
|
302
|
+
const carried = await carriedBack(runtime, locator, leaving.flatMap(({ batch, returned }) => (returned === null ? [] : [batch])), written);
|
|
286
303
|
return {
|
|
287
304
|
locator,
|
|
288
305
|
left: batches,
|
|
@@ -300,8 +317,6 @@ async function unpairing(runtime, local, locator, batches) {
|
|
|
300
317
|
],
|
|
301
318
|
},
|
|
302
319
|
apply() {
|
|
303
|
-
for (const batch of batches)
|
|
304
|
-
journal.record(`outcome ${locator} ${batch.id} ${outcome}`);
|
|
305
320
|
return mergeChangeSets([
|
|
306
321
|
changeSet(locator, {
|
|
307
322
|
queue: true,
|
|
@@ -368,6 +383,12 @@ export function settle(runtime, locators, decide) {
|
|
|
368
383
|
await settled(runtime, local, settlements, decided.flatMap(({ after }) => (after === undefined ? [] : [after])));
|
|
369
384
|
});
|
|
370
385
|
}
|
|
386
|
+
function awaited(head, confirmedLayer, composition, { affected }, held) {
|
|
387
|
+
const touched = [...touchedBy([head])];
|
|
388
|
+
if (held)
|
|
389
|
+
return landed(head, confirmedLayer, composition) ? [] : touched;
|
|
390
|
+
return touched.filter((path) => Object.hasOwn(affected, path) && confirmedLayer.documents[path] !== affected[path]);
|
|
391
|
+
}
|
|
371
392
|
export function answered(runtime, locator, head, answer) {
|
|
372
393
|
const { store, socket } = runtime;
|
|
373
394
|
return store.exclusive(async () => {
|
|
@@ -381,18 +402,22 @@ export function answered(runtime, locator, head, answer) {
|
|
|
381
402
|
const confirmedLayer = await sliceAt(store, current.record, 'confirmed', [head]);
|
|
382
403
|
const held = answer.kind === 'conflicted' &&
|
|
383
404
|
(await landedWhole(store, current.record, head, confirmedLayer, answer.affected));
|
|
384
|
-
if (held &&
|
|
385
|
-
partnerOf(head, locator) === null &&
|
|
386
|
-
!landed(head, confirmedLayer, store.composed(current.record))) {
|
|
387
|
-
store.landed.hold(locator, head.id, Object.fromEntries([...touchedBy([head])].map((path) => [path, confirmedLayer.revisions[path]])));
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
405
|
const returned = {
|
|
391
406
|
kind: answer.kind,
|
|
392
407
|
code: answer.code,
|
|
393
408
|
fields: answer.fields,
|
|
394
409
|
retryable: answer.retryable,
|
|
395
410
|
};
|
|
411
|
+
if (answer.kind === 'conflicted' && partnerOf(head, locator) === null) {
|
|
412
|
+
const behind = awaited(head, confirmedLayer, store.composed(current.record), answer, held);
|
|
413
|
+
if (behind.length > 0) {
|
|
414
|
+
store.conflicted.hold(locator, head.id, {
|
|
415
|
+
revisions: Object.fromEntries(behind.map((path) => [path, confirmedLayer.revisions[path]])),
|
|
416
|
+
returned: held ? null : returned,
|
|
417
|
+
});
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
396
421
|
await settled(runtime, local, [
|
|
397
422
|
await settlement(runtime, local, locator, work, current.record, current.queue.filter((batch) => batch.id !== head.id), { leaving: [{ batch: head, returned: held ? null : returned }] }),
|
|
398
423
|
], []);
|
package/dist/reach.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ReadinessPort } from './preparation.js';
|
|
1
|
+
import type { ListedRoom } from './listing.js';
|
|
2
|
+
import type { ReadinessMessage, ReadinessPort } from './preparation.js';
|
|
3
|
+
import { type CodeAvailability } from './readiness.js';
|
|
3
4
|
import type { MdRuntime, RuntimeTopic } from './surface.js';
|
|
5
|
+
import type { QueriedRoom } from './adapter.js';
|
|
4
6
|
import type { Plan, PlanReach, QueryResult } from './query.js';
|
|
5
|
-
import type { Readiness } from './readiness.js';
|
|
6
7
|
import type { SearchResult } from './search.js';
|
|
8
|
+
import type { HouseQueryResult } from './house-query.js';
|
|
7
9
|
export type ReachedDocument = {
|
|
8
10
|
readonly room: string;
|
|
9
11
|
readonly path: string;
|
|
@@ -17,6 +19,7 @@ export type PortReach = {
|
|
|
17
19
|
readonly rooms: readonly string[];
|
|
18
20
|
readonly documents: readonly ReachedDocument[];
|
|
19
21
|
readonly areas?: readonly ReachedArea[];
|
|
22
|
+
readonly queriesOnly?: readonly QueriedRoom[];
|
|
20
23
|
readonly conversations: boolean;
|
|
21
24
|
};
|
|
22
25
|
export type Deliver = (message: unknown) => void;
|
|
@@ -28,19 +31,25 @@ export type RuntimeView = {
|
|
|
28
31
|
};
|
|
29
32
|
export type NarrowedView = RuntimeView & {
|
|
30
33
|
narrow(reach: PortReach | null): void;
|
|
34
|
+
code(code: CodeAvailability): void;
|
|
35
|
+
close(): void;
|
|
31
36
|
};
|
|
32
37
|
export type Reachable = RuntimeView & {
|
|
33
38
|
plan(input: unknown, reach: PortReach | null): Promise<Plan>;
|
|
34
39
|
query(plan: Plan): Promise<QueryResult>;
|
|
35
40
|
watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
|
|
36
41
|
search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
|
|
37
|
-
|
|
42
|
+
queryHouse(input: unknown, reach: PortReach | null, options: unknown): Promise<HouseQueryResult>;
|
|
43
|
+
queried(): readonly QueriedRoom[];
|
|
44
|
+
watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
|
|
38
45
|
locked(room: string): Promise<boolean>;
|
|
39
46
|
lockedRooms(): Promise<readonly string[]>;
|
|
40
47
|
watchLocks(notify: () => void): () => void;
|
|
41
48
|
located(room: string, path: string, destination: string): Promise<ReachedDocument | null>;
|
|
42
|
-
room(locator: string): Promise<
|
|
49
|
+
room(locator: string): Promise<ListedRoom | undefined>;
|
|
43
50
|
};
|
|
51
|
+
export declare function queriedOf(reach: PortReach | null, provided: readonly QueriedRoom[]): readonly QueriedRoom[];
|
|
52
|
+
export declare function queriedOnly(reach: PortReach | null, provided: readonly QueriedRoom[], room: string): boolean;
|
|
44
53
|
export declare function holds(reach: PortReach | null, room: string): boolean;
|
|
45
54
|
export declare function governs(reach: PortReach | null, room: {
|
|
46
55
|
readonly locator: string;
|
|
@@ -52,5 +61,5 @@ export declare function governs(reach: PortReach | null, room: {
|
|
|
52
61
|
readonly selection: boolean;
|
|
53
62
|
};
|
|
54
63
|
export declare function planReach(reach: PortReach | null): PlanReach | null;
|
|
55
|
-
export declare function narrowed(runtime: Reachable, given: PortReach | null,
|
|
64
|
+
export declare function narrowed(runtime: Reachable, given: PortReach | null, attached: ReadinessPort): NarrowedView;
|
|
56
65
|
//# sourceMappingURL=reach.d.ts.map
|
package/dist/reach.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,UAAU,EAA4B,MAAM,cAAc,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAA4C,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEjG,OAAO,KAAK,EAAE,SAAS,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,KAAK,EAAsB,WAAW,EAAE,MAAM,cAAc,CAAC;AA4BpE,OAAO,KAAK,EAAiB,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAS9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA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