@agentshouse/mdruntime 0.1.0-alpha.39 → 0.1.0-alpha.40
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/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +2 -1
- package/dist/bootstrap.js.map +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +90 -69
- package/dist/connection.js.map +1 -1
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +2 -1
- package/dist/refresh.js.map +1 -1
- package/package.json +1 -1
package/dist/bootstrap.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export type BootstrapOutcome = Staged | AdapterFailure;
|
|
|
5
5
|
export declare function bootstrapRoom(adapter: Adapter, authorization: Authorization, room: DiscoveredRoom, models: {
|
|
6
6
|
collection: ModelState;
|
|
7
7
|
selection: ModelState;
|
|
8
|
-
}): Promise<BootstrapOutcome>;
|
|
8
|
+
}, continuing: () => boolean): Promise<BootstrapOutcome>;
|
|
9
9
|
//# sourceMappingURL=bootstrap.d.ts.map
|
package/dist/bootstrap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAGvD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,cAAc,CAAC;AAEvD,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAGvD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,cAAc,CAAC;AAEvD,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAE,EACzD,UAAU,EAAE,MAAM,OAAO,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAyC3B"}
|
package/dist/bootstrap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readStaged } from './replica.js';
|
|
2
2
|
import { unconfirmed } from './transfer.js';
|
|
3
|
-
export async function bootstrapRoom(adapter, authorization, room, models) {
|
|
3
|
+
export async function bootstrapRoom(adapter, authorization, room, models, continuing) {
|
|
4
4
|
const first = await adapter.bootstrap(authorization, {
|
|
5
5
|
locator: room.locator,
|
|
6
6
|
selection: room.replica.selection
|
|
@@ -16,6 +16,7 @@ export async function bootstrapRoom(adapter, authorization, room, models) {
|
|
|
16
16
|
const binaryTargets = new Set(first.binaryTargets);
|
|
17
17
|
let pageToken = first.pageToken;
|
|
18
18
|
while(pageToken !== undefined){
|
|
19
|
+
if (!continuing()) return unconfirmed;
|
|
19
20
|
const page = await adapter.bootstrap(authorization, {
|
|
20
21
|
locator: room.locator,
|
|
21
22
|
selection: room.replica.selection,
|
package/dist/bootstrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/bootstrap.ts"],"sourcesContent":["import type { ModelState } from './model.js';\nimport type { Adapter, AdapterFailure, Authorization, DiscoveredRoom } from './adapter.js';\nimport { readStaged, type Staged } from './replica.js';\nimport { unconfirmed } from './transfer.js';\n\nexport type BootstrapOutcome = Staged | AdapterFailure;\n\nexport async function bootstrapRoom(\n adapter: Adapter,\n authorization: Authorization,\n room: DiscoveredRoom,\n models: { collection: ModelState; selection: ModelState },\n): Promise<BootstrapOutcome> {\n const first = await adapter.bootstrap(authorization, {\n locator: room.locator,\n selection: room.replica.selection,\n });\n if (first.kind !== 'bootstrap') return first;\n const roomVersion = first.roomVersion;\n const documents: Record<string, string> = { ...first.documents };\n const revisions: Record<string, string> = { ...first.revisions };\n const binaryTargets = new Set(first.binaryTargets);\n let pageToken = first.pageToken;\n while (pageToken !== undefined) {\n const page = await adapter.bootstrap(authorization, {\n locator: room.locator,\n selection: room.replica.selection,\n pageToken,\n });\n if (page.kind !== 'bootstrap') return page;\n if (page.roomVersion !== roomVersion) return unconfirmed;\n Object.assign(documents, page.documents);\n Object.assign(revisions, page.revisions);\n for (const target of page.binaryTargets) binaryTargets.add(target);\n pageToken = page.pageToken;\n }\n return readStaged({\n locator: room.locator,\n collectionRoot: room.collectionRoot,\n name: room.name,\n operations: room.operations,\n replica: room.replica,\n attachedModel: room.attachedModel,\n model: models.collection,\n typedSelection: room.typedSelection ?? null,\n selectionModel: models.selection,\n providerOwnedPaths: room.providerOwnedPaths,\n roomVersion,\n documents,\n binaryTargets: [...binaryTargets].sort(),\n revisions,\n });\n}\n"],"names":["readStaged","unconfirmed","bootstrapRoom","adapter","authorization","room","models","first","bootstrap","locator","selection","replica","kind","roomVersion","documents","revisions","binaryTargets","Set","pageToken","undefined","page","Object","assign","target","add","collectionRoot","name","operations","attachedModel","model","collection","typedSelection","selectionModel","providerOwnedPaths","sort"],"mappings":"AAEA,SAASA,UAAU,QAAqB,eAAe;AACvD,SAASC,WAAW,QAAQ,gBAAgB;AAI5C,OAAO,eAAeC,cACpBC,OAAgB,EAChBC,aAA4B,EAC5BC,IAAoB,EACpBC,MAAyD;
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/bootstrap.ts"],"sourcesContent":["import type { ModelState } from './model.js';\nimport type { Adapter, AdapterFailure, Authorization, DiscoveredRoom } from './adapter.js';\nimport { readStaged, type Staged } from './replica.js';\nimport { unconfirmed } from './transfer.js';\n\nexport type BootstrapOutcome = Staged | AdapterFailure;\n\nexport async function bootstrapRoom(\n adapter: Adapter,\n authorization: Authorization,\n room: DiscoveredRoom,\n models: { collection: ModelState; selection: ModelState },\n continuing: () => boolean,\n): Promise<BootstrapOutcome> {\n const first = await adapter.bootstrap(authorization, {\n locator: room.locator,\n selection: room.replica.selection,\n });\n if (first.kind !== 'bootstrap') return first;\n const roomVersion = first.roomVersion;\n const documents: Record<string, string> = { ...first.documents };\n const revisions: Record<string, string> = { ...first.revisions };\n const binaryTargets = new Set(first.binaryTargets);\n let pageToken = first.pageToken;\n while (pageToken !== undefined) {\n if (!continuing()) return unconfirmed;\n const page = await adapter.bootstrap(authorization, {\n locator: room.locator,\n selection: room.replica.selection,\n pageToken,\n });\n if (page.kind !== 'bootstrap') return page;\n if (page.roomVersion !== roomVersion) return unconfirmed;\n Object.assign(documents, page.documents);\n Object.assign(revisions, page.revisions);\n for (const target of page.binaryTargets) binaryTargets.add(target);\n pageToken = page.pageToken;\n }\n return readStaged({\n locator: room.locator,\n collectionRoot: room.collectionRoot,\n name: room.name,\n operations: room.operations,\n replica: room.replica,\n attachedModel: room.attachedModel,\n model: models.collection,\n typedSelection: room.typedSelection ?? null,\n selectionModel: models.selection,\n providerOwnedPaths: room.providerOwnedPaths,\n roomVersion,\n documents,\n binaryTargets: [...binaryTargets].sort(),\n revisions,\n });\n}\n"],"names":["readStaged","unconfirmed","bootstrapRoom","adapter","authorization","room","models","continuing","first","bootstrap","locator","selection","replica","kind","roomVersion","documents","revisions","binaryTargets","Set","pageToken","undefined","page","Object","assign","target","add","collectionRoot","name","operations","attachedModel","model","collection","typedSelection","selectionModel","providerOwnedPaths","sort"],"mappings":"AAEA,SAASA,UAAU,QAAqB,eAAe;AACvD,SAASC,WAAW,QAAQ,gBAAgB;AAI5C,OAAO,eAAeC,cACpBC,OAAgB,EAChBC,aAA4B,EAC5BC,IAAoB,EACpBC,MAAyD,EACzDC,UAAyB;IAEzB,MAAMC,QAAQ,MAAML,QAAQM,SAAS,CAACL,eAAe;QACnDM,SAASL,KAAKK,OAAO;QACrBC,WAAWN,KAAKO,OAAO,CAACD,SAAS;IACnC;IACA,IAAIH,MAAMK,IAAI,KAAK,aAAa,OAAOL;IACvC,MAAMM,cAAcN,MAAMM,WAAW;IACrC,MAAMC,YAAoC;QAAE,GAAGP,MAAMO,SAAS;IAAC;IAC/D,MAAMC,YAAoC;QAAE,GAAGR,MAAMQ,SAAS;IAAC;IAC/D,MAAMC,gBAAgB,IAAIC,IAAIV,MAAMS,aAAa;IACjD,IAAIE,YAAYX,MAAMW,SAAS;IAC/B,MAAOA,cAAcC,UAAW;QAC9B,IAAI,CAACb,cAAc,OAAON;QAC1B,MAAMoB,OAAO,MAAMlB,QAAQM,SAAS,CAACL,eAAe;YAClDM,SAASL,KAAKK,OAAO;YACrBC,WAAWN,KAAKO,OAAO,CAACD,SAAS;YACjCQ;QACF;QACA,IAAIE,KAAKR,IAAI,KAAK,aAAa,OAAOQ;QACtC,IAAIA,KAAKP,WAAW,KAAKA,aAAa,OAAOb;QAC7CqB,OAAOC,MAAM,CAACR,WAAWM,KAAKN,SAAS;QACvCO,OAAOC,MAAM,CAACP,WAAWK,KAAKL,SAAS;QACvC,KAAK,MAAMQ,UAAUH,KAAKJ,aAAa,CAAEA,cAAcQ,GAAG,CAACD;QAC3DL,YAAYE,KAAKF,SAAS;IAC5B;IACA,OAAOnB,WAAW;QAChBU,SAASL,KAAKK,OAAO;QACrBgB,gBAAgBrB,KAAKqB,cAAc;QACnCC,MAAMtB,KAAKsB,IAAI;QACfC,YAAYvB,KAAKuB,UAAU;QAC3BhB,SAASP,KAAKO,OAAO;QACrBiB,eAAexB,KAAKwB,aAAa;QACjCC,OAAOxB,OAAOyB,UAAU;QACxBC,gBAAgB3B,KAAK2B,cAAc,IAAI;QACvCC,gBAAgB3B,OAAOK,SAAS;QAChCuB,oBAAoB7B,KAAK6B,kBAAkB;QAC3CpB;QACAC;QACAE,eAAe;eAAIA;SAAc,CAACkB,IAAI;QACtCnB;IACF;AACF"}
|
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,EAEjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,KAAK,OAAO,EAEZ,KAAK,aAAa,EAIlB,KAAK,aAAa,EAKlB,KAAK,eAAe,EACpB,KAAK,WAAW,EAEjB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EAExB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAc,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE1F,OAAO,EAA8B,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAWzE,OAAO,E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gB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAEpE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAuuEzE"}
|
package/dist/connection.js
CHANGED
|
@@ -742,6 +742,7 @@ export function composeRuntime(options) {
|
|
|
742
742
|
}
|
|
743
743
|
function publish(local, room, confirmed) {
|
|
744
744
|
return exclusive(async ()=>{
|
|
745
|
+
if (!continuing()) return;
|
|
745
746
|
const prior = replicas.get(room.locator);
|
|
746
747
|
const retained = readConfirmed({
|
|
747
748
|
...confirmed.record,
|
|
@@ -860,7 +861,7 @@ export function composeRuntime(options) {
|
|
|
860
861
|
}
|
|
861
862
|
async function mark(local, locator, identifier, submission, lost) {
|
|
862
863
|
const state = pendings.get(identifier);
|
|
863
|
-
if (state === undefined || JSON.stringify(state.submission) === JSON.stringify(submission) && state.lost === lost) {
|
|
864
|
+
if (!continuing() || state === undefined || JSON.stringify(state.submission) === JSON.stringify(submission) && state.lost === lost) {
|
|
864
865
|
return;
|
|
865
866
|
}
|
|
866
867
|
await local.submit(locator, identifier, submission, lost);
|
|
@@ -879,11 +880,13 @@ export function composeRuntime(options) {
|
|
|
879
880
|
});
|
|
880
881
|
}
|
|
881
882
|
async function keepUpload(local, locator, identifier, upload) {
|
|
883
|
+
if (!continuing()) throw new Error('connection refused');
|
|
882
884
|
await local.keepUpload(locator, identifier, upload);
|
|
883
885
|
pendings.set(identifier, {
|
|
884
886
|
...pendings.get(identifier),
|
|
885
887
|
upload
|
|
886
888
|
});
|
|
889
|
+
if (!continuing()) throw new Error('connection refused');
|
|
887
890
|
}
|
|
888
891
|
async function readHistory(locator, path, query = {}) {
|
|
889
892
|
if (closed || refusal !== null) return {
|
|
@@ -990,9 +993,13 @@ export function composeRuntime(options) {
|
|
|
990
993
|
};
|
|
991
994
|
}
|
|
992
995
|
}
|
|
996
|
+
function continuing() {
|
|
997
|
+
return !closed && !discoveryPaused;
|
|
998
|
+
}
|
|
993
999
|
async function pullRefresh(authorized, confirmed) {
|
|
1000
|
+
if (!continuing()) return unconfirmed;
|
|
994
1001
|
try {
|
|
995
|
-
const result = await refreshRoom(options.adapter, authorized, confirmed);
|
|
1002
|
+
const result = await refreshRoom(options.adapter, authorized, confirmed, continuing);
|
|
996
1003
|
const detail = result.kind === 'advanced' ? result.confirmed.record.roomVersion : result.kind;
|
|
997
1004
|
journal.record(`transfer refresh ${confirmed.record.locator} ${detail}`);
|
|
998
1005
|
return result;
|
|
@@ -1002,11 +1009,12 @@ export function composeRuntime(options) {
|
|
|
1002
1009
|
}
|
|
1003
1010
|
}
|
|
1004
1011
|
async function pullBootstrap(authorized, room) {
|
|
1012
|
+
if (!continuing()) return unconfirmed;
|
|
1005
1013
|
try {
|
|
1006
1014
|
const result = await bootstrapRoom(options.adapter, authorized, room, {
|
|
1007
1015
|
collection: modelOf(room.locator),
|
|
1008
1016
|
selection: modelOf(room.locator, 'typed-selection')
|
|
1009
|
-
});
|
|
1017
|
+
}, continuing);
|
|
1010
1018
|
const detail = result.kind === 'staged' ? result.confirmed.record.roomVersion : result.kind;
|
|
1011
1019
|
journal.record(`transfer bootstrap ${room.locator} ${detail}`);
|
|
1012
1020
|
return result;
|
|
@@ -1019,6 +1027,7 @@ export function composeRuntime(options) {
|
|
|
1019
1027
|
const held = replicas.get(room.locator);
|
|
1020
1028
|
if (held !== undefined) {
|
|
1021
1029
|
const refreshed = await pullRefresh(authorized, held.confirmed);
|
|
1030
|
+
if (!continuing()) return unconfirmed;
|
|
1022
1031
|
if (refreshed.kind === 'still-current') {
|
|
1023
1032
|
if (sourceRefusals.has(room.locator)) return unconfirmed;
|
|
1024
1033
|
if (unreadable.delete(room.locator)) {
|
|
@@ -1028,15 +1037,14 @@ export function composeRuntime(options) {
|
|
|
1028
1037
|
return null;
|
|
1029
1038
|
}
|
|
1030
1039
|
if (refreshed.kind === 'advanced') {
|
|
1031
|
-
if (closed) return unconfirmed;
|
|
1032
1040
|
await publish(local, room, refreshed.confirmed);
|
|
1033
1041
|
return null;
|
|
1034
1042
|
}
|
|
1035
1043
|
if (refreshed.kind !== 'beyond-horizon') return refreshed;
|
|
1036
1044
|
}
|
|
1037
1045
|
const bootstrapped = await pullBootstrap(authorized, room);
|
|
1046
|
+
if (!continuing()) return unconfirmed;
|
|
1038
1047
|
if (bootstrapped.kind !== 'staged') return bootstrapped;
|
|
1039
|
-
if (closed) return unconfirmed;
|
|
1040
1048
|
await publish(local, room, bootstrapped.confirmed);
|
|
1041
1049
|
return null;
|
|
1042
1050
|
}
|
|
@@ -1054,9 +1062,7 @@ export function composeRuntime(options) {
|
|
|
1054
1062
|
refusedSource(room, withheld);
|
|
1055
1063
|
} else if (withheld.kind === 'revoked-authorization') {
|
|
1056
1064
|
await refuse('revoked-authorization');
|
|
1057
|
-
return 'stop';
|
|
1058
1065
|
}
|
|
1059
|
-
return null;
|
|
1060
1066
|
}
|
|
1061
1067
|
function refusedSource(room, { refusal }) {
|
|
1062
1068
|
sourceRefusals.set(room.locator, {
|
|
@@ -1141,6 +1147,7 @@ export function composeRuntime(options) {
|
|
|
1141
1147
|
}
|
|
1142
1148
|
async function holdAccepted(room, local, submitted, accepted, refused) {
|
|
1143
1149
|
await exclusive(async ()=>{
|
|
1150
|
+
if (!continuing()) return;
|
|
1144
1151
|
const current = replicas.get(room.locator);
|
|
1145
1152
|
if (current === undefined || !current.queue.some((batch)=>batch.id === submitted.id)) {
|
|
1146
1153
|
return;
|
|
@@ -1162,9 +1169,10 @@ export function composeRuntime(options) {
|
|
|
1162
1169
|
outcomeRooms.set(submitted.id, room.locator);
|
|
1163
1170
|
logAccepted(room.locator, submitted, accepted);
|
|
1164
1171
|
});
|
|
1165
|
-
if (refused !== null) refusedSource(room, refused);
|
|
1172
|
+
if (refused !== null && continuing()) refusedSource(room, refused);
|
|
1166
1173
|
}
|
|
1167
1174
|
async function commitAccept(room, local, submitted, accepted, base, overlay) {
|
|
1175
|
+
if (!continuing()) return unconfirmed;
|
|
1168
1176
|
const current = replicas.get(room.locator);
|
|
1169
1177
|
if (current === undefined || !current.queue.some((batch)=>batch.id === submitted.id)) {
|
|
1170
1178
|
return null;
|
|
@@ -1203,13 +1211,13 @@ export function composeRuntime(options) {
|
|
|
1203
1211
|
return false;
|
|
1204
1212
|
}
|
|
1205
1213
|
async function submitRoom(room, local, authorized, progress) {
|
|
1206
|
-
while(
|
|
1214
|
+
while(continuing() && authorization !== undefined){
|
|
1207
1215
|
const replica = replicas.get(room.locator);
|
|
1208
1216
|
const head = replica?.queue[0];
|
|
1209
|
-
if (replica === undefined || head === undefined) return
|
|
1217
|
+
if (replica === undefined || head === undefined) return;
|
|
1210
1218
|
if (outcomes.get(head.id)?.kind === 'accepted') {
|
|
1211
1219
|
progress.complete = false;
|
|
1212
|
-
return
|
|
1220
|
+
return;
|
|
1213
1221
|
}
|
|
1214
1222
|
const state = pendings.get(head.id);
|
|
1215
1223
|
const { submission, lost: earlier } = state ?? {
|
|
@@ -1220,12 +1228,12 @@ export function composeRuntime(options) {
|
|
|
1220
1228
|
};
|
|
1221
1229
|
if (submission.state === 'reset' && Date.now() < Date.parse(submission.reset)) {
|
|
1222
1230
|
progress.complete = false;
|
|
1223
|
-
return
|
|
1231
|
+
return;
|
|
1224
1232
|
}
|
|
1225
1233
|
if (writesHeld()) {
|
|
1226
1234
|
progress.complete = false;
|
|
1227
1235
|
journal.record(`submission ${room.locator} ${head.id} held`);
|
|
1228
|
-
return
|
|
1236
|
+
return;
|
|
1229
1237
|
}
|
|
1230
1238
|
const lost = earlier || submission.state === 'submitted';
|
|
1231
1239
|
let result;
|
|
@@ -1233,11 +1241,12 @@ export function composeRuntime(options) {
|
|
|
1233
1241
|
await exclusive(()=>mark(local, room.locator, head.id, {
|
|
1234
1242
|
state: 'submitted'
|
|
1235
1243
|
}, lost));
|
|
1244
|
+
if (discoveryPaused) return;
|
|
1236
1245
|
if (writesHeld()) {
|
|
1237
1246
|
await exclusive(()=>mark(local, room.locator, head.id, submission, earlier));
|
|
1238
1247
|
progress.complete = false;
|
|
1239
1248
|
journal.record(`submission ${room.locator} ${head.id} held`);
|
|
1240
|
-
return
|
|
1249
|
+
return;
|
|
1241
1250
|
}
|
|
1242
1251
|
const opensBefore = openSignals;
|
|
1243
1252
|
try {
|
|
@@ -1250,30 +1259,30 @@ export function composeRuntime(options) {
|
|
|
1250
1259
|
}, (upload)=>exclusive(()=>keepUpload(local, room.locator, head.id, upload)));
|
|
1251
1260
|
} catch {
|
|
1252
1261
|
progress.complete = false;
|
|
1253
|
-
progress.reachable = false;
|
|
1254
|
-
return
|
|
1262
|
+
if (continuing()) progress.reachable = false;
|
|
1263
|
+
return;
|
|
1255
1264
|
}
|
|
1256
|
-
if (
|
|
1265
|
+
if (!continuing()) return;
|
|
1257
1266
|
if (result.kind === 'transport-uncertainty') {
|
|
1258
1267
|
progress.complete = false;
|
|
1259
1268
|
progress.reachable = false;
|
|
1260
|
-
return
|
|
1269
|
+
return;
|
|
1261
1270
|
}
|
|
1262
1271
|
if (result.kind === 'room-not-readable') {
|
|
1263
1272
|
progress.complete = false;
|
|
1264
1273
|
unreadable.add(room.locator);
|
|
1265
1274
|
list(room, false);
|
|
1266
1275
|
emitRooms();
|
|
1267
|
-
return
|
|
1276
|
+
return;
|
|
1268
1277
|
}
|
|
1269
1278
|
if (result.kind === 'revoked-authorization') {
|
|
1270
1279
|
await refuse('revoked-authorization');
|
|
1271
|
-
return
|
|
1280
|
+
return;
|
|
1272
1281
|
}
|
|
1273
1282
|
if (result.kind === 'scoped-refusal') {
|
|
1274
1283
|
await scoped(result, room, local);
|
|
1275
1284
|
progress.complete = false;
|
|
1276
|
-
return
|
|
1285
|
+
return;
|
|
1277
1286
|
}
|
|
1278
1287
|
if (result.kind === 'write-halted') {
|
|
1279
1288
|
journal.record(`outcome ${room.locator} ${head.id} write-halted`);
|
|
@@ -1283,7 +1292,7 @@ export function composeRuntime(options) {
|
|
|
1283
1292
|
if (serviceMode === 'open' && openSignals !== opensBefore) continue;
|
|
1284
1293
|
haltedRefusal = true;
|
|
1285
1294
|
progress.complete = false;
|
|
1286
|
-
return
|
|
1295
|
+
return;
|
|
1287
1296
|
}
|
|
1288
1297
|
if (result.kind === 'conflicted' || result.kind === 'rejected' || result.kind === 'expired' || result.kind === 'retryable-refusal') {
|
|
1289
1298
|
if (result.kind === 'expired') {
|
|
@@ -1302,11 +1311,12 @@ export function composeRuntime(options) {
|
|
|
1302
1311
|
state: 'reset',
|
|
1303
1312
|
reset
|
|
1304
1313
|
}, lost));
|
|
1305
|
-
return
|
|
1314
|
+
return;
|
|
1306
1315
|
}
|
|
1307
1316
|
if (result.kind === 'conflicted' || result.kind === 'rejected' || result.kind === 'expired') {
|
|
1308
1317
|
const left = leaving(head, result);
|
|
1309
1318
|
await exclusive(async ()=>{
|
|
1319
|
+
if (!continuing()) return;
|
|
1310
1320
|
const current = replicas.get(room.locator);
|
|
1311
1321
|
if (current === undefined || !current.queue.some((batch)=>batch.id === head.id)) {
|
|
1312
1322
|
return;
|
|
@@ -1329,21 +1339,22 @@ export function composeRuntime(options) {
|
|
|
1329
1339
|
continue;
|
|
1330
1340
|
}
|
|
1331
1341
|
const from = replicas.get(room.locator)?.confirmed;
|
|
1332
|
-
if (from === undefined) return
|
|
1342
|
+
if (from === undefined) return;
|
|
1333
1343
|
const pulled = await pullRefresh(authorized, from);
|
|
1344
|
+
if (!continuing()) return;
|
|
1334
1345
|
if (pulled.kind === 'revoked-authorization') {
|
|
1335
1346
|
await refuse('revoked-authorization');
|
|
1336
|
-
return
|
|
1347
|
+
return;
|
|
1337
1348
|
}
|
|
1338
1349
|
if (pulled.kind === 'scoped-refusal') {
|
|
1339
1350
|
await scoped(pulled, room, local);
|
|
1340
1351
|
progress.complete = false;
|
|
1341
|
-
return
|
|
1352
|
+
return;
|
|
1342
1353
|
}
|
|
1343
1354
|
if (pulled.kind === 'still-current') {
|
|
1344
1355
|
if (!await committed(room, local, head, result, from, true)) {
|
|
1345
1356
|
progress.complete = false;
|
|
1346
|
-
return
|
|
1357
|
+
return;
|
|
1347
1358
|
}
|
|
1348
1359
|
continue;
|
|
1349
1360
|
}
|
|
@@ -1351,26 +1362,27 @@ export function composeRuntime(options) {
|
|
|
1351
1362
|
const overlay = pulled.confirmed.record.roomVersion === result.roomVersion;
|
|
1352
1363
|
if (!await committed(room, local, head, result, pulled.confirmed, overlay)) {
|
|
1353
1364
|
progress.complete = false;
|
|
1354
|
-
return
|
|
1365
|
+
return;
|
|
1355
1366
|
}
|
|
1356
1367
|
continue;
|
|
1357
1368
|
}
|
|
1358
1369
|
if (pulled.kind === 'beyond-horizon') {
|
|
1359
1370
|
const bootstrapped = await pullBootstrap(authorized, room);
|
|
1371
|
+
if (!continuing()) return;
|
|
1360
1372
|
if (bootstrapped.kind === 'revoked-authorization') {
|
|
1361
1373
|
await refuse('revoked-authorization');
|
|
1362
|
-
return
|
|
1374
|
+
return;
|
|
1363
1375
|
}
|
|
1364
1376
|
if (bootstrapped.kind === 'scoped-refusal') {
|
|
1365
1377
|
await scoped(bootstrapped, room, local);
|
|
1366
1378
|
progress.complete = false;
|
|
1367
|
-
return
|
|
1379
|
+
return;
|
|
1368
1380
|
}
|
|
1369
1381
|
if (bootstrapped.kind === 'staged') {
|
|
1370
1382
|
const overlay = bootstrapped.confirmed.record.roomVersion === result.roomVersion;
|
|
1371
1383
|
if (!await committed(room, local, head, result, bootstrapped.confirmed, overlay)) {
|
|
1372
1384
|
progress.complete = false;
|
|
1373
|
-
return
|
|
1385
|
+
return;
|
|
1374
1386
|
}
|
|
1375
1387
|
continue;
|
|
1376
1388
|
}
|
|
@@ -1384,7 +1396,7 @@ export function composeRuntime(options) {
|
|
|
1384
1396
|
} else if (bootstrapped.kind === 'refused') {
|
|
1385
1397
|
await holdAccepted(room, local, head, result, bootstrapped);
|
|
1386
1398
|
}
|
|
1387
|
-
return
|
|
1399
|
+
return;
|
|
1388
1400
|
}
|
|
1389
1401
|
progress.complete = false;
|
|
1390
1402
|
if (pulled.kind === 'transport-uncertainty') {
|
|
@@ -1396,9 +1408,9 @@ export function composeRuntime(options) {
|
|
|
1396
1408
|
} else if (pulled.kind === 'refused') {
|
|
1397
1409
|
await holdAccepted(room, local, head, result, pulled);
|
|
1398
1410
|
}
|
|
1399
|
-
return
|
|
1411
|
+
return;
|
|
1400
1412
|
}
|
|
1401
|
-
return
|
|
1413
|
+
return;
|
|
1402
1414
|
}
|
|
1403
1415
|
async function retainModel(local, room, attached, next) {
|
|
1404
1416
|
const key = modelKey(room.locator, attached);
|
|
@@ -1412,6 +1424,7 @@ export function composeRuntime(options) {
|
|
|
1412
1424
|
liveModels.delete(key);
|
|
1413
1425
|
}
|
|
1414
1426
|
await exclusive(async ()=>{
|
|
1427
|
+
if (!continuing()) return;
|
|
1415
1428
|
if (next.status !== 'unavailable' && epoch !== (modelEpoch.get(key) ?? 0)) return;
|
|
1416
1429
|
const held = replicas.get(room.locator);
|
|
1417
1430
|
if (held !== undefined) {
|
|
@@ -1474,6 +1487,7 @@ export function composeRuntime(options) {
|
|
|
1474
1487
|
reason: 'version-changed'
|
|
1475
1488
|
};
|
|
1476
1489
|
await retainModel(local, room, attached, previous);
|
|
1490
|
+
if (discoveryPaused) return;
|
|
1477
1491
|
}
|
|
1478
1492
|
const epoch = modelEpoch.get(key) ?? 0;
|
|
1479
1493
|
let answer;
|
|
@@ -1494,7 +1508,7 @@ export function composeRuntime(options) {
|
|
|
1494
1508
|
kind: 'transport-uncertainty'
|
|
1495
1509
|
};
|
|
1496
1510
|
}
|
|
1497
|
-
if (epoch !== (modelEpoch.get(key) ?? 0)) return;
|
|
1511
|
+
if (discoveryPaused || epoch !== (modelEpoch.get(key) ?? 0)) return;
|
|
1498
1512
|
if (answer.kind === 'revoked-authorization') {
|
|
1499
1513
|
await refuse('revoked-authorization');
|
|
1500
1514
|
return;
|
|
@@ -1569,46 +1583,52 @@ export function composeRuntime(options) {
|
|
|
1569
1583
|
};
|
|
1570
1584
|
await retainModel(local, scopedAway, 'collection', modelOf(room.locator));
|
|
1571
1585
|
}
|
|
1586
|
+
if (!continuing()) return;
|
|
1572
1587
|
list(scopedAway, scopedAway.replica.admission === 'admitted' && !unreadable.has(room.locator));
|
|
1573
1588
|
emitRooms();
|
|
1574
1589
|
journal.record(`scoped refusal ${room.locator} ${result.scope} ${result.code}`);
|
|
1575
1590
|
}
|
|
1576
1591
|
async function synchronize(discovered, local, progress) {
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1592
|
+
const rooms = await Promise.allSettled(discovered.map((room)=>synchronizeRoom(room, local, progress)));
|
|
1593
|
+
const failed = rooms.find((room)=>room.status === 'rejected');
|
|
1594
|
+
if (failed !== undefined) throw failed.reason;
|
|
1595
|
+
}
|
|
1596
|
+
async function synchronizeRoom(room, local, progress) {
|
|
1597
|
+
if (closed || authorization === undefined) {
|
|
1598
|
+
progress.complete = false;
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1601
|
+
const prior = replicas.get(room.locator)?.confirmed.record;
|
|
1602
|
+
if (prior !== undefined && prior.replica.selection !== room.replica.selection) {
|
|
1603
|
+
list(prior, false);
|
|
1604
|
+
emitRooms();
|
|
1605
|
+
journal.record(`selection changed ${room.locator}`);
|
|
1606
|
+
progress.complete = false;
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1609
|
+
const selection = room.typedSelection;
|
|
1610
|
+
await Promise.all([
|
|
1611
|
+
acquireModel(local, room, authorization, null),
|
|
1612
|
+
...selection === undefined ? [] : [
|
|
1613
|
+
acquireModel(local, room, authorization, selection)
|
|
1614
|
+
]
|
|
1615
|
+
]);
|
|
1616
|
+
if (discoveryPaused || authorization === undefined) return;
|
|
1617
|
+
if (room.replica.admission !== 'admitted') {
|
|
1618
|
+
progress.complete = false;
|
|
1619
|
+
return;
|
|
1620
|
+
}
|
|
1621
|
+
const held = replicas.get(room.locator);
|
|
1622
|
+
if (held !== undefined && held.confirmed.record.replica.selection !== room.replica.selection) {
|
|
1623
|
+
progress.complete = false;
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
const withheld = await advance(room, local, authorization);
|
|
1627
|
+
if (withheld !== null) {
|
|
1628
|
+
await withhold(withheld, room, local, progress);
|
|
1629
|
+
return;
|
|
1611
1630
|
}
|
|
1631
|
+
await submitRoom(room, local, authorization, progress);
|
|
1612
1632
|
}
|
|
1613
1633
|
async function cycle(local, progress) {
|
|
1614
1634
|
if (closed || authorization === undefined) {
|
|
@@ -2207,6 +2227,7 @@ export function composeRuntime(options) {
|
|
|
2207
2227
|
async reauthorize () {
|
|
2208
2228
|
if (refusal === null || !refusal.reauthorizationOffered) return;
|
|
2209
2229
|
journal.record('connection reauthorize');
|
|
2230
|
+
await chain.catch(()=>undefined);
|
|
2210
2231
|
await mutations;
|
|
2211
2232
|
authorization = undefined;
|
|
2212
2233
|
discoveryPaused = false;
|