@githolon/runtime 0.112.7 → 0.112.11
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/RUNTIME-SOURCES.sha256 +22 -19
- package/dist/nomos-native-runtime.js +330 -106
- package/dist/nomos-runner-web.js +145 -0
- package/dist/nomos-runner-worker.js +36411 -0
- package/dist/nomos-runner.js +547 -230
- package/package.json +4 -2
- package/runner/README.md +2 -1
- package/runner/build.ts +36 -3
- package/runner/node-entry.mjs +437 -187
package/dist/nomos-runner.js
CHANGED
|
@@ -7894,16 +7894,22 @@
|
|
|
7894
7894
|
// ../../platform-shells/browser/runtime_fetch.ts
|
|
7895
7895
|
init_define_NOMOS_KERNEL_RELEASE();
|
|
7896
7896
|
init_shims();
|
|
7897
|
-
function browserRuntimeFetch(base, fetchImpl, caches) {
|
|
7897
|
+
function browserRuntimeFetch(base, fetchImpl, caches, repositoryUrl) {
|
|
7898
7898
|
const root = base.replace(/\/+$/, "");
|
|
7899
7899
|
return async (input, init) => {
|
|
7900
7900
|
const url = String(input);
|
|
7901
|
-
const bootArtifact = url === `${root}/v1/runtime/repository.xml` || url === `${root}/v1/runtime/nomos.law.usdz`;
|
|
7902
|
-
if (!bootArtifact
|
|
7901
|
+
const bootArtifact = url === (repositoryUrl ?? `${root}/v1/runtime/repository.xml`) || url === `${root}/v1/runtime/nomos.law.usdz`;
|
|
7902
|
+
if (!bootArtifact) return fetchImpl(input, init);
|
|
7903
|
+
const networkInit = {
|
|
7904
|
+
...init,
|
|
7905
|
+
cache: "no-store",
|
|
7906
|
+
signal: init?.signal ?? AbortSignal.timeout(15e3)
|
|
7907
|
+
};
|
|
7908
|
+
if (!caches) return fetchImpl(input, networkInit);
|
|
7903
7909
|
const cache = await caches.open("nomos-browser-boot-v1");
|
|
7904
7910
|
let response;
|
|
7905
7911
|
try {
|
|
7906
|
-
response = await fetchImpl(input,
|
|
7912
|
+
response = await fetchImpl(input, networkInit);
|
|
7907
7913
|
} catch (error) {
|
|
7908
7914
|
const retained = await cache.match(url);
|
|
7909
7915
|
if (retained) return retained;
|
|
@@ -12060,10 +12066,11 @@
|
|
|
12060
12066
|
var copyRecord = (record) => ({ ...record, value: record.value.slice() });
|
|
12061
12067
|
var currentCacheFile = (path) => path.endsWith("/nomos.git/nomos-cache/raw-frontier-v2/current.sqlite");
|
|
12062
12068
|
var durableFile = (path) => !path.includes("/nomos.git/nomos-cache/raw-frontier-v2/addressed/") && !path.endsWith("/nomos.git/nomos-cache/raw-frontier-v2/addressed") && !currentCacheFile(path);
|
|
12063
|
-
var keyOf = (
|
|
12064
|
-
var _backend, _records, _knownNodes, _mutatedNodes, _changedRecords, _cachePaths, _cacheDirty, _cacheDisabled, _cacheTimer, _cachePending, _revision, _committed, _queued, _failure, _closed;
|
|
12069
|
+
var keyOf = (namespace2, key) => JSON.stringify([namespace2, key]);
|
|
12070
|
+
var _backend, _records, _knownNodes, _mutatedNodes, _changedRecords, _cachePaths, _cacheDirty, _cacheDisabled, _cacheTimer, _cachePending, _revision, _committed, _queued, _checkpoints, _failure, _closed;
|
|
12065
12071
|
var _BrowserCustodyStore = class _BrowserCustodyStore {
|
|
12066
12072
|
constructor(backend, snapshot) {
|
|
12073
|
+
__publicField(this, "onCheckpoint");
|
|
12067
12074
|
__publicField(this, "filesystem", memoryCustodyFilesystem());
|
|
12068
12075
|
__publicField(this, "replica");
|
|
12069
12076
|
__publicField(this, "identity");
|
|
@@ -12080,6 +12087,7 @@
|
|
|
12080
12087
|
__privateAdd(this, _revision, 0);
|
|
12081
12088
|
__privateAdd(this, _committed, -1);
|
|
12082
12089
|
__privateAdd(this, _queued);
|
|
12090
|
+
__privateAdd(this, _checkpoints, /* @__PURE__ */ new Set());
|
|
12083
12091
|
__privateAdd(this, _failure);
|
|
12084
12092
|
__privateAdd(this, _closed, false);
|
|
12085
12093
|
__publicField(this, "changed", (inode) => {
|
|
@@ -12095,7 +12103,7 @@
|
|
|
12095
12103
|
}, 3e4));
|
|
12096
12104
|
__privateGet(this, _cacheTimer).unref?.();
|
|
12097
12105
|
}
|
|
12098
|
-
void this.
|
|
12106
|
+
void this.flushDurable().catch(() => {
|
|
12099
12107
|
});
|
|
12100
12108
|
});
|
|
12101
12109
|
__privateSet(this, _backend, backend);
|
|
@@ -12141,16 +12149,16 @@
|
|
|
12141
12149
|
if (__privateGet(this, _failure)) throw new Error("Browser custody could not be saved. Keep this tab open, free storage space, and reload only after recovery.", { cause: __privateGet(this, _failure) });
|
|
12142
12150
|
if (__privateGet(this, _closed)) throw new Error("Browser custody is closed");
|
|
12143
12151
|
}
|
|
12144
|
-
list(
|
|
12152
|
+
list(namespace2) {
|
|
12145
12153
|
this.assertUsable();
|
|
12146
|
-
return [...__privateGet(this, _records).values()].filter((record) => record.namespace ===
|
|
12154
|
+
return [...__privateGet(this, _records).values()].filter((record) => record.namespace === namespace2).sort((a, b) => a.key.localeCompare(b.key)).map(copyRecord);
|
|
12147
12155
|
}
|
|
12148
|
-
compareExchange(
|
|
12156
|
+
compareExchange(namespace2, key, expected, value) {
|
|
12149
12157
|
this.assertUsable();
|
|
12150
|
-
const id = keyOf(
|
|
12158
|
+
const id = keyOf(namespace2, key);
|
|
12151
12159
|
const current = __privateGet(this, _records).get(id);
|
|
12152
|
-
if (current?.revision !== expected) throw new Error(`peer desk record '${
|
|
12153
|
-
const next = value === void 0 ? void 0 : { namespace, key, revision: (current?.revision ?? 0n) + 1n, value: value.slice() };
|
|
12160
|
+
if (current?.revision !== expected) throw new Error(`peer desk record '${namespace2}/${key}' changed at revision ${current?.revision ?? "absent"}`);
|
|
12161
|
+
const next = value === void 0 ? void 0 : { namespace: namespace2, key, revision: (current?.revision ?? 0n) + 1n, value: value.slice() };
|
|
12154
12162
|
if (next) __privateGet(this, _records).set(id, next);
|
|
12155
12163
|
else __privateGet(this, _records).delete(id);
|
|
12156
12164
|
__privateGet(this, _changedRecords).set(id, next && copyRecord(next));
|
|
@@ -12158,16 +12166,30 @@
|
|
|
12158
12166
|
return next && copyRecord(next);
|
|
12159
12167
|
}
|
|
12160
12168
|
checkpoint() {
|
|
12169
|
+
this.assertUsable();
|
|
12170
|
+
const revision = __privateGet(this, _revision);
|
|
12171
|
+
if (__privateGet(this, _committed) >= revision) return Promise.resolve();
|
|
12172
|
+
const completed = new Promise((resolve, reject) => {
|
|
12173
|
+
__privateGet(this, _checkpoints).add({ revision, resolve, reject });
|
|
12174
|
+
});
|
|
12175
|
+
void this.flushDurable().catch(() => {
|
|
12176
|
+
});
|
|
12177
|
+
return completed;
|
|
12178
|
+
}
|
|
12179
|
+
flushDurable() {
|
|
12161
12180
|
this.assertUsable();
|
|
12162
12181
|
if (!__privateGet(this, _queued)) {
|
|
12163
12182
|
__privateSet(this, _queued, Promise.resolve().then(async () => {
|
|
12164
12183
|
while (__privateGet(this, _committed) !== __privateGet(this, _revision)) {
|
|
12184
|
+
const snapshotStarted = performance.now();
|
|
12165
12185
|
const revision = __privateGet(this, _revision);
|
|
12166
12186
|
const delta = this.filesystem.delta(__privateGet(this, _knownNodes), __privateGet(this, _mutatedNodes), durableFile);
|
|
12167
12187
|
__privateGet(this, _mutatedNodes).clear();
|
|
12168
12188
|
const records = [...__privateGet(this, _changedRecords).values()].filter((record) => record !== void 0).map(copyRecord);
|
|
12169
12189
|
const removedRecords = [...__privateGet(this, _changedRecords).entries()].filter(([, record]) => record === void 0).map(([id]) => id);
|
|
12170
12190
|
__privateGet(this, _changedRecords).clear();
|
|
12191
|
+
const snapshotMs = performance.now() - snapshotStarted;
|
|
12192
|
+
const commitStarted = performance.now();
|
|
12171
12193
|
await __privateGet(this, _backend).commit({
|
|
12172
12194
|
control: { format: 2, replica: this.replica, identity: this.identity },
|
|
12173
12195
|
files: delta.changed,
|
|
@@ -12175,19 +12197,39 @@
|
|
|
12175
12197
|
records,
|
|
12176
12198
|
removedRecords
|
|
12177
12199
|
});
|
|
12200
|
+
try {
|
|
12201
|
+
this.onCheckpoint?.({
|
|
12202
|
+
snapshotMs,
|
|
12203
|
+
commitMs: performance.now() - commitStarted,
|
|
12204
|
+
files: delta.changed.length,
|
|
12205
|
+
bytes: delta.changed.reduce((total, file) => total + (file.bytes?.byteLength ?? 0), 0),
|
|
12206
|
+
records: records.length,
|
|
12207
|
+
removedFiles: delta.removed.length
|
|
12208
|
+
});
|
|
12209
|
+
} catch {
|
|
12210
|
+
}
|
|
12178
12211
|
__privateSet(this, _knownNodes, new Map(delta.nodes));
|
|
12179
12212
|
__privateSet(this, _committed, revision);
|
|
12213
|
+
for (const checkpoint of __privateGet(this, _checkpoints)) {
|
|
12214
|
+
if (checkpoint.revision > revision) continue;
|
|
12215
|
+
__privateGet(this, _checkpoints).delete(checkpoint);
|
|
12216
|
+
checkpoint.resolve();
|
|
12217
|
+
}
|
|
12180
12218
|
}
|
|
12181
12219
|
}).catch((error) => {
|
|
12182
12220
|
__privateSet(this, _failure, error);
|
|
12221
|
+
for (const checkpoint of __privateGet(this, _checkpoints)) checkpoint.reject(error);
|
|
12222
|
+
__privateGet(this, _checkpoints).clear();
|
|
12183
12223
|
throw error;
|
|
12184
12224
|
}).finally(() => {
|
|
12185
12225
|
__privateSet(this, _queued, void 0);
|
|
12226
|
+
if (!__privateGet(this, _failure) && __privateGet(this, _committed) !== __privateGet(this, _revision)) {
|
|
12227
|
+
void this.flushDurable().catch(() => {
|
|
12228
|
+
});
|
|
12229
|
+
}
|
|
12186
12230
|
}));
|
|
12187
12231
|
}
|
|
12188
|
-
return __privateGet(this, _queued)
|
|
12189
|
-
if (__privateGet(this, _committed) !== __privateGet(this, _revision)) return this.checkpoint();
|
|
12190
|
-
});
|
|
12232
|
+
return __privateGet(this, _queued);
|
|
12191
12233
|
}
|
|
12192
12234
|
isCheckpointCurrent() {
|
|
12193
12235
|
return !__privateGet(this, _failure) && !__privateGet(this, _closed) && __privateGet(this, _committed) === __privateGet(this, _revision);
|
|
@@ -12209,7 +12251,7 @@
|
|
|
12209
12251
|
await __privateGet(this, _cachePending);
|
|
12210
12252
|
}
|
|
12211
12253
|
async close() {
|
|
12212
|
-
await this.
|
|
12254
|
+
await this.flushDurable();
|
|
12213
12255
|
if (__privateGet(this, _cacheTimer)) clearTimeout(__privateGet(this, _cacheTimer));
|
|
12214
12256
|
__privateSet(this, _cacheTimer, void 0);
|
|
12215
12257
|
await this.flushCache();
|
|
@@ -12230,6 +12272,7 @@
|
|
|
12230
12272
|
_revision = new WeakMap();
|
|
12231
12273
|
_committed = new WeakMap();
|
|
12232
12274
|
_queued = new WeakMap();
|
|
12275
|
+
_checkpoints = new WeakMap();
|
|
12233
12276
|
_failure = new WeakMap();
|
|
12234
12277
|
_closed = new WeakMap();
|
|
12235
12278
|
var BrowserCustodyStore = _BrowserCustodyStore;
|
|
@@ -12954,7 +12997,8 @@
|
|
|
12954
12997
|
}
|
|
12955
12998
|
}));
|
|
12956
12999
|
if (response.outcome.case === "failure") {
|
|
12957
|
-
|
|
13000
|
+
throwUnnamedHistoryRequirement(response.outcome.value, mount.workspace);
|
|
13001
|
+
throwKernelFailure(response.outcome.value);
|
|
12958
13002
|
}
|
|
12959
13003
|
if (response.outcome.case !== "outbox") {
|
|
12960
13004
|
throw new Error(`kernel returned '${response.outcome.case || "empty"}' while reading correspondence`);
|
|
@@ -12983,7 +13027,8 @@
|
|
|
12983
13027
|
}
|
|
12984
13028
|
}));
|
|
12985
13029
|
if (response.outcome.case === "failure") {
|
|
12986
|
-
|
|
13030
|
+
throwUnnamedHistoryRequirement(response.outcome.value, mount.workspace);
|
|
13031
|
+
throwKernelFailure(response.outcome.value);
|
|
12987
13032
|
}
|
|
12988
13033
|
if (response.outcome.case !== "outbox") {
|
|
12989
13034
|
throw new Error(
|
|
@@ -16092,19 +16137,19 @@
|
|
|
16092
16137
|
init_define_NOMOS_KERNEL_RELEASE();
|
|
16093
16138
|
init_shims();
|
|
16094
16139
|
var WORKSPACE_NAME_SEP = "";
|
|
16095
|
-
var keyedBirthNameOf = (
|
|
16140
|
+
var keyedBirthNameOf = (namespace2, key) => `${namespace2}-${sha256Hex(new TextEncoder().encode(namespace2 + WORKSPACE_NAME_SEP + key)).slice(0, 40)}`;
|
|
16096
16141
|
var RECEIVING_GROUP_NAME_PREFIX = "nomos-rg-";
|
|
16097
16142
|
var receivingGroupNameOf = (principal) => `${RECEIVING_GROUP_NAME_PREFIX}${sha256Hex(new TextEncoder().encode(principal)).slice(0, 40)}`;
|
|
16098
|
-
var isKeyedBirthOf = (
|
|
16143
|
+
var isKeyedBirthOf = (namespace2, workspace) => workspace.startsWith(`${namespace2}-`);
|
|
16099
16144
|
var WORKSPACE_NAME_REQUEST_INVALID = "nomos.runtime.workspace_name_request_invalid";
|
|
16100
16145
|
function resolveWorkspaceName(command) {
|
|
16101
16146
|
switch (command.birth.case) {
|
|
16102
16147
|
case "keyed": {
|
|
16103
|
-
const { namespace, key } = command.birth.value;
|
|
16104
|
-
if (
|
|
16148
|
+
const { namespace: namespace2, key } = command.birth.value;
|
|
16149
|
+
if (namespace2.length === 0 || key.length === 0) {
|
|
16105
16150
|
throw new Error(`${WORKSPACE_NAME_REQUEST_INVALID}: a keyed birth name needs both its namespace and its key`);
|
|
16106
16151
|
}
|
|
16107
|
-
return create(ResolvedWorkspaceNameSchema, { workspace: keyedBirthNameOf(
|
|
16152
|
+
return create(ResolvedWorkspaceNameSchema, { workspace: keyedBirthNameOf(namespace2, key) });
|
|
16108
16153
|
}
|
|
16109
16154
|
case "receivingGroup": {
|
|
16110
16155
|
const { principal } = command.birth.value;
|
|
@@ -18091,6 +18136,147 @@
|
|
|
18091
18136
|
return result;
|
|
18092
18137
|
};
|
|
18093
18138
|
|
|
18139
|
+
// ../src/runtime/custody_receipts.ts
|
|
18140
|
+
init_define_NOMOS_KERNEL_RELEASE();
|
|
18141
|
+
init_shims();
|
|
18142
|
+
|
|
18143
|
+
// ../src/runtime/peer_desk_store.ts
|
|
18144
|
+
init_define_NOMOS_KERNEL_RELEASE();
|
|
18145
|
+
init_shims();
|
|
18146
|
+
var recordId = (namespace2, key) => `${namespace2.length}:${namespace2}${key}`;
|
|
18147
|
+
var copy2 = (record) => ({
|
|
18148
|
+
...record,
|
|
18149
|
+
value: record.value.slice()
|
|
18150
|
+
});
|
|
18151
|
+
var _records2;
|
|
18152
|
+
var MemoryPeerDeskStore = class {
|
|
18153
|
+
constructor() {
|
|
18154
|
+
__privateAdd(this, _records2, /* @__PURE__ */ new Map());
|
|
18155
|
+
}
|
|
18156
|
+
list(namespace2) {
|
|
18157
|
+
return [...__privateGet(this, _records2).values()].filter((record) => record.namespace === namespace2).sort((left, right) => left.key.localeCompare(right.key)).map(copy2);
|
|
18158
|
+
}
|
|
18159
|
+
compareExchange(namespace2, key, expectedRevision, value) {
|
|
18160
|
+
const id = recordId(namespace2, key);
|
|
18161
|
+
const current = __privateGet(this, _records2).get(id);
|
|
18162
|
+
if (current?.revision !== expectedRevision) {
|
|
18163
|
+
throw new Error(
|
|
18164
|
+
`peer desk record '${namespace2}/${key}' changed at revision ${current?.revision ?? "absent"}`
|
|
18165
|
+
);
|
|
18166
|
+
}
|
|
18167
|
+
if (value === void 0) {
|
|
18168
|
+
__privateGet(this, _records2).delete(id);
|
|
18169
|
+
return void 0;
|
|
18170
|
+
}
|
|
18171
|
+
const next = Object.freeze({
|
|
18172
|
+
namespace: namespace2,
|
|
18173
|
+
key,
|
|
18174
|
+
revision: (current?.revision ?? 0n) + 1n,
|
|
18175
|
+
value: value.slice()
|
|
18176
|
+
});
|
|
18177
|
+
__privateGet(this, _records2).set(id, next);
|
|
18178
|
+
return copy2(next);
|
|
18179
|
+
}
|
|
18180
|
+
};
|
|
18181
|
+
_records2 = new WeakMap();
|
|
18182
|
+
|
|
18183
|
+
// ../src/runtime/custody_receipts.ts
|
|
18184
|
+
var namespace = "nomos.peer-desk.custody-receipts/v1";
|
|
18185
|
+
var encoder = new TextEncoder();
|
|
18186
|
+
var decoder = new TextDecoder();
|
|
18187
|
+
var MAX_BASES = 256;
|
|
18188
|
+
var MAX_RECEIPTS = 4096;
|
|
18189
|
+
var _store, _records3, _journals, _receipts;
|
|
18190
|
+
var CustodyReceipts = class {
|
|
18191
|
+
constructor(store = new MemoryPeerDeskStore()) {
|
|
18192
|
+
__privateAdd(this, _store);
|
|
18193
|
+
__privateAdd(this, _records3, /* @__PURE__ */ new Map());
|
|
18194
|
+
__privateAdd(this, _journals, /* @__PURE__ */ new Map());
|
|
18195
|
+
__privateAdd(this, _receipts, /* @__PURE__ */ new Map());
|
|
18196
|
+
__privateSet(this, _store, store);
|
|
18197
|
+
for (const record of store.list(namespace)) {
|
|
18198
|
+
__privateGet(this, _records3).set(record.key, record);
|
|
18199
|
+
try {
|
|
18200
|
+
if (record.key.startsWith("receipt:")) {
|
|
18201
|
+
const newline = record.value.indexOf(10);
|
|
18202
|
+
if (newline < 0) continue;
|
|
18203
|
+
const receipt = fromBinary(CustodyIntentAdmissionSchema, record.value.subarray(newline + 1));
|
|
18204
|
+
const header2 = JSON.parse(decoder.decode(record.value.subarray(0, newline)));
|
|
18205
|
+
if (receipt.outcome.case === "admitted" && typeof header2.generation === "string" && typeof header2.head === "string") __privateGet(this, _receipts).set(record.key, { ...header2, receipt });
|
|
18206
|
+
continue;
|
|
18207
|
+
}
|
|
18208
|
+
if (!record.key.startsWith("head:")) continue;
|
|
18209
|
+
const value = JSON.parse(decoder.decode(record.value));
|
|
18210
|
+
if (typeof value.head !== "string" || typeof value.generation !== "string" || !Array.isArray(value.bases) || !Array.isArray(value.keys) || value.bases.length > MAX_BASES || value.keys.length > MAX_RECEIPTS) continue;
|
|
18211
|
+
if (!value.bases.every((base) => typeof base === "string") || !value.keys.every((key) => typeof key === "string")) continue;
|
|
18212
|
+
__privateGet(this, _journals).set(record.key.slice(5), value);
|
|
18213
|
+
} catch {
|
|
18214
|
+
}
|
|
18215
|
+
}
|
|
18216
|
+
}
|
|
18217
|
+
covers(workspace, current, base) {
|
|
18218
|
+
const value = __privateGet(this, _journals).get(workspace);
|
|
18219
|
+
return value?.head === current && value.bases.includes(base);
|
|
18220
|
+
}
|
|
18221
|
+
receipt(workspace, current, change) {
|
|
18222
|
+
const value = __privateGet(this, _journals).get(workspace);
|
|
18223
|
+
if (value?.head !== current) return void 0;
|
|
18224
|
+
const stored = __privateGet(this, _receipts).get(`receipt:${workspace}:${sha256Hex(change)}`);
|
|
18225
|
+
if (stored?.generation !== value.generation) return void 0;
|
|
18226
|
+
if (stored.head !== value.head && !value.bases.includes(stored.head)) return void 0;
|
|
18227
|
+
return fromBinary(CustodyIntentAdmissionSchema, toBinary(CustodyIntentAdmissionSchema, stored.receipt));
|
|
18228
|
+
}
|
|
18229
|
+
record(workspace, before, after, receipts) {
|
|
18230
|
+
const old = __privateGet(this, _journals).get(workspace);
|
|
18231
|
+
const journalKey = `head:${workspace}`;
|
|
18232
|
+
const value = old?.head === before ? { ...old, head: after, bases: [...old.bases], keys: [...old.keys] } : { head: after, bases: [], keys: [], generation: String((__privateGet(this, _records3).get(journalKey)?.revision ?? 0n) + 1n) };
|
|
18233
|
+
if (before && before !== after) value.bases.push(before);
|
|
18234
|
+
value.bases = [...new Set(value.bases)].slice(-MAX_BASES);
|
|
18235
|
+
const keys = new Set(value.keys);
|
|
18236
|
+
const discarded = new Set(old?.generation !== value.generation ? old?.keys : []);
|
|
18237
|
+
for (const { change, receipt } of receipts) {
|
|
18238
|
+
if (receipt.outcome.case !== "admitted") continue;
|
|
18239
|
+
const key = `receipt:${workspace}:${sha256Hex(change)}`;
|
|
18240
|
+
keys.delete(key);
|
|
18241
|
+
keys.add(key);
|
|
18242
|
+
discarded.delete(key);
|
|
18243
|
+
const header2 = encoder.encode(`${JSON.stringify({ generation: value.generation, head: after })}
|
|
18244
|
+
`);
|
|
18245
|
+
const body = toBinary(CustodyIntentAdmissionSchema, receipt);
|
|
18246
|
+
const bytes = new Uint8Array(header2.length + body.length);
|
|
18247
|
+
bytes.set(header2);
|
|
18248
|
+
bytes.set(body, header2.length);
|
|
18249
|
+
const record2 = __privateGet(this, _store).compareExchange(namespace, key, __privateGet(this, _records3).get(key)?.revision, bytes);
|
|
18250
|
+
if (record2) __privateGet(this, _records3).set(key, record2);
|
|
18251
|
+
__privateGet(this, _receipts).set(key, {
|
|
18252
|
+
generation: value.generation,
|
|
18253
|
+
head: after,
|
|
18254
|
+
receipt: fromBinary(CustodyIntentAdmissionSchema, body)
|
|
18255
|
+
});
|
|
18256
|
+
}
|
|
18257
|
+
const ordered = [...keys];
|
|
18258
|
+
for (const key of ordered.slice(0, -MAX_RECEIPTS)) discarded.add(key);
|
|
18259
|
+
value.keys = ordered.slice(-MAX_RECEIPTS);
|
|
18260
|
+
for (const key of discarded) {
|
|
18261
|
+
__privateGet(this, _store).compareExchange(namespace, key, __privateGet(this, _records3).get(key)?.revision, void 0);
|
|
18262
|
+
__privateGet(this, _records3).delete(key);
|
|
18263
|
+
__privateGet(this, _receipts).delete(key);
|
|
18264
|
+
}
|
|
18265
|
+
const record = __privateGet(this, _store).compareExchange(
|
|
18266
|
+
namespace,
|
|
18267
|
+
journalKey,
|
|
18268
|
+
__privateGet(this, _records3).get(journalKey)?.revision,
|
|
18269
|
+
encoder.encode(JSON.stringify(value))
|
|
18270
|
+
);
|
|
18271
|
+
if (record) __privateGet(this, _records3).set(journalKey, record);
|
|
18272
|
+
__privateGet(this, _journals).set(workspace, value);
|
|
18273
|
+
}
|
|
18274
|
+
};
|
|
18275
|
+
_store = new WeakMap();
|
|
18276
|
+
_records3 = new WeakMap();
|
|
18277
|
+
_journals = new WeakMap();
|
|
18278
|
+
_receipts = new WeakMap();
|
|
18279
|
+
|
|
18094
18280
|
// ../src/runtime/custodian_placement.ts
|
|
18095
18281
|
init_define_NOMOS_KERNEL_RELEASE();
|
|
18096
18282
|
init_shims();
|
|
@@ -18200,19 +18386,21 @@
|
|
|
18200
18386
|
this.reference = reference;
|
|
18201
18387
|
}
|
|
18202
18388
|
};
|
|
18203
|
-
var _kernel6, _custody, _CustodyAdmissionDesk_instances, candidateOffers_fn, offer_fn, record_fn2;
|
|
18389
|
+
var _kernel6, _custody, _receipts2, _CustodyAdmissionDesk_instances, candidateOffers_fn, offer_fn, record_fn2;
|
|
18204
18390
|
var CustodyAdmissionDesk = class {
|
|
18205
|
-
constructor(kernel, custody) {
|
|
18391
|
+
constructor(kernel, custody, receipts = new CustodyReceipts()) {
|
|
18206
18392
|
__privateAdd(this, _CustodyAdmissionDesk_instances);
|
|
18207
18393
|
__privateAdd(this, _kernel6);
|
|
18208
18394
|
__privateAdd(this, _custody);
|
|
18395
|
+
__privateAdd(this, _receipts2);
|
|
18209
18396
|
__privateSet(this, _kernel6, kernel);
|
|
18210
18397
|
__privateSet(this, _custody, custody);
|
|
18398
|
+
__privateSet(this, _receipts2, receipts);
|
|
18211
18399
|
}
|
|
18212
18400
|
admit(request, command) {
|
|
18213
|
-
const
|
|
18214
|
-
if (!
|
|
18215
|
-
const mount = __privateGet(this, _custody).
|
|
18401
|
+
const workspace = request.target?.workspace;
|
|
18402
|
+
if (!workspace) throw new Error("custody admission requires an addressed workspace");
|
|
18403
|
+
const mount = __privateGet(this, _custody).mountForWorkspace(workspace);
|
|
18216
18404
|
if (command.evidencePack.byteLength > 0) {
|
|
18217
18405
|
__privateGet(this, _kernel6).applyPack(mount, request.requestId, command.evidencePack);
|
|
18218
18406
|
}
|
|
@@ -18223,21 +18411,42 @@
|
|
|
18223
18411
|
const births = [];
|
|
18224
18412
|
const admittedBase = __privateGet(this, _kernel6).head(mount, request.requestId) ?? "";
|
|
18225
18413
|
if (command.fastForwardOnly && offers.length > 0 && (command.baseHead ?? "") !== admittedBase) {
|
|
18414
|
+
for (const offer of offers) {
|
|
18415
|
+
const receipt = __privateGet(this, _receipts2).receipt(mount.workspace, admittedBase, offer.changeUsda);
|
|
18416
|
+
if (!receipt) continue;
|
|
18417
|
+
receipt.commitOid = offer.commitOid;
|
|
18418
|
+
const records = sessions.get(offer.session) ?? [];
|
|
18419
|
+
records.push(receipt);
|
|
18420
|
+
sessions.set(offer.session, records);
|
|
18421
|
+
}
|
|
18422
|
+
let delta = custodyReturnDelta(
|
|
18423
|
+
__privateGet(this, _kernel6),
|
|
18424
|
+
mount,
|
|
18425
|
+
request.requestId,
|
|
18426
|
+
command.baseHead,
|
|
18427
|
+
admittedBase,
|
|
18428
|
+
admittedBase,
|
|
18429
|
+
command.observedHead
|
|
18430
|
+
);
|
|
18431
|
+
if (command.baseHead && command.observedHead !== admittedBase && __privateGet(this, _receipts2).covers(mount.workspace, admittedBase, command.baseHead)) {
|
|
18432
|
+
try {
|
|
18433
|
+
delta = {
|
|
18434
|
+
resultBase: command.baseHead,
|
|
18435
|
+
resultPack: __privateGet(this, _kernel6).packDelta(mount, request.requestId, admittedBase, command.baseHead),
|
|
18436
|
+
recoveryRequired: false
|
|
18437
|
+
};
|
|
18438
|
+
} catch {
|
|
18439
|
+
}
|
|
18440
|
+
}
|
|
18226
18441
|
return create(CustodyAdmissionSchema, {
|
|
18227
18442
|
main: admittedBase,
|
|
18228
|
-
...
|
|
18229
|
-
|
|
18230
|
-
mount,
|
|
18231
|
-
request.requestId,
|
|
18232
|
-
command.baseHead,
|
|
18233
|
-
admittedBase,
|
|
18234
|
-
admittedBase,
|
|
18235
|
-
command.observedHead
|
|
18236
|
-
)
|
|
18443
|
+
sessions: [...sessions].map(([session, intents]) => create(CustodySessionAdmissionSchema, { session, intents })),
|
|
18444
|
+
...delta
|
|
18237
18445
|
});
|
|
18238
18446
|
}
|
|
18239
18447
|
let main = admittedBase;
|
|
18240
18448
|
const heldSessions = /* @__PURE__ */ new Map();
|
|
18449
|
+
const receipts = [];
|
|
18241
18450
|
for (const offer of offers) {
|
|
18242
18451
|
const heldBehind = heldSessions.get(offer.session);
|
|
18243
18452
|
const verdict = heldBehind === void 0 ? __privateMethod(this, _CustodyAdmissionDesk_instances, offer_fn).call(this, request, mount, offer) : create(OfferResponseSchema, { outcome: { case: "blockedOnDependency", value: {
|
|
@@ -18247,7 +18456,9 @@
|
|
|
18247
18456
|
heldSessions.set(offer.session, verdict.outcome.value.offerId || offer.commitOid);
|
|
18248
18457
|
}
|
|
18249
18458
|
const records = sessions.get(offer.session) ?? [];
|
|
18250
|
-
|
|
18459
|
+
const receipt = __privateMethod(this, _CustodyAdmissionDesk_instances, record_fn2).call(this, offer, verdict);
|
|
18460
|
+
records.push(receipt);
|
|
18461
|
+
receipts.push({ change: offer.changeUsda, receipt });
|
|
18251
18462
|
sessions.set(offer.session, records);
|
|
18252
18463
|
if (verdict.outcome.case === "admitted") {
|
|
18253
18464
|
main = verdict.outcome.value.head;
|
|
@@ -18263,6 +18474,9 @@
|
|
|
18263
18474
|
}
|
|
18264
18475
|
}
|
|
18265
18476
|
}
|
|
18477
|
+
if (receipts.some((entry) => entry.receipt.outcome.case === "admitted")) {
|
|
18478
|
+
__privateGet(this, _receipts2).record(mount.workspace, admittedBase, main, receipts);
|
|
18479
|
+
}
|
|
18266
18480
|
return create(CustodyAdmissionSchema, {
|
|
18267
18481
|
main,
|
|
18268
18482
|
sessions: [...sessions].map(
|
|
@@ -18275,6 +18489,7 @@
|
|
|
18275
18489
|
};
|
|
18276
18490
|
_kernel6 = new WeakMap();
|
|
18277
18491
|
_custody = new WeakMap();
|
|
18492
|
+
_receipts2 = new WeakMap();
|
|
18278
18493
|
_CustodyAdmissionDesk_instances = new WeakSet();
|
|
18279
18494
|
candidateOffers_fn = function(request, mount, reference, requestedBase) {
|
|
18280
18495
|
if (!/^refs\/heads\/session\/[A-Za-z0-9._/-]+$/.test(reference)) {
|
|
@@ -21137,18 +21352,18 @@
|
|
|
21137
21352
|
}
|
|
21138
21353
|
throw corrupt(record, `invalid '${state.case}' state`);
|
|
21139
21354
|
}
|
|
21140
|
-
var
|
|
21355
|
+
var _store2, _inventory, _loaded, _ReplicaFollowDesk_instances, sorted_fn, commit_fn;
|
|
21141
21356
|
var ReplicaFollowDesk = class {
|
|
21142
21357
|
constructor(store) {
|
|
21143
21358
|
__privateAdd(this, _ReplicaFollowDesk_instances);
|
|
21144
|
-
__privateAdd(this,
|
|
21359
|
+
__privateAdd(this, _store2);
|
|
21145
21360
|
__privateAdd(this, _inventory, /* @__PURE__ */ new Map());
|
|
21146
21361
|
__privateAdd(this, _loaded, false);
|
|
21147
|
-
__privateSet(this,
|
|
21362
|
+
__privateSet(this, _store2, store);
|
|
21148
21363
|
}
|
|
21149
21364
|
load() {
|
|
21150
21365
|
if (!__privateGet(this, _loaded)) {
|
|
21151
|
-
for (const record of __privateGet(this,
|
|
21366
|
+
for (const record of __privateGet(this, _store2).list(REPLICA_FOLLOW_NAMESPACE)) {
|
|
21152
21367
|
const follow = decode(record);
|
|
21153
21368
|
__privateGet(this, _inventory).set(follow.spec.workspace, follow);
|
|
21154
21369
|
}
|
|
@@ -21180,7 +21395,7 @@
|
|
|
21180
21395
|
this.load();
|
|
21181
21396
|
const current = __privateGet(this, _inventory).get(workspace);
|
|
21182
21397
|
if (!current) return false;
|
|
21183
|
-
__privateGet(this,
|
|
21398
|
+
__privateGet(this, _store2).compareExchange(REPLICA_FOLLOW_NAMESPACE, workspace, current.revision, void 0);
|
|
21184
21399
|
__privateGet(this, _inventory).delete(workspace);
|
|
21185
21400
|
return true;
|
|
21186
21401
|
}
|
|
@@ -21261,7 +21476,7 @@
|
|
|
21261
21476
|
return wakes;
|
|
21262
21477
|
}
|
|
21263
21478
|
};
|
|
21264
|
-
|
|
21479
|
+
_store2 = new WeakMap();
|
|
21265
21480
|
_inventory = new WeakMap();
|
|
21266
21481
|
_loaded = new WeakMap();
|
|
21267
21482
|
_ReplicaFollowDesk_instances = new WeakSet();
|
|
@@ -21269,7 +21484,7 @@
|
|
|
21269
21484
|
return [...__privateGet(this, _inventory).values()].sort((left, right) => left.spec.workspace.localeCompare(right.spec.workspace));
|
|
21270
21485
|
};
|
|
21271
21486
|
commit_fn = function(next, expectedRevision) {
|
|
21272
|
-
const stored = __privateGet(this,
|
|
21487
|
+
const stored = __privateGet(this, _store2).compareExchange(
|
|
21273
21488
|
REPLICA_FOLLOW_NAMESPACE,
|
|
21274
21489
|
next.spec.workspace,
|
|
21275
21490
|
expectedRevision,
|
|
@@ -21359,37 +21574,37 @@
|
|
|
21359
21574
|
init_define_NOMOS_KERNEL_RELEASE();
|
|
21360
21575
|
init_shims();
|
|
21361
21576
|
var PRESERVED_COPIES_NAMESPACE = "nomos.peer-desk.preserved-local-copies/v1";
|
|
21362
|
-
var
|
|
21363
|
-
var
|
|
21364
|
-
var
|
|
21577
|
+
var encoder2 = new TextEncoder();
|
|
21578
|
+
var decoder2 = new TextDecoder();
|
|
21579
|
+
var _store3;
|
|
21365
21580
|
var PreservedCopiesDesk = class {
|
|
21366
21581
|
constructor(store) {
|
|
21367
|
-
__privateAdd(this,
|
|
21368
|
-
__privateSet(this,
|
|
21582
|
+
__privateAdd(this, _store3);
|
|
21583
|
+
__privateSet(this, _store3, store);
|
|
21369
21584
|
}
|
|
21370
21585
|
list(workspace) {
|
|
21371
|
-
const record = __privateGet(this,
|
|
21586
|
+
const record = __privateGet(this, _store3).list(PRESERVED_COPIES_NAMESPACE).find((entry) => entry.key === workspace);
|
|
21372
21587
|
if (!record) return [];
|
|
21373
|
-
const values = JSON.parse(
|
|
21588
|
+
const values = JSON.parse(decoder2.decode(record.value));
|
|
21374
21589
|
if (!Array.isArray(values)) {
|
|
21375
21590
|
throw new Error(`corrupt preserved-copy record for '${workspace}' at revision ${record.revision}`);
|
|
21376
21591
|
}
|
|
21377
21592
|
return values.map((value) => fromJsonString(PreservedLocalCopySchema, JSON.stringify(value)));
|
|
21378
21593
|
}
|
|
21379
21594
|
record(copy3) {
|
|
21380
|
-
const current = __privateGet(this,
|
|
21595
|
+
const current = __privateGet(this, _store3).list(PRESERVED_COPIES_NAMESPACE).find((entry) => entry.key === copy3.workspace);
|
|
21381
21596
|
const existing = this.list(copy3.workspace).filter((entry) => entry.preservedHead !== copy3.preservedHead);
|
|
21382
21597
|
const next = [...existing, create(PreservedLocalCopySchema, copy3)];
|
|
21383
|
-
const stored = __privateGet(this,
|
|
21598
|
+
const stored = __privateGet(this, _store3).compareExchange(
|
|
21384
21599
|
PRESERVED_COPIES_NAMESPACE,
|
|
21385
21600
|
copy3.workspace,
|
|
21386
21601
|
current?.revision,
|
|
21387
|
-
|
|
21602
|
+
encoder2.encode(`[${next.map((entry) => toJsonString(PreservedLocalCopySchema, entry)).join(",")}]`)
|
|
21388
21603
|
);
|
|
21389
21604
|
if (!stored) throw new Error(`preserved copy of '${copy3.workspace}' was not recorded`);
|
|
21390
21605
|
}
|
|
21391
21606
|
};
|
|
21392
|
-
|
|
21607
|
+
_store3 = new WeakMap();
|
|
21393
21608
|
|
|
21394
21609
|
// ../src/runtime/office_seat.ts
|
|
21395
21610
|
init_define_NOMOS_KERNEL_RELEASE();
|
|
@@ -21430,9 +21645,9 @@
|
|
|
21430
21645
|
]);
|
|
21431
21646
|
var SEAT_PREFIX = "nomos-office-seat/v1:";
|
|
21432
21647
|
var SEAT_DIGEST_HEX = 64;
|
|
21433
|
-
var
|
|
21434
|
-
var
|
|
21435
|
-
var header = (digest) =>
|
|
21648
|
+
var encoder3 = new TextEncoder();
|
|
21649
|
+
var decoder3 = new TextDecoder();
|
|
21650
|
+
var header = (digest) => encoder3.encode(`${SEAT_PREFIX}${digest}
|
|
21436
21651
|
`);
|
|
21437
21652
|
var QuarantineReason = Object.freeze({
|
|
21438
21653
|
/** Another office's seat: a copied state directory, or a store lifted from another peer. */
|
|
@@ -21443,7 +21658,7 @@
|
|
|
21443
21658
|
function readSeal(value) {
|
|
21444
21659
|
const headerLength = SEAT_PREFIX.length + SEAT_DIGEST_HEX + 1;
|
|
21445
21660
|
if (value.byteLength < headerLength) return void 0;
|
|
21446
|
-
const text =
|
|
21661
|
+
const text = decoder3.decode(value.subarray(0, headerLength));
|
|
21447
21662
|
if (!text.startsWith(SEAT_PREFIX) || !text.endsWith("\n")) return void 0;
|
|
21448
21663
|
const seat = text.slice(SEAT_PREFIX.length, headerLength - 1);
|
|
21449
21664
|
if (!/^[0-9a-f]{64}$/.test(seat)) return void 0;
|
|
@@ -21469,32 +21684,32 @@
|
|
|
21469
21684
|
__privateSet(this, _seat, seat);
|
|
21470
21685
|
__privateSet(this, _report, report);
|
|
21471
21686
|
}
|
|
21472
|
-
list(
|
|
21473
|
-
if (LOCAL_ONLY_NAMESPACES.has(
|
|
21687
|
+
list(namespace2) {
|
|
21688
|
+
if (LOCAL_ONLY_NAMESPACES.has(namespace2)) return __privateGet(this, _inner).list(namespace2);
|
|
21474
21689
|
const kept = [];
|
|
21475
|
-
for (const record of __privateGet(this, _inner).list(
|
|
21690
|
+
for (const record of __privateGet(this, _inner).list(namespace2)) {
|
|
21476
21691
|
const sealed = readSeal(record.value);
|
|
21477
21692
|
if (sealed?.seat === __privateGet(this, _seat).digest) {
|
|
21478
21693
|
kept.push({ ...record, value: sealed.value.slice() });
|
|
21479
21694
|
continue;
|
|
21480
21695
|
}
|
|
21481
|
-
__privateMethod(this, _SeatedPeerDeskStore_instances, quarantine_fn).call(this,
|
|
21696
|
+
__privateMethod(this, _SeatedPeerDeskStore_instances, quarantine_fn).call(this, namespace2, record, sealed?.seat);
|
|
21482
21697
|
}
|
|
21483
21698
|
return kept;
|
|
21484
21699
|
}
|
|
21485
|
-
compareExchange(
|
|
21486
|
-
if (LOCAL_ONLY_NAMESPACES.has(
|
|
21487
|
-
return __privateGet(this, _inner).compareExchange(
|
|
21700
|
+
compareExchange(namespace2, key, expectedRevision, value) {
|
|
21701
|
+
if (LOCAL_ONLY_NAMESPACES.has(namespace2)) {
|
|
21702
|
+
return __privateGet(this, _inner).compareExchange(namespace2, key, expectedRevision, value);
|
|
21488
21703
|
}
|
|
21489
21704
|
const stored = __privateGet(this, _inner).compareExchange(
|
|
21490
|
-
|
|
21705
|
+
namespace2,
|
|
21491
21706
|
key,
|
|
21492
21707
|
expectedRevision,
|
|
21493
21708
|
value === void 0 ? void 0 : seal(__privateGet(this, _seat).digest, value)
|
|
21494
21709
|
);
|
|
21495
21710
|
if (stored === void 0) return void 0;
|
|
21496
21711
|
const sealed = readSeal(stored.value);
|
|
21497
|
-
if (!sealed) throw new Error(`peer desk record '${
|
|
21712
|
+
if (!sealed) throw new Error(`peer desk record '${namespace2}/${key}' lost its office seat`);
|
|
21498
21713
|
return { ...stored, value: sealed.value.slice() };
|
|
21499
21714
|
}
|
|
21500
21715
|
};
|
|
@@ -21503,15 +21718,15 @@
|
|
|
21503
21718
|
_report = new WeakMap();
|
|
21504
21719
|
_SeatedPeerDeskStore_instances = new WeakSet();
|
|
21505
21720
|
/** Preserve the foreign record under the quarantine namespace, then free the slot. */
|
|
21506
|
-
quarantine_fn = function(
|
|
21507
|
-
const key = `${
|
|
21721
|
+
quarantine_fn = function(namespace2, record, recordedSeat) {
|
|
21722
|
+
const key = `${namespace2}\0${record.key}\0${record.revision}`;
|
|
21508
21723
|
try {
|
|
21509
21724
|
__privateGet(this, _inner).compareExchange(QUARANTINED_BINDINGS_NAMESPACE, key, void 0, record.value);
|
|
21510
21725
|
} catch {
|
|
21511
21726
|
}
|
|
21512
|
-
__privateGet(this, _inner).compareExchange(
|
|
21727
|
+
__privateGet(this, _inner).compareExchange(namespace2, record.key, record.revision, void 0);
|
|
21513
21728
|
__privateGet(this, _report).call(this, create(QuarantinedBindingSchema, {
|
|
21514
|
-
namespace,
|
|
21729
|
+
namespace: namespace2,
|
|
21515
21730
|
key: record.key,
|
|
21516
21731
|
reason: recordedSeat === void 0 ? QuarantineReason.Unseated : QuarantineReason.ForeignSeat,
|
|
21517
21732
|
recordedSeat: recordedSeat ?? "",
|
|
@@ -21563,6 +21778,7 @@
|
|
|
21563
21778
|
const undiscovered = /* @__PURE__ */ new Set();
|
|
21564
21779
|
for (const restored of __privateGet(this, _follows).recover()) {
|
|
21565
21780
|
following.set(restored.workspace, restored.delayMillis);
|
|
21781
|
+
followed.add(restored.workspace);
|
|
21566
21782
|
}
|
|
21567
21783
|
if (!__privateGet(this, _bootstrapped)) {
|
|
21568
21784
|
__privateSet(this, _bootstrapped, true);
|
|
@@ -21600,6 +21816,7 @@
|
|
|
21600
21816
|
stopped.delete(workspace);
|
|
21601
21817
|
} else if (reconciliation.changed) {
|
|
21602
21818
|
following.delete(workspace);
|
|
21819
|
+
followed.delete(workspace);
|
|
21603
21820
|
stopped.add(workspace);
|
|
21604
21821
|
}
|
|
21605
21822
|
} catch (error) {
|
|
@@ -21968,13 +22185,16 @@
|
|
|
21968
22185
|
wasResident: this.kernel.isResident(binding.workspace) !== false
|
|
21969
22186
|
};
|
|
21970
22187
|
__privateGet(this, _links).set(binding.workspace, link);
|
|
21971
|
-
if (link.wasResident) __privateMethod(this, _LiveCorrespondenceDesk_instances, open_fn2).call(this, link);
|
|
22188
|
+
if (!link.publisher || link.wasResident) __privateMethod(this, _LiveCorrespondenceDesk_instances, open_fn2).call(this, link);
|
|
21972
22189
|
}
|
|
21973
22190
|
changed(workspace) {
|
|
21974
22191
|
const link = __privateGet(this, _links).get(workspace);
|
|
21975
22192
|
if (link) link.dirty = true;
|
|
21976
22193
|
}
|
|
21977
22194
|
export(binding, base, requestId) {
|
|
22195
|
+
if (this.kernel.isResident(binding.workspace) === false) {
|
|
22196
|
+
return create(CustodyOfferBatchRequestSchema, { protocolVersion: 2 });
|
|
22197
|
+
}
|
|
21978
22198
|
const mount = workspaceMount(binding.workspace);
|
|
21979
22199
|
const head = this.kernel.head(mount, requestId);
|
|
21980
22200
|
if (!base || !head || base === head) return create(CustodyOfferBatchRequestSchema, { protocolVersion: 2 });
|
|
@@ -22035,6 +22255,7 @@
|
|
|
22035
22255
|
}
|
|
22036
22256
|
if (frame.message.case === "frontier") {
|
|
22037
22257
|
__privateMethod(this, _LiveCorrespondenceDesk_instances, announced_fn).call(this, link, frame.message.value.head);
|
|
22258
|
+
if (this.kernel.isResident(link.binding.workspace) === false) return;
|
|
22038
22259
|
if (!frame.message.value.response) {
|
|
22039
22260
|
__privateMethod(this, _LiveCorrespondenceDesk_instances, send_fn).call(this, link, { case: "frontier", value: {
|
|
22040
22261
|
head: this.kernel.head(workspaceMount(link.binding.workspace), ++__privateWrapper(this, _requestId2)._) ?? "",
|
|
@@ -22051,6 +22272,10 @@
|
|
|
22051
22272
|
if (frame.message.case !== "offers") return;
|
|
22052
22273
|
const batch = frame.message.value;
|
|
22053
22274
|
if (batch.protocolVersion !== 2 || !batch.requestId || batch.source.case !== "inline" || !batch.source.value.offers.length) return;
|
|
22275
|
+
if (this.kernel.isResident(link.binding.workspace) === false) {
|
|
22276
|
+
this.remoteAdvanced?.(link.binding.workspace);
|
|
22277
|
+
return;
|
|
22278
|
+
}
|
|
22054
22279
|
if ([...__privateGet(this, _pending3).values()].some((pending) => pending.link === link && pending.bytes.length === bytes.length && pending.bytes.every((byte, index) => byte === bytes[index]))) return;
|
|
22055
22280
|
if (__privateGet(this, _pending3).size >= 32) return;
|
|
22056
22281
|
__privateGet(this, _pending3).set(request.requestId, { link, bytes });
|
|
@@ -22058,7 +22283,16 @@
|
|
|
22058
22283
|
protocolVersion: 2,
|
|
22059
22284
|
requestId: request.requestId,
|
|
22060
22285
|
target: { workspace: link.binding.workspace, session: link.binding.replicaId },
|
|
22061
|
-
|
|
22286
|
+
// HTTP sender reconciliation controls are not part of a live proposal.
|
|
22287
|
+
// Keeping fastForwardOnly while removing baseHead silently skips every
|
|
22288
|
+
// offer against a nonempty local head. The Kernel judges sealed causality;
|
|
22289
|
+
// live receivers neither ask for a return archive nor confirm the sender.
|
|
22290
|
+
command: { case: "admitCustodyOffers", value: create(CustodyOfferBatchRequestSchema, {
|
|
22291
|
+
...batch,
|
|
22292
|
+
baseHead: void 0,
|
|
22293
|
+
observedHead: void 0,
|
|
22294
|
+
fastForwardOnly: false
|
|
22295
|
+
}) }
|
|
22062
22296
|
});
|
|
22063
22297
|
}
|
|
22064
22298
|
settled(request, response) {
|
|
@@ -22073,6 +22307,7 @@
|
|
|
22073
22307
|
disconnect(workspace) {
|
|
22074
22308
|
const link = __privateGet(this, _links).get(workspace);
|
|
22075
22309
|
if (!link) return;
|
|
22310
|
+
if (link.state === "open") this.linkClosed?.(workspace);
|
|
22076
22311
|
__privateMethod(this, _LiveCorrespondenceDesk_instances, effect_fn).call(this, link, { case: "close", value: true });
|
|
22077
22312
|
__privateGet(this, _links).delete(workspace);
|
|
22078
22313
|
for (const [id, pending] of __privateGet(this, _pending3)) if (pending.link === link) __privateGet(this, _pending3).delete(id);
|
|
@@ -22081,19 +22316,20 @@
|
|
|
22081
22316
|
const now = this.clock.monotonicNanoseconds();
|
|
22082
22317
|
let wake;
|
|
22083
22318
|
for (const link of __privateGet(this, _links).values()) {
|
|
22084
|
-
|
|
22319
|
+
const resident = this.kernel.isResident(link.binding.workspace) !== false;
|
|
22320
|
+
if (link.publisher && !resident) {
|
|
22085
22321
|
if (link.wasResident) this.disconnect(link.binding.workspace);
|
|
22086
22322
|
else wake = wake === void 0 || wake > 250n ? 250n : wake;
|
|
22087
22323
|
continue;
|
|
22088
22324
|
}
|
|
22089
|
-
link.wasResident = true;
|
|
22325
|
+
if (resident) link.wasResident = true;
|
|
22090
22326
|
if (link.state === "opening" && now >= link.due) {
|
|
22091
22327
|
__privateMethod(this, _LiveCorrespondenceDesk_instances, effect_fn).call(this, link, { case: "close", value: true });
|
|
22092
22328
|
link.state = "closed";
|
|
22093
22329
|
}
|
|
22094
22330
|
if (link.state === "closed" && now >= link.due) __privateMethod(this, _LiveCorrespondenceDesk_instances, open_fn2).call(this, link);
|
|
22095
22331
|
if (link.state === "open") {
|
|
22096
|
-
if (link.dirty) {
|
|
22332
|
+
if (link.dirty && resident) {
|
|
22097
22333
|
link.dirty = false;
|
|
22098
22334
|
try {
|
|
22099
22335
|
link.published ?? (link.published = link.publisher ? this.kernel.head(workspaceMount(link.binding.workspace), ++__privateWrapper(this, _requestId2)._) : this.kernel.resolveRef(workspaceMount(link.binding.workspace), ++__privateWrapper(this, _requestId2)._, "refs/remotes/nomos/main"));
|
|
@@ -22112,8 +22348,7 @@
|
|
|
22112
22348
|
return wake;
|
|
22113
22349
|
}
|
|
22114
22350
|
close() {
|
|
22115
|
-
for (const
|
|
22116
|
-
__privateGet(this, _links).clear();
|
|
22351
|
+
for (const workspace of [...__privateGet(this, _links).keys()]) this.disconnect(workspace);
|
|
22117
22352
|
__privateGet(this, _pending3).clear();
|
|
22118
22353
|
}
|
|
22119
22354
|
};
|
|
@@ -22148,6 +22383,10 @@
|
|
|
22148
22383
|
announced_fn = function(link, head) {
|
|
22149
22384
|
if (!head || link.lastAnnounced === head) return;
|
|
22150
22385
|
link.lastAnnounced = head;
|
|
22386
|
+
if (this.kernel.isResident(link.binding.workspace) === false) {
|
|
22387
|
+
this.remoteAdvanced?.(link.binding.workspace);
|
|
22388
|
+
return;
|
|
22389
|
+
}
|
|
22151
22390
|
const mount = workspaceMount(link.binding.workspace);
|
|
22152
22391
|
if (head === this.kernel.head(mount, ++__privateWrapper(this, _requestId2)._) || head === this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId2)._, "refs/remotes/nomos/main")) return;
|
|
22153
22392
|
this.remoteAdvanced?.(link.binding.workspace);
|
|
@@ -22157,11 +22396,16 @@
|
|
|
22157
22396
|
placementAnnounced_fn = function(link, frontier) {
|
|
22158
22397
|
if (!frontier || link.lastPlacementAnnounced === frontier) return;
|
|
22159
22398
|
link.lastPlacementAnnounced = frontier;
|
|
22399
|
+
if (this.kernel.isResident(link.binding.workspace) === false) {
|
|
22400
|
+
this.placementAdvanced?.(link.binding.workspace);
|
|
22401
|
+
return;
|
|
22402
|
+
}
|
|
22160
22403
|
const mount = workspaceMount(link.binding.workspace);
|
|
22161
22404
|
if (frontier === this.kernel.resolveRef(mount, ++__privateWrapper(this, _requestId2)._, PLACEMENT_REF2)) return;
|
|
22162
22405
|
this.placementAdvanced?.(link.binding.workspace);
|
|
22163
22406
|
};
|
|
22164
22407
|
hello_fn = function(link) {
|
|
22408
|
+
if (this.kernel.isResident(link.binding.workspace) === false) return;
|
|
22165
22409
|
const head = this.kernel.head(workspaceMount(link.binding.workspace), ++__privateWrapper(this, _requestId2)._);
|
|
22166
22410
|
__privateMethod(this, _LiveCorrespondenceDesk_instances, send_fn).call(this, link, { case: "frontier", value: { head: head ?? "" } });
|
|
22167
22411
|
};
|
|
@@ -22298,9 +22542,9 @@
|
|
|
22298
22542
|
command.namespace === void 0 ? {} : { "custody.children_namespace": command.namespace },
|
|
22299
22543
|
() => __privateGet(this, _kernel12).childWorkspaces(mount, request.requestId)
|
|
22300
22544
|
);
|
|
22301
|
-
const
|
|
22302
|
-
const selected =
|
|
22303
|
-
(child) => child.status === ChildWorkspaceLifecycleStatus.ACTIVE && isKeyedBirthOf(
|
|
22545
|
+
const namespace2 = command.namespace;
|
|
22546
|
+
const selected = namespace2 === void 0 ? result.children : result.children.filter(
|
|
22547
|
+
(child) => child.status === ChildWorkspaceLifecycleStatus.ACTIVE && isKeyedBirthOf(namespace2, child.workspace)
|
|
22304
22548
|
);
|
|
22305
22549
|
return create(ChildWorkspaceListSchema, {
|
|
22306
22550
|
children: selected.map((child) => create(ChildWorkspaceSchema, {
|
|
@@ -22691,46 +22935,6 @@
|
|
|
22691
22935
|
init_define_NOMOS_KERNEL_RELEASE();
|
|
22692
22936
|
init_shims();
|
|
22693
22937
|
|
|
22694
|
-
// ../src/runtime/peer_desk_store.ts
|
|
22695
|
-
init_define_NOMOS_KERNEL_RELEASE();
|
|
22696
|
-
init_shims();
|
|
22697
|
-
var recordId = (namespace, key) => `${namespace.length}:${namespace}${key}`;
|
|
22698
|
-
var copy2 = (record) => ({
|
|
22699
|
-
...record,
|
|
22700
|
-
value: record.value.slice()
|
|
22701
|
-
});
|
|
22702
|
-
var _records2;
|
|
22703
|
-
var MemoryPeerDeskStore = class {
|
|
22704
|
-
constructor() {
|
|
22705
|
-
__privateAdd(this, _records2, /* @__PURE__ */ new Map());
|
|
22706
|
-
}
|
|
22707
|
-
list(namespace) {
|
|
22708
|
-
return [...__privateGet(this, _records2).values()].filter((record) => record.namespace === namespace).sort((left, right) => left.key.localeCompare(right.key)).map(copy2);
|
|
22709
|
-
}
|
|
22710
|
-
compareExchange(namespace, key, expectedRevision, value) {
|
|
22711
|
-
const id = recordId(namespace, key);
|
|
22712
|
-
const current = __privateGet(this, _records2).get(id);
|
|
22713
|
-
if (current?.revision !== expectedRevision) {
|
|
22714
|
-
throw new Error(
|
|
22715
|
-
`peer desk record '${namespace}/${key}' changed at revision ${current?.revision ?? "absent"}`
|
|
22716
|
-
);
|
|
22717
|
-
}
|
|
22718
|
-
if (value === void 0) {
|
|
22719
|
-
__privateGet(this, _records2).delete(id);
|
|
22720
|
-
return void 0;
|
|
22721
|
-
}
|
|
22722
|
-
const next = Object.freeze({
|
|
22723
|
-
namespace,
|
|
22724
|
-
key,
|
|
22725
|
-
revision: (current?.revision ?? 0n) + 1n,
|
|
22726
|
-
value: value.slice()
|
|
22727
|
-
});
|
|
22728
|
-
__privateGet(this, _records2).set(id, next);
|
|
22729
|
-
return copy2(next);
|
|
22730
|
-
}
|
|
22731
|
-
};
|
|
22732
|
-
_records2 = new WeakMap();
|
|
22733
|
-
|
|
22734
22938
|
// ../src/runtime/correspondence_recovery.ts
|
|
22735
22939
|
init_define_NOMOS_KERNEL_RELEASE();
|
|
22736
22940
|
init_shims();
|
|
@@ -23098,7 +23302,7 @@
|
|
|
23098
23302
|
const finished = clock.monotonicNanoseconds();
|
|
23099
23303
|
return finished >= started ? Number(finished - started) / 1e6 : 0;
|
|
23100
23304
|
};
|
|
23101
|
-
var _kernel16, _credentials4, _clock13, _mount, _binding, _route2, _rediscover, _reroute, _discoveredFrontier, _observePlacement, _recheckPlacement, _directoryAnswered, _placementFetched, _leased, _command2, _requestId4, _started, _state, _localHead, _offerHead, _previousHead, _pushMillis, _pushBytes, _desiredHead, _returnedPackHead, _candidateDurable, _admissionSummary, _offerReceipt, _pushError, _current3, _lastReceiptEffectId2, _offerSequence, _lastStep2, _probeOnly, _establishedBase, _receiveState, _completeHistory, _lawProductsImported, _shallowMounted, _fetchedLawProducts, _beforeConverge, _needsReconciliation, _offerAfterConverge, _rebaseFrom, _rebases, _parkedLocal, _replaceLocalHead, _repairMissingCommit, _WorkspaceSyncWork_instances, openRound_fn, offerOrReconcile_fn, establishBase_fn, missingTrackedBase_fn, holdsLocalWork_fn, pullBeforeOffer_fn, leaseEffect_fn, beginOffer_fn, acceptOffer_fn, acceptLease_fn, placementFrontier_fn, placementOnly_fn, acceptDiscovery_fn, providerCustody_fn, beginMainFetch_fn, acceptFetch_fn, mountFetched_fn, lawProductsAlongside_fn, acceptLawProducts_fn, providerCustodyMounted_fn, importLawProducts_fn, converge_fn2, unrelatedLineageRefusal_fn, replaceLocal_fn, converged_fn, offerAfterRebase_fn, preservedCopy_fn, alreadyJudged_fn, rememberJudgment_fn, forgetJudgment_fn, present_fn, finishOfferOutcome_fn, transportFailure_fn, remember_fn4, finish_fn2, cloudBase_fn, offerEndpoint_fn, workspaceEndpoint_fn, authToken_fn;
|
|
23305
|
+
var _kernel16, _credentials4, _clock13, _mount, _binding, _route2, _rediscover, _reroute, _discoveredFrontier, _observePlacement, _recheckPlacement, _directoryAnswered, _placementFetched, _leased, _command2, _requestId4, _started, _state, _localHead, _offerHead, _previousHead, _pushMillis, _pushBytes, _desiredHead, _returnedPackHead, _candidateDurable, _admissionSummary, _offerReceipt, _pushError, _current3, _lastReceiptEffectId2, _offerSequence, _lastStep2, _probeOnly, _liveConnected, _establishedBase, _receiveState, _completeHistory, _lawProductsImported, _shallowMounted, _fetchedLawProducts, _beforeConverge, _needsReconciliation, _offerAfterConverge, _rebaseFrom, _rebases, _parkedLocal, _replaceLocalHead, _repairMissingCommit, _WorkspaceSyncWork_instances, openRound_fn, offerOrReconcile_fn, establishBase_fn, missingTrackedBase_fn, holdsLocalWork_fn, pullBeforeOffer_fn, leaseEffect_fn, beginOffer_fn, acceptOffer_fn, acceptLease_fn, placementFrontier_fn, placementOnly_fn, acceptDiscovery_fn, providerCustody_fn, beginMainFetch_fn, acceptFetch_fn, mountFetched_fn, lawProductsAlongside_fn, acceptLawProducts_fn, providerCustodyMounted_fn, importLawProducts_fn, converge_fn2, unrelatedLineageRefusal_fn, replaceLocal_fn, converged_fn, offerAfterRebase_fn, preservedCopy_fn, alreadyJudged_fn, rememberJudgment_fn, forgetJudgment_fn, present_fn, finishOfferOutcome_fn, transportFailure_fn, remember_fn4, finish_fn2, cloudBase_fn, offerEndpoint_fn, workspaceEndpoint_fn, authToken_fn;
|
|
23102
23306
|
var WorkspaceSyncWork = class {
|
|
23103
23307
|
constructor(args) {
|
|
23104
23308
|
__privateAdd(this, _WorkspaceSyncWork_instances);
|
|
@@ -23142,6 +23346,7 @@
|
|
|
23142
23346
|
__privateAdd(this, _offerSequence, 0);
|
|
23143
23347
|
__privateAdd(this, _lastStep2);
|
|
23144
23348
|
__privateAdd(this, _probeOnly);
|
|
23349
|
+
__privateAdd(this, _liveConnected);
|
|
23145
23350
|
/** Set when this round adopted the upstream's own head as its base (see #establishBase). */
|
|
23146
23351
|
__privateAdd(this, _establishedBase);
|
|
23147
23352
|
__privateAdd(this, _receiveState);
|
|
@@ -23169,6 +23374,7 @@
|
|
|
23169
23374
|
__privateSet(this, _directoryAnswered, args.directoryAnswered);
|
|
23170
23375
|
__privateSet(this, _placementFetched, args.placementFetched);
|
|
23171
23376
|
__privateSet(this, _probeOnly, args.probeOnly ?? false);
|
|
23377
|
+
__privateSet(this, _liveConnected, args.liveConnected === true);
|
|
23172
23378
|
__privateSet(this, _receiveState, args.receiveState);
|
|
23173
23379
|
__privateSet(this, _completeHistory, args.completeHistory === true);
|
|
23174
23380
|
__privateSet(this, _repairMissingCommit, args.repairMissingCommit === true);
|
|
@@ -23318,6 +23524,7 @@
|
|
|
23318
23524
|
_offerSequence = new WeakMap();
|
|
23319
23525
|
_lastStep2 = new WeakMap();
|
|
23320
23526
|
_probeOnly = new WeakMap();
|
|
23527
|
+
_liveConnected = new WeakMap();
|
|
23321
23528
|
_establishedBase = new WeakMap();
|
|
23322
23529
|
_receiveState = new WeakMap();
|
|
23323
23530
|
_completeHistory = new WeakMap();
|
|
@@ -23336,6 +23543,9 @@
|
|
|
23336
23543
|
openRound_fn = function() {
|
|
23337
23544
|
if (__privateGet(this, _receiveState) || __privateGet(this, _replaceLocalHead) !== void 0) return __privateMethod(this, _WorkspaceSyncWork_instances, leaseEffect_fn).call(this);
|
|
23338
23545
|
if (!__privateGet(this, _localHead)) return __privateMethod(this, _WorkspaceSyncWork_instances, leaseEffect_fn).call(this);
|
|
23546
|
+
if (__privateGet(this, _liveConnected) && !__privateGet(this, _probeOnly) && __privateMethod(this, _WorkspaceSyncWork_instances, holdsLocalWork_fn).call(this) && __privateGet(this, _previousHead)) {
|
|
23547
|
+
return __privateMethod(this, _WorkspaceSyncWork_instances, offerOrReconcile_fn).call(this);
|
|
23548
|
+
}
|
|
23339
23549
|
const requestId = `${__privateGet(this, _binding).replicaId}:${__privateGet(this, _requestId4)}:${this.workId}:frontier`;
|
|
23340
23550
|
return __privateMethod(this, _WorkspaceSyncWork_instances, beginOffer_fn).call(this, encodeInlineCustodyOffer({
|
|
23341
23551
|
session: __privateGet(this, _binding).replicaId,
|
|
@@ -23522,6 +23732,18 @@
|
|
|
23522
23732
|
return __privateMethod(this, _WorkspaceSyncWork_instances, finishOfferOutcome_fn).call(this, false);
|
|
23523
23733
|
}
|
|
23524
23734
|
const admission = outcome.value;
|
|
23735
|
+
globalThis.__nomosSyncDiagnostic?.("sync.admission", {
|
|
23736
|
+
workspace: __privateGet(this, _mount).workspace,
|
|
23737
|
+
phase: state.phase,
|
|
23738
|
+
local: __privateGet(this, _localHead),
|
|
23739
|
+
tracked: __privateGet(this, _previousHead),
|
|
23740
|
+
remote: admission.main,
|
|
23741
|
+
sealed: admission.sealedMain,
|
|
23742
|
+
resultBase: admission.resultBase,
|
|
23743
|
+
resultBytes: admission.resultPack.byteLength,
|
|
23744
|
+
recoveryRequired: admission.recoveryRequired,
|
|
23745
|
+
summary: summarizeCustodyAdmission(admission)
|
|
23746
|
+
});
|
|
23525
23747
|
__privateSet(this, _desiredHead, admission.main || void 0);
|
|
23526
23748
|
if (!__privateGet(this, _desiredHead)) return __privateMethod(this, _WorkspaceSyncWork_instances, transportFailure_fn).call(this, "resident peer returned no admitted frontier", false);
|
|
23527
23749
|
__privateSet(this, _candidateDurable, admission.sealedMain === __privateGet(this, _desiredHead));
|
|
@@ -24109,6 +24331,19 @@
|
|
|
24109
24331
|
return step;
|
|
24110
24332
|
};
|
|
24111
24333
|
finish_fn2 = function(value) {
|
|
24334
|
+
globalThis.__nomosSyncDiagnostic?.("sync.finished", {
|
|
24335
|
+
workspace: value.workspace,
|
|
24336
|
+
previous: value.previousHead,
|
|
24337
|
+
current: value.currentHead,
|
|
24338
|
+
stillAhead: value.stillAhead,
|
|
24339
|
+
deferred: String(value.deferred),
|
|
24340
|
+
admitted: String(value.admitted),
|
|
24341
|
+
reconnect: value.reconnectRequired,
|
|
24342
|
+
directOfferDeferred: value.directOfferDeferred,
|
|
24343
|
+
pushFailed: value.pushFailed,
|
|
24344
|
+
failure: value.pushError?.message,
|
|
24345
|
+
wallMs: elapsedMillis(__privateGet(this, _clock13), __privateGet(this, _started))
|
|
24346
|
+
});
|
|
24112
24347
|
__privateSet(this, _state, { phase: WorkspaceSyncPhase.Done });
|
|
24113
24348
|
__privateSet(this, _current3, void 0);
|
|
24114
24349
|
return __privateMethod(this, _WorkspaceSyncWork_instances, remember_fn4).call(this, { case: "synced", value });
|
|
@@ -24167,6 +24402,10 @@
|
|
|
24167
24402
|
__privateSet(this, _plan2, [__privateGet(this, _args).root]);
|
|
24168
24403
|
return __privateMethod(this, _WorkspaceDependencySyncWork_instances, advance_fn4).call(this);
|
|
24169
24404
|
}
|
|
24405
|
+
if (__privateGet(this, _args).liveConnected && __privateGet(this, _args).kernel.resolveRef(__privateGet(this, _args).root.mount, __privateGet(this, _args).requestId, trackedMain2)) {
|
|
24406
|
+
__privateSet(this, _plan2, __privateMethod(this, _WorkspaceDependencySyncWork_instances, planDependencies_fn).call(this));
|
|
24407
|
+
return __privateMethod(this, _WorkspaceDependencySyncWork_instances, advance_fn4).call(this);
|
|
24408
|
+
}
|
|
24170
24409
|
__privateSet(this, _current4, __privateMethod(this, _WorkspaceDependencySyncWork_instances, work_fn).call(this, __privateGet(this, _args).root, `${this.workId}:frontier`, true));
|
|
24171
24410
|
return __privateMethod(this, _WorkspaceDependencySyncWork_instances, accept_fn).call(this, __privateGet(this, _current4).start());
|
|
24172
24411
|
}
|
|
@@ -25396,7 +25635,7 @@
|
|
|
25396
25635
|
// ../src/runtime/correspondence_desk.ts
|
|
25397
25636
|
var REFETCH_AWAITS_PROVIDER = "nomos.runtime.refetch_awaits_provider";
|
|
25398
25637
|
var LOCAL_COPY_REFETCHING = "nomos.runtime.local_copy_refetching";
|
|
25399
|
-
var _kernel20, _retention3, _custodyStorage, _custody3, _sessions11, _credentials5, _placement3, _clock18, _outboxClock, _follows2, _followLane, _readability2, _origins3, _preserved, _dropReasons, _lawProductsImported2, _replacing, _providerServesSameCopy, _events4, _onSyncFrontier, _onSyncCompleted, _onPlacementFetched, _onShallowMount, _remoteOffers, _recoveries, _deliveries, _httpDeliveries, _syncs, _syncWorkspaces, _retries, _remoteDeliveryKeys, _outboxDueAt, _settledFollowReported, _openLinks, _linkReported, _followsReported, _recoveredOutboxes, _outboxObservations, _outboxCursor, _httpDeliveryPaths, _executesCustodianObligations, _CorrespondenceDesk_instances, eligibleOutboxEntry_fn, settleDelivery_fn, activeSyncEffect_fn, dropReason_fn, roundInFlight_fn, observeSyncResult_fn, syncFailed_fn, scheduleFromResult_fn, syncCompleted_fn, recordPreserved_fn, scheduleOutbox_fn;
|
|
25638
|
+
var _kernel20, _retention3, _custodyStorage, _custody3, _sessions11, _credentials5, _placement3, _clock18, _outboxClock, _follows2, _followLane, _readability2, _origins3, _preserved, _dropReasons, _lawProductsImported2, _replacing, _providerServesSameCopy, _events4, _onSyncFrontier, _onSyncCompleted, _onPlacementFetched, _onShallowMount, _onOutboxHistoryRequired, _remoteOffers, _recoveries, _deliveries, _httpDeliveries, _syncs, _syncWorkspaces, _retries, _remoteDeliveryKeys, _outboxDueAt, _settledFollowReported, _openLinks, _linkReported, _followsReported, _recoveredOutboxes, _outboxObservations, _outboxCursor, _httpDeliveryPaths, _executesCustodianObligations, _CorrespondenceDesk_instances, eligibleOutboxEntry_fn, settleDelivery_fn, activeSyncEffect_fn, dropReason_fn, roundInFlight_fn, observeSyncResult_fn, syncFailed_fn, scheduleFromResult_fn, syncCompleted_fn, recordPreserved_fn, scheduleOutbox_fn;
|
|
25400
25639
|
var CorrespondenceDesk = class {
|
|
25401
25640
|
constructor(args) {
|
|
25402
25641
|
__privateAdd(this, _CorrespondenceDesk_instances);
|
|
@@ -25427,6 +25666,7 @@
|
|
|
25427
25666
|
__privateAdd(this, _onSyncCompleted);
|
|
25428
25667
|
__privateAdd(this, _onPlacementFetched);
|
|
25429
25668
|
__privateAdd(this, _onShallowMount);
|
|
25669
|
+
__privateAdd(this, _onOutboxHistoryRequired);
|
|
25430
25670
|
__privateAdd(this, _remoteOffers, new CorrespondenceWorkRegistry());
|
|
25431
25671
|
__privateAdd(this, _recoveries, new CorrespondenceWorkRegistry());
|
|
25432
25672
|
__privateAdd(this, _deliveries, new CorrespondenceWorkRegistry());
|
|
@@ -25472,6 +25712,7 @@
|
|
|
25472
25712
|
__privateSet(this, _onSyncCompleted, args.onSyncCompleted);
|
|
25473
25713
|
__privateSet(this, _onPlacementFetched, args.onPlacementFetched);
|
|
25474
25714
|
__privateSet(this, _onShallowMount, args.onShallowMount);
|
|
25715
|
+
__privateSet(this, _onOutboxHistoryRequired, args.onOutboxHistoryRequired);
|
|
25475
25716
|
__privateSet(this, _clock18, args.clock);
|
|
25476
25717
|
__privateSet(this, _outboxClock, new OutboxObservationClock(args.clock, args.peerIdentity));
|
|
25477
25718
|
__privateSet(this, _executesCustodianObligations, args.executesCustodianObligations ?? false);
|
|
@@ -25601,6 +25842,15 @@
|
|
|
25601
25842
|
__privateGet(this, _followLane).dependencyAdvanced(workspace);
|
|
25602
25843
|
this.reportFollows();
|
|
25603
25844
|
}
|
|
25845
|
+
/** Received custody can release correspondence and foreign-read dependencies,
|
|
25846
|
+
* but is not newly authored work to send back to its upstream. Recovery is
|
|
25847
|
+
* driven separately by missing history, reconnects and provider announcements.
|
|
25848
|
+
* In particular an optimistic relay is not a durable upstream receipt. */
|
|
25849
|
+
receivedFrontierChanged(workspace) {
|
|
25850
|
+
this.wakeOutbox(workspace);
|
|
25851
|
+
__privateGet(this, _followLane).dependencyAdvanced(workspace);
|
|
25852
|
+
this.reportFollows();
|
|
25853
|
+
}
|
|
25604
25854
|
/**
|
|
25605
25855
|
* Tell a workspace's sessions what its durable follow ALREADY knows.
|
|
25606
25856
|
*
|
|
@@ -25830,8 +26080,16 @@
|
|
|
25830
26080
|
)
|
|
25831
26081
|
);
|
|
25832
26082
|
} catch (error) {
|
|
26083
|
+
if (error instanceof KernelHistoryRequired && __privateGet(this, _onOutboxHistoryRequired)) {
|
|
26084
|
+
const retry = __privateGet(this, _onOutboxHistoryRequired).call(this, workspace, binding.credentialCapability);
|
|
26085
|
+
__privateGet(this, _outboxDueAt).set(workspace, now + Math.max(250, retry));
|
|
26086
|
+
return { nextAfterMillis: 0 };
|
|
26087
|
+
}
|
|
25833
26088
|
const format = localCopyFormatRefusal(error);
|
|
25834
|
-
if (format === void 0)
|
|
26089
|
+
if (format === void 0) {
|
|
26090
|
+
__privateGet(this, _outboxDueAt).set(workspace, now + 3e4);
|
|
26091
|
+
return { nextAfterMillis: 0 };
|
|
26092
|
+
}
|
|
25835
26093
|
__privateGet(this, _readability2).mark(workspace, void 0, format);
|
|
25836
26094
|
__privateGet(this, _outboxDueAt).delete(workspace);
|
|
25837
26095
|
return { nextAfterMillis: 0 };
|
|
@@ -26108,6 +26366,7 @@
|
|
|
26108
26366
|
requestId: request.requestId,
|
|
26109
26367
|
workId: id,
|
|
26110
26368
|
probeOnly,
|
|
26369
|
+
liveConnected: __privateGet(this, _openLinks).has(target3.mount.workspace),
|
|
26111
26370
|
...beforeConverge === void 0 ? {} : { beforeConverge },
|
|
26112
26371
|
...target3.receiveState === void 0 ? {} : { receiveState: target3.receiveState },
|
|
26113
26372
|
...target3.offerHead === void 0 ? {} : { offerHead: target3.offerHead },
|
|
@@ -26138,6 +26397,7 @@
|
|
|
26138
26397
|
root,
|
|
26139
26398
|
work,
|
|
26140
26399
|
outbound: command.admit,
|
|
26400
|
+
liveConnected: __privateGet(this, _openLinks).has(mount.workspace),
|
|
26141
26401
|
dependency: (workspace, source, acquire2 = false) => {
|
|
26142
26402
|
if (__privateMethod(this, _CorrespondenceDesk_instances, roundInFlight_fn).call(this, workspace, workId2)) return void 0;
|
|
26143
26403
|
const existing = __privateGet(this, _follows2).bindingForWorkspace(workspace);
|
|
@@ -26303,6 +26563,7 @@
|
|
|
26303
26563
|
_onSyncCompleted = new WeakMap();
|
|
26304
26564
|
_onPlacementFetched = new WeakMap();
|
|
26305
26565
|
_onShallowMount = new WeakMap();
|
|
26566
|
+
_onOutboxHistoryRequired = new WeakMap();
|
|
26306
26567
|
_remoteOffers = new WeakMap();
|
|
26307
26568
|
_recoveries = new WeakMap();
|
|
26308
26569
|
_deliveries = new WeakMap();
|
|
@@ -27855,15 +28116,15 @@
|
|
|
27855
28116
|
var HISTORY_ACQUISITION_NAMESPACE = "nomos.peer-desk.history-acquisition/v1";
|
|
27856
28117
|
var HISTORY_BACKGROUND_START_MILLIS = 1e4;
|
|
27857
28118
|
var SLICE_ANSWER_MILLIS = 5 * 6e4;
|
|
27858
|
-
var
|
|
27859
|
-
var
|
|
28119
|
+
var encoder4 = new TextEncoder();
|
|
28120
|
+
var decoder4 = new TextDecoder();
|
|
27860
28121
|
var workId = (workspace) => `history-acquisition:${workspace}`;
|
|
27861
28122
|
var effectId = (workspace, attempt) => `history-acquisition:${workspace}:${HistoryAcquisitionPhase.Acquiring}:${attempt}`;
|
|
27862
28123
|
var encode2 = (work) => {
|
|
27863
28124
|
if (!work.credentialCapability) {
|
|
27864
28125
|
throw new Error(`history acquisition for '${work.workspace}' has not restored its credential capability`);
|
|
27865
28126
|
}
|
|
27866
|
-
return
|
|
28127
|
+
return encoder4.encode(JSON.stringify({
|
|
27867
28128
|
version: 2,
|
|
27868
28129
|
workspace: work.workspace,
|
|
27869
28130
|
credentialCapability: work.credentialCapability,
|
|
@@ -27872,7 +28133,7 @@
|
|
|
27872
28133
|
};
|
|
27873
28134
|
var upgraded = (state) => state.case === "backoff" ? { case: HistoryAcquisitionPhase.Paced, attempt: state.attempt, delayMillis: state.delayMillis, failed: true } : state;
|
|
27874
28135
|
var decode2 = (record) => {
|
|
27875
|
-
const value = JSON.parse(
|
|
28136
|
+
const value = JSON.parse(decoder4.decode(record.value));
|
|
27876
28137
|
if (!value || typeof value !== "object") throw corrupt2(record, "not an object");
|
|
27877
28138
|
const candidate = value;
|
|
27878
28139
|
if (candidate.version !== 1 && candidate.version !== 2 || candidate.workspace !== record.key || !candidate.state) {
|
|
@@ -27908,11 +28169,11 @@
|
|
|
27908
28169
|
}
|
|
27909
28170
|
throw corrupt2(record, `invalid '${state.case}' state`);
|
|
27910
28171
|
}
|
|
27911
|
-
var
|
|
28172
|
+
var _store4, _clock20, _credentialCapabilityForWorkspace2, _inventory5, _dueAt2, _handedOutAt, _settled3, _loaded2, _HistoryAcquisitionDesk_instances, ensure_fn, activate_fn, load_fn, all_fn, get_fn, transition_fn, commit_fn2, pending_fn2, now_fn8;
|
|
27912
28173
|
var HistoryAcquisitionDesk = class {
|
|
27913
28174
|
constructor(store, clock, credentialCapabilityForWorkspace) {
|
|
27914
28175
|
__privateAdd(this, _HistoryAcquisitionDesk_instances);
|
|
27915
|
-
__privateAdd(this,
|
|
28176
|
+
__privateAdd(this, _store4);
|
|
27916
28177
|
__privateAdd(this, _clock20);
|
|
27917
28178
|
__privateAdd(this, _credentialCapabilityForWorkspace2);
|
|
27918
28179
|
__privateAdd(this, _inventory5, /* @__PURE__ */ new Map());
|
|
@@ -27925,7 +28186,7 @@
|
|
|
27925
28186
|
* same answer, never "unknown work". */
|
|
27926
28187
|
__privateAdd(this, _settled3, /* @__PURE__ */ new Set());
|
|
27927
28188
|
__privateAdd(this, _loaded2, false);
|
|
27928
|
-
__privateSet(this,
|
|
28189
|
+
__privateSet(this, _store4, store);
|
|
27929
28190
|
__privateSet(this, _clock20, clock);
|
|
27930
28191
|
__privateSet(this, _credentialCapabilityForWorkspace2, credentialCapabilityForWorkspace);
|
|
27931
28192
|
}
|
|
@@ -27937,6 +28198,21 @@
|
|
|
27937
28198
|
__privateMethod(this, _HistoryAcquisitionDesk_instances, ensure_fn).call(this, workspace, credentialCapability);
|
|
27938
28199
|
__privateGet(this, _dueAt2).set(workspace, __privateMethod(this, _HistoryAcquisitionDesk_instances, now_fn8).call(this) + HISTORY_BACKGROUND_START_MILLIS);
|
|
27939
28200
|
}
|
|
28201
|
+
/** A background kernel read needs an omitted ancestor now. Queue one bounded
|
|
28202
|
+
* slice on the existing history lane; a failed slice keeps its retry pace. */
|
|
28203
|
+
requestFromBackground(workspace, credentialCapability) {
|
|
28204
|
+
if (!workspace) throw new Error("kernel history requirement names no workspace");
|
|
28205
|
+
__privateMethod(this, _HistoryAcquisitionDesk_instances, ensure_fn).call(this, workspace, credentialCapability);
|
|
28206
|
+
const work = __privateMethod(this, _HistoryAcquisitionDesk_instances, get_fn).call(this, workspace);
|
|
28207
|
+
const now = __privateMethod(this, _HistoryAcquisitionDesk_instances, now_fn8).call(this);
|
|
28208
|
+
if (work.state.case === HistoryAcquisitionPhase.Paced && work.state.failed) {
|
|
28209
|
+
const due2 = __privateGet(this, _dueAt2).get(workspace) ?? now + work.state.delayMillis;
|
|
28210
|
+
__privateGet(this, _dueAt2).set(workspace, due2);
|
|
28211
|
+
if (due2 > now) return due2 - now;
|
|
28212
|
+
}
|
|
28213
|
+
__privateGet(this, _dueAt2).set(workspace, now);
|
|
28214
|
+
return 250;
|
|
28215
|
+
}
|
|
27940
28216
|
/** An operation needs history this custody lacks: its next slice now, joining one in flight. */
|
|
27941
28217
|
begin(workspace, credentialCapability) {
|
|
27942
28218
|
if (!workspace) throw new Error("kernel history requirement names no workspace");
|
|
@@ -27993,7 +28269,7 @@
|
|
|
27993
28269
|
__privateGet(this, _handedOutAt).delete(work.workspace);
|
|
27994
28270
|
switch (next.state.case) {
|
|
27995
28271
|
case HistoryAcquisitionPhase.Settled:
|
|
27996
|
-
__privateGet(this,
|
|
28272
|
+
__privateGet(this, _store4).compareExchange(HISTORY_ACQUISITION_NAMESPACE, work.workspace, next.revision, void 0);
|
|
27997
28273
|
__privateGet(this, _inventory5).delete(work.workspace);
|
|
27998
28274
|
__privateGet(this, _dueAt2).delete(work.workspace);
|
|
27999
28275
|
__privateGet(this, _settled3).add(workId(work.workspace));
|
|
@@ -28050,7 +28326,7 @@
|
|
|
28050
28326
|
return [...__privateMethod(this, _HistoryAcquisitionDesk_instances, all_fn).call(this)].map((work) => work.workspace);
|
|
28051
28327
|
}
|
|
28052
28328
|
};
|
|
28053
|
-
|
|
28329
|
+
_store4 = new WeakMap();
|
|
28054
28330
|
_clock20 = new WeakMap();
|
|
28055
28331
|
_credentialCapabilityForWorkspace2 = new WeakMap();
|
|
28056
28332
|
_inventory5 = new WeakMap();
|
|
@@ -28087,7 +28363,7 @@
|
|
|
28087
28363
|
};
|
|
28088
28364
|
load_fn = function() {
|
|
28089
28365
|
if (__privateGet(this, _loaded2)) return;
|
|
28090
|
-
for (const record of __privateGet(this,
|
|
28366
|
+
for (const record of __privateGet(this, _store4).list(HISTORY_ACQUISITION_NAMESPACE)) {
|
|
28091
28367
|
const work = decode2(record);
|
|
28092
28368
|
__privateGet(this, _inventory5).set(work.workspace, work);
|
|
28093
28369
|
}
|
|
@@ -28109,7 +28385,7 @@
|
|
|
28109
28385
|
}, work.revision);
|
|
28110
28386
|
};
|
|
28111
28387
|
commit_fn2 = function(next, expectedRevision) {
|
|
28112
|
-
const stored = __privateGet(this,
|
|
28388
|
+
const stored = __privateGet(this, _store4).compareExchange(
|
|
28113
28389
|
HISTORY_ACQUISITION_NAMESPACE,
|
|
28114
28390
|
next.workspace,
|
|
28115
28391
|
expectedRevision,
|
|
@@ -28162,7 +28438,7 @@
|
|
|
28162
28438
|
}
|
|
28163
28439
|
var INTERACTIVE_PEER_CLASSES = /* @__PURE__ */ new Set(["personal-device", "browser"]);
|
|
28164
28440
|
var INTERACTION_FIRST_MILLIS = 15e3;
|
|
28165
|
-
var _kernel25, _sessions14, _interactivePeer, _interaction, _trace13, _credentials7, _credentialRecovery, _deviceIdentity, _receivingGroup2, _modelAdoption, _deviceChallenges, _enrolledCapabilities, _custody4, _readability3, _origins5, _seat2, _custodyAdmission, _correspondence3, _birthCustody, _placement5, _access, _identity2, _custodianPlacement, _identityRecovery, _queries8, _application3, _compatibility2, _custodyVerification, _commandPreparation, _applicationReadiness, _authenticationReadiness, _lawPackages, _readMaintenance, _readResponses, _residency4, _residencyPins, _subscriptions5, _follows3, _replicaInventory, _placementDiscovery2, _live3,
|
|
28441
|
+
var _kernel25, _sessions14, _interactivePeer, _interaction, _trace13, _credentials7, _credentialRecovery, _deviceIdentity, _receivingGroup2, _modelAdoption, _deviceChallenges, _enrolledCapabilities, _custody4, _readability3, _origins5, _seat2, _custodyAdmission, _correspondence3, _birthCustody, _placement5, _access, _identity2, _custodianPlacement, _identityRecovery, _queries8, _application3, _compatibility2, _custodyVerification, _commandPreparation, _applicationReadiness, _authenticationReadiness, _lawPackages, _readMaintenance, _readResponses, _residency4, _residencyPins, _subscriptions5, _follows3, _replicaInventory, _placementDiscovery2, _live3, _records4, _historicQueries, _authoringPreflight, _recovery, _lifecycle, _maintenance2, _background2, _paperSlots, _retentionObserver, _admissionDurability, _historyAcquisition, _responses, _PeerOffice_instances, fenced_fn, handleRequest_fn, localCopyUnreadable_fn, probeLocalCopyFormat_fn, protectedResidents_fn, bindInteraction_fn, keepCustodianPlacement_fn, dispatchRequest_fn, historyCredentialCapability_fn, preferredCredentialCapability_fn, correspondenceResponse_fn, authenticationReadinessResponse_fn, completedKernelCall_fn, modelAdoptionResponse_fn, receivingGroupResponse_fn, deviceIdentityResponse_fn, deviceChallengeFor_fn, deviceChallengeForCapability_fn, credentialRecoveryResponse_fn, afterCredentialKernelCall_fn, acknowledgedWhenDurable_fn, admissionDurabilityResponse_fn, birthCustodyResponse_fn, identityResponse_fn, identityRecoveryResponse_fn, response_fn, failure_fn, custodyRequired_fn, kernelResidencyRequired_fn, candidateCustodyRequired_fn;
|
|
28166
28442
|
var PeerOffice = class {
|
|
28167
28443
|
constructor(kernel, credentials, profile, observations, custodyStorage, peerDeskStore) {
|
|
28168
28444
|
__privateAdd(this, _PeerOffice_instances);
|
|
@@ -28214,7 +28490,7 @@
|
|
|
28214
28490
|
__privateAdd(this, _replicaInventory);
|
|
28215
28491
|
__privateAdd(this, _placementDiscovery2);
|
|
28216
28492
|
__privateAdd(this, _live3);
|
|
28217
|
-
__privateAdd(this,
|
|
28493
|
+
__privateAdd(this, _records4);
|
|
28218
28494
|
__privateAdd(this, _historicQueries);
|
|
28219
28495
|
__privateAdd(this, _authoringPreflight);
|
|
28220
28496
|
__privateAdd(this, _recovery);
|
|
@@ -28258,7 +28534,7 @@
|
|
|
28258
28534
|
__privateGet(this, _trace13),
|
|
28259
28535
|
__privateGet(this, _readability3)
|
|
28260
28536
|
));
|
|
28261
|
-
__privateSet(this, _custodyAdmission, new CustodyAdmissionDesk(__privateGet(this, _kernel25), __privateGet(this, _custody4)));
|
|
28537
|
+
__privateSet(this, _custodyAdmission, new CustodyAdmissionDesk(__privateGet(this, _kernel25), __privateGet(this, _custody4), new CustodyReceipts(seatedStore)));
|
|
28262
28538
|
__privateSet(this, _queries8, new KernelQueries(__privateGet(this, _kernel25), __privateGet(this, _credentials7)));
|
|
28263
28539
|
__privateSet(this, _follows3, new ReplicaFollowController(
|
|
28264
28540
|
new ReplicaFollowDesk(seatedStore),
|
|
@@ -28420,6 +28696,7 @@
|
|
|
28420
28696
|
// Lazy history: a head-only mount materialises its history in the background, never on
|
|
28421
28697
|
// the path of an operation (architecture/lazy_history.md).
|
|
28422
28698
|
onShallowMount: (workspace, credentialCapability) => __privateGet(this, _historyAcquisition).materialise(workspace, credentialCapability),
|
|
28699
|
+
onOutboxHistoryRequired: (workspace, credentialCapability) => __privateGet(this, _historyAcquisition).requestFromBackground(workspace, credentialCapability),
|
|
28423
28700
|
onSyncCompleted: (session, event) => {
|
|
28424
28701
|
if (event.result?.workspace) {
|
|
28425
28702
|
__privateGet(this, _replicaInventory).placementMayHaveChanged(event.result.workspace);
|
|
@@ -28468,7 +28745,7 @@
|
|
|
28468
28745
|
command.criterion === AuthenticationReadinessCriterion.BIRTH_EVIDENCE
|
|
28469
28746
|
)
|
|
28470
28747
|
));
|
|
28471
|
-
__privateSet(this,
|
|
28748
|
+
__privateSet(this, _records4, new RecordsDesk(
|
|
28472
28749
|
__privateGet(this, _kernel25),
|
|
28473
28750
|
__privateGet(this, _queries8),
|
|
28474
28751
|
__privateGet(this, _sessions14),
|
|
@@ -28922,7 +29199,7 @@
|
|
|
28922
29199
|
_replicaInventory = new WeakMap();
|
|
28923
29200
|
_placementDiscovery2 = new WeakMap();
|
|
28924
29201
|
_live3 = new WeakMap();
|
|
28925
|
-
|
|
29202
|
+
_records4 = new WeakMap();
|
|
28926
29203
|
_historicQueries = new WeakMap();
|
|
28927
29204
|
_authoringPreflight = new WeakMap();
|
|
28928
29205
|
_recovery = new WeakMap();
|
|
@@ -29030,8 +29307,8 @@
|
|
|
29030
29307
|
__privateGet(this, _replicaInventory).placementMayHaveChanged(workspace);
|
|
29031
29308
|
}
|
|
29032
29309
|
};
|
|
29033
|
-
/** Execute a typed paper after the access desk
|
|
29034
|
-
*
|
|
29310
|
+
/** Execute a typed paper after the access desk. Custody admission addresses a
|
|
29311
|
+
* workspace by replica identity; application calls retain session binding. */
|
|
29035
29312
|
dispatchRequest_fn = function(request) {
|
|
29036
29313
|
validateRuntimeV2Request(request);
|
|
29037
29314
|
try {
|
|
@@ -29045,18 +29322,20 @@
|
|
|
29045
29322
|
if (!request.target.workspace || !request.target.session) {
|
|
29046
29323
|
throw new Error("addressed runtime request requires workspace and session");
|
|
29047
29324
|
}
|
|
29048
|
-
|
|
29049
|
-
|
|
29050
|
-
if (binding
|
|
29051
|
-
|
|
29052
|
-
|
|
29053
|
-
|
|
29325
|
+
if (request.command.case !== "admitCustodyOffers") {
|
|
29326
|
+
const binding = __privateGet(this, _sessions14).bindingIfPresent(request.target.session);
|
|
29327
|
+
if (binding !== void 0) {
|
|
29328
|
+
if (binding.workspace !== request.target.workspace) {
|
|
29329
|
+
throw new Error(
|
|
29330
|
+
`session '${request.target.session}' is bound to workspace '${binding.workspace}', not '${request.target.workspace}'`
|
|
29331
|
+
);
|
|
29332
|
+
}
|
|
29333
|
+
} else {
|
|
29334
|
+
__privateMethod(this, _PeerOffice_instances, bindInteraction_fn).call(this, create(BindSessionRequestSchema, {
|
|
29335
|
+
session: request.target.session,
|
|
29336
|
+
workspace: request.target.workspace
|
|
29337
|
+
}));
|
|
29054
29338
|
}
|
|
29055
|
-
} else {
|
|
29056
|
-
__privateMethod(this, _PeerOffice_instances, bindInteraction_fn).call(this, create(BindSessionRequestSchema, {
|
|
29057
|
-
session: request.target.session,
|
|
29058
|
-
workspace: request.target.workspace
|
|
29059
|
-
}));
|
|
29060
29339
|
}
|
|
29061
29340
|
}
|
|
29062
29341
|
switch (request.command.case) {
|
|
@@ -29241,7 +29520,7 @@
|
|
|
29241
29520
|
ReadMaintenanceCause.ADMITTED_OFFER
|
|
29242
29521
|
);
|
|
29243
29522
|
__privateGet(this, _subscriptions5).refreshWorkspace(request.target.workspace);
|
|
29244
|
-
__privateGet(this, _correspondence3).
|
|
29523
|
+
__privateGet(this, _correspondence3).receivedFrontierChanged(request.target.workspace);
|
|
29245
29524
|
}
|
|
29246
29525
|
return __privateMethod(this, _PeerOffice_instances, birthCustodyResponse_fn).call(this, request, __privateGet(this, _birthCustody).afterCustodyAdmission(request, admission));
|
|
29247
29526
|
} catch (error) {
|
|
@@ -29295,29 +29574,29 @@
|
|
|
29295
29574
|
case "listWorkspaceMoments":
|
|
29296
29575
|
return __privateMethod(this, _PeerOffice_instances, response_fn).call(this, request, {
|
|
29297
29576
|
case: "workspaceMoments",
|
|
29298
|
-
value: __privateGet(this,
|
|
29577
|
+
value: __privateGet(this, _records4).moments(request, request.command.value)
|
|
29299
29578
|
});
|
|
29300
29579
|
case "estimateWorkspaceTransfer":
|
|
29301
29580
|
return __privateMethod(this, _PeerOffice_instances, response_fn).call(this, request, {
|
|
29302
29581
|
case: "workspaceTransferEstimate",
|
|
29303
|
-
value: __privateGet(this,
|
|
29582
|
+
value: __privateGet(this, _records4).transferEstimate(request, request.command.value)
|
|
29304
29583
|
});
|
|
29305
29584
|
case "readWorkspaceGenesis":
|
|
29306
29585
|
return __privateMethod(this, _PeerOffice_instances, response_fn).call(this, request, {
|
|
29307
29586
|
case: "workspaceGenesis",
|
|
29308
|
-
value: __privateGet(this,
|
|
29587
|
+
value: __privateGet(this, _records4).genesis(request, request.command.value)
|
|
29309
29588
|
});
|
|
29310
29589
|
case "listChildWorkspaces":
|
|
29311
29590
|
return __privateMethod(this, _PeerOffice_instances, response_fn).call(this, request, {
|
|
29312
29591
|
case: "childWorkspaces",
|
|
29313
|
-
value: __privateGet(this,
|
|
29592
|
+
value: __privateGet(this, _records4).children(request, request.command.value)
|
|
29314
29593
|
});
|
|
29315
29594
|
// The kernel still answers this in its transitional value arm; the desk
|
|
29316
29595
|
// decodes it once so no client infers a version status for itself.
|
|
29317
29596
|
case "checkReferenceVersions":
|
|
29318
29597
|
return __privateMethod(this, _PeerOffice_instances, response_fn).call(this, request, {
|
|
29319
29598
|
case: "referenceVersions",
|
|
29320
|
-
value: __privateGet(this,
|
|
29599
|
+
value: __privateGet(this, _records4).referenceVersions(request, request.command.value)
|
|
29321
29600
|
});
|
|
29322
29601
|
// A naming answer, not a custody read: it binds no session and mounts
|
|
29323
29602
|
// nothing, so a client can ask which workspace a keyed birth addresses
|
|
@@ -29707,6 +29986,15 @@
|
|
|
29707
29986
|
const correspondenceNotBefore = /* @__PURE__ */ new Map();
|
|
29708
29987
|
let retention = 0;
|
|
29709
29988
|
let closed = false;
|
|
29989
|
+
let selectionFailures = 0;
|
|
29990
|
+
const selectionFault = (error) => {
|
|
29991
|
+
try {
|
|
29992
|
+
options.onSelectionError?.(error);
|
|
29993
|
+
} catch {
|
|
29994
|
+
}
|
|
29995
|
+
selectionFailures += 1;
|
|
29996
|
+
wake(Math.min(3e4, 250 * 2 ** Math.min(selectionFailures - 1, 7)));
|
|
29997
|
+
};
|
|
29710
29998
|
const wake = (delayMillis = 0) => {
|
|
29711
29999
|
if (closed) return;
|
|
29712
30000
|
const delay = Math.max(0, Math.ceil(delayMillis));
|
|
@@ -29717,53 +30005,58 @@
|
|
|
29717
30005
|
}
|
|
29718
30006
|
wakeAt = at;
|
|
29719
30007
|
timer = setTimer(() => {
|
|
29720
|
-
|
|
29721
|
-
|
|
29722
|
-
|
|
29723
|
-
|
|
29724
|
-
|
|
29725
|
-
|
|
29726
|
-
|
|
29727
|
-
|
|
29728
|
-
|
|
29729
|
-
|
|
29730
|
-
|
|
29731
|
-
|
|
29732
|
-
if (
|
|
29733
|
-
|
|
29734
|
-
|
|
29735
|
-
|
|
29736
|
-
|
|
30008
|
+
try {
|
|
30009
|
+
timer = void 0;
|
|
30010
|
+
wakeAt = void 0;
|
|
30011
|
+
if (closed) return;
|
|
30012
|
+
const now = options.monotonicNanoseconds();
|
|
30013
|
+
for (const [workspace2, at2] of correspondenceNotBefore) {
|
|
30014
|
+
if (at2 <= now) correspondenceNotBefore.delete(workspace2);
|
|
30015
|
+
}
|
|
30016
|
+
const backoffMillis = correspondenceNotBefore.size ? Math.min(...[...correspondenceNotBefore.values()].map((at2) => Number((at2 - now + 999999n) / 1000000n))) : void 0;
|
|
30017
|
+
const retentionOnly = correspondenceInFlight;
|
|
30018
|
+
const next = options.nextPaper(retentionOnly, new Set(correspondenceNotBefore.keys()));
|
|
30019
|
+
selectionFailures = 0;
|
|
30020
|
+
if (next.frame === void 0) {
|
|
30021
|
+
const delays = [next.nextAfterMillis, backoffMillis].filter((delay2) => delay2 !== void 0);
|
|
30022
|
+
if (delays.length) wake(Math.min(...delays));
|
|
30023
|
+
return;
|
|
30024
|
+
}
|
|
30025
|
+
if (options.isRetention(next.frame)) {
|
|
30026
|
+
retention += 1;
|
|
30027
|
+
void options.drive(next.frame).then(
|
|
30028
|
+
() => {
|
|
30029
|
+
retention -= 1;
|
|
30030
|
+
wake(0);
|
|
30031
|
+
},
|
|
30032
|
+
() => {
|
|
30033
|
+
retention -= 1;
|
|
30034
|
+
wake(0);
|
|
30035
|
+
}
|
|
30036
|
+
);
|
|
30037
|
+
wake(next.nextAfterMillis ?? 0);
|
|
30038
|
+
return;
|
|
30039
|
+
}
|
|
30040
|
+
if (retentionOnly) throw new Error("background desk reserved correspondence while its lane was unavailable");
|
|
30041
|
+
const workspace = next.workspace;
|
|
30042
|
+
if (!workspace) throw new Error("background correspondence has no source workspace");
|
|
30043
|
+
if (correspondenceNotBefore.has(workspace)) throw new Error("background desk bypassed a workspace's physical backoff");
|
|
30044
|
+
correspondenceInFlight = true;
|
|
29737
30045
|
void options.drive(next.frame).then(
|
|
29738
30046
|
() => {
|
|
29739
|
-
|
|
29740
|
-
wake(0);
|
|
30047
|
+
correspondenceInFlight = false;
|
|
30048
|
+
wake(next.nextAfterMillis ?? 0);
|
|
29741
30049
|
},
|
|
29742
30050
|
() => {
|
|
29743
|
-
|
|
30051
|
+
correspondenceInFlight = false;
|
|
30052
|
+
correspondenceNotBefore.set(workspace, options.monotonicNanoseconds() + BigInt(failureBackoffMillis) * 1000000n);
|
|
29744
30053
|
wake(0);
|
|
29745
30054
|
}
|
|
29746
30055
|
);
|
|
29747
|
-
wake(
|
|
29748
|
-
|
|
30056
|
+
wake(0);
|
|
30057
|
+
} catch (error) {
|
|
30058
|
+
selectionFault(error);
|
|
29749
30059
|
}
|
|
29750
|
-
if (retentionOnly) throw new Error("background desk reserved correspondence while its lane was unavailable");
|
|
29751
|
-
const workspace = next.workspace;
|
|
29752
|
-
if (!workspace) throw new Error("background correspondence has no source workspace");
|
|
29753
|
-
if (correspondenceNotBefore.has(workspace)) throw new Error("background desk bypassed a workspace's physical backoff");
|
|
29754
|
-
correspondenceInFlight = true;
|
|
29755
|
-
void options.drive(next.frame).then(
|
|
29756
|
-
() => {
|
|
29757
|
-
correspondenceInFlight = false;
|
|
29758
|
-
wake(next.nextAfterMillis ?? 0);
|
|
29759
|
-
},
|
|
29760
|
-
() => {
|
|
29761
|
-
correspondenceInFlight = false;
|
|
29762
|
-
correspondenceNotBefore.set(workspace, options.monotonicNanoseconds() + BigInt(failureBackoffMillis) * 1000000n);
|
|
29763
|
-
wake(0);
|
|
29764
|
-
}
|
|
29765
|
-
);
|
|
29766
|
-
wake(0);
|
|
29767
30060
|
}, delay);
|
|
29768
30061
|
};
|
|
29769
30062
|
return {
|
|
@@ -29838,7 +30131,8 @@
|
|
|
29838
30131
|
throw error;
|
|
29839
30132
|
}),
|
|
29840
30133
|
isRetention: (frame) => fromBinary(RuntimeRequestSchema, frame).command.case === "retainFrontier",
|
|
29841
|
-
monotonicNanoseconds: () => observations.monotonicNanoseconds()
|
|
30134
|
+
monotonicNanoseconds: () => observations.monotonicNanoseconds(),
|
|
30135
|
+
onSelectionError: (error) => console.error("Nomos background paper selection failed", error)
|
|
29842
30136
|
});
|
|
29843
30137
|
const scheduleCorrespondence = (delayMillis = 0) => {
|
|
29844
30138
|
lanes?.wake(delayMillis);
|
|
@@ -30070,13 +30364,19 @@
|
|
|
30070
30364
|
};
|
|
30071
30365
|
var executeGitFetchWithAlongside = async (effect, fetchImpl) => {
|
|
30072
30366
|
if (!effect.alongside) return executeGitFetchEffect(effect, fetchImpl);
|
|
30073
|
-
const
|
|
30074
|
-
|
|
30075
|
-
|
|
30076
|
-
|
|
30077
|
-
|
|
30367
|
+
const cancelAlongside = new AbortController();
|
|
30368
|
+
let alongside;
|
|
30369
|
+
void executeHttpEffect(effect.alongside, (input, init) => fetchImpl(input, {
|
|
30370
|
+
...init,
|
|
30371
|
+
signal: init?.signal ? AbortSignal.any([init.signal, cancelAlongside.signal]) : cancelAlongside.signal
|
|
30372
|
+
})).then((receipt) => {
|
|
30373
|
+
alongside = receipt;
|
|
30374
|
+
});
|
|
30375
|
+
const fetched = await executeGitFetchEffect(effect, fetchImpl);
|
|
30376
|
+
if (fetched.outcome.case === "gitFetch" && alongside?.outcome.case === "response") {
|
|
30078
30377
|
fetched.outcome.value.alongside = alongside.outcome.value;
|
|
30079
30378
|
}
|
|
30379
|
+
cancelAlongside.abort();
|
|
30080
30380
|
return fetched;
|
|
30081
30381
|
};
|
|
30082
30382
|
var executeGitPushEffect = async (effect, fetchImpl) => {
|
|
@@ -30445,7 +30745,8 @@
|
|
|
30445
30745
|
requestId: ++sequence,
|
|
30446
30746
|
command: { case: "socketReceipt", value: create(PeerSocketReceiptSchema, { connectionId, observation }) }
|
|
30447
30747
|
}));
|
|
30448
|
-
void Promise.resolve().then(() => invoke2(frame)).catch(() => {
|
|
30748
|
+
void Promise.resolve().then(() => invoke2(frame)).catch((error) => {
|
|
30749
|
+
console.warn("[nomos-socket] receipt failed", { connectionId, error });
|
|
30449
30750
|
sockets.get(connectionId)?.close();
|
|
30450
30751
|
});
|
|
30451
30752
|
};
|
|
@@ -30467,6 +30768,7 @@
|
|
|
30467
30768
|
socket.onopen = () => receipt(id, { case: "opened", value: true });
|
|
30468
30769
|
socket.onmessage = (message) => {
|
|
30469
30770
|
if (message.data instanceof ArrayBuffer) receipt(id, { case: "received", value: new Uint8Array(message.data) });
|
|
30771
|
+
else if (typeof message.data === "string") receipt(id, { case: "received", value: new TextEncoder().encode(message.data) });
|
|
30470
30772
|
};
|
|
30471
30773
|
socket.onclose = () => {
|
|
30472
30774
|
if (sockets.get(id) === socket) sockets.delete(id);
|
|
@@ -32660,13 +32962,13 @@
|
|
|
32660
32962
|
}
|
|
32661
32963
|
}
|
|
32662
32964
|
}
|
|
32663
|
-
let
|
|
32965
|
+
let namespace2 = void 0;
|
|
32664
32966
|
let tagAndPosition = withoutBrackets;
|
|
32665
32967
|
if (withoutBrackets.includes("::")) {
|
|
32666
32968
|
const nsIndex = withoutBrackets.indexOf("::");
|
|
32667
|
-
|
|
32969
|
+
namespace2 = withoutBrackets.substring(0, nsIndex).trim();
|
|
32668
32970
|
tagAndPosition = withoutBrackets.substring(nsIndex + 2).trim();
|
|
32669
|
-
if (!
|
|
32971
|
+
if (!namespace2) {
|
|
32670
32972
|
throw new Error(`Invalid namespace in pattern: ${part}`);
|
|
32671
32973
|
}
|
|
32672
32974
|
}
|
|
@@ -32690,8 +32992,8 @@
|
|
|
32690
32992
|
throw new Error(`Invalid segment pattern: ${part}`);
|
|
32691
32993
|
}
|
|
32692
32994
|
segment.tag = tag;
|
|
32693
|
-
if (
|
|
32694
|
-
segment.namespace =
|
|
32995
|
+
if (namespace2) {
|
|
32996
|
+
segment.namespace = namespace2;
|
|
32695
32997
|
}
|
|
32696
32998
|
if (bracketContent) {
|
|
32697
32999
|
if (bracketContent.includes("=")) {
|
|
@@ -33083,7 +33385,7 @@
|
|
|
33083
33385
|
* @param {Object|null} [options=null]
|
|
33084
33386
|
* @param {string[]} [options.keep] - Names of attributes (from attrValues)
|
|
33085
33387
|
*/
|
|
33086
|
-
push(tagName, attrValues = null,
|
|
33388
|
+
push(tagName, attrValues = null, namespace2 = null, options = null) {
|
|
33087
33389
|
this._pathStringCache = null;
|
|
33088
33390
|
if (this.path.length > 0) {
|
|
33089
33391
|
this.path[this.path.length - 1].values = void 0;
|
|
@@ -33094,7 +33396,7 @@
|
|
|
33094
33396
|
level = { counts: /* @__PURE__ */ new Map(), total: 0 };
|
|
33095
33397
|
this.siblingStacks[currentLevel] = level;
|
|
33096
33398
|
}
|
|
33097
|
-
const siblingKey =
|
|
33399
|
+
const siblingKey = namespace2 ? `${namespace2}:${tagName}` : tagName;
|
|
33098
33400
|
const counter = level.counts.get(siblingKey) || 0;
|
|
33099
33401
|
const position = level.total;
|
|
33100
33402
|
level.counts.set(siblingKey, counter + 1);
|
|
@@ -33104,8 +33406,8 @@
|
|
|
33104
33406
|
position,
|
|
33105
33407
|
counter
|
|
33106
33408
|
};
|
|
33107
|
-
if (
|
|
33108
|
-
node.namespace =
|
|
33409
|
+
if (namespace2 !== null && namespace2 !== void 0) {
|
|
33410
|
+
node.namespace = namespace2;
|
|
33109
33411
|
}
|
|
33110
33412
|
if (attrValues !== null && attrValues !== void 0) {
|
|
33111
33413
|
node.values = attrValues;
|
|
@@ -34498,10 +34800,10 @@
|
|
|
34498
34800
|
}
|
|
34499
34801
|
let prefixedAttrs = null;
|
|
34500
34802
|
let rawAttrs = {};
|
|
34501
|
-
let
|
|
34502
|
-
|
|
34803
|
+
let namespace2 = void 0;
|
|
34804
|
+
namespace2 = extractNamespace(rawTagName);
|
|
34503
34805
|
if (tagName !== xmlObj.tagname) {
|
|
34504
|
-
this.matcher.push(tagName, {},
|
|
34806
|
+
this.matcher.push(tagName, {}, namespace2);
|
|
34505
34807
|
}
|
|
34506
34808
|
if (tagName !== tagExp && attrExpPresent) {
|
|
34507
34809
|
prefixedAttrs = this.buildAttributesMap(tagExp, this.matcher, tagName);
|
|
@@ -35732,17 +36034,17 @@
|
|
|
35732
36034
|
}
|
|
35733
36035
|
return result;
|
|
35734
36036
|
}
|
|
35735
|
-
function capabilityByNamespace(capabilities,
|
|
35736
|
-
const matches = capabilities.filter((capability) => capability.namespace ===
|
|
36037
|
+
function capabilityByNamespace(capabilities, namespace2) {
|
|
36038
|
+
const matches = capabilities.filter((capability) => capability.namespace === namespace2);
|
|
35737
36039
|
if (matches.length !== 1) {
|
|
35738
|
-
throw new Error(`OSGi resource needs exactly one ${
|
|
36040
|
+
throw new Error(`OSGi resource needs exactly one ${namespace2} capability`);
|
|
35739
36041
|
}
|
|
35740
36042
|
return matches[0];
|
|
35741
36043
|
}
|
|
35742
|
-
function optionalCapabilityByNamespace(capabilities,
|
|
35743
|
-
const matches = capabilities.filter((capability) => capability.namespace ===
|
|
36044
|
+
function optionalCapabilityByNamespace(capabilities, namespace2) {
|
|
36045
|
+
const matches = capabilities.filter((capability) => capability.namespace === namespace2);
|
|
35744
36046
|
if (matches.length > 1) {
|
|
35745
|
-
throw new Error(`OSGi resource needs at most one ${
|
|
36047
|
+
throw new Error(`OSGi resource needs at most one ${namespace2} capability`);
|
|
35746
36048
|
}
|
|
35747
36049
|
return matches[0];
|
|
35748
36050
|
}
|
|
@@ -35850,7 +36152,7 @@
|
|
|
35850
36152
|
async function selectReleaseKernel(args) {
|
|
35851
36153
|
const fetchImpl = args.fetchImpl ?? ((input, init) => globalThis.fetch(input, init));
|
|
35852
36154
|
const base = args.base.replace(/\/+$/, "");
|
|
35853
|
-
const repositoryUrl = `${base}/v1/runtime/repository.xml`;
|
|
36155
|
+
const repositoryUrl = args.repositoryUrl ?? `${base}/v1/runtime/repository.xml`;
|
|
35854
36156
|
const repositoryResponse = await fetchImpl(repositoryUrl);
|
|
35855
36157
|
if (!repositoryResponse.ok) {
|
|
35856
36158
|
throw new Error(`custodian kernel repository ${repositoryUrl}: HTTP ${repositoryResponse.status}`);
|
|
@@ -35895,22 +36197,36 @@
|
|
|
35895
36197
|
|
|
35896
36198
|
// ../../platform-shells/browser/peer.ts
|
|
35897
36199
|
async function openBrowserPeer(options) {
|
|
36200
|
+
const progress = (stage) => {
|
|
36201
|
+
try {
|
|
36202
|
+
options.onBootProgress?.(stage);
|
|
36203
|
+
} catch {
|
|
36204
|
+
}
|
|
36205
|
+
};
|
|
36206
|
+
progress("opening browser custody");
|
|
35898
36207
|
const storage = options.custodyStore ?? await openBrowserCustody(options.base);
|
|
36208
|
+
storage.onCheckpoint = options.onCustodyCheckpoint;
|
|
35899
36209
|
try {
|
|
36210
|
+
progress("selecting Kernel artifacts");
|
|
35900
36211
|
const fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);
|
|
35901
36212
|
const selected = await selectReleaseKernel({
|
|
35902
36213
|
base: options.base,
|
|
36214
|
+
repositoryUrl: options.kernelRepositoryUrl,
|
|
35903
36215
|
release: options.release,
|
|
35904
|
-
fetchImpl: browserRuntimeFetch(options.base, fetchImpl, globalThis.caches),
|
|
36216
|
+
fetchImpl: browserRuntimeFetch(options.base, fetchImpl, globalThis.caches, options.kernelRepositoryUrl),
|
|
35905
36217
|
cache: options.kernelCache
|
|
35906
36218
|
});
|
|
36219
|
+
progress(`compiling Kernel ${selected.resource.contentSha256}`);
|
|
36220
|
+
const wasmModule = await WebAssembly.compile(selected.wasm);
|
|
36221
|
+
progress("opening Kernel machine");
|
|
35907
36222
|
const machine = await createKernelMachine({
|
|
35908
|
-
wasmModule
|
|
36223
|
+
wasmModule,
|
|
35909
36224
|
bootstrapLawUsdz: selected.bootstrapLaw,
|
|
35910
36225
|
nomosLawUsdz: selected.controllerLaw,
|
|
35911
36226
|
replica: options.replica ?? storage.replica,
|
|
35912
36227
|
trustRootPublicKey: options.trustRootPublicKey
|
|
35913
36228
|
}, storage.filesystem, storage.changed);
|
|
36229
|
+
progress("opening Peer Office");
|
|
35914
36230
|
const kernelWork = new KernelWorkAccounting(options.onKernelWorkChanged, false);
|
|
35915
36231
|
const physicalKernel = observeBrowserKernelCalls(kernelExecutionDesk(machine), kernelWork);
|
|
35916
36232
|
const kernel = options.observeKernel?.(physicalKernel) ?? physicalKernel;
|
|
@@ -35926,7 +36242,7 @@
|
|
|
35926
36242
|
physical,
|
|
35927
36243
|
{ ...options.profile, identity: storage.identity },
|
|
35928
36244
|
void 0,
|
|
35929
|
-
{ list: (
|
|
36245
|
+
{ list: (namespace2) => storage.list(namespace2), compareExchange: (...args) => storage.compareExchange(...args) }
|
|
35930
36246
|
);
|
|
35931
36247
|
const office = openPeerOfficeHost(
|
|
35932
36248
|
kernel,
|
|
@@ -35940,6 +36256,7 @@
|
|
|
35940
36256
|
options.lawPackage,
|
|
35941
36257
|
options.performExternalEffect
|
|
35942
36258
|
);
|
|
36259
|
+
progress("peer ready");
|
|
35943
36260
|
return {
|
|
35944
36261
|
invoke: async (frame) => {
|
|
35945
36262
|
storage.assertUsable();
|