githolon 0.112.8 → 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/compile_mountability_entry.js +517 -258
- package/dist/dev-server.mjs +505 -255
- package/dist/framework/bootstrap.law.usdz +0 -0
- package/dist/framework/nomos.law.usdz +0 -0
- package/dist/framework/nomos.reception.mjs +1 -1
- package/dist/full-cli.mjs +529 -270
- package/package.json +2 -2
package/dist/full-cli.mjs
CHANGED
|
@@ -3534,7 +3534,7 @@ function birth(recipeOrAggregate, spec) {
|
|
|
3534
3534
|
.../* @__PURE__ */ new Set([AUTH_PROVIDER_AUTHORITY, ...spec.parentWorkspace?.roles ?? []])
|
|
3535
3535
|
].sort();
|
|
3536
3536
|
const aggregateNoun = aggregate2.id.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
3537
|
-
const
|
|
3537
|
+
const namespace2 = (spec.namespace ?? aggregateNoun).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
3538
3538
|
const rootId = `${aggregateNoun}:self`;
|
|
3539
3539
|
const declaration = {
|
|
3540
3540
|
__isBusinessBirth: true,
|
|
@@ -3542,7 +3542,7 @@ function birth(recipeOrAggregate, spec) {
|
|
|
3542
3542
|
payloadSchema,
|
|
3543
3543
|
key: (payload) => String(payload[spec.key]),
|
|
3544
3544
|
reference: (payload) => ({
|
|
3545
|
-
workspace: workspaceNameForKey(
|
|
3545
|
+
workspace: workspaceNameForKey(namespace2, String(payload[spec.key])),
|
|
3546
3546
|
type: aggregate2.id,
|
|
3547
3547
|
id: rootId
|
|
3548
3548
|
}),
|
|
@@ -3569,8 +3569,8 @@ function birth(recipeOrAggregate, spec) {
|
|
|
3569
3569
|
}
|
|
3570
3570
|
footprint2.push(recipeOrAggregate);
|
|
3571
3571
|
}
|
|
3572
|
-
function workspaceNameForKey(
|
|
3573
|
-
return
|
|
3572
|
+
function workspaceNameForKey(namespace2, key2) {
|
|
3573
|
+
return namespace2 + "-" + nomos.sha256(String(namespace2) + WORKSPACE_NAME_SEP + String(key2)).slice(0, 40);
|
|
3574
3574
|
}
|
|
3575
3575
|
function resolveChain(child, c) {
|
|
3576
3576
|
return typeof c === "function" ? c(child) : c;
|
|
@@ -3585,10 +3585,10 @@ var init_births = __esm({
|
|
|
3585
3585
|
WORKSPACE_NAME_SEP = "";
|
|
3586
3586
|
birthKeyed = ({
|
|
3587
3587
|
key: key2,
|
|
3588
|
-
namespace,
|
|
3588
|
+
namespace: namespace2,
|
|
3589
3589
|
genesisChain
|
|
3590
3590
|
}) => {
|
|
3591
|
-
const child = workspaceNameForKey(
|
|
3591
|
+
const child = workspaceNameForKey(namespace2, String(key2));
|
|
3592
3592
|
footprint2.push({ workspace: child, genesisChain: resolveChain(child, genesisChain) });
|
|
3593
3593
|
return child;
|
|
3594
3594
|
};
|
|
@@ -3603,11 +3603,11 @@ var init_births = __esm({
|
|
|
3603
3603
|
};
|
|
3604
3604
|
birthSingleton = ({
|
|
3605
3605
|
keyedBy,
|
|
3606
|
-
namespace,
|
|
3606
|
+
namespace: namespace2,
|
|
3607
3607
|
genesisChain
|
|
3608
3608
|
}) => {
|
|
3609
3609
|
const key2 = (Array.isArray(keyedBy) ? keyedBy : [keyedBy]).map(String).join(WORKSPACE_NAME_SEP);
|
|
3610
|
-
return birthKeyed({ key: key2, namespace, genesisChain });
|
|
3610
|
+
return birthKeyed({ key: key2, namespace: namespace2, genesisChain });
|
|
3611
3611
|
};
|
|
3612
3612
|
((birth2) => {
|
|
3613
3613
|
birth2.keyed = birthKeyed;
|
|
@@ -7130,7 +7130,7 @@ function lowerOne(decl, domain, initialBirthPolicyDomains = [domain]) {
|
|
|
7130
7130
|
}
|
|
7131
7131
|
const stem = decl.aggregate.id.replace(/[^A-Za-z0-9]/g, "");
|
|
7132
7132
|
const aggregateNoun = decl.aggregate.id.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
7133
|
-
const
|
|
7133
|
+
const namespace2 = (decl.namespace ?? aggregateNoun).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
7134
7134
|
const rootId = `${aggregateNoun}:self`;
|
|
7135
7135
|
const seedId = `nomosSeed${stem}`;
|
|
7136
7136
|
const birthId = `nomosBirth${stem}`;
|
|
@@ -7194,7 +7194,7 @@ function lowerOne(decl, domain, initialBirthPolicyDomains = [domain]) {
|
|
|
7194
7194
|
};
|
|
7195
7195
|
const birthBase = directive(birthId).creates(decl.aggregate).payload(parentSchema).plan((p, ctx) => {
|
|
7196
7196
|
const founder = p.principal;
|
|
7197
|
-
const child = workspaceNameForKey(
|
|
7197
|
+
const child = workspaceNameForKey(namespace2, String(decl.key(p)));
|
|
7198
7198
|
const foundingKeyHash = foundedBirthKeyHash(founder);
|
|
7199
7199
|
const founded = foundingKeyHash !== void 0;
|
|
7200
7200
|
if (founded) {
|
|
@@ -7273,7 +7273,7 @@ function lowerOne(decl, domain, initialBirthPolicyDomains = [domain]) {
|
|
|
7273
7273
|
),
|
|
7274
7274
|
// The roles the parent delegates into every child of this namespace its founder's scope
|
|
7275
7275
|
// founds (formerly a per-intent delegation certificate), as state tuples for the founder.
|
|
7276
|
-
...delegatedRolesSteps(founder, founder,
|
|
7276
|
+
...delegatedRolesSteps(founder, founder, namespace2, Date.parse(String(p.bornAt)))
|
|
7277
7277
|
] : [],
|
|
7278
7278
|
{
|
|
7279
7279
|
domain,
|
|
@@ -7321,7 +7321,7 @@ function lowerOne(decl, domain, initialBirthPolicyDomains = [domain]) {
|
|
|
7321
7321
|
owned: decl.aggregate.audience?.kind === "owned",
|
|
7322
7322
|
publicPayloadSchema: publicSchema,
|
|
7323
7323
|
rootId,
|
|
7324
|
-
namespace,
|
|
7324
|
+
namespace: namespace2,
|
|
7325
7325
|
keyField: decl.keyField,
|
|
7326
7326
|
seedDirectiveId: seedId,
|
|
7327
7327
|
genesisDirectiveIds: [
|
|
@@ -9808,10 +9808,10 @@ var init_node_custody_filesystem = __esm({
|
|
|
9808
9808
|
// ../platform-shells/node/kernel_wasi_stdio.ts
|
|
9809
9809
|
import { TextDecoder as TextDecoder2 } from "node:util";
|
|
9810
9810
|
function kernelWasiStdio(memory, stderr, writeFile2, stderrPartial) {
|
|
9811
|
-
const
|
|
9811
|
+
const decoder5 = new TextDecoder2();
|
|
9812
9812
|
let pending = "";
|
|
9813
9813
|
const accept = (bytes) => {
|
|
9814
|
-
pending +=
|
|
9814
|
+
pending += decoder5.decode(bytes, { stream: true });
|
|
9815
9815
|
for (; ; ) {
|
|
9816
9816
|
const newline = pending.indexOf("\n");
|
|
9817
9817
|
if (newline >= 0 && newline < 16384) {
|
|
@@ -11504,17 +11504,17 @@ function attributes(capability) {
|
|
|
11504
11504
|
}
|
|
11505
11505
|
return result;
|
|
11506
11506
|
}
|
|
11507
|
-
function capabilityByNamespace(capabilities,
|
|
11508
|
-
const matches = capabilities.filter((capability) => capability.namespace ===
|
|
11507
|
+
function capabilityByNamespace(capabilities, namespace2) {
|
|
11508
|
+
const matches = capabilities.filter((capability) => capability.namespace === namespace2);
|
|
11509
11509
|
if (matches.length !== 1) {
|
|
11510
|
-
throw new Error(`OSGi resource needs exactly one ${
|
|
11510
|
+
throw new Error(`OSGi resource needs exactly one ${namespace2} capability`);
|
|
11511
11511
|
}
|
|
11512
11512
|
return matches[0];
|
|
11513
11513
|
}
|
|
11514
|
-
function optionalCapabilityByNamespace(capabilities,
|
|
11515
|
-
const matches = capabilities.filter((capability) => capability.namespace ===
|
|
11514
|
+
function optionalCapabilityByNamespace(capabilities, namespace2) {
|
|
11515
|
+
const matches = capabilities.filter((capability) => capability.namespace === namespace2);
|
|
11516
11516
|
if (matches.length > 1) {
|
|
11517
|
-
throw new Error(`OSGi resource needs at most one ${
|
|
11517
|
+
throw new Error(`OSGi resource needs at most one ${namespace2} capability`);
|
|
11518
11518
|
}
|
|
11519
11519
|
return matches[0];
|
|
11520
11520
|
}
|
|
@@ -12553,7 +12553,8 @@ var init_kernel_port = __esm({
|
|
|
12553
12553
|
}
|
|
12554
12554
|
}));
|
|
12555
12555
|
if (response.outcome.case === "failure") {
|
|
12556
|
-
|
|
12556
|
+
throwUnnamedHistoryRequirement(response.outcome.value, mount.workspace);
|
|
12557
|
+
throwKernelFailure(response.outcome.value);
|
|
12557
12558
|
}
|
|
12558
12559
|
if (response.outcome.case !== "outbox") {
|
|
12559
12560
|
throw new Error(`kernel returned '${response.outcome.case || "empty"}' while reading correspondence`);
|
|
@@ -12582,7 +12583,8 @@ var init_kernel_port = __esm({
|
|
|
12582
12583
|
}
|
|
12583
12584
|
}));
|
|
12584
12585
|
if (response.outcome.case === "failure") {
|
|
12585
|
-
|
|
12586
|
+
throwUnnamedHistoryRequirement(response.outcome.value, mount.workspace);
|
|
12587
|
+
throwKernelFailure(response.outcome.value);
|
|
12586
12588
|
}
|
|
12587
12589
|
if (response.outcome.case !== "outbox") {
|
|
12588
12590
|
throw new Error(
|
|
@@ -15779,11 +15781,11 @@ import { create as create20 } from "@bufbuild/protobuf";
|
|
|
15779
15781
|
function resolveWorkspaceName(command) {
|
|
15780
15782
|
switch (command.birth.case) {
|
|
15781
15783
|
case "keyed": {
|
|
15782
|
-
const { namespace, key: key2 } = command.birth.value;
|
|
15783
|
-
if (
|
|
15784
|
+
const { namespace: namespace2, key: key2 } = command.birth.value;
|
|
15785
|
+
if (namespace2.length === 0 || key2.length === 0) {
|
|
15784
15786
|
throw new Error(`${WORKSPACE_NAME_REQUEST_INVALID}: a keyed birth name needs both its namespace and its key`);
|
|
15785
15787
|
}
|
|
15786
|
-
return create20(ResolvedWorkspaceNameSchema, { workspace: keyedBirthNameOf(
|
|
15788
|
+
return create20(ResolvedWorkspaceNameSchema, { workspace: keyedBirthNameOf(namespace2, key2) });
|
|
15787
15789
|
}
|
|
15788
15790
|
case "receivingGroup": {
|
|
15789
15791
|
const { principal } = command.birth.value;
|
|
@@ -15807,10 +15809,10 @@ var init_workspace_naming = __esm({
|
|
|
15807
15809
|
init_records_desk_pb();
|
|
15808
15810
|
init_sha256();
|
|
15809
15811
|
WORKSPACE_NAME_SEP2 = "";
|
|
15810
|
-
keyedBirthNameOf = (
|
|
15812
|
+
keyedBirthNameOf = (namespace2, key2) => `${namespace2}-${sha256Hex6(new TextEncoder().encode(namespace2 + WORKSPACE_NAME_SEP2 + key2)).slice(0, 40)}`;
|
|
15811
15813
|
RECEIVING_GROUP_NAME_PREFIX2 = "nomos-rg-";
|
|
15812
15814
|
receivingGroupNameOf2 = (principal) => `${RECEIVING_GROUP_NAME_PREFIX2}${sha256Hex6(new TextEncoder().encode(principal)).slice(0, 40)}`;
|
|
15813
|
-
isKeyedBirthOf = (
|
|
15815
|
+
isKeyedBirthOf = (namespace2, workspace) => workspace.startsWith(`${namespace2}-`);
|
|
15814
15816
|
WORKSPACE_NAME_REQUEST_INVALID = "nomos.runtime.workspace_name_request_invalid";
|
|
15815
15817
|
}
|
|
15816
15818
|
});
|
|
@@ -17910,8 +17912,150 @@ var init_model_adoption_desk = __esm({
|
|
|
17910
17912
|
}
|
|
17911
17913
|
});
|
|
17912
17914
|
|
|
17915
|
+
// ../peer-office/src/runtime/peer_desk_store.ts
|
|
17916
|
+
var recordId, copy2, MemoryPeerDeskStore;
|
|
17917
|
+
var init_peer_desk_store = __esm({
|
|
17918
|
+
"../peer-office/src/runtime/peer_desk_store.ts"() {
|
|
17919
|
+
"use strict";
|
|
17920
|
+
recordId = (namespace2, key2) => `${namespace2.length}:${namespace2}${key2}`;
|
|
17921
|
+
copy2 = (record) => ({
|
|
17922
|
+
...record,
|
|
17923
|
+
value: record.value.slice()
|
|
17924
|
+
});
|
|
17925
|
+
MemoryPeerDeskStore = class {
|
|
17926
|
+
#records = /* @__PURE__ */ new Map();
|
|
17927
|
+
list(namespace2) {
|
|
17928
|
+
return [...this.#records.values()].filter((record) => record.namespace === namespace2).sort((left, right) => left.key.localeCompare(right.key)).map(copy2);
|
|
17929
|
+
}
|
|
17930
|
+
compareExchange(namespace2, key2, expectedRevision, value) {
|
|
17931
|
+
const id = recordId(namespace2, key2);
|
|
17932
|
+
const current = this.#records.get(id);
|
|
17933
|
+
if (current?.revision !== expectedRevision) {
|
|
17934
|
+
throw new Error(
|
|
17935
|
+
`peer desk record '${namespace2}/${key2}' changed at revision ${current?.revision ?? "absent"}`
|
|
17936
|
+
);
|
|
17937
|
+
}
|
|
17938
|
+
if (value === void 0) {
|
|
17939
|
+
this.#records.delete(id);
|
|
17940
|
+
return void 0;
|
|
17941
|
+
}
|
|
17942
|
+
const next = Object.freeze({
|
|
17943
|
+
namespace: namespace2,
|
|
17944
|
+
key: key2,
|
|
17945
|
+
revision: (current?.revision ?? 0n) + 1n,
|
|
17946
|
+
value: value.slice()
|
|
17947
|
+
});
|
|
17948
|
+
this.#records.set(id, next);
|
|
17949
|
+
return copy2(next);
|
|
17950
|
+
}
|
|
17951
|
+
};
|
|
17952
|
+
}
|
|
17953
|
+
});
|
|
17954
|
+
|
|
17955
|
+
// ../peer-office/src/runtime/custody_receipts.ts
|
|
17956
|
+
import { fromBinary as fromBinary15, toBinary as toBinary12 } from "@bufbuild/protobuf";
|
|
17957
|
+
var namespace, encoder, decoder, MAX_BASES, MAX_RECEIPTS, CustodyReceipts;
|
|
17958
|
+
var init_custody_receipts = __esm({
|
|
17959
|
+
"../peer-office/src/runtime/custody_receipts.ts"() {
|
|
17960
|
+
"use strict";
|
|
17961
|
+
init_correspondence_desk_pb();
|
|
17962
|
+
init_peer_desk_store();
|
|
17963
|
+
init_sha256();
|
|
17964
|
+
namespace = "nomos.peer-desk.custody-receipts/v1";
|
|
17965
|
+
encoder = new TextEncoder();
|
|
17966
|
+
decoder = new TextDecoder();
|
|
17967
|
+
MAX_BASES = 256;
|
|
17968
|
+
MAX_RECEIPTS = 4096;
|
|
17969
|
+
CustodyReceipts = class {
|
|
17970
|
+
#store;
|
|
17971
|
+
#records = /* @__PURE__ */ new Map();
|
|
17972
|
+
#journals = /* @__PURE__ */ new Map();
|
|
17973
|
+
#receipts = /* @__PURE__ */ new Map();
|
|
17974
|
+
constructor(store = new MemoryPeerDeskStore()) {
|
|
17975
|
+
this.#store = store;
|
|
17976
|
+
for (const record of store.list(namespace)) {
|
|
17977
|
+
this.#records.set(record.key, record);
|
|
17978
|
+
try {
|
|
17979
|
+
if (record.key.startsWith("receipt:")) {
|
|
17980
|
+
const newline = record.value.indexOf(10);
|
|
17981
|
+
if (newline < 0) continue;
|
|
17982
|
+
const receipt = fromBinary15(CustodyIntentAdmissionSchema, record.value.subarray(newline + 1));
|
|
17983
|
+
const header2 = JSON.parse(decoder.decode(record.value.subarray(0, newline)));
|
|
17984
|
+
if (receipt.outcome.case === "admitted" && typeof header2.generation === "string" && typeof header2.head === "string") this.#receipts.set(record.key, { ...header2, receipt });
|
|
17985
|
+
continue;
|
|
17986
|
+
}
|
|
17987
|
+
if (!record.key.startsWith("head:")) continue;
|
|
17988
|
+
const value = JSON.parse(decoder.decode(record.value));
|
|
17989
|
+
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;
|
|
17990
|
+
if (!value.bases.every((base) => typeof base === "string") || !value.keys.every((key2) => typeof key2 === "string")) continue;
|
|
17991
|
+
this.#journals.set(record.key.slice(5), value);
|
|
17992
|
+
} catch {
|
|
17993
|
+
}
|
|
17994
|
+
}
|
|
17995
|
+
}
|
|
17996
|
+
covers(workspace, current, base) {
|
|
17997
|
+
const value = this.#journals.get(workspace);
|
|
17998
|
+
return value?.head === current && value.bases.includes(base);
|
|
17999
|
+
}
|
|
18000
|
+
receipt(workspace, current, change) {
|
|
18001
|
+
const value = this.#journals.get(workspace);
|
|
18002
|
+
if (value?.head !== current) return void 0;
|
|
18003
|
+
const stored = this.#receipts.get(`receipt:${workspace}:${sha256Hex6(change)}`);
|
|
18004
|
+
if (stored?.generation !== value.generation) return void 0;
|
|
18005
|
+
if (stored.head !== value.head && !value.bases.includes(stored.head)) return void 0;
|
|
18006
|
+
return fromBinary15(CustodyIntentAdmissionSchema, toBinary12(CustodyIntentAdmissionSchema, stored.receipt));
|
|
18007
|
+
}
|
|
18008
|
+
record(workspace, before, after, receipts) {
|
|
18009
|
+
const old = this.#journals.get(workspace);
|
|
18010
|
+
const journalKey = `head:${workspace}`;
|
|
18011
|
+
const value = old?.head === before ? { ...old, head: after, bases: [...old.bases], keys: [...old.keys] } : { head: after, bases: [], keys: [], generation: String((this.#records.get(journalKey)?.revision ?? 0n) + 1n) };
|
|
18012
|
+
if (before && before !== after) value.bases.push(before);
|
|
18013
|
+
value.bases = [...new Set(value.bases)].slice(-MAX_BASES);
|
|
18014
|
+
const keys = new Set(value.keys);
|
|
18015
|
+
const discarded = new Set(old?.generation !== value.generation ? old?.keys : []);
|
|
18016
|
+
for (const { change, receipt } of receipts) {
|
|
18017
|
+
if (receipt.outcome.case !== "admitted") continue;
|
|
18018
|
+
const key2 = `receipt:${workspace}:${sha256Hex6(change)}`;
|
|
18019
|
+
keys.delete(key2);
|
|
18020
|
+
keys.add(key2);
|
|
18021
|
+
discarded.delete(key2);
|
|
18022
|
+
const header2 = encoder.encode(`${JSON.stringify({ generation: value.generation, head: after })}
|
|
18023
|
+
`);
|
|
18024
|
+
const body = toBinary12(CustodyIntentAdmissionSchema, receipt);
|
|
18025
|
+
const bytes = new Uint8Array(header2.length + body.length);
|
|
18026
|
+
bytes.set(header2);
|
|
18027
|
+
bytes.set(body, header2.length);
|
|
18028
|
+
const record2 = this.#store.compareExchange(namespace, key2, this.#records.get(key2)?.revision, bytes);
|
|
18029
|
+
if (record2) this.#records.set(key2, record2);
|
|
18030
|
+
this.#receipts.set(key2, {
|
|
18031
|
+
generation: value.generation,
|
|
18032
|
+
head: after,
|
|
18033
|
+
receipt: fromBinary15(CustodyIntentAdmissionSchema, body)
|
|
18034
|
+
});
|
|
18035
|
+
}
|
|
18036
|
+
const ordered = [...keys];
|
|
18037
|
+
for (const key2 of ordered.slice(0, -MAX_RECEIPTS)) discarded.add(key2);
|
|
18038
|
+
value.keys = ordered.slice(-MAX_RECEIPTS);
|
|
18039
|
+
for (const key2 of discarded) {
|
|
18040
|
+
this.#store.compareExchange(namespace, key2, this.#records.get(key2)?.revision, void 0);
|
|
18041
|
+
this.#records.delete(key2);
|
|
18042
|
+
this.#receipts.delete(key2);
|
|
18043
|
+
}
|
|
18044
|
+
const record = this.#store.compareExchange(
|
|
18045
|
+
namespace,
|
|
18046
|
+
journalKey,
|
|
18047
|
+
this.#records.get(journalKey)?.revision,
|
|
18048
|
+
encoder.encode(JSON.stringify(value))
|
|
18049
|
+
);
|
|
18050
|
+
if (record) this.#records.set(journalKey, record);
|
|
18051
|
+
this.#journals.set(workspace, value);
|
|
18052
|
+
}
|
|
18053
|
+
};
|
|
18054
|
+
}
|
|
18055
|
+
});
|
|
18056
|
+
|
|
17913
18057
|
// ../peer-office/src/runtime/custodian_placement.ts
|
|
17914
|
-
import { create as create26, fromBinary as
|
|
18058
|
+
import { create as create26, fromBinary as fromBinary16, toBinary as toBinary13 } from "@bufbuild/protobuf";
|
|
17915
18059
|
var CustodianPlacement;
|
|
17916
18060
|
var init_custodian_placement = __esm({
|
|
17917
18061
|
"../peer-office/src/runtime/custodian_placement.ts"() {
|
|
@@ -17925,7 +18069,7 @@ var init_custodian_placement = __esm({
|
|
|
17925
18069
|
#clock;
|
|
17926
18070
|
#template;
|
|
17927
18071
|
constructor(kernel, clock, templateProtobuf) {
|
|
17928
|
-
const template =
|
|
18072
|
+
const template = fromBinary16(CustodyPlacementPolicySchema, templateProtobuf);
|
|
17929
18073
|
if (!template.declaration || !template.adoptedBy || template.rules.length === 0 || template.remotes.length === 0) {
|
|
17930
18074
|
throw new Error("custodian placement template requires a declaration, adoptedBy, rules and remotes");
|
|
17931
18075
|
}
|
|
@@ -17957,7 +18101,7 @@ var init_custodian_placement = __esm({
|
|
|
17957
18101
|
});
|
|
17958
18102
|
return create26(CustodyPlacementPolicySchema, {
|
|
17959
18103
|
...content,
|
|
17960
|
-
packageSha256: sha256Hex6(
|
|
18104
|
+
packageSha256: sha256Hex6(toBinary13(CustodyPlacementPolicySchema, content))
|
|
17961
18105
|
});
|
|
17962
18106
|
}
|
|
17963
18107
|
/** Adopt this custodian's placement for an opened, born workspace that has none. True when it adopted. */
|
|
@@ -18022,6 +18166,7 @@ var init_custody_admission_desk = __esm({
|
|
|
18022
18166
|
init_correspondence_desk_pb();
|
|
18023
18167
|
init_session_directory();
|
|
18024
18168
|
init_custody_return_delta();
|
|
18169
|
+
init_custody_receipts();
|
|
18025
18170
|
CandidateCustodyRequiredError = class extends Error {
|
|
18026
18171
|
workspace;
|
|
18027
18172
|
reference;
|
|
@@ -18035,14 +18180,16 @@ var init_custody_admission_desk = __esm({
|
|
|
18035
18180
|
CustodyAdmissionDesk = class {
|
|
18036
18181
|
#kernel;
|
|
18037
18182
|
#custody;
|
|
18038
|
-
|
|
18183
|
+
#receipts;
|
|
18184
|
+
constructor(kernel, custody, receipts = new CustodyReceipts()) {
|
|
18039
18185
|
this.#kernel = kernel;
|
|
18040
18186
|
this.#custody = custody;
|
|
18187
|
+
this.#receipts = receipts;
|
|
18041
18188
|
}
|
|
18042
18189
|
admit(request, command) {
|
|
18043
|
-
const
|
|
18044
|
-
if (!
|
|
18045
|
-
const mount = this.#custody.
|
|
18190
|
+
const workspace = request.target?.workspace;
|
|
18191
|
+
if (!workspace) throw new Error("custody admission requires an addressed workspace");
|
|
18192
|
+
const mount = this.#custody.mountForWorkspace(workspace);
|
|
18046
18193
|
if (command.evidencePack.byteLength > 0) {
|
|
18047
18194
|
this.#kernel.applyPack(mount, request.requestId, command.evidencePack);
|
|
18048
18195
|
}
|
|
@@ -18053,21 +18200,42 @@ var init_custody_admission_desk = __esm({
|
|
|
18053
18200
|
const births = [];
|
|
18054
18201
|
const admittedBase = this.#kernel.head(mount, request.requestId) ?? "";
|
|
18055
18202
|
if (command.fastForwardOnly && offers.length > 0 && (command.baseHead ?? "") !== admittedBase) {
|
|
18203
|
+
for (const offer of offers) {
|
|
18204
|
+
const receipt = this.#receipts.receipt(mount.workspace, admittedBase, offer.changeUsda);
|
|
18205
|
+
if (!receipt) continue;
|
|
18206
|
+
receipt.commitOid = offer.commitOid;
|
|
18207
|
+
const records = sessions.get(offer.session) ?? [];
|
|
18208
|
+
records.push(receipt);
|
|
18209
|
+
sessions.set(offer.session, records);
|
|
18210
|
+
}
|
|
18211
|
+
let delta = custodyReturnDelta(
|
|
18212
|
+
this.#kernel,
|
|
18213
|
+
mount,
|
|
18214
|
+
request.requestId,
|
|
18215
|
+
command.baseHead,
|
|
18216
|
+
admittedBase,
|
|
18217
|
+
admittedBase,
|
|
18218
|
+
command.observedHead
|
|
18219
|
+
);
|
|
18220
|
+
if (command.baseHead && command.observedHead !== admittedBase && this.#receipts.covers(mount.workspace, admittedBase, command.baseHead)) {
|
|
18221
|
+
try {
|
|
18222
|
+
delta = {
|
|
18223
|
+
resultBase: command.baseHead,
|
|
18224
|
+
resultPack: this.#kernel.packDelta(mount, request.requestId, admittedBase, command.baseHead),
|
|
18225
|
+
recoveryRequired: false
|
|
18226
|
+
};
|
|
18227
|
+
} catch {
|
|
18228
|
+
}
|
|
18229
|
+
}
|
|
18056
18230
|
return create27(CustodyAdmissionSchema, {
|
|
18057
18231
|
main: admittedBase,
|
|
18058
|
-
...
|
|
18059
|
-
|
|
18060
|
-
mount,
|
|
18061
|
-
request.requestId,
|
|
18062
|
-
command.baseHead,
|
|
18063
|
-
admittedBase,
|
|
18064
|
-
admittedBase,
|
|
18065
|
-
command.observedHead
|
|
18066
|
-
)
|
|
18232
|
+
sessions: [...sessions].map(([session, intents]) => create27(CustodySessionAdmissionSchema, { session, intents })),
|
|
18233
|
+
...delta
|
|
18067
18234
|
});
|
|
18068
18235
|
}
|
|
18069
18236
|
let main2 = admittedBase;
|
|
18070
18237
|
const heldSessions = /* @__PURE__ */ new Map();
|
|
18238
|
+
const receipts = [];
|
|
18071
18239
|
for (const offer of offers) {
|
|
18072
18240
|
const heldBehind = heldSessions.get(offer.session);
|
|
18073
18241
|
const verdict = heldBehind === void 0 ? this.#offer(request, mount, offer) : create27(OfferResponseSchema, { outcome: { case: "blockedOnDependency", value: {
|
|
@@ -18077,7 +18245,9 @@ var init_custody_admission_desk = __esm({
|
|
|
18077
18245
|
heldSessions.set(offer.session, verdict.outcome.value.offerId || offer.commitOid);
|
|
18078
18246
|
}
|
|
18079
18247
|
const records = sessions.get(offer.session) ?? [];
|
|
18080
|
-
|
|
18248
|
+
const receipt = this.#record(offer, verdict);
|
|
18249
|
+
records.push(receipt);
|
|
18250
|
+
receipts.push({ change: offer.changeUsda, receipt });
|
|
18081
18251
|
sessions.set(offer.session, records);
|
|
18082
18252
|
if (verdict.outcome.case === "admitted") {
|
|
18083
18253
|
main2 = verdict.outcome.value.head;
|
|
@@ -18093,6 +18263,9 @@ var init_custody_admission_desk = __esm({
|
|
|
18093
18263
|
}
|
|
18094
18264
|
}
|
|
18095
18265
|
}
|
|
18266
|
+
if (receipts.some((entry) => entry.receipt.outcome.case === "admitted")) {
|
|
18267
|
+
this.#receipts.record(mount.workspace, admittedBase, main2, receipts);
|
|
18268
|
+
}
|
|
18096
18269
|
return create27(CustodyAdmissionSchema, {
|
|
18097
18270
|
main: main2,
|
|
18098
18271
|
sessions: [...sessions].map(
|
|
@@ -19111,7 +19284,7 @@ var init_application_readiness_desk = __esm({
|
|
|
19111
19284
|
});
|
|
19112
19285
|
|
|
19113
19286
|
// ../peer-office/src/runtime/authentication_readiness_desk.ts
|
|
19114
|
-
import { create as create35, fromBinary as
|
|
19287
|
+
import { create as create35, fromBinary as fromBinary17, toBinary as toBinary14 } from "@bufbuild/protobuf";
|
|
19115
19288
|
var AuthenticationReadinessDesk;
|
|
19116
19289
|
var init_authentication_readiness_desk = __esm({
|
|
19117
19290
|
"../peer-office/src/runtime/authentication_readiness_desk.ts"() {
|
|
@@ -19134,7 +19307,7 @@ var init_authentication_readiness_desk = __esm({
|
|
|
19134
19307
|
begin(request, input) {
|
|
19135
19308
|
if (![AuthenticationReadinessCriterion.ENROLLED_DEVICE, AuthenticationReadinessCriterion.PROVIDER_TOKEN, AuthenticationReadinessCriterion.BIRTH_EVIDENCE].includes(input.criterion)) throw new Error("authentication readiness requires a criterion");
|
|
19136
19309
|
if (!input.session) throw new Error("authentication readiness requires a session");
|
|
19137
|
-
const command =
|
|
19310
|
+
const command = fromBinary17(AwaitAuthenticationRequestSchema, toBinary14(AwaitAuthenticationRequestSchema, input));
|
|
19138
19311
|
const now = this.#now();
|
|
19139
19312
|
for (const [id2, work2] of this.#waiting) if (work2.expiresAt <= now) this.#waiting.delete(id2);
|
|
19140
19313
|
const work = {
|
|
@@ -19924,7 +20097,7 @@ var init_residency_pins = __esm({
|
|
|
19924
20097
|
});
|
|
19925
20098
|
|
|
19926
20099
|
// ../peer-office/src/runtime/subscription_manager.ts
|
|
19927
|
-
import { clone, create as create40, toBinary as
|
|
20100
|
+
import { clone, create as create40, toBinary as toBinary15 } from "@bufbuild/protobuf";
|
|
19928
20101
|
function createSyntheticRequest(requestId) {
|
|
19929
20102
|
return create40(RuntimeRequestSchema, {
|
|
19930
20103
|
protocolVersion: 2,
|
|
@@ -20068,7 +20241,7 @@ var init_subscription_manager = __esm({
|
|
|
20068
20241
|
const groups = [];
|
|
20069
20242
|
for (const subscription of this.#subscriptions.values()) {
|
|
20070
20243
|
if (!matches(subscription) || !subscription.request.query) continue;
|
|
20071
|
-
const declaration =
|
|
20244
|
+
const declaration = toBinary15(QueryRequestSchema, subscription.request.query);
|
|
20072
20245
|
const session = subscription.request.session;
|
|
20073
20246
|
const group = groups.find((group2) => group2.session === session && sameBytes(group2.declaration, declaration));
|
|
20074
20247
|
if (group) group.watches.push(subscription);
|
|
@@ -21218,14 +21391,14 @@ var init_local_copy_drop = __esm({
|
|
|
21218
21391
|
|
|
21219
21392
|
// ../peer-office/src/runtime/preserved_copies_desk.ts
|
|
21220
21393
|
import { create as create42, fromJsonString, toJsonString } from "@bufbuild/protobuf";
|
|
21221
|
-
var PRESERVED_COPIES_NAMESPACE,
|
|
21394
|
+
var PRESERVED_COPIES_NAMESPACE, encoder2, decoder2, PreservedCopiesDesk;
|
|
21222
21395
|
var init_preserved_copies_desk = __esm({
|
|
21223
21396
|
"../peer-office/src/runtime/preserved_copies_desk.ts"() {
|
|
21224
21397
|
"use strict";
|
|
21225
21398
|
init_custody_desk_pb();
|
|
21226
21399
|
PRESERVED_COPIES_NAMESPACE = "nomos.peer-desk.preserved-local-copies/v1";
|
|
21227
|
-
|
|
21228
|
-
|
|
21400
|
+
encoder2 = new TextEncoder();
|
|
21401
|
+
decoder2 = new TextDecoder();
|
|
21229
21402
|
PreservedCopiesDesk = class {
|
|
21230
21403
|
#store;
|
|
21231
21404
|
constructor(store) {
|
|
@@ -21234,7 +21407,7 @@ var init_preserved_copies_desk = __esm({
|
|
|
21234
21407
|
list(workspace) {
|
|
21235
21408
|
const record = this.#store.list(PRESERVED_COPIES_NAMESPACE).find((entry) => entry.key === workspace);
|
|
21236
21409
|
if (!record) return [];
|
|
21237
|
-
const values = JSON.parse(
|
|
21410
|
+
const values = JSON.parse(decoder2.decode(record.value));
|
|
21238
21411
|
if (!Array.isArray(values)) {
|
|
21239
21412
|
throw new Error(`corrupt preserved-copy record for '${workspace}' at revision ${record.revision}`);
|
|
21240
21413
|
}
|
|
@@ -21248,7 +21421,7 @@ var init_preserved_copies_desk = __esm({
|
|
|
21248
21421
|
PRESERVED_COPIES_NAMESPACE,
|
|
21249
21422
|
copy3.workspace,
|
|
21250
21423
|
current?.revision,
|
|
21251
|
-
|
|
21424
|
+
encoder2.encode(`[${next.map((entry) => toJsonString(PreservedLocalCopySchema, entry)).join(",")}]`)
|
|
21252
21425
|
);
|
|
21253
21426
|
if (!stored) throw new Error(`preserved copy of '${copy3.workspace}' was not recorded`);
|
|
21254
21427
|
}
|
|
@@ -21257,7 +21430,7 @@ var init_preserved_copies_desk = __esm({
|
|
|
21257
21430
|
});
|
|
21258
21431
|
|
|
21259
21432
|
// ../peer-office/src/runtime/office_seat.ts
|
|
21260
|
-
import { fromBinary as
|
|
21433
|
+
import { fromBinary as fromBinary18 } from "@bufbuild/protobuf";
|
|
21261
21434
|
function officeSeat(profile) {
|
|
21262
21435
|
const origins = /* @__PURE__ */ new Set();
|
|
21263
21436
|
const add = (url) => {
|
|
@@ -21267,7 +21440,7 @@ function officeSeat(profile) {
|
|
|
21267
21440
|
add(profile.liveRelayOrigin);
|
|
21268
21441
|
if (profile.custodianPlacement !== void 0 && profile.custodianPlacement.byteLength > 0) {
|
|
21269
21442
|
try {
|
|
21270
|
-
for (const remote of
|
|
21443
|
+
for (const remote of fromBinary18(CustodyPlacementPolicySchema, profile.custodianPlacement).remotes) {
|
|
21271
21444
|
add(remote.url);
|
|
21272
21445
|
}
|
|
21273
21446
|
} catch {
|
|
@@ -21297,7 +21470,7 @@ import { create as create43 } from "@bufbuild/protobuf";
|
|
|
21297
21470
|
function readSeal(value) {
|
|
21298
21471
|
const headerLength = SEAT_PREFIX.length + SEAT_DIGEST_HEX + 1;
|
|
21299
21472
|
if (value.byteLength < headerLength) return void 0;
|
|
21300
|
-
const text2 =
|
|
21473
|
+
const text2 = decoder3.decode(value.subarray(0, headerLength));
|
|
21301
21474
|
if (!text2.startsWith(SEAT_PREFIX) || !text2.endsWith("\n")) return void 0;
|
|
21302
21475
|
const seat = text2.slice(SEAT_PREFIX.length, headerLength - 1);
|
|
21303
21476
|
if (!/^[0-9a-f]{64}$/.test(seat)) return void 0;
|
|
@@ -21310,7 +21483,7 @@ function seal(digest, value) {
|
|
|
21310
21483
|
sealed.set(value, prefix.byteLength);
|
|
21311
21484
|
return sealed;
|
|
21312
21485
|
}
|
|
21313
|
-
var QUARANTINED_BINDINGS_NAMESPACE, LOCAL_ONLY_NAMESPACES, SEAT_PREFIX, SEAT_DIGEST_HEX,
|
|
21486
|
+
var QUARANTINED_BINDINGS_NAMESPACE, LOCAL_ONLY_NAMESPACES, SEAT_PREFIX, SEAT_DIGEST_HEX, encoder3, decoder3, header, QuarantineReason, SeatedPeerDeskStore;
|
|
21314
21487
|
var init_seated_peer_desk_store = __esm({
|
|
21315
21488
|
"../peer-office/src/runtime/seated_peer_desk_store.ts"() {
|
|
21316
21489
|
"use strict";
|
|
@@ -21323,9 +21496,9 @@ var init_seated_peer_desk_store = __esm({
|
|
|
21323
21496
|
]);
|
|
21324
21497
|
SEAT_PREFIX = "nomos-office-seat/v1:";
|
|
21325
21498
|
SEAT_DIGEST_HEX = 64;
|
|
21326
|
-
|
|
21327
|
-
|
|
21328
|
-
header = (digest) =>
|
|
21499
|
+
encoder3 = new TextEncoder();
|
|
21500
|
+
decoder3 = new TextDecoder();
|
|
21501
|
+
header = (digest) => encoder3.encode(`${SEAT_PREFIX}${digest}
|
|
21329
21502
|
`);
|
|
21330
21503
|
QuarantineReason = Object.freeze({
|
|
21331
21504
|
/** Another office's seat: a copied state directory, or a store lifted from another peer. */
|
|
@@ -21344,44 +21517,44 @@ var init_seated_peer_desk_store = __esm({
|
|
|
21344
21517
|
this.#seat = seat;
|
|
21345
21518
|
this.#report = report;
|
|
21346
21519
|
}
|
|
21347
|
-
list(
|
|
21348
|
-
if (LOCAL_ONLY_NAMESPACES.has(
|
|
21520
|
+
list(namespace2) {
|
|
21521
|
+
if (LOCAL_ONLY_NAMESPACES.has(namespace2)) return this.#inner.list(namespace2);
|
|
21349
21522
|
const kept = [];
|
|
21350
|
-
for (const record of this.#inner.list(
|
|
21523
|
+
for (const record of this.#inner.list(namespace2)) {
|
|
21351
21524
|
const sealed = readSeal(record.value);
|
|
21352
21525
|
if (sealed?.seat === this.#seat.digest) {
|
|
21353
21526
|
kept.push({ ...record, value: sealed.value.slice() });
|
|
21354
21527
|
continue;
|
|
21355
21528
|
}
|
|
21356
|
-
this.#quarantine(
|
|
21529
|
+
this.#quarantine(namespace2, record, sealed?.seat);
|
|
21357
21530
|
}
|
|
21358
21531
|
return kept;
|
|
21359
21532
|
}
|
|
21360
|
-
compareExchange(
|
|
21361
|
-
if (LOCAL_ONLY_NAMESPACES.has(
|
|
21362
|
-
return this.#inner.compareExchange(
|
|
21533
|
+
compareExchange(namespace2, key2, expectedRevision, value) {
|
|
21534
|
+
if (LOCAL_ONLY_NAMESPACES.has(namespace2)) {
|
|
21535
|
+
return this.#inner.compareExchange(namespace2, key2, expectedRevision, value);
|
|
21363
21536
|
}
|
|
21364
21537
|
const stored = this.#inner.compareExchange(
|
|
21365
|
-
|
|
21538
|
+
namespace2,
|
|
21366
21539
|
key2,
|
|
21367
21540
|
expectedRevision,
|
|
21368
21541
|
value === void 0 ? void 0 : seal(this.#seat.digest, value)
|
|
21369
21542
|
);
|
|
21370
21543
|
if (stored === void 0) return void 0;
|
|
21371
21544
|
const sealed = readSeal(stored.value);
|
|
21372
|
-
if (!sealed) throw new Error(`peer desk record '${
|
|
21545
|
+
if (!sealed) throw new Error(`peer desk record '${namespace2}/${key2}' lost its office seat`);
|
|
21373
21546
|
return { ...stored, value: sealed.value.slice() };
|
|
21374
21547
|
}
|
|
21375
21548
|
/** Preserve the foreign record under the quarantine namespace, then free the slot. */
|
|
21376
|
-
#quarantine(
|
|
21377
|
-
const key2 = `${
|
|
21549
|
+
#quarantine(namespace2, record, recordedSeat) {
|
|
21550
|
+
const key2 = `${namespace2}\0${record.key}\0${record.revision}`;
|
|
21378
21551
|
try {
|
|
21379
21552
|
this.#inner.compareExchange(QUARANTINED_BINDINGS_NAMESPACE, key2, void 0, record.value);
|
|
21380
21553
|
} catch {
|
|
21381
21554
|
}
|
|
21382
|
-
this.#inner.compareExchange(
|
|
21555
|
+
this.#inner.compareExchange(namespace2, record.key, record.revision, void 0);
|
|
21383
21556
|
this.#report(create43(QuarantinedBindingSchema, {
|
|
21384
|
-
namespace,
|
|
21557
|
+
namespace: namespace2,
|
|
21385
21558
|
key: record.key,
|
|
21386
21559
|
reason: recordedSeat === void 0 ? QuarantineReason.Unseated : QuarantineReason.ForeignSeat,
|
|
21387
21560
|
recordedSeat: recordedSeat ?? "",
|
|
@@ -21440,6 +21613,7 @@ var init_replica_inventory_desk = __esm({
|
|
|
21440
21613
|
const undiscovered = /* @__PURE__ */ new Set();
|
|
21441
21614
|
for (const restored of this.#follows.recover()) {
|
|
21442
21615
|
following.set(restored.workspace, restored.delayMillis);
|
|
21616
|
+
followed.add(restored.workspace);
|
|
21443
21617
|
}
|
|
21444
21618
|
if (!this.#bootstrapped) {
|
|
21445
21619
|
this.#bootstrapped = true;
|
|
@@ -21477,6 +21651,7 @@ var init_replica_inventory_desk = __esm({
|
|
|
21477
21651
|
stopped.delete(workspace);
|
|
21478
21652
|
} else if (reconciliation.changed) {
|
|
21479
21653
|
following.delete(workspace);
|
|
21654
|
+
followed.delete(workspace);
|
|
21480
21655
|
stopped.add(workspace);
|
|
21481
21656
|
}
|
|
21482
21657
|
} catch (error) {
|
|
@@ -21620,7 +21795,7 @@ var init_correspondence_work_registry = __esm({
|
|
|
21620
21795
|
});
|
|
21621
21796
|
|
|
21622
21797
|
// ../peer-office/src/runtime/placement_discovery_desk.ts
|
|
21623
|
-
import { create as create44, toBinary as
|
|
21798
|
+
import { create as create44, toBinary as toBinary16 } from "@bufbuild/protobuf";
|
|
21624
21799
|
var DiscoveryPhase, PlacementDiscoveryDesk;
|
|
21625
21800
|
var init_placement_discovery_desk = __esm({
|
|
21626
21801
|
"../peer-office/src/runtime/placement_discovery_desk.ts"() {
|
|
@@ -21681,7 +21856,7 @@ var init_placement_discovery_desk = __esm({
|
|
|
21681
21856
|
return {
|
|
21682
21857
|
workspace: next.workspace,
|
|
21683
21858
|
nextAfterMillis: 0,
|
|
21684
|
-
frame:
|
|
21859
|
+
frame: toBinary16(RuntimeRequestSchema, create44(RuntimeRequestSchema, {
|
|
21685
21860
|
protocolVersion: 2,
|
|
21686
21861
|
requestId,
|
|
21687
21862
|
command: { case: "workspacePlacement", value: {
|
|
@@ -21768,7 +21943,7 @@ var init_placement_discovery_desk = __esm({
|
|
|
21768
21943
|
});
|
|
21769
21944
|
|
|
21770
21945
|
// ../peer-office/src/runtime/live_correspondence_desk.ts
|
|
21771
|
-
import { create as create45, fromBinary as
|
|
21946
|
+
import { create as create45, fromBinary as fromBinary19, toBinary as toBinary17 } from "@bufbuild/protobuf";
|
|
21772
21947
|
function presencePeerToken(replicaId2) {
|
|
21773
21948
|
return sha256Hex6(new TextEncoder().encode(`nomos-presence-peer:${replicaId2}`)).slice(0, PRESENCE_PEER_TOKEN_HEX);
|
|
21774
21949
|
}
|
|
@@ -21832,7 +22007,7 @@ var init_live_correspondence_desk = __esm({
|
|
|
21832
22007
|
wasResident: this.kernel.isResident(binding.workspace) !== false
|
|
21833
22008
|
};
|
|
21834
22009
|
this.#links.set(binding.workspace, link);
|
|
21835
|
-
if (link.wasResident) this.#open(link);
|
|
22010
|
+
if (!link.publisher || link.wasResident) this.#open(link);
|
|
21836
22011
|
}
|
|
21837
22012
|
changed(workspace) {
|
|
21838
22013
|
const link = this.#links.get(workspace);
|
|
@@ -21854,11 +22029,14 @@ var init_live_correspondence_desk = __esm({
|
|
|
21854
22029
|
this.#effect(link, { case: "openUrl", value: `${endpoint}/v2/workspaces/${encodeURIComponent(link.binding.workspace)}/subscribe?${subscribeQuery(link)}` });
|
|
21855
22030
|
}
|
|
21856
22031
|
#send(link, message) {
|
|
21857
|
-
const bytes =
|
|
22032
|
+
const bytes = toBinary17(LiveOfferFrameSchema, create45(LiveOfferFrameSchema, { message }));
|
|
21858
22033
|
if (bytes.byteLength > MAX_LIVE_FRAME_BYTES) return;
|
|
21859
22034
|
this.#effect(link, { case: "send", value: bytes });
|
|
21860
22035
|
}
|
|
21861
22036
|
export(binding, base, requestId) {
|
|
22037
|
+
if (this.kernel.isResident(binding.workspace) === false) {
|
|
22038
|
+
return create45(CustodyOfferBatchRequestSchema, { protocolVersion: 2 });
|
|
22039
|
+
}
|
|
21862
22040
|
const mount = workspaceMount(binding.workspace);
|
|
21863
22041
|
const head = this.kernel.head(mount, requestId);
|
|
21864
22042
|
if (!base || !head || base === head) return create45(CustodyOfferBatchRequestSchema, { protocolVersion: 2 });
|
|
@@ -21904,7 +22082,7 @@ var init_live_correspondence_desk = __esm({
|
|
|
21904
22082
|
if (!bytes.byteLength || bytes.byteLength > MAX_LIVE_FRAME_BYTES) return;
|
|
21905
22083
|
let frame;
|
|
21906
22084
|
try {
|
|
21907
|
-
frame =
|
|
22085
|
+
frame = fromBinary19(LiveOfferFrameSchema, bytes);
|
|
21908
22086
|
} catch {
|
|
21909
22087
|
let ring;
|
|
21910
22088
|
try {
|
|
@@ -21919,6 +22097,7 @@ var init_live_correspondence_desk = __esm({
|
|
|
21919
22097
|
}
|
|
21920
22098
|
if (frame.message.case === "frontier") {
|
|
21921
22099
|
this.#announced(link, frame.message.value.head);
|
|
22100
|
+
if (this.kernel.isResident(link.binding.workspace) === false) return;
|
|
21922
22101
|
if (!frame.message.value.response) {
|
|
21923
22102
|
this.#send(link, { case: "frontier", value: {
|
|
21924
22103
|
head: this.kernel.head(workspaceMount(link.binding.workspace), ++this.#requestId) ?? "",
|
|
@@ -21935,6 +22114,10 @@ var init_live_correspondence_desk = __esm({
|
|
|
21935
22114
|
if (frame.message.case !== "offers") return;
|
|
21936
22115
|
const batch = frame.message.value;
|
|
21937
22116
|
if (batch.protocolVersion !== 2 || !batch.requestId || batch.source.case !== "inline" || !batch.source.value.offers.length) return;
|
|
22117
|
+
if (this.kernel.isResident(link.binding.workspace) === false) {
|
|
22118
|
+
this.remoteAdvanced?.(link.binding.workspace);
|
|
22119
|
+
return;
|
|
22120
|
+
}
|
|
21938
22121
|
if ([...this.#pending.values()].some((pending) => pending.link === link && pending.bytes.length === bytes.length && pending.bytes.every((byte, index) => byte === bytes[index]))) return;
|
|
21939
22122
|
if (this.#pending.size >= 32) return;
|
|
21940
22123
|
this.#pending.set(request.requestId, { link, bytes });
|
|
@@ -21942,7 +22125,16 @@ var init_live_correspondence_desk = __esm({
|
|
|
21942
22125
|
protocolVersion: 2,
|
|
21943
22126
|
requestId: request.requestId,
|
|
21944
22127
|
target: { workspace: link.binding.workspace, session: link.binding.replicaId },
|
|
21945
|
-
|
|
22128
|
+
// HTTP sender reconciliation controls are not part of a live proposal.
|
|
22129
|
+
// Keeping fastForwardOnly while removing baseHead silently skips every
|
|
22130
|
+
// offer against a nonempty local head. The Kernel judges sealed causality;
|
|
22131
|
+
// live receivers neither ask for a return archive nor confirm the sender.
|
|
22132
|
+
command: { case: "admitCustodyOffers", value: create45(CustodyOfferBatchRequestSchema, {
|
|
22133
|
+
...batch,
|
|
22134
|
+
baseHead: void 0,
|
|
22135
|
+
observedHead: void 0,
|
|
22136
|
+
fastForwardOnly: false
|
|
22137
|
+
}) }
|
|
21946
22138
|
});
|
|
21947
22139
|
}
|
|
21948
22140
|
/** Upstream news is a frontier this replica has NEVER seen: neither its own head nor the
|
|
@@ -21951,6 +22143,10 @@ var init_live_correspondence_desk = __esm({
|
|
|
21951
22143
|
#announced(link, head) {
|
|
21952
22144
|
if (!head || link.lastAnnounced === head) return;
|
|
21953
22145
|
link.lastAnnounced = head;
|
|
22146
|
+
if (this.kernel.isResident(link.binding.workspace) === false) {
|
|
22147
|
+
this.remoteAdvanced?.(link.binding.workspace);
|
|
22148
|
+
return;
|
|
22149
|
+
}
|
|
21954
22150
|
const mount = workspaceMount(link.binding.workspace);
|
|
21955
22151
|
if (head === this.kernel.head(mount, ++this.#requestId) || head === this.kernel.resolveRef(mount, ++this.#requestId, "refs/remotes/nomos/main")) return;
|
|
21956
22152
|
this.remoteAdvanced?.(link.binding.workspace);
|
|
@@ -21960,6 +22156,10 @@ var init_live_correspondence_desk = __esm({
|
|
|
21960
22156
|
#placementAnnounced(link, frontier) {
|
|
21961
22157
|
if (!frontier || link.lastPlacementAnnounced === frontier) return;
|
|
21962
22158
|
link.lastPlacementAnnounced = frontier;
|
|
22159
|
+
if (this.kernel.isResident(link.binding.workspace) === false) {
|
|
22160
|
+
this.placementAdvanced?.(link.binding.workspace);
|
|
22161
|
+
return;
|
|
22162
|
+
}
|
|
21963
22163
|
const mount = workspaceMount(link.binding.workspace);
|
|
21964
22164
|
if (frontier === this.kernel.resolveRef(mount, ++this.#requestId, PLACEMENT_REF2)) return;
|
|
21965
22165
|
this.placementAdvanced?.(link.binding.workspace);
|
|
@@ -21976,11 +22176,13 @@ var init_live_correspondence_desk = __esm({
|
|
|
21976
22176
|
disconnect(workspace) {
|
|
21977
22177
|
const link = this.#links.get(workspace);
|
|
21978
22178
|
if (!link) return;
|
|
22179
|
+
if (link.state === "open") this.linkClosed?.(workspace);
|
|
21979
22180
|
this.#effect(link, { case: "close", value: true });
|
|
21980
22181
|
this.#links.delete(workspace);
|
|
21981
22182
|
for (const [id, pending] of this.#pending) if (pending.link === link) this.#pending.delete(id);
|
|
21982
22183
|
}
|
|
21983
22184
|
#hello(link) {
|
|
22185
|
+
if (this.kernel.isResident(link.binding.workspace) === false) return;
|
|
21984
22186
|
const head = this.kernel.head(workspaceMount(link.binding.workspace), ++this.#requestId);
|
|
21985
22187
|
this.#send(link, { case: "frontier", value: { head: head ?? "" } });
|
|
21986
22188
|
}
|
|
@@ -21988,19 +22190,20 @@ var init_live_correspondence_desk = __esm({
|
|
|
21988
22190
|
const now = this.clock.monotonicNanoseconds();
|
|
21989
22191
|
let wake;
|
|
21990
22192
|
for (const link of this.#links.values()) {
|
|
21991
|
-
|
|
22193
|
+
const resident = this.kernel.isResident(link.binding.workspace) !== false;
|
|
22194
|
+
if (link.publisher && !resident) {
|
|
21992
22195
|
if (link.wasResident) this.disconnect(link.binding.workspace);
|
|
21993
22196
|
else wake = wake === void 0 || wake > 250n ? 250n : wake;
|
|
21994
22197
|
continue;
|
|
21995
22198
|
}
|
|
21996
|
-
link.wasResident = true;
|
|
22199
|
+
if (resident) link.wasResident = true;
|
|
21997
22200
|
if (link.state === "opening" && now >= link.due) {
|
|
21998
22201
|
this.#effect(link, { case: "close", value: true });
|
|
21999
22202
|
link.state = "closed";
|
|
22000
22203
|
}
|
|
22001
22204
|
if (link.state === "closed" && now >= link.due) this.#open(link);
|
|
22002
22205
|
if (link.state === "open") {
|
|
22003
|
-
if (link.dirty) {
|
|
22206
|
+
if (link.dirty && resident) {
|
|
22004
22207
|
link.dirty = false;
|
|
22005
22208
|
try {
|
|
22006
22209
|
link.published ??= link.publisher ? this.kernel.head(workspaceMount(link.binding.workspace), ++this.#requestId) : this.kernel.resolveRef(workspaceMount(link.binding.workspace), ++this.#requestId, "refs/remotes/nomos/main");
|
|
@@ -22019,8 +22222,7 @@ var init_live_correspondence_desk = __esm({
|
|
|
22019
22222
|
return wake;
|
|
22020
22223
|
}
|
|
22021
22224
|
close() {
|
|
22022
|
-
for (const
|
|
22023
|
-
this.#links.clear();
|
|
22225
|
+
for (const workspace of [...this.#links.keys()]) this.disconnect(workspace);
|
|
22024
22226
|
this.#pending.clear();
|
|
22025
22227
|
}
|
|
22026
22228
|
};
|
|
@@ -22192,9 +22394,9 @@ var init_records_desk = __esm({
|
|
|
22192
22394
|
command.namespace === void 0 ? {} : { "custody.children_namespace": command.namespace },
|
|
22193
22395
|
() => this.#kernel.childWorkspaces(mount, request.requestId)
|
|
22194
22396
|
);
|
|
22195
|
-
const
|
|
22196
|
-
const selected =
|
|
22197
|
-
(child) => child.status === ChildWorkspaceLifecycleStatus.ACTIVE && isKeyedBirthOf(
|
|
22397
|
+
const namespace2 = command.namespace;
|
|
22398
|
+
const selected = namespace2 === void 0 ? result.children : result.children.filter(
|
|
22399
|
+
(child) => child.status === ChildWorkspaceLifecycleStatus.ACTIVE && isKeyedBirthOf(namespace2, child.workspace)
|
|
22198
22400
|
);
|
|
22199
22401
|
return create47(ChildWorkspaceListSchema, {
|
|
22200
22402
|
children: selected.map((child) => create47(ChildWorkspaceSchema, {
|
|
@@ -22564,46 +22766,6 @@ var init_recovery_desk = __esm({
|
|
|
22564
22766
|
}
|
|
22565
22767
|
});
|
|
22566
22768
|
|
|
22567
|
-
// ../peer-office/src/runtime/peer_desk_store.ts
|
|
22568
|
-
var recordId, copy2, MemoryPeerDeskStore;
|
|
22569
|
-
var init_peer_desk_store = __esm({
|
|
22570
|
-
"../peer-office/src/runtime/peer_desk_store.ts"() {
|
|
22571
|
-
"use strict";
|
|
22572
|
-
recordId = (namespace, key2) => `${namespace.length}:${namespace}${key2}`;
|
|
22573
|
-
copy2 = (record) => ({
|
|
22574
|
-
...record,
|
|
22575
|
-
value: record.value.slice()
|
|
22576
|
-
});
|
|
22577
|
-
MemoryPeerDeskStore = class {
|
|
22578
|
-
#records = /* @__PURE__ */ new Map();
|
|
22579
|
-
list(namespace) {
|
|
22580
|
-
return [...this.#records.values()].filter((record) => record.namespace === namespace).sort((left, right) => left.key.localeCompare(right.key)).map(copy2);
|
|
22581
|
-
}
|
|
22582
|
-
compareExchange(namespace, key2, expectedRevision, value) {
|
|
22583
|
-
const id = recordId(namespace, key2);
|
|
22584
|
-
const current = this.#records.get(id);
|
|
22585
|
-
if (current?.revision !== expectedRevision) {
|
|
22586
|
-
throw new Error(
|
|
22587
|
-
`peer desk record '${namespace}/${key2}' changed at revision ${current?.revision ?? "absent"}`
|
|
22588
|
-
);
|
|
22589
|
-
}
|
|
22590
|
-
if (value === void 0) {
|
|
22591
|
-
this.#records.delete(id);
|
|
22592
|
-
return void 0;
|
|
22593
|
-
}
|
|
22594
|
-
const next = Object.freeze({
|
|
22595
|
-
namespace,
|
|
22596
|
-
key: key2,
|
|
22597
|
-
revision: (current?.revision ?? 0n) + 1n,
|
|
22598
|
-
value: value.slice()
|
|
22599
|
-
});
|
|
22600
|
-
this.#records.set(id, next);
|
|
22601
|
-
return copy2(next);
|
|
22602
|
-
}
|
|
22603
|
-
};
|
|
22604
|
-
}
|
|
22605
|
-
});
|
|
22606
|
-
|
|
22607
22769
|
// ../peer-office/src/runtime/correspondence_recovery.ts
|
|
22608
22770
|
import { create as create51 } from "@bufbuild/protobuf";
|
|
22609
22771
|
var CorrespondenceRecoveryWork;
|
|
@@ -22789,7 +22951,7 @@ var init_custody_replacement = __esm({
|
|
|
22789
22951
|
});
|
|
22790
22952
|
|
|
22791
22953
|
// ../peer-office/src/runtime/custody_offer.ts
|
|
22792
|
-
import { create as create54, fromBinary as
|
|
22954
|
+
import { create as create54, fromBinary as fromBinary20, toBinary as toBinary18 } from "@bufbuild/protobuf";
|
|
22793
22955
|
function settleCustodyOfferExchange(awaiting, response) {
|
|
22794
22956
|
if (response.status === 202 && response.contentType?.includes("application/json")) {
|
|
22795
22957
|
try {
|
|
@@ -22819,7 +22981,7 @@ function settleCustodyOfferExchange(awaiting, response) {
|
|
|
22819
22981
|
}
|
|
22820
22982
|
}
|
|
22821
22983
|
function encodeInlineCustodyOffer(args) {
|
|
22822
|
-
return
|
|
22984
|
+
return toBinary18(CustodyOfferBatchRequestSchema, create54(CustodyOfferBatchRequestSchema, {
|
|
22823
22985
|
protocolVersion: 2,
|
|
22824
22986
|
requestId: args.requestId,
|
|
22825
22987
|
source: {
|
|
@@ -22839,7 +23001,7 @@ function encodeInlineCustodyOffer(args) {
|
|
|
22839
23001
|
}));
|
|
22840
23002
|
}
|
|
22841
23003
|
function decodeCustodyOffer(bytes, requestId) {
|
|
22842
|
-
const response =
|
|
23004
|
+
const response = fromBinary20(CustodyOfferBatchResponseSchema, bytes);
|
|
22843
23005
|
if (response.protocolVersion !== 2 || response.requestId !== requestId) {
|
|
22844
23006
|
throw new Error("custody offer returned a mismatched generated response");
|
|
22845
23007
|
}
|
|
@@ -22951,7 +23113,7 @@ var init_custody_offer = __esm({
|
|
|
22951
23113
|
});
|
|
22952
23114
|
|
|
22953
23115
|
// ../peer-office/src/runtime/workspace_sync.ts
|
|
22954
|
-
import { create as create55, fromBinary as
|
|
23116
|
+
import { create as create55, fromBinary as fromBinary21 } from "@bufbuild/protobuf";
|
|
22955
23117
|
function releaseSyncJudgment(workspace) {
|
|
22956
23118
|
judgedThisLifetime.delete(workspace);
|
|
22957
23119
|
}
|
|
@@ -23030,6 +23192,7 @@ var init_workspace_sync = __esm({
|
|
|
23030
23192
|
#offerSequence = 0;
|
|
23031
23193
|
#lastStep;
|
|
23032
23194
|
#probeOnly;
|
|
23195
|
+
#liveConnected;
|
|
23033
23196
|
/** Set when this round adopted the upstream's own head as its base (see #establishBase). */
|
|
23034
23197
|
#establishedBase;
|
|
23035
23198
|
#receiveState;
|
|
@@ -23062,6 +23225,7 @@ var init_workspace_sync = __esm({
|
|
|
23062
23225
|
this.#directoryAnswered = args.directoryAnswered;
|
|
23063
23226
|
this.#placementFetched = args.placementFetched;
|
|
23064
23227
|
this.#probeOnly = args.probeOnly ?? false;
|
|
23228
|
+
this.#liveConnected = args.liveConnected === true;
|
|
23065
23229
|
this.#receiveState = args.receiveState;
|
|
23066
23230
|
this.#completeHistory = args.completeHistory === true;
|
|
23067
23231
|
this.#repairMissingCommit = args.repairMissingCommit === true;
|
|
@@ -23132,6 +23296,9 @@ var init_workspace_sync = __esm({
|
|
|
23132
23296
|
#openRound() {
|
|
23133
23297
|
if (this.#receiveState || this.#replaceLocalHead !== void 0) return this.#leaseEffect();
|
|
23134
23298
|
if (!this.#localHead) return this.#leaseEffect();
|
|
23299
|
+
if (this.#liveConnected && !this.#probeOnly && this.#holdsLocalWork() && this.#previousHead) {
|
|
23300
|
+
return this.#offerOrReconcile();
|
|
23301
|
+
}
|
|
23135
23302
|
const requestId = `${this.#binding.replicaId}:${this.#requestId}:${this.workId}:frontier`;
|
|
23136
23303
|
return this.#beginOffer(encodeInlineCustodyOffer({
|
|
23137
23304
|
session: this.#binding.replicaId,
|
|
@@ -23363,6 +23530,18 @@ var init_workspace_sync = __esm({
|
|
|
23363
23530
|
return this.#finishOfferOutcome(false);
|
|
23364
23531
|
}
|
|
23365
23532
|
const admission = outcome.value;
|
|
23533
|
+
globalThis.__nomosSyncDiagnostic?.("sync.admission", {
|
|
23534
|
+
workspace: this.#mount.workspace,
|
|
23535
|
+
phase: state.phase,
|
|
23536
|
+
local: this.#localHead,
|
|
23537
|
+
tracked: this.#previousHead,
|
|
23538
|
+
remote: admission.main,
|
|
23539
|
+
sealed: admission.sealedMain,
|
|
23540
|
+
resultBase: admission.resultBase,
|
|
23541
|
+
resultBytes: admission.resultPack.byteLength,
|
|
23542
|
+
recoveryRequired: admission.recoveryRequired,
|
|
23543
|
+
summary: summarizeCustodyAdmission(admission)
|
|
23544
|
+
});
|
|
23366
23545
|
this.#desiredHead = admission.main || void 0;
|
|
23367
23546
|
if (!this.#desiredHead) return this.#transportFailure("resident peer returned no admitted frontier", false);
|
|
23368
23547
|
this.#candidateDurable = admission.sealedMain === this.#desiredHead;
|
|
@@ -23637,7 +23816,7 @@ var init_workspace_sync = __esm({
|
|
|
23637
23816
|
#acceptLawProducts(response) {
|
|
23638
23817
|
if (response.status !== 200 || response.contentType?.split(";")[0]?.trim() !== LAW_PRODUCTS_MEDIA_TYPE) return;
|
|
23639
23818
|
try {
|
|
23640
|
-
const exported =
|
|
23819
|
+
const exported = fromBinary21(ExportLawProductsResponseSchema, response.body);
|
|
23641
23820
|
this.#fetchedLawProducts = { head: exported.head, products: exported.products };
|
|
23642
23821
|
} catch {
|
|
23643
23822
|
}
|
|
@@ -23979,6 +24158,19 @@ var init_workspace_sync = __esm({
|
|
|
23979
24158
|
return step;
|
|
23980
24159
|
}
|
|
23981
24160
|
#finish(value) {
|
|
24161
|
+
globalThis.__nomosSyncDiagnostic?.("sync.finished", {
|
|
24162
|
+
workspace: value.workspace,
|
|
24163
|
+
previous: value.previousHead,
|
|
24164
|
+
current: value.currentHead,
|
|
24165
|
+
stillAhead: value.stillAhead,
|
|
24166
|
+
deferred: String(value.deferred),
|
|
24167
|
+
admitted: String(value.admitted),
|
|
24168
|
+
reconnect: value.reconnectRequired,
|
|
24169
|
+
directOfferDeferred: value.directOfferDeferred,
|
|
24170
|
+
pushFailed: value.pushFailed,
|
|
24171
|
+
failure: value.pushError?.message,
|
|
24172
|
+
wallMs: elapsedMillis(this.#clock, this.#started)
|
|
24173
|
+
});
|
|
23982
24174
|
this.#state = { phase: WorkspaceSyncPhase.Done };
|
|
23983
24175
|
this.#current = void 0;
|
|
23984
24176
|
return this.#remember({ case: "synced", value });
|
|
@@ -24043,6 +24235,10 @@ var init_workspace_sync_dependencies = __esm({
|
|
|
24043
24235
|
this.#plan = [this.#args.root];
|
|
24044
24236
|
return this.#advance();
|
|
24045
24237
|
}
|
|
24238
|
+
if (this.#args.liveConnected && this.#args.kernel.resolveRef(this.#args.root.mount, this.#args.requestId, trackedMain2)) {
|
|
24239
|
+
this.#plan = this.#planDependencies();
|
|
24240
|
+
return this.#advance();
|
|
24241
|
+
}
|
|
24046
24242
|
this.#current = this.#work(this.#args.root, `${this.workId}:frontier`, true);
|
|
24047
24243
|
return this.#accept(this.#current.start());
|
|
24048
24244
|
}
|
|
@@ -24362,7 +24558,7 @@ var init_offer_transport_contract = __esm({
|
|
|
24362
24558
|
});
|
|
24363
24559
|
|
|
24364
24560
|
// ../peer-office/src/runtime/workspace_effect_delivery.ts
|
|
24365
|
-
import { create as create57, fromBinary as
|
|
24561
|
+
import { create as create57, fromBinary as fromBinary22, toBinary as toBinary19 } from "@bufbuild/protobuf";
|
|
24366
24562
|
function answered(response) {
|
|
24367
24563
|
const text2 = (response.contentType ?? "").startsWith("text/") || (response.contentType ?? "").includes("json") ? new TextDecoder().decode(response.body.subarray(0, RETRY_DETAIL_CHARACTERS)).trim() : "";
|
|
24368
24564
|
return `HTTP ${response.status} ${response.contentType || "without a media type"}${text2 ? `: ${text2}` : ""}`;
|
|
@@ -24753,7 +24949,7 @@ var init_workspace_effect_delivery = __esm({
|
|
|
24753
24949
|
}
|
|
24754
24950
|
let status2;
|
|
24755
24951
|
try {
|
|
24756
|
-
status2 =
|
|
24952
|
+
status2 = fromBinary22(WorkspaceEffectStatusResponseSchema, observation.body);
|
|
24757
24953
|
} catch {
|
|
24758
24954
|
return this.#transportFailed("mailbox returned an invalid effect observation");
|
|
24759
24955
|
}
|
|
@@ -24768,7 +24964,7 @@ var init_workspace_effect_delivery = __esm({
|
|
|
24768
24964
|
return this.#advance(this.#delivery.next(response2, this.#settlement));
|
|
24769
24965
|
}
|
|
24770
24966
|
if (receipt.outcome.value.status === 202 && (receipt.outcome.value.contentType ?? "").includes(WORKSPACE_EFFECT_DEFERRED)) {
|
|
24771
|
-
const deferred =
|
|
24967
|
+
const deferred = fromBinary22(WorkspaceEffectDeferredSchema, receipt.outcome.value.body);
|
|
24772
24968
|
this.#deferredRetryAfterMillis = Math.max(
|
|
24773
24969
|
this.#deferredRetryAfterMillis ?? 0,
|
|
24774
24970
|
Number(deferred.retryAfterMillis)
|
|
@@ -24793,7 +24989,7 @@ var init_workspace_effect_delivery = __esm({
|
|
|
24793
24989
|
}
|
|
24794
24990
|
let applied;
|
|
24795
24991
|
try {
|
|
24796
|
-
applied =
|
|
24992
|
+
applied = fromBinary22(OfferResponseSchema, receipt.outcome.value.body);
|
|
24797
24993
|
} catch {
|
|
24798
24994
|
return this.#transportFailed("remote workspace returned an invalid offer response");
|
|
24799
24995
|
}
|
|
@@ -24915,7 +25111,7 @@ var init_workspace_effect_delivery = __esm({
|
|
|
24915
25111
|
url: this.#mailboxUrl,
|
|
24916
25112
|
contentType: WORKSPACE_EFFECT_STATUS,
|
|
24917
25113
|
accept: WORKSPACE_EFFECT_STATUS_RESPONSE,
|
|
24918
|
-
body:
|
|
25114
|
+
body: toBinary19(WorkspaceEffectStatusRequestSchema, create57(WorkspaceEffectStatusRequestSchema, {
|
|
24919
25115
|
sourceWorkspaceGenesis: offer.sourceWorkspaceGenesis,
|
|
24920
25116
|
effectDigest: offer.effectDigest
|
|
24921
25117
|
}))
|
|
@@ -24942,7 +25138,7 @@ var init_workspace_effect_delivery = __esm({
|
|
|
24942
25138
|
url: this.#mailboxUrl,
|
|
24943
25139
|
contentType: CARRIED_OFFER,
|
|
24944
25140
|
accept: CARRIED_OFFER_RESPONSE,
|
|
24945
|
-
body:
|
|
25141
|
+
body: toBinary19(OfferRequestSchema, body)
|
|
24946
25142
|
});
|
|
24947
25143
|
this.#pending = create57(CorrespondencePendingSchema, {
|
|
24948
25144
|
workId: this.workId,
|
|
@@ -24955,7 +25151,7 @@ var init_workspace_effect_delivery = __esm({
|
|
|
24955
25151
|
});
|
|
24956
25152
|
|
|
24957
25153
|
// ../peer-office/src/runtime/replica_follow_lane.ts
|
|
24958
|
-
import { create as create58, toBinary as
|
|
25154
|
+
import { create as create58, toBinary as toBinary20 } from "@bufbuild/protobuf";
|
|
24959
25155
|
var ReplicaFollowLane;
|
|
24960
25156
|
var init_replica_follow_lane = __esm({
|
|
24961
25157
|
"../peer-office/src/runtime/replica_follow_lane.ts"() {
|
|
@@ -25037,7 +25233,7 @@ var init_replica_follow_lane = __esm({
|
|
|
25037
25233
|
if (action === ReplicaFollowAction.RefreshCredential) {
|
|
25038
25234
|
return {
|
|
25039
25235
|
workspace,
|
|
25040
|
-
frame:
|
|
25236
|
+
frame: toBinary20(RuntimeRequestSchema, create58(RuntimeRequestSchema, {
|
|
25041
25237
|
protocolVersion: 2,
|
|
25042
25238
|
requestId,
|
|
25043
25239
|
command: {
|
|
@@ -25052,7 +25248,7 @@ var init_replica_follow_lane = __esm({
|
|
|
25052
25248
|
const replaceLocalHead = this.#controller.replacementHead(workspace);
|
|
25053
25249
|
return {
|
|
25054
25250
|
workspace,
|
|
25055
|
-
frame:
|
|
25251
|
+
frame: toBinary20(RuntimeRequestSchema, create58(RuntimeRequestSchema, {
|
|
25056
25252
|
protocolVersion: 2,
|
|
25057
25253
|
requestId,
|
|
25058
25254
|
command: {
|
|
@@ -25249,7 +25445,7 @@ var init_http_obligation_delivery = __esm({
|
|
|
25249
25445
|
});
|
|
25250
25446
|
|
|
25251
25447
|
// ../peer-office/src/runtime/correspondence_desk.ts
|
|
25252
|
-
import { create as create60, toBinary as
|
|
25448
|
+
import { create as create60, toBinary as toBinary21 } from "@bufbuild/protobuf";
|
|
25253
25449
|
var REFETCH_AWAITS_PROVIDER, LOCAL_COPY_REFETCHING, CorrespondenceDesk;
|
|
25254
25450
|
var init_correspondence_desk = __esm({
|
|
25255
25451
|
"../peer-office/src/runtime/correspondence_desk.ts"() {
|
|
@@ -25307,6 +25503,7 @@ var init_correspondence_desk = __esm({
|
|
|
25307
25503
|
#onSyncCompleted;
|
|
25308
25504
|
#onPlacementFetched;
|
|
25309
25505
|
#onShallowMount;
|
|
25506
|
+
#onOutboxHistoryRequired;
|
|
25310
25507
|
#remoteOffers = new CorrespondenceWorkRegistry();
|
|
25311
25508
|
#recoveries = new CorrespondenceWorkRegistry();
|
|
25312
25509
|
#deliveries = new CorrespondenceWorkRegistry();
|
|
@@ -25353,6 +25550,7 @@ var init_correspondence_desk = __esm({
|
|
|
25353
25550
|
this.#onSyncCompleted = args.onSyncCompleted;
|
|
25354
25551
|
this.#onPlacementFetched = args.onPlacementFetched;
|
|
25355
25552
|
this.#onShallowMount = args.onShallowMount;
|
|
25553
|
+
this.#onOutboxHistoryRequired = args.onOutboxHistoryRequired;
|
|
25356
25554
|
this.#clock = args.clock;
|
|
25357
25555
|
this.#outboxClock = new OutboxObservationClock(args.clock, args.peerIdentity);
|
|
25358
25556
|
this.#executesCustodianObligations = args.executesCustodianObligations ?? false;
|
|
@@ -25516,6 +25714,15 @@ var init_correspondence_desk = __esm({
|
|
|
25516
25714
|
this.#followLane.dependencyAdvanced(workspace);
|
|
25517
25715
|
this.reportFollows();
|
|
25518
25716
|
}
|
|
25717
|
+
/** Received custody can release correspondence and foreign-read dependencies,
|
|
25718
|
+
* but is not newly authored work to send back to its upstream. Recovery is
|
|
25719
|
+
* driven separately by missing history, reconnects and provider announcements.
|
|
25720
|
+
* In particular an optimistic relay is not a durable upstream receipt. */
|
|
25721
|
+
receivedFrontierChanged(workspace) {
|
|
25722
|
+
this.wakeOutbox(workspace);
|
|
25723
|
+
this.#followLane.dependencyAdvanced(workspace);
|
|
25724
|
+
this.reportFollows();
|
|
25725
|
+
}
|
|
25519
25726
|
/**
|
|
25520
25727
|
* Tell a workspace's sessions what its durable follow ALREADY knows.
|
|
25521
25728
|
*
|
|
@@ -25752,8 +25959,16 @@ var init_correspondence_desk = __esm({
|
|
|
25752
25959
|
)
|
|
25753
25960
|
);
|
|
25754
25961
|
} catch (error) {
|
|
25962
|
+
if (error instanceof KernelHistoryRequired && this.#onOutboxHistoryRequired) {
|
|
25963
|
+
const retry = this.#onOutboxHistoryRequired(workspace, binding.credentialCapability);
|
|
25964
|
+
this.#outboxDueAt.set(workspace, now + Math.max(250, retry));
|
|
25965
|
+
return { nextAfterMillis: 0 };
|
|
25966
|
+
}
|
|
25755
25967
|
const format = localCopyFormatRefusal(error);
|
|
25756
|
-
if (format === void 0)
|
|
25968
|
+
if (format === void 0) {
|
|
25969
|
+
this.#outboxDueAt.set(workspace, now + 3e4);
|
|
25970
|
+
return { nextAfterMillis: 0 };
|
|
25971
|
+
}
|
|
25757
25972
|
this.#readability.mark(workspace, void 0, format);
|
|
25758
25973
|
this.#outboxDueAt.delete(workspace);
|
|
25759
25974
|
return { nextAfterMillis: 0 };
|
|
@@ -25834,7 +26049,7 @@ var init_correspondence_desk = __esm({
|
|
|
25834
26049
|
};
|
|
25835
26050
|
return {
|
|
25836
26051
|
workspace,
|
|
25837
|
-
frame:
|
|
26052
|
+
frame: toBinary21(RuntimeRequestSchema, create60(RuntimeRequestSchema, {
|
|
25838
26053
|
protocolVersion: 2,
|
|
25839
26054
|
requestId,
|
|
25840
26055
|
target: { workspace, session: binding.session },
|
|
@@ -26033,6 +26248,7 @@ var init_correspondence_desk = __esm({
|
|
|
26033
26248
|
requestId: request.requestId,
|
|
26034
26249
|
workId: id,
|
|
26035
26250
|
probeOnly,
|
|
26251
|
+
liveConnected: this.#openLinks.has(target3.mount.workspace),
|
|
26036
26252
|
...beforeConverge === void 0 ? {} : { beforeConverge },
|
|
26037
26253
|
...target3.receiveState === void 0 ? {} : { receiveState: target3.receiveState },
|
|
26038
26254
|
...target3.offerHead === void 0 ? {} : { offerHead: target3.offerHead },
|
|
@@ -26060,6 +26276,7 @@ var init_correspondence_desk = __esm({
|
|
|
26060
26276
|
root,
|
|
26061
26277
|
work,
|
|
26062
26278
|
outbound: command.admit,
|
|
26279
|
+
liveConnected: this.#openLinks.has(mount.workspace),
|
|
26063
26280
|
dependency: (workspace, source, acquire2 = false) => {
|
|
26064
26281
|
if (this.#roundInFlight(workspace, workId2)) return void 0;
|
|
26065
26282
|
const existing = this.#follows.bindingForWorkspace(workspace);
|
|
@@ -26530,7 +26747,7 @@ var init_identity_witness_cache = __esm({
|
|
|
26530
26747
|
});
|
|
26531
26748
|
|
|
26532
26749
|
// ../peer-office/src/runtime/identity_witness_read.ts
|
|
26533
|
-
import { create as create63, fromBinary as
|
|
26750
|
+
import { create as create63, fromBinary as fromBinary23, toBinary as toBinary22 } from "@bufbuild/protobuf";
|
|
26534
26751
|
function prepareWitnessRead(args) {
|
|
26535
26752
|
if (args.reception.workspace !== args.rootWorkspace) {
|
|
26536
26753
|
throw new Error("identity-provider witness route addresses another workspace");
|
|
@@ -26568,7 +26785,7 @@ function prepareWitnessRead(args) {
|
|
|
26568
26785
|
contentType: "application/vnd.nomos.runtime-request+protobuf",
|
|
26569
26786
|
accept: "application/vnd.nomos.runtime-response+protobuf",
|
|
26570
26787
|
bearerToken: args.bearerToken.slice(),
|
|
26571
|
-
body:
|
|
26788
|
+
body: toBinary22(RuntimeRequestSchema, request),
|
|
26572
26789
|
// Opening provider custody from cold storage can exceed 30 seconds.
|
|
26573
26790
|
timeoutMillis: 5 * 6e4
|
|
26574
26791
|
})
|
|
@@ -26598,7 +26815,7 @@ function acceptWitnessResponse(pending, receipt) {
|
|
|
26598
26815
|
`identity-provider witness receipt '${receipt.effectId}' does not answer '${pending.effectId}'`
|
|
26599
26816
|
);
|
|
26600
26817
|
}
|
|
26601
|
-
const response =
|
|
26818
|
+
const response = fromBinary23(RuntimeResponseSchema, responseBody2(receipt));
|
|
26602
26819
|
if (response.protocolVersion !== RUNTIME_V2_PROTOCOL_VERSION) {
|
|
26603
26820
|
throw new Error("identity-provider root returned an incompatible runtime response");
|
|
26604
26821
|
}
|
|
@@ -26964,7 +27181,7 @@ var init_admission_durability_desk = __esm({
|
|
|
26964
27181
|
});
|
|
26965
27182
|
|
|
26966
27183
|
// ../peer-office/src/runtime/identity_recovery_desk.ts
|
|
26967
|
-
import { create as create67, fromBinary as
|
|
27184
|
+
import { create as create67, fromBinary as fromBinary24, toBinary as toBinary23 } from "@bufbuild/protobuf";
|
|
26968
27185
|
var cloneCall, IdentityRecoveryDesk;
|
|
26969
27186
|
var init_identity_recovery_desk = __esm({
|
|
26970
27187
|
"../peer-office/src/runtime/identity_recovery_desk.ts"() {
|
|
@@ -26973,7 +27190,7 @@ var init_identity_recovery_desk = __esm({
|
|
|
26973
27190
|
init_credentials_desk_pb();
|
|
26974
27191
|
init_identity_desk_pb();
|
|
26975
27192
|
init_application_desk_pb();
|
|
26976
|
-
cloneCall = (call) =>
|
|
27193
|
+
cloneCall = (call) => fromBinary24(CallRequestSchema, toBinary23(CallRequestSchema, call));
|
|
26977
27194
|
IdentityRecoveryDesk = class {
|
|
26978
27195
|
#identity;
|
|
26979
27196
|
#application;
|
|
@@ -26991,7 +27208,7 @@ var init_identity_recovery_desk = __esm({
|
|
|
26991
27208
|
if (!command.request || !["query", "offer"].includes(command.request.operation.case ?? "")) {
|
|
26992
27209
|
throw new Error("identity-provider recovery demand did not originate from an application call");
|
|
26993
27210
|
}
|
|
26994
|
-
const originalCall =
|
|
27211
|
+
const originalCall = toBinary23(CallRequestSchema, command.request);
|
|
26995
27212
|
const step = this.#identity.execute(
|
|
26996
27213
|
runtimeRequest,
|
|
26997
27214
|
create67(IdentityProviderWitnessRequestSchema, {
|
|
@@ -27071,7 +27288,7 @@ var init_identity_recovery_desk = __esm({
|
|
|
27071
27288
|
}
|
|
27072
27289
|
}
|
|
27073
27290
|
#adoptAndRetry(runtimeRequest, command, originalCall, requirement, ready) {
|
|
27074
|
-
const original =
|
|
27291
|
+
const original = fromBinary24(CallRequestSchema, originalCall);
|
|
27075
27292
|
const query2 = original.operation.case === "query" ? original.operation.value : void 0;
|
|
27076
27293
|
const offer = original.operation.case === "offer" ? original.operation.value : void 0;
|
|
27077
27294
|
const target3 = query2?.target ?? offer?.target;
|
|
@@ -27119,7 +27336,7 @@ var init_identity_recovery_desk = __esm({
|
|
|
27119
27336
|
const retryCommand = create67(KernelCallRequestSchema, {
|
|
27120
27337
|
session: command.session,
|
|
27121
27338
|
credentialUse: command.credentialUse,
|
|
27122
|
-
request: cloneCall(
|
|
27339
|
+
request: cloneCall(fromBinary24(CallRequestSchema, originalCall))
|
|
27123
27340
|
});
|
|
27124
27341
|
const retried = this.#application.call(runtimeRequest, retryCommand);
|
|
27125
27342
|
if (retried.outcome.case === "failure" && retried.outcome.value.identityProviderWitnessRequired) {
|
|
@@ -27193,7 +27410,7 @@ var init_peer_maintenance_scheduler = __esm({
|
|
|
27193
27410
|
});
|
|
27194
27411
|
|
|
27195
27412
|
// ../peer-office/src/runtime/peer_background_scheduler.ts
|
|
27196
|
-
import { create as create68, toBinary as
|
|
27413
|
+
import { create as create68, toBinary as toBinary24 } from "@bufbuild/protobuf";
|
|
27197
27414
|
function yielding(paper) {
|
|
27198
27415
|
if (paper.frame !== void 0 || paper.nextAfterMillis === void 0 || paper.nextAfterMillis > 0) return paper;
|
|
27199
27416
|
return { ...paper, nextAfterMillis: BACKGROUND_CONTINUATION_YIELD_MILLIS };
|
|
@@ -27233,7 +27450,7 @@ var init_peer_background_scheduler = __esm({
|
|
|
27233
27450
|
const recovery = retentionOnly ? {} : this.#subscriptions.nextRecovery(id, excludedWorkspaces);
|
|
27234
27451
|
if (recovery.request) {
|
|
27235
27452
|
return {
|
|
27236
|
-
frame:
|
|
27453
|
+
frame: toBinary24(RuntimeRequestSchema, recovery.request),
|
|
27237
27454
|
nextAfterMillis: 0,
|
|
27238
27455
|
workspace: recovery.request.target.workspace
|
|
27239
27456
|
};
|
|
@@ -27241,7 +27458,7 @@ var init_peer_background_scheduler = __esm({
|
|
|
27241
27458
|
const retention = this.#residency.nextRetention();
|
|
27242
27459
|
if (retention.request !== void 0) {
|
|
27243
27460
|
return {
|
|
27244
|
-
frame:
|
|
27461
|
+
frame: toBinary24(RuntimeRequestSchema, create68(RuntimeRequestSchema, {
|
|
27245
27462
|
protocolVersion: 2,
|
|
27246
27463
|
requestId: id,
|
|
27247
27464
|
command: {
|
|
@@ -27258,7 +27475,7 @@ var init_peer_background_scheduler = __esm({
|
|
|
27258
27475
|
const convergence = this.#receivingGroup.nextBackgroundPaper(id, excludedWorkspaces);
|
|
27259
27476
|
if (convergence.frame !== void 0) {
|
|
27260
27477
|
return {
|
|
27261
|
-
frame:
|
|
27478
|
+
frame: toBinary24(RuntimeRequestSchema, convergence.frame),
|
|
27262
27479
|
nextAfterMillis: 0,
|
|
27263
27480
|
...convergence.workspace === void 0 ? {} : { workspace: convergence.workspace }
|
|
27264
27481
|
};
|
|
@@ -27319,7 +27536,7 @@ var init_peer_background_scheduler = __esm({
|
|
|
27319
27536
|
const recovery = this.#subscriptions.nextRecovery(id, excluded);
|
|
27320
27537
|
if (recovery.request) {
|
|
27321
27538
|
return {
|
|
27322
|
-
frame:
|
|
27539
|
+
frame: toBinary24(RuntimeRequestSchema, recovery.request),
|
|
27323
27540
|
nextAfterMillis: 0,
|
|
27324
27541
|
workspace: recovery.request.target.workspace
|
|
27325
27542
|
};
|
|
@@ -27327,7 +27544,7 @@ var init_peer_background_scheduler = __esm({
|
|
|
27327
27544
|
const convergence = this.#receivingGroup.nextBackgroundPaper(id, excluded);
|
|
27328
27545
|
if (convergence.frame !== void 0) {
|
|
27329
27546
|
return {
|
|
27330
|
-
frame:
|
|
27547
|
+
frame: toBinary24(RuntimeRequestSchema, convergence.frame),
|
|
27331
27548
|
nextAfterMillis: 0,
|
|
27332
27549
|
...convergence.workspace === void 0 ? {} : { workspace: convergence.workspace }
|
|
27333
27550
|
};
|
|
@@ -27699,7 +27916,7 @@ var init_history_acquisition_state = __esm({
|
|
|
27699
27916
|
});
|
|
27700
27917
|
|
|
27701
27918
|
// ../peer-office/src/runtime/history_acquisition_desk.ts
|
|
27702
|
-
import { create as create70, toBinary as
|
|
27919
|
+
import { create as create70, toBinary as toBinary25 } from "@bufbuild/protobuf";
|
|
27703
27920
|
function assertState2(record, state) {
|
|
27704
27921
|
switch (state.case) {
|
|
27705
27922
|
case HistoryAcquisitionPhase.Desired:
|
|
@@ -27718,7 +27935,7 @@ function assertState2(record, state) {
|
|
|
27718
27935
|
}
|
|
27719
27936
|
throw corrupt2(record, `invalid '${state.case}' state`);
|
|
27720
27937
|
}
|
|
27721
|
-
var HISTORY_ACQUISITION_NAMESPACE, HISTORY_BACKGROUND_START_MILLIS, SLICE_ANSWER_MILLIS,
|
|
27938
|
+
var HISTORY_ACQUISITION_NAMESPACE, HISTORY_BACKGROUND_START_MILLIS, SLICE_ANSWER_MILLIS, encoder4, decoder4, workId, effectId, encode2, upgraded, decode2, corrupt2, HistoryAcquisitionDesk;
|
|
27722
27939
|
var init_history_acquisition_desk = __esm({
|
|
27723
27940
|
"../peer-office/src/runtime/history_acquisition_desk.ts"() {
|
|
27724
27941
|
"use strict";
|
|
@@ -27729,15 +27946,15 @@ var init_history_acquisition_desk = __esm({
|
|
|
27729
27946
|
HISTORY_ACQUISITION_NAMESPACE = "nomos.peer-desk.history-acquisition/v1";
|
|
27730
27947
|
HISTORY_BACKGROUND_START_MILLIS = 1e4;
|
|
27731
27948
|
SLICE_ANSWER_MILLIS = 5 * 6e4;
|
|
27732
|
-
|
|
27733
|
-
|
|
27949
|
+
encoder4 = new TextEncoder();
|
|
27950
|
+
decoder4 = new TextDecoder();
|
|
27734
27951
|
workId = (workspace) => `history-acquisition:${workspace}`;
|
|
27735
27952
|
effectId = (workspace, attempt) => `history-acquisition:${workspace}:${HistoryAcquisitionPhase.Acquiring}:${attempt}`;
|
|
27736
27953
|
encode2 = (work) => {
|
|
27737
27954
|
if (!work.credentialCapability) {
|
|
27738
27955
|
throw new Error(`history acquisition for '${work.workspace}' has not restored its credential capability`);
|
|
27739
27956
|
}
|
|
27740
|
-
return
|
|
27957
|
+
return encoder4.encode(JSON.stringify({
|
|
27741
27958
|
version: 2,
|
|
27742
27959
|
workspace: work.workspace,
|
|
27743
27960
|
credentialCapability: work.credentialCapability,
|
|
@@ -27746,7 +27963,7 @@ var init_history_acquisition_desk = __esm({
|
|
|
27746
27963
|
};
|
|
27747
27964
|
upgraded = (state) => state.case === "backoff" ? { case: HistoryAcquisitionPhase.Paced, attempt: state.attempt, delayMillis: state.delayMillis, failed: true } : state;
|
|
27748
27965
|
decode2 = (record) => {
|
|
27749
|
-
const value = JSON.parse(
|
|
27966
|
+
const value = JSON.parse(decoder4.decode(record.value));
|
|
27750
27967
|
if (!value || typeof value !== "object") throw corrupt2(record, "not an object");
|
|
27751
27968
|
const candidate = value;
|
|
27752
27969
|
if (candidate.version !== 1 && candidate.version !== 2 || candidate.workspace !== record.key || !candidate.state) {
|
|
@@ -27791,6 +28008,21 @@ var init_history_acquisition_desk = __esm({
|
|
|
27791
28008
|
this.#ensure(workspace, credentialCapability);
|
|
27792
28009
|
this.#dueAt.set(workspace, this.#now() + HISTORY_BACKGROUND_START_MILLIS);
|
|
27793
28010
|
}
|
|
28011
|
+
/** A background kernel read needs an omitted ancestor now. Queue one bounded
|
|
28012
|
+
* slice on the existing history lane; a failed slice keeps its retry pace. */
|
|
28013
|
+
requestFromBackground(workspace, credentialCapability) {
|
|
28014
|
+
if (!workspace) throw new Error("kernel history requirement names no workspace");
|
|
28015
|
+
this.#ensure(workspace, credentialCapability);
|
|
28016
|
+
const work = this.#get(workspace);
|
|
28017
|
+
const now = this.#now();
|
|
28018
|
+
if (work.state.case === HistoryAcquisitionPhase.Paced && work.state.failed) {
|
|
28019
|
+
const due2 = this.#dueAt.get(workspace) ?? now + work.state.delayMillis;
|
|
28020
|
+
this.#dueAt.set(workspace, due2);
|
|
28021
|
+
if (due2 > now) return due2 - now;
|
|
28022
|
+
}
|
|
28023
|
+
this.#dueAt.set(workspace, now);
|
|
28024
|
+
return 250;
|
|
28025
|
+
}
|
|
27794
28026
|
/** An operation needs history this custody lacks: its next slice now, joining one in flight. */
|
|
27795
28027
|
begin(workspace, credentialCapability) {
|
|
27796
28028
|
if (!workspace) throw new Error("kernel history requirement names no workspace");
|
|
@@ -27887,7 +28119,7 @@ var init_history_acquisition_desk = __esm({
|
|
|
27887
28119
|
return {
|
|
27888
28120
|
workspace: next.workspace,
|
|
27889
28121
|
nextAfterMillis: 0,
|
|
27890
|
-
frame:
|
|
28122
|
+
frame: toBinary25(RuntimeRequestSchema, create70(RuntimeRequestSchema, {
|
|
27891
28123
|
protocolVersion: 2,
|
|
27892
28124
|
requestId,
|
|
27893
28125
|
target: { workspace: next.workspace, session: `history-materialisation:${next.workspace}` },
|
|
@@ -27988,7 +28220,7 @@ var init_history_acquisition_desk = __esm({
|
|
|
27988
28220
|
});
|
|
27989
28221
|
|
|
27990
28222
|
// ../peer-office/src/peer_office.ts
|
|
27991
|
-
import { create as create71, toBinary as
|
|
28223
|
+
import { create as create71, toBinary as toBinary26 } from "@bufbuild/protobuf";
|
|
27992
28224
|
function isAnsweredStateRead(command, response) {
|
|
27993
28225
|
if (command.request?.operation.case !== "query" || response.outcome.case !== "query" || response.outcome.value.result.case === "readIndexPending") return false;
|
|
27994
28226
|
switch (command.request.operation.value.query.case) {
|
|
@@ -28030,6 +28262,7 @@ var init_peer_office = __esm({
|
|
|
28030
28262
|
init_credentials_desk_pb();
|
|
28031
28263
|
init_framework_pb();
|
|
28032
28264
|
init_sha256();
|
|
28265
|
+
init_custody_receipts();
|
|
28033
28266
|
init_custodian_placement();
|
|
28034
28267
|
init_custody_admission_desk();
|
|
28035
28268
|
init_kernel_queries();
|
|
@@ -28175,7 +28408,7 @@ var init_peer_office = __esm({
|
|
|
28175
28408
|
this.#trace,
|
|
28176
28409
|
this.#readability
|
|
28177
28410
|
);
|
|
28178
|
-
this.#custodyAdmission = new CustodyAdmissionDesk(this.#kernel, this.#custody);
|
|
28411
|
+
this.#custodyAdmission = new CustodyAdmissionDesk(this.#kernel, this.#custody, new CustodyReceipts(seatedStore));
|
|
28179
28412
|
this.#queries = new KernelQueries(this.#kernel, this.#credentials);
|
|
28180
28413
|
this.#follows = new ReplicaFollowController(
|
|
28181
28414
|
new ReplicaFollowDesk(seatedStore),
|
|
@@ -28337,6 +28570,7 @@ var init_peer_office = __esm({
|
|
|
28337
28570
|
// Lazy history: a head-only mount materialises its history in the background, never on
|
|
28338
28571
|
// the path of an operation (architecture/lazy_history.md).
|
|
28339
28572
|
onShallowMount: (workspace, credentialCapability) => this.#historyAcquisition.materialise(workspace, credentialCapability),
|
|
28573
|
+
onOutboxHistoryRequired: (workspace, credentialCapability) => this.#historyAcquisition.requestFromBackground(workspace, credentialCapability),
|
|
28340
28574
|
onSyncCompleted: (session, event) => {
|
|
28341
28575
|
if (event.result?.workspace) {
|
|
28342
28576
|
this.#replicaInventory.placementMayHaveChanged(event.result.workspace);
|
|
@@ -28686,7 +28920,7 @@ var init_peer_office = __esm({
|
|
|
28686
28920
|
this.#origins.observeReceipt(request);
|
|
28687
28921
|
const response = this.#fenced(this.#handleRequest(request));
|
|
28688
28922
|
this.#paperSlots.answered(request, response, (session) => this.#sessions.bindingIfPresent(session)?.workspace);
|
|
28689
|
-
return { responseProtobuf:
|
|
28923
|
+
return { responseProtobuf: toBinary26(RuntimeResponseSchema, response) };
|
|
28690
28924
|
}
|
|
28691
28925
|
/** Every response leaving the office passes the origin fence (see fenceEffects). */
|
|
28692
28926
|
#fenced(response) {
|
|
@@ -28803,8 +29037,8 @@ var init_peer_office = __esm({
|
|
|
28803
29037
|
this.#replicaInventory.placementMayHaveChanged(workspace);
|
|
28804
29038
|
}
|
|
28805
29039
|
}
|
|
28806
|
-
/** Execute a typed paper after the access desk
|
|
28807
|
-
*
|
|
29040
|
+
/** Execute a typed paper after the access desk. Custody admission addresses a
|
|
29041
|
+
* workspace by replica identity; application calls retain session binding. */
|
|
28808
29042
|
#dispatchRequest(request) {
|
|
28809
29043
|
validateRuntimeV2Request(request);
|
|
28810
29044
|
try {
|
|
@@ -28818,18 +29052,20 @@ var init_peer_office = __esm({
|
|
|
28818
29052
|
if (!request.target.workspace || !request.target.session) {
|
|
28819
29053
|
throw new Error("addressed runtime request requires workspace and session");
|
|
28820
29054
|
}
|
|
28821
|
-
|
|
28822
|
-
|
|
28823
|
-
if (binding
|
|
28824
|
-
|
|
28825
|
-
|
|
28826
|
-
|
|
29055
|
+
if (request.command.case !== "admitCustodyOffers") {
|
|
29056
|
+
const binding = this.#sessions.bindingIfPresent(request.target.session);
|
|
29057
|
+
if (binding !== void 0) {
|
|
29058
|
+
if (binding.workspace !== request.target.workspace) {
|
|
29059
|
+
throw new Error(
|
|
29060
|
+
`session '${request.target.session}' is bound to workspace '${binding.workspace}', not '${request.target.workspace}'`
|
|
29061
|
+
);
|
|
29062
|
+
}
|
|
29063
|
+
} else {
|
|
29064
|
+
this.#bindInteraction(create71(BindSessionRequestSchema, {
|
|
29065
|
+
session: request.target.session,
|
|
29066
|
+
workspace: request.target.workspace
|
|
29067
|
+
}));
|
|
28827
29068
|
}
|
|
28828
|
-
} else {
|
|
28829
|
-
this.#bindInteraction(create71(BindSessionRequestSchema, {
|
|
28830
|
-
session: request.target.session,
|
|
28831
|
-
workspace: request.target.workspace
|
|
28832
|
-
}));
|
|
28833
29069
|
}
|
|
28834
29070
|
}
|
|
28835
29071
|
switch (request.command.case) {
|
|
@@ -29026,7 +29262,7 @@ var init_peer_office = __esm({
|
|
|
29026
29262
|
ReadMaintenanceCause.ADMITTED_OFFER
|
|
29027
29263
|
);
|
|
29028
29264
|
this.#subscriptions.refreshWorkspace(request.target.workspace);
|
|
29029
|
-
this.#correspondence.
|
|
29265
|
+
this.#correspondence.receivedFrontierChanged(request.target.workspace);
|
|
29030
29266
|
}
|
|
29031
29267
|
return this.#birthCustodyResponse(
|
|
29032
29268
|
request,
|
|
@@ -29605,6 +29841,15 @@ function createBackgroundLanes(options) {
|
|
|
29605
29841
|
const correspondenceNotBefore = /* @__PURE__ */ new Map();
|
|
29606
29842
|
let retention = 0;
|
|
29607
29843
|
let closed = false;
|
|
29844
|
+
let selectionFailures = 0;
|
|
29845
|
+
const selectionFault = (error) => {
|
|
29846
|
+
try {
|
|
29847
|
+
options.onSelectionError?.(error);
|
|
29848
|
+
} catch {
|
|
29849
|
+
}
|
|
29850
|
+
selectionFailures += 1;
|
|
29851
|
+
wake(Math.min(3e4, 250 * 2 ** Math.min(selectionFailures - 1, 7)));
|
|
29852
|
+
};
|
|
29608
29853
|
const wake = (delayMillis = 0) => {
|
|
29609
29854
|
if (closed) return;
|
|
29610
29855
|
const delay = Math.max(0, Math.ceil(delayMillis));
|
|
@@ -29615,53 +29860,58 @@ function createBackgroundLanes(options) {
|
|
|
29615
29860
|
}
|
|
29616
29861
|
wakeAt = at;
|
|
29617
29862
|
timer = setTimer(() => {
|
|
29618
|
-
|
|
29619
|
-
|
|
29620
|
-
|
|
29621
|
-
|
|
29622
|
-
|
|
29623
|
-
|
|
29624
|
-
|
|
29625
|
-
|
|
29626
|
-
|
|
29627
|
-
|
|
29628
|
-
|
|
29629
|
-
|
|
29630
|
-
if (
|
|
29631
|
-
|
|
29632
|
-
|
|
29633
|
-
|
|
29634
|
-
|
|
29863
|
+
try {
|
|
29864
|
+
timer = void 0;
|
|
29865
|
+
wakeAt = void 0;
|
|
29866
|
+
if (closed) return;
|
|
29867
|
+
const now = options.monotonicNanoseconds();
|
|
29868
|
+
for (const [workspace2, at2] of correspondenceNotBefore) {
|
|
29869
|
+
if (at2 <= now) correspondenceNotBefore.delete(workspace2);
|
|
29870
|
+
}
|
|
29871
|
+
const backoffMillis = correspondenceNotBefore.size ? Math.min(...[...correspondenceNotBefore.values()].map((at2) => Number((at2 - now + 999999n) / 1000000n))) : void 0;
|
|
29872
|
+
const retentionOnly = correspondenceInFlight;
|
|
29873
|
+
const next = options.nextPaper(retentionOnly, new Set(correspondenceNotBefore.keys()));
|
|
29874
|
+
selectionFailures = 0;
|
|
29875
|
+
if (next.frame === void 0) {
|
|
29876
|
+
const delays = [next.nextAfterMillis, backoffMillis].filter((delay2) => delay2 !== void 0);
|
|
29877
|
+
if (delays.length) wake(Math.min(...delays));
|
|
29878
|
+
return;
|
|
29879
|
+
}
|
|
29880
|
+
if (options.isRetention(next.frame)) {
|
|
29881
|
+
retention += 1;
|
|
29882
|
+
void options.drive(next.frame).then(
|
|
29883
|
+
() => {
|
|
29884
|
+
retention -= 1;
|
|
29885
|
+
wake(0);
|
|
29886
|
+
},
|
|
29887
|
+
() => {
|
|
29888
|
+
retention -= 1;
|
|
29889
|
+
wake(0);
|
|
29890
|
+
}
|
|
29891
|
+
);
|
|
29892
|
+
wake(next.nextAfterMillis ?? 0);
|
|
29893
|
+
return;
|
|
29894
|
+
}
|
|
29895
|
+
if (retentionOnly) throw new Error("background desk reserved correspondence while its lane was unavailable");
|
|
29896
|
+
const workspace = next.workspace;
|
|
29897
|
+
if (!workspace) throw new Error("background correspondence has no source workspace");
|
|
29898
|
+
if (correspondenceNotBefore.has(workspace)) throw new Error("background desk bypassed a workspace's physical backoff");
|
|
29899
|
+
correspondenceInFlight = true;
|
|
29635
29900
|
void options.drive(next.frame).then(
|
|
29636
29901
|
() => {
|
|
29637
|
-
|
|
29638
|
-
wake(0);
|
|
29902
|
+
correspondenceInFlight = false;
|
|
29903
|
+
wake(next.nextAfterMillis ?? 0);
|
|
29639
29904
|
},
|
|
29640
29905
|
() => {
|
|
29641
|
-
|
|
29906
|
+
correspondenceInFlight = false;
|
|
29907
|
+
correspondenceNotBefore.set(workspace, options.monotonicNanoseconds() + BigInt(failureBackoffMillis) * 1000000n);
|
|
29642
29908
|
wake(0);
|
|
29643
29909
|
}
|
|
29644
29910
|
);
|
|
29645
|
-
wake(
|
|
29646
|
-
|
|
29911
|
+
wake(0);
|
|
29912
|
+
} catch (error) {
|
|
29913
|
+
selectionFault(error);
|
|
29647
29914
|
}
|
|
29648
|
-
if (retentionOnly) throw new Error("background desk reserved correspondence while its lane was unavailable");
|
|
29649
|
-
const workspace = next.workspace;
|
|
29650
|
-
if (!workspace) throw new Error("background correspondence has no source workspace");
|
|
29651
|
-
if (correspondenceNotBefore.has(workspace)) throw new Error("background desk bypassed a workspace's physical backoff");
|
|
29652
|
-
correspondenceInFlight = true;
|
|
29653
|
-
void options.drive(next.frame).then(
|
|
29654
|
-
() => {
|
|
29655
|
-
correspondenceInFlight = false;
|
|
29656
|
-
wake(next.nextAfterMillis ?? 0);
|
|
29657
|
-
},
|
|
29658
|
-
() => {
|
|
29659
|
-
correspondenceInFlight = false;
|
|
29660
|
-
correspondenceNotBefore.set(workspace, options.monotonicNanoseconds() + BigInt(failureBackoffMillis) * 1000000n);
|
|
29661
|
-
wake(0);
|
|
29662
|
-
}
|
|
29663
|
-
);
|
|
29664
|
-
wake(0);
|
|
29665
29915
|
}, delay);
|
|
29666
29916
|
};
|
|
29667
29917
|
return {
|
|
@@ -29689,7 +29939,7 @@ var init_background_lanes = __esm({
|
|
|
29689
29939
|
});
|
|
29690
29940
|
|
|
29691
29941
|
// ../peer-office/src/runtime/frame_runner.ts
|
|
29692
|
-
import { fromBinary as
|
|
29942
|
+
import { fromBinary as fromBinary25 } from "@bufbuild/protobuf";
|
|
29693
29943
|
function createPeerOfficeFrameRunner(kernel, credentials, profile, observations, custody, postEvent, maintenanceSettled, driveBackground, peerDeskStore, executeBackground) {
|
|
29694
29944
|
if (!peerDeskStore) {
|
|
29695
29945
|
throw new Error("Peer Office frame runner requires an explicit PeerDeskStore capability");
|
|
@@ -29710,7 +29960,7 @@ function createPeerOfficeFrameRunner(kernel, credentials, profile, observations,
|
|
|
29710
29960
|
const event = peer2.nextEvent();
|
|
29711
29961
|
if (event === void 0) return;
|
|
29712
29962
|
if (maintenanceSettled !== void 0) {
|
|
29713
|
-
const decoded =
|
|
29963
|
+
const decoded = fromBinary25(RuntimeEventSchema, event);
|
|
29714
29964
|
if (decoded.event.case === "maintenanceProgress" && decoded.event.value.kernel && !decoded.event.value.kernel.maintenancePending) {
|
|
29715
29965
|
maintenanceSettled(decoded.event.value);
|
|
29716
29966
|
}
|
|
@@ -29745,11 +29995,12 @@ function createPeerOfficeFrameRunner(kernel, credentials, profile, observations,
|
|
|
29745
29995
|
return paper;
|
|
29746
29996
|
},
|
|
29747
29997
|
drive: (frame) => driveBackground(frame).catch((error) => {
|
|
29748
|
-
peer2.backgroundPaperAbandoned(
|
|
29998
|
+
peer2.backgroundPaperAbandoned(fromBinary25(RuntimeRequestSchema, frame).requestId);
|
|
29749
29999
|
throw error;
|
|
29750
30000
|
}),
|
|
29751
|
-
isRetention: (frame) =>
|
|
29752
|
-
monotonicNanoseconds: () => observations.monotonicNanoseconds()
|
|
30001
|
+
isRetention: (frame) => fromBinary25(RuntimeRequestSchema, frame).command.case === "retainFrontier",
|
|
30002
|
+
monotonicNanoseconds: () => observations.monotonicNanoseconds(),
|
|
30003
|
+
onSelectionError: (error) => console.error("Nomos background paper selection failed", error)
|
|
29753
30004
|
});
|
|
29754
30005
|
const scheduleCorrespondence = (delayMillis = 0) => {
|
|
29755
30006
|
lanes?.wake(delayMillis);
|
|
@@ -29758,7 +30009,7 @@ function createPeerOfficeFrameRunner(kernel, credentials, profile, observations,
|
|
|
29758
30009
|
handleFrame(frame) {
|
|
29759
30010
|
const response = peer2.invoke(frame).responseProtobuf;
|
|
29760
30011
|
drainEvents();
|
|
29761
|
-
if (
|
|
30012
|
+
if (fromBinary25(RuntimeRequestSchema, frame).command.case !== "workspaceStatus") {
|
|
29762
30013
|
scheduleMaintenance();
|
|
29763
30014
|
scheduleCorrespondence();
|
|
29764
30015
|
}
|
|
@@ -29820,21 +30071,21 @@ var init_frame_runner = __esm({
|
|
|
29820
30071
|
});
|
|
29821
30072
|
|
|
29822
30073
|
// ../peer-office/src/runtime/platform_effect_driver.ts
|
|
29823
|
-
import { create as create72, fromBinary as
|
|
30074
|
+
import { create as create72, fromBinary as fromBinary26, toBinary as toBinary27 } from "@bufbuild/protobuf";
|
|
29824
30075
|
async function drivePeerFrame(runner, initialFrame, fetchImpl = globalThis.fetch, custody, bornCustody, credentialRefresh, yieldWakeToCaller = false, deviceIdentity, lawPackage, yieldLocalReadToCaller = false, yieldHistoryToCaller = false, performExternalEffect) {
|
|
29825
30076
|
const persistBornCustody = bornCustody ?? (custody?.persistBornCustody ? (effect) => custody.persistBornCustody(effect) : void 0);
|
|
29826
30077
|
let responseFrame = runner.handleFrame(initialFrame);
|
|
29827
30078
|
const satisfied = /* @__PURE__ */ new Set();
|
|
29828
30079
|
const resendable = (() => {
|
|
29829
30080
|
try {
|
|
29830
|
-
return
|
|
30081
|
+
return fromBinary26(RuntimeRequestSchema, initialFrame).command.case !== "continueCorrespondence";
|
|
29831
30082
|
} catch {
|
|
29832
30083
|
return false;
|
|
29833
30084
|
}
|
|
29834
30085
|
})();
|
|
29835
30086
|
let historyRetries = 0;
|
|
29836
30087
|
for (; ; ) {
|
|
29837
|
-
const response =
|
|
30088
|
+
const response = fromBinary26(RuntimeResponseSchema, responseFrame);
|
|
29838
30089
|
if (response.outcome.case === "historyAcquired" && resendable && historyRetries < 32) {
|
|
29839
30090
|
historyRetries += 1;
|
|
29840
30091
|
responseFrame = runner.handleFrame(initialFrame);
|
|
@@ -29844,7 +30095,7 @@ async function drivePeerFrame(runner, initialFrame, fetchImpl = globalThis.fetch
|
|
|
29844
30095
|
if (yieldLocalReadToCaller) return responseFrame;
|
|
29845
30096
|
const pending2 = response.outcome.value;
|
|
29846
30097
|
await new Promise((resolve9) => setTimeout(resolve9, pending2.resumeAfterMillis));
|
|
29847
|
-
responseFrame = runner.handleFrame(
|
|
30098
|
+
responseFrame = runner.handleFrame(toBinary27(RuntimeRequestSchema, create72(RuntimeRequestSchema, {
|
|
29848
30099
|
protocolVersion: response.protocolVersion,
|
|
29849
30100
|
requestId: response.requestId,
|
|
29850
30101
|
command: { case: "continueLocalRead", value: create72(ContinueLocalReadRequestSchema, { workId: pending2.workId }) }
|
|
@@ -29944,7 +30195,7 @@ async function drivePeerFrame(runner, initialFrame, fetchImpl = globalThis.fetch
|
|
|
29944
30195
|
outcome: { case: "failure", value: { reason: PeerEffectFailureReason.TRANSPORT, message: error instanceof Error ? error.message : String(error) } }
|
|
29945
30196
|
});
|
|
29946
30197
|
}
|
|
29947
|
-
responseFrame = runner.handleFrame(
|
|
30198
|
+
responseFrame = runner.handleFrame(toBinary27(RuntimeRequestSchema, create72(RuntimeRequestSchema, {
|
|
29948
30199
|
protocolVersion: response.protocolVersion,
|
|
29949
30200
|
requestId: response.requestId,
|
|
29950
30201
|
command: { case: "continueCorrespondence", value: { workId: pending.workId, receipt: receipt2 } }
|
|
@@ -29972,7 +30223,7 @@ async function drivePeerFrame(runner, initialFrame, fetchImpl = globalThis.fetch
|
|
|
29972
30223
|
}) : pending.effect.case === "retainFrontier" ? await executeRetainFrontierEffect(pending.effect.value, custody) : pending.effect.case === "wake" ? await executeWakeEffect(pending.effect.value) : pending.effect.case === "refreshCredential" ? await executeCredentialRefreshEffect(pending.effect.value, credentialRefresh) : pending.effect.case === "deviceIdentity" ? await executeDeviceIdentityEffect(pending.effect.value, deviceIdentity) : pending.effect.case === "lawPackage" ? await executeLawPackageEffect(pending.effect.value, lawPackage) : pending.effect.case === "historyAcquisition" ? await executeHistoryAcquisitionEffect(pending.effect.value, custody) : (() => {
|
|
29973
30224
|
throw new Error(`correspondence work '${pending.workId}' has no effect`);
|
|
29974
30225
|
})();
|
|
29975
|
-
responseFrame = runner.handleFrame(
|
|
30226
|
+
responseFrame = runner.handleFrame(toBinary27(RuntimeRequestSchema, create72(RuntimeRequestSchema, {
|
|
29976
30227
|
protocolVersion: response.protocolVersion,
|
|
29977
30228
|
requestId: response.requestId,
|
|
29978
30229
|
command: {
|
|
@@ -30044,11 +30295,11 @@ async function executeDeviceIdentityEffect(effect, store) {
|
|
|
30044
30295
|
await store.save(effect.identity, effect.operation.value.secret.slice());
|
|
30045
30296
|
} else if (effect.operation.case === "loadRecovery") {
|
|
30046
30297
|
const bytes = await store.load(`nomos-device-recovery-v1|${effect.identity}`);
|
|
30047
|
-
if (bytes !== void 0) recovery =
|
|
30298
|
+
if (bytes !== void 0) recovery = fromBinary26(DeviceRecoveryRecordSchema, bytes);
|
|
30048
30299
|
} else if (effect.operation.case === "saveRecovery") {
|
|
30049
30300
|
const record = effect.operation.value.record;
|
|
30050
30301
|
if (!record) throw new Error("device recovery save contains no record");
|
|
30051
|
-
await store.save(`nomos-device-recovery-v1|${effect.identity}`,
|
|
30302
|
+
await store.save(`nomos-device-recovery-v1|${effect.identity}`, toBinary27(DeviceRecoveryRecordSchema, record));
|
|
30052
30303
|
} else throw new Error("device identity effect has no operation");
|
|
30053
30304
|
return create72(PeerEffectReceiptSchema, { effectId: effect.effectId, outcome: {
|
|
30054
30305
|
case: "deviceIdentity",
|
|
@@ -30160,7 +30411,7 @@ var init_platform_effect_driver = __esm({
|
|
|
30160
30411
|
correspondenceWakeups = /* @__PURE__ */ new WeakMap();
|
|
30161
30412
|
deliveryIdentity = (requestFrame) => {
|
|
30162
30413
|
try {
|
|
30163
|
-
const request =
|
|
30414
|
+
const request = fromBinary26(RuntimeRequestSchema, requestFrame);
|
|
30164
30415
|
if (request.command.case !== "deliverWorkspaceEffects") return void 0;
|
|
30165
30416
|
const command = request.command.value;
|
|
30166
30417
|
return `${command.sourceSession}\0${command.targetWorkspace}\0${command.sourceCommit ?? ""}`;
|
|
@@ -30171,7 +30422,7 @@ var init_platform_effect_driver = __esm({
|
|
|
30171
30422
|
arrangeCorrespondenceWakeup = (runner, requestFrame, responseFrame, fetchImpl) => {
|
|
30172
30423
|
const identity = deliveryIdentity(requestFrame);
|
|
30173
30424
|
if (!identity) return;
|
|
30174
|
-
const response =
|
|
30425
|
+
const response = fromBinary26(RuntimeResponseSchema, responseFrame);
|
|
30175
30426
|
const retryAt = response.outcome.case === "workspaceEffectsDelivered" ? response.outcome.value.retryAtMillis : void 0;
|
|
30176
30427
|
const wakeups = correspondenceWakeups.get(runner) ?? /* @__PURE__ */ new Map();
|
|
30177
30428
|
correspondenceWakeups.set(runner, wakeups);
|
|
@@ -30296,13 +30547,19 @@ var init_platform_effect_driver = __esm({
|
|
|
30296
30547
|
};
|
|
30297
30548
|
executeGitFetchWithAlongside = async (effect, fetchImpl) => {
|
|
30298
30549
|
if (!effect.alongside) return executeGitFetchEffect(effect, fetchImpl);
|
|
30299
|
-
const
|
|
30300
|
-
|
|
30301
|
-
|
|
30302
|
-
|
|
30303
|
-
|
|
30550
|
+
const cancelAlongside = new AbortController();
|
|
30551
|
+
let alongside;
|
|
30552
|
+
void executeHttpEffect(effect.alongside, (input, init) => fetchImpl(input, {
|
|
30553
|
+
...init,
|
|
30554
|
+
signal: init?.signal ? AbortSignal.any([init.signal, cancelAlongside.signal]) : cancelAlongside.signal
|
|
30555
|
+
})).then((receipt) => {
|
|
30556
|
+
alongside = receipt;
|
|
30557
|
+
});
|
|
30558
|
+
const fetched = await executeGitFetchEffect(effect, fetchImpl);
|
|
30559
|
+
if (fetched.outcome.case === "gitFetch" && alongside?.outcome.case === "response") {
|
|
30304
30560
|
fetched.outcome.value.alongside = alongside.outcome.value;
|
|
30305
30561
|
}
|
|
30562
|
+
cancelAlongside.abort();
|
|
30306
30563
|
return fetched;
|
|
30307
30564
|
};
|
|
30308
30565
|
executeGitPushEffect = async (effect, fetchImpl) => {
|
|
@@ -30362,25 +30619,26 @@ var init_platform_effect_driver = __esm({
|
|
|
30362
30619
|
});
|
|
30363
30620
|
|
|
30364
30621
|
// ../platform-shells/shared/socket_effects.ts
|
|
30365
|
-
import { create as create73, fromBinary as
|
|
30622
|
+
import { create as create73, fromBinary as fromBinary27, toBinary as toBinary28 } from "@bufbuild/protobuf";
|
|
30366
30623
|
function socketEffects(invoke2, permits = () => true) {
|
|
30367
30624
|
const sockets = /* @__PURE__ */ new Map();
|
|
30368
30625
|
let sequence = 50000000000n;
|
|
30369
30626
|
let closed = false;
|
|
30370
30627
|
const receipt = (connectionId, observation) => {
|
|
30371
30628
|
if (closed) return;
|
|
30372
|
-
const frame =
|
|
30629
|
+
const frame = toBinary28(RuntimeRequestSchema, create73(RuntimeRequestSchema, {
|
|
30373
30630
|
protocolVersion: 2,
|
|
30374
30631
|
requestId: ++sequence,
|
|
30375
30632
|
command: { case: "socketReceipt", value: create73(PeerSocketReceiptSchema, { connectionId, observation }) }
|
|
30376
30633
|
}));
|
|
30377
|
-
void Promise.resolve().then(() => invoke2(frame)).catch(() => {
|
|
30634
|
+
void Promise.resolve().then(() => invoke2(frame)).catch((error) => {
|
|
30635
|
+
console.warn("[nomos-socket] receipt failed", { connectionId, error });
|
|
30378
30636
|
sockets.get(connectionId)?.close();
|
|
30379
30637
|
});
|
|
30380
30638
|
};
|
|
30381
30639
|
return {
|
|
30382
30640
|
consume(frame) {
|
|
30383
|
-
const event =
|
|
30641
|
+
const event = fromBinary27(RuntimeEventSchema, frame);
|
|
30384
30642
|
if (event.event.case !== "socketEffect") return false;
|
|
30385
30643
|
const effect = event.event.value;
|
|
30386
30644
|
const id = effect.connectionId;
|
|
@@ -30396,6 +30654,7 @@ function socketEffects(invoke2, permits = () => true) {
|
|
|
30396
30654
|
socket.onopen = () => receipt(id, { case: "opened", value: true });
|
|
30397
30655
|
socket.onmessage = (message) => {
|
|
30398
30656
|
if (message.data instanceof ArrayBuffer) receipt(id, { case: "received", value: new Uint8Array(message.data) });
|
|
30657
|
+
else if (typeof message.data === "string") receipt(id, { case: "received", value: new TextEncoder().encode(message.data) });
|
|
30399
30658
|
};
|
|
30400
30659
|
socket.onclose = () => {
|
|
30401
30660
|
if (sockets.get(id) === socket) sockets.delete(id);
|
|
@@ -30436,17 +30695,17 @@ var init_socket_effects = __esm({
|
|
|
30436
30695
|
});
|
|
30437
30696
|
|
|
30438
30697
|
// ../platform-shells/shared/credential_effects.ts
|
|
30439
|
-
import { create as create74, fromBinary as
|
|
30698
|
+
import { create as create74, fromBinary as fromBinary28, toBinary as toBinary29 } from "@bufbuild/protobuf";
|
|
30440
30699
|
function credentialEffects(invoke2, provider) {
|
|
30441
30700
|
return { consume(frame) {
|
|
30442
|
-
const event =
|
|
30701
|
+
const event = fromBinary28(RuntimeEventSchema, frame);
|
|
30443
30702
|
if (event.event.case !== "credentialRefreshRequested" || provider === externalPeerEffect) return false;
|
|
30444
30703
|
const pending = event.event.value.pending;
|
|
30445
30704
|
if (pending?.effect.case !== "refreshCredential") throw new Error("credential refresh event omitted its physical effect");
|
|
30446
30705
|
const effect = pending.effect.value;
|
|
30447
30706
|
void Promise.resolve().then(async () => {
|
|
30448
30707
|
const receipt = await executeCredentialRefreshEffect(effect, provider);
|
|
30449
|
-
const response =
|
|
30708
|
+
const response = fromBinary28(RuntimeResponseSchema, await invoke2(toBinary29(RuntimeRequestSchema, create74(RuntimeRequestSchema, {
|
|
30450
30709
|
protocolVersion: 2,
|
|
30451
30710
|
requestId: event.sequence,
|
|
30452
30711
|
command: { case: "continueCorrespondence", value: create74(ContinueCorrespondenceRequestSchema, { workId: pending.workId, receipt }) }
|
|
@@ -30469,7 +30728,7 @@ var init_credential_effects = __esm({
|
|
|
30469
30728
|
});
|
|
30470
30729
|
|
|
30471
30730
|
// ../platform-shells/shared/peer_office_host.ts
|
|
30472
|
-
import { create as create75, fromBinary as
|
|
30731
|
+
import { create as create75, fromBinary as fromBinary29, toBinary as toBinary30 } from "@bufbuild/protobuf";
|
|
30473
30732
|
function openPeerOfficeHost(kernel, shell, fetchImpl = globalThis.fetch, maintenanceSettled, postEvent = () => {
|
|
30474
30733
|
}, credentialRefresh, yieldWakeToCaller = false, deviceIdentity, lawPackage, performExternalEffect) {
|
|
30475
30734
|
let runner;
|
|
@@ -30518,7 +30777,7 @@ function openPeerOfficeHost(kernel, shell, fetchImpl = globalThis.fetch, mainten
|
|
|
30518
30777
|
);
|
|
30519
30778
|
const providerOrigins = [...configuredOrigins];
|
|
30520
30779
|
if (providerOrigins.length > 0) {
|
|
30521
|
-
const configured =
|
|
30780
|
+
const configured = fromBinary29(RuntimeResponseSchema, runner.handleFrame(toBinary30(
|
|
30522
30781
|
RuntimeRequestSchema,
|
|
30523
30782
|
create75(RuntimeRequestSchema, {
|
|
30524
30783
|
protocolVersion: 2,
|
|
@@ -30532,7 +30791,7 @@ function openPeerOfficeHost(kernel, shell, fetchImpl = globalThis.fetch, mainten
|
|
|
30532
30791
|
}
|
|
30533
30792
|
return {
|
|
30534
30793
|
async invoke(args) {
|
|
30535
|
-
const request =
|
|
30794
|
+
const request = fromBinary29(RuntimeRequestSchema, args.requestBytes);
|
|
30536
30795
|
if (request.protocolVersion !== 2) {
|
|
30537
30796
|
throw new Error(`unsupported Nomos runtime protocol ${request.protocolVersion}`);
|
|
30538
30797
|
}
|
|
@@ -30588,7 +30847,7 @@ var init_peer_office_host = __esm({
|
|
|
30588
30847
|
init_socket_effects();
|
|
30589
30848
|
init_credential_effects();
|
|
30590
30849
|
targetOf = (frame) => {
|
|
30591
|
-
const target3 =
|
|
30850
|
+
const target3 = fromBinary29(RuntimeRequestSchema, frame).target;
|
|
30592
30851
|
return {
|
|
30593
30852
|
...target3?.session === void 0 ? {} : { session: target3.session },
|
|
30594
30853
|
...target3?.workspace === void 0 ? {} : { workspace: target3.workspace }
|
|
@@ -30642,21 +30901,21 @@ var init_sqlite_peer_desk_store = __esm({
|
|
|
30642
30901
|
}
|
|
30643
30902
|
return this.#opened = database;
|
|
30644
30903
|
}
|
|
30645
|
-
list(
|
|
30904
|
+
list(namespace2) {
|
|
30646
30905
|
const rows = this.#database().prepare(`
|
|
30647
30906
|
SELECT record_key AS key, revision, value
|
|
30648
30907
|
FROM peer_desk_record
|
|
30649
30908
|
WHERE namespace = ?
|
|
30650
30909
|
ORDER BY record_key
|
|
30651
|
-
`).all(
|
|
30910
|
+
`).all(namespace2);
|
|
30652
30911
|
return rows.map((row) => ({
|
|
30653
|
-
namespace,
|
|
30912
|
+
namespace: namespace2,
|
|
30654
30913
|
key: row.key,
|
|
30655
30914
|
revision: BigInt(row.revision),
|
|
30656
30915
|
value: Uint8Array.from(row.value)
|
|
30657
30916
|
}));
|
|
30658
30917
|
}
|
|
30659
|
-
compareExchange(
|
|
30918
|
+
compareExchange(namespace2, key2, expectedRevision, value) {
|
|
30660
30919
|
const expected = expectedRevision === void 0 ? void 0 : Number(expectedRevision);
|
|
30661
30920
|
if (expected !== void 0 && (!Number.isSafeInteger(expected) || expected <= 0)) {
|
|
30662
30921
|
throw new Error(`peer desk revision ${expectedRevision} cannot be represented by SQLite`);
|
|
@@ -30669,8 +30928,8 @@ var init_sqlite_peer_desk_store = __esm({
|
|
|
30669
30928
|
const removed = database.prepare(`
|
|
30670
30929
|
DELETE FROM peer_desk_record
|
|
30671
30930
|
WHERE namespace = ? AND record_key = ? AND revision = ?
|
|
30672
|
-
`).run(
|
|
30673
|
-
if (removed.changes !== 1) this.#conflict(
|
|
30931
|
+
`).run(namespace2, key2, expected);
|
|
30932
|
+
if (removed.changes !== 1) this.#conflict(namespace2, key2);
|
|
30674
30933
|
return this.#commit(void 0);
|
|
30675
30934
|
}
|
|
30676
30935
|
const bytes = Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
@@ -30682,14 +30941,14 @@ var init_sqlite_peer_desk_store = __esm({
|
|
|
30682
30941
|
INSERT INTO peer_desk_record(namespace, record_key, revision, value)
|
|
30683
30942
|
VALUES (?, ?, 1, ?)
|
|
30684
30943
|
ON CONFLICT(namespace, record_key) DO NOTHING
|
|
30685
|
-
`).run(
|
|
30944
|
+
`).run(namespace2, key2, bytes) : database.prepare(`
|
|
30686
30945
|
UPDATE peer_desk_record
|
|
30687
30946
|
SET revision = ?, value = ?
|
|
30688
30947
|
WHERE namespace = ? AND record_key = ? AND revision = ?
|
|
30689
|
-
`).run(nextRevision, bytes,
|
|
30690
|
-
if (changed.changes !== 1) this.#conflict(
|
|
30948
|
+
`).run(nextRevision, bytes, namespace2, key2, expected);
|
|
30949
|
+
if (changed.changes !== 1) this.#conflict(namespace2, key2);
|
|
30691
30950
|
return this.#commit({
|
|
30692
|
-
namespace,
|
|
30951
|
+
namespace: namespace2,
|
|
30693
30952
|
key: key2,
|
|
30694
30953
|
revision: BigInt(nextRevision),
|
|
30695
30954
|
value: value.slice()
|
|
@@ -30707,12 +30966,12 @@ var init_sqlite_peer_desk_store = __esm({
|
|
|
30707
30966
|
this.#database().exec("COMMIT");
|
|
30708
30967
|
return value;
|
|
30709
30968
|
}
|
|
30710
|
-
#conflict(
|
|
30969
|
+
#conflict(namespace2, key2) {
|
|
30711
30970
|
const current = this.#database().prepare(`
|
|
30712
30971
|
SELECT revision FROM peer_desk_record WHERE namespace = ? AND record_key = ?
|
|
30713
|
-
`).get(
|
|
30972
|
+
`).get(namespace2, key2);
|
|
30714
30973
|
throw new Error(
|
|
30715
|
-
`peer desk record '${
|
|
30974
|
+
`peer desk record '${namespace2}/${key2}' changed at revision ${current?.revision ?? "absent"}`
|
|
30716
30975
|
);
|
|
30717
30976
|
}
|
|
30718
30977
|
};
|
|
@@ -31109,7 +31368,7 @@ __export(peer_office_exports, {
|
|
|
31109
31368
|
signEraCertification: () => signEraCertification,
|
|
31110
31369
|
verifyRemoteChain: () => verifyRemoteChain
|
|
31111
31370
|
});
|
|
31112
|
-
import { create as create77, fromBinary as
|
|
31371
|
+
import { create as create77, fromBinary as fromBinary30, toBinary as toBinary31 } from "@bufbuild/protobuf";
|
|
31113
31372
|
import { createHash as createHash3, randomUUID as randomUUID2 } from "node:crypto";
|
|
31114
31373
|
import {
|
|
31115
31374
|
existsSync as existsSync6,
|
|
@@ -31190,13 +31449,13 @@ async function invokeLocalPeerOffice(cloud, command, target3) {
|
|
|
31190
31449
|
command
|
|
31191
31450
|
});
|
|
31192
31451
|
const office = await peer(cloud);
|
|
31193
|
-
const response =
|
|
31452
|
+
const response = fromBinary30(RuntimeResponseSchema, await office.invoke({
|
|
31194
31453
|
...target3 === void 0 ? {} : {
|
|
31195
31454
|
workspace: target3.workspace,
|
|
31196
31455
|
authToken: target3.authToken,
|
|
31197
31456
|
sourceDeviceKeySecret: target3.authorSecret
|
|
31198
31457
|
},
|
|
31199
|
-
requestBytes:
|
|
31458
|
+
requestBytes: toBinary31(RuntimeRequestSchema, request)
|
|
31200
31459
|
}));
|
|
31201
31460
|
if (response.requestId !== requestId) {
|
|
31202
31461
|
throw new Error(`Peer Office returned response ${response.requestId} for request ${requestId}`);
|