githolon 0.112.7 → 0.112.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/dev-server.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import http from "node:http";
|
|
|
3
3
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
4
4
|
import { mkdirSync as mkdirSync5, readFileSync as readFileSync4, rmSync as rmSync4, writeFileSync as writeFileSync5 } from "node:fs";
|
|
5
5
|
import path4 from "node:path";
|
|
6
|
-
import { create as create82, fromBinary as
|
|
6
|
+
import { create as create82, fromBinary as fromBinary34, toBinary as toBinary36 } from "@bufbuild/protobuf";
|
|
7
7
|
|
|
8
8
|
// ../adapter/proto/nomos/kernel/v1/kernel_pb.js
|
|
9
9
|
import { enumDesc, fileDesc, messageDesc, serviceDesc, tsEnum } from "@bufbuild/protobuf/codegenv2";
|
|
@@ -792,17 +792,17 @@ function attributes(capability) {
|
|
|
792
792
|
}
|
|
793
793
|
return result;
|
|
794
794
|
}
|
|
795
|
-
function capabilityByNamespace(capabilities,
|
|
796
|
-
const matches = capabilities.filter((capability) => capability.namespace ===
|
|
795
|
+
function capabilityByNamespace(capabilities, namespace2) {
|
|
796
|
+
const matches = capabilities.filter((capability) => capability.namespace === namespace2);
|
|
797
797
|
if (matches.length !== 1) {
|
|
798
|
-
throw new Error(`OSGi resource needs exactly one ${
|
|
798
|
+
throw new Error(`OSGi resource needs exactly one ${namespace2} capability`);
|
|
799
799
|
}
|
|
800
800
|
return matches[0];
|
|
801
801
|
}
|
|
802
|
-
function optionalCapabilityByNamespace(capabilities,
|
|
803
|
-
const matches = capabilities.filter((capability) => capability.namespace ===
|
|
802
|
+
function optionalCapabilityByNamespace(capabilities, namespace2) {
|
|
803
|
+
const matches = capabilities.filter((capability) => capability.namespace === namespace2);
|
|
804
804
|
if (matches.length > 1) {
|
|
805
|
-
throw new Error(`OSGi resource needs at most one ${
|
|
805
|
+
throw new Error(`OSGi resource needs at most one ${namespace2} capability`);
|
|
806
806
|
}
|
|
807
807
|
return matches[0];
|
|
808
808
|
}
|
|
@@ -2515,10 +2515,10 @@ function nodeCustodyFilesystem(directory3) {
|
|
|
2515
2515
|
// ../platform-shells/node/kernel_wasi_stdio.ts
|
|
2516
2516
|
import { TextDecoder as TextDecoder2 } from "node:util";
|
|
2517
2517
|
function kernelWasiStdio(memory, stderr, writeFile2, stderrPartial) {
|
|
2518
|
-
const
|
|
2518
|
+
const decoder5 = new TextDecoder2();
|
|
2519
2519
|
let pending = "";
|
|
2520
2520
|
const accept = (bytes) => {
|
|
2521
|
-
pending +=
|
|
2521
|
+
pending += decoder5.decode(bytes, { stream: true });
|
|
2522
2522
|
for (; ; ) {
|
|
2523
2523
|
const newline = pending.indexOf("\n");
|
|
2524
2524
|
if (newline >= 0 && newline < 16384) {
|
|
@@ -3997,10 +3997,10 @@ var PeerPlatformShell = class {
|
|
|
3997
3997
|
};
|
|
3998
3998
|
|
|
3999
3999
|
// ../platform-shells/shared/peer_office_host.ts
|
|
4000
|
-
import { create as create79, fromBinary as
|
|
4000
|
+
import { create as create79, fromBinary as fromBinary33, toBinary as toBinary35 } from "@bufbuild/protobuf";
|
|
4001
4001
|
|
|
4002
4002
|
// ../peer-office/src/peer_office.ts
|
|
4003
|
-
import { create as create75, toBinary as
|
|
4003
|
+
import { create as create75, toBinary as toBinary31 } from "@bufbuild/protobuf";
|
|
4004
4004
|
|
|
4005
4005
|
// ../peer-office/src/runtime/kernel_port.ts
|
|
4006
4006
|
import { create as create12, fromBinary as fromBinary8, toBinary as toBinary9 } from "@bufbuild/protobuf";
|
|
@@ -4509,7 +4509,8 @@ var KernelPort = class {
|
|
|
4509
4509
|
}
|
|
4510
4510
|
}));
|
|
4511
4511
|
if (response.outcome.case === "failure") {
|
|
4512
|
-
|
|
4512
|
+
throwUnnamedHistoryRequirement(response.outcome.value, mount.workspace);
|
|
4513
|
+
throwKernelFailure(response.outcome.value);
|
|
4513
4514
|
}
|
|
4514
4515
|
if (response.outcome.case !== "outbox") {
|
|
4515
4516
|
throw new Error(`kernel returned '${response.outcome.case || "empty"}' while reading correspondence`);
|
|
@@ -4538,7 +4539,8 @@ var KernelPort = class {
|
|
|
4538
4539
|
}
|
|
4539
4540
|
}));
|
|
4540
4541
|
if (response.outcome.case === "failure") {
|
|
4541
|
-
|
|
4542
|
+
throwUnnamedHistoryRequirement(response.outcome.value, mount.workspace);
|
|
4543
|
+
throwKernelFailure(response.outcome.value);
|
|
4542
4544
|
}
|
|
4543
4545
|
if (response.outcome.case !== "outbox") {
|
|
4544
4546
|
throw new Error(
|
|
@@ -7569,19 +7571,19 @@ function base64(bytes) {
|
|
|
7569
7571
|
// ../peer-office/src/runtime/workspace_naming.ts
|
|
7570
7572
|
import { create as create24 } from "@bufbuild/protobuf";
|
|
7571
7573
|
var WORKSPACE_NAME_SEP = "";
|
|
7572
|
-
var keyedBirthNameOf = (
|
|
7574
|
+
var keyedBirthNameOf = (namespace2, key) => `${namespace2}-${sha256Hex(new TextEncoder().encode(namespace2 + WORKSPACE_NAME_SEP + key)).slice(0, 40)}`;
|
|
7573
7575
|
var RECEIVING_GROUP_NAME_PREFIX = "nomos-rg-";
|
|
7574
7576
|
var receivingGroupNameOf = (principal) => `${RECEIVING_GROUP_NAME_PREFIX}${sha256Hex(new TextEncoder().encode(principal)).slice(0, 40)}`;
|
|
7575
|
-
var isKeyedBirthOf = (
|
|
7577
|
+
var isKeyedBirthOf = (namespace2, workspace) => workspace.startsWith(`${namespace2}-`);
|
|
7576
7578
|
var WORKSPACE_NAME_REQUEST_INVALID = "nomos.runtime.workspace_name_request_invalid";
|
|
7577
7579
|
function resolveWorkspaceName(command) {
|
|
7578
7580
|
switch (command.birth.case) {
|
|
7579
7581
|
case "keyed": {
|
|
7580
|
-
const { namespace, key } = command.birth.value;
|
|
7581
|
-
if (
|
|
7582
|
+
const { namespace: namespace2, key } = command.birth.value;
|
|
7583
|
+
if (namespace2.length === 0 || key.length === 0) {
|
|
7582
7584
|
throw new Error(`${WORKSPACE_NAME_REQUEST_INVALID}: a keyed birth name needs both its namespace and its key`);
|
|
7583
7585
|
}
|
|
7584
|
-
return create24(ResolvedWorkspaceNameSchema, { workspace: keyedBirthNameOf(
|
|
7586
|
+
return create24(ResolvedWorkspaceNameSchema, { workspace: keyedBirthNameOf(namespace2, key) });
|
|
7585
7587
|
}
|
|
7586
7588
|
case "receivingGroup": {
|
|
7587
7589
|
const { principal } = command.birth.value;
|
|
@@ -9632,14 +9634,143 @@ var ModelAdoptionDesk = class {
|
|
|
9632
9634
|
}
|
|
9633
9635
|
};
|
|
9634
9636
|
|
|
9637
|
+
// ../peer-office/src/runtime/custody_receipts.ts
|
|
9638
|
+
import { fromBinary as fromBinary19, toBinary as toBinary17 } from "@bufbuild/protobuf";
|
|
9639
|
+
|
|
9640
|
+
// ../peer-office/src/runtime/peer_desk_store.ts
|
|
9641
|
+
var recordId = (namespace2, key) => `${namespace2.length}:${namespace2}${key}`;
|
|
9642
|
+
var copy2 = (record) => ({
|
|
9643
|
+
...record,
|
|
9644
|
+
value: record.value.slice()
|
|
9645
|
+
});
|
|
9646
|
+
var MemoryPeerDeskStore = class {
|
|
9647
|
+
#records = /* @__PURE__ */ new Map();
|
|
9648
|
+
list(namespace2) {
|
|
9649
|
+
return [...this.#records.values()].filter((record) => record.namespace === namespace2).sort((left, right) => left.key.localeCompare(right.key)).map(copy2);
|
|
9650
|
+
}
|
|
9651
|
+
compareExchange(namespace2, key, expectedRevision, value) {
|
|
9652
|
+
const id = recordId(namespace2, key);
|
|
9653
|
+
const current = this.#records.get(id);
|
|
9654
|
+
if (current?.revision !== expectedRevision) {
|
|
9655
|
+
throw new Error(
|
|
9656
|
+
`peer desk record '${namespace2}/${key}' changed at revision ${current?.revision ?? "absent"}`
|
|
9657
|
+
);
|
|
9658
|
+
}
|
|
9659
|
+
if (value === void 0) {
|
|
9660
|
+
this.#records.delete(id);
|
|
9661
|
+
return void 0;
|
|
9662
|
+
}
|
|
9663
|
+
const next = Object.freeze({
|
|
9664
|
+
namespace: namespace2,
|
|
9665
|
+
key,
|
|
9666
|
+
revision: (current?.revision ?? 0n) + 1n,
|
|
9667
|
+
value: value.slice()
|
|
9668
|
+
});
|
|
9669
|
+
this.#records.set(id, next);
|
|
9670
|
+
return copy2(next);
|
|
9671
|
+
}
|
|
9672
|
+
};
|
|
9673
|
+
|
|
9674
|
+
// ../peer-office/src/runtime/custody_receipts.ts
|
|
9675
|
+
var namespace = "nomos.peer-desk.custody-receipts/v1";
|
|
9676
|
+
var encoder = new TextEncoder();
|
|
9677
|
+
var decoder = new TextDecoder();
|
|
9678
|
+
var MAX_BASES = 256;
|
|
9679
|
+
var MAX_RECEIPTS = 4096;
|
|
9680
|
+
var CustodyReceipts = class {
|
|
9681
|
+
#store;
|
|
9682
|
+
#records = /* @__PURE__ */ new Map();
|
|
9683
|
+
#journals = /* @__PURE__ */ new Map();
|
|
9684
|
+
#receipts = /* @__PURE__ */ new Map();
|
|
9685
|
+
constructor(store = new MemoryPeerDeskStore()) {
|
|
9686
|
+
this.#store = store;
|
|
9687
|
+
for (const record of store.list(namespace)) {
|
|
9688
|
+
this.#records.set(record.key, record);
|
|
9689
|
+
try {
|
|
9690
|
+
if (record.key.startsWith("receipt:")) {
|
|
9691
|
+
const newline = record.value.indexOf(10);
|
|
9692
|
+
if (newline < 0) continue;
|
|
9693
|
+
const receipt = fromBinary19(CustodyIntentAdmissionSchema, record.value.subarray(newline + 1));
|
|
9694
|
+
const header3 = JSON.parse(decoder.decode(record.value.subarray(0, newline)));
|
|
9695
|
+
if (receipt.outcome.case === "admitted" && typeof header3.generation === "string" && typeof header3.head === "string") this.#receipts.set(record.key, { ...header3, receipt });
|
|
9696
|
+
continue;
|
|
9697
|
+
}
|
|
9698
|
+
if (!record.key.startsWith("head:")) continue;
|
|
9699
|
+
const value = JSON.parse(decoder.decode(record.value));
|
|
9700
|
+
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;
|
|
9701
|
+
if (!value.bases.every((base) => typeof base === "string") || !value.keys.every((key) => typeof key === "string")) continue;
|
|
9702
|
+
this.#journals.set(record.key.slice(5), value);
|
|
9703
|
+
} catch {
|
|
9704
|
+
}
|
|
9705
|
+
}
|
|
9706
|
+
}
|
|
9707
|
+
covers(workspace, current, base) {
|
|
9708
|
+
const value = this.#journals.get(workspace);
|
|
9709
|
+
return value?.head === current && value.bases.includes(base);
|
|
9710
|
+
}
|
|
9711
|
+
receipt(workspace, current, change) {
|
|
9712
|
+
const value = this.#journals.get(workspace);
|
|
9713
|
+
if (value?.head !== current) return void 0;
|
|
9714
|
+
const stored = this.#receipts.get(`receipt:${workspace}:${sha256Hex(change)}`);
|
|
9715
|
+
if (stored?.generation !== value.generation) return void 0;
|
|
9716
|
+
if (stored.head !== value.head && !value.bases.includes(stored.head)) return void 0;
|
|
9717
|
+
return fromBinary19(CustodyIntentAdmissionSchema, toBinary17(CustodyIntentAdmissionSchema, stored.receipt));
|
|
9718
|
+
}
|
|
9719
|
+
record(workspace, before, after, receipts) {
|
|
9720
|
+
const old = this.#journals.get(workspace);
|
|
9721
|
+
const journalKey = `head:${workspace}`;
|
|
9722
|
+
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) };
|
|
9723
|
+
if (before && before !== after) value.bases.push(before);
|
|
9724
|
+
value.bases = [...new Set(value.bases)].slice(-MAX_BASES);
|
|
9725
|
+
const keys = new Set(value.keys);
|
|
9726
|
+
const discarded = new Set(old?.generation !== value.generation ? old?.keys : []);
|
|
9727
|
+
for (const { change, receipt } of receipts) {
|
|
9728
|
+
if (receipt.outcome.case !== "admitted") continue;
|
|
9729
|
+
const key = `receipt:${workspace}:${sha256Hex(change)}`;
|
|
9730
|
+
keys.delete(key);
|
|
9731
|
+
keys.add(key);
|
|
9732
|
+
discarded.delete(key);
|
|
9733
|
+
const header3 = encoder.encode(`${JSON.stringify({ generation: value.generation, head: after })}
|
|
9734
|
+
`);
|
|
9735
|
+
const body = toBinary17(CustodyIntentAdmissionSchema, receipt);
|
|
9736
|
+
const bytes = new Uint8Array(header3.length + body.length);
|
|
9737
|
+
bytes.set(header3);
|
|
9738
|
+
bytes.set(body, header3.length);
|
|
9739
|
+
const record2 = this.#store.compareExchange(namespace, key, this.#records.get(key)?.revision, bytes);
|
|
9740
|
+
if (record2) this.#records.set(key, record2);
|
|
9741
|
+
this.#receipts.set(key, {
|
|
9742
|
+
generation: value.generation,
|
|
9743
|
+
head: after,
|
|
9744
|
+
receipt: fromBinary19(CustodyIntentAdmissionSchema, body)
|
|
9745
|
+
});
|
|
9746
|
+
}
|
|
9747
|
+
const ordered = [...keys];
|
|
9748
|
+
for (const key of ordered.slice(0, -MAX_RECEIPTS)) discarded.add(key);
|
|
9749
|
+
value.keys = ordered.slice(-MAX_RECEIPTS);
|
|
9750
|
+
for (const key of discarded) {
|
|
9751
|
+
this.#store.compareExchange(namespace, key, this.#records.get(key)?.revision, void 0);
|
|
9752
|
+
this.#records.delete(key);
|
|
9753
|
+
this.#receipts.delete(key);
|
|
9754
|
+
}
|
|
9755
|
+
const record = this.#store.compareExchange(
|
|
9756
|
+
namespace,
|
|
9757
|
+
journalKey,
|
|
9758
|
+
this.#records.get(journalKey)?.revision,
|
|
9759
|
+
encoder.encode(JSON.stringify(value))
|
|
9760
|
+
);
|
|
9761
|
+
if (record) this.#records.set(journalKey, record);
|
|
9762
|
+
this.#journals.set(workspace, value);
|
|
9763
|
+
}
|
|
9764
|
+
};
|
|
9765
|
+
|
|
9635
9766
|
// ../peer-office/src/runtime/custodian_placement.ts
|
|
9636
|
-
import { create as create30, fromBinary as
|
|
9767
|
+
import { create as create30, fromBinary as fromBinary20, toBinary as toBinary18 } from "@bufbuild/protobuf";
|
|
9637
9768
|
var CustodianPlacement = class {
|
|
9638
9769
|
#kernel;
|
|
9639
9770
|
#clock;
|
|
9640
9771
|
#template;
|
|
9641
9772
|
constructor(kernel, clock, templateProtobuf) {
|
|
9642
|
-
const template =
|
|
9773
|
+
const template = fromBinary20(CustodyPlacementPolicySchema, templateProtobuf);
|
|
9643
9774
|
if (!template.declaration || !template.adoptedBy || template.rules.length === 0 || template.remotes.length === 0) {
|
|
9644
9775
|
throw new Error("custodian placement template requires a declaration, adoptedBy, rules and remotes");
|
|
9645
9776
|
}
|
|
@@ -9671,7 +9802,7 @@ var CustodianPlacement = class {
|
|
|
9671
9802
|
});
|
|
9672
9803
|
return create30(CustodyPlacementPolicySchema, {
|
|
9673
9804
|
...content,
|
|
9674
|
-
packageSha256: sha256Hex(
|
|
9805
|
+
packageSha256: sha256Hex(toBinary18(CustodyPlacementPolicySchema, content))
|
|
9675
9806
|
});
|
|
9676
9807
|
}
|
|
9677
9808
|
/** Adopt this custodian's placement for an opened, born workspace that has none. True when it adopted. */
|
|
@@ -9736,14 +9867,16 @@ var CandidateCustodyRequiredError = class extends Error {
|
|
|
9736
9867
|
var CustodyAdmissionDesk = class {
|
|
9737
9868
|
#kernel;
|
|
9738
9869
|
#custody;
|
|
9739
|
-
|
|
9870
|
+
#receipts;
|
|
9871
|
+
constructor(kernel, custody, receipts = new CustodyReceipts()) {
|
|
9740
9872
|
this.#kernel = kernel;
|
|
9741
9873
|
this.#custody = custody;
|
|
9874
|
+
this.#receipts = receipts;
|
|
9742
9875
|
}
|
|
9743
9876
|
admit(request, command) {
|
|
9744
|
-
const
|
|
9745
|
-
if (!
|
|
9746
|
-
const mount = this.#custody.
|
|
9877
|
+
const workspace = request.target?.workspace;
|
|
9878
|
+
if (!workspace) throw new Error("custody admission requires an addressed workspace");
|
|
9879
|
+
const mount = this.#custody.mountForWorkspace(workspace);
|
|
9747
9880
|
if (command.evidencePack.byteLength > 0) {
|
|
9748
9881
|
this.#kernel.applyPack(mount, request.requestId, command.evidencePack);
|
|
9749
9882
|
}
|
|
@@ -9754,21 +9887,42 @@ var CustodyAdmissionDesk = class {
|
|
|
9754
9887
|
const births = [];
|
|
9755
9888
|
const admittedBase = this.#kernel.head(mount, request.requestId) ?? "";
|
|
9756
9889
|
if (command.fastForwardOnly && offers.length > 0 && (command.baseHead ?? "") !== admittedBase) {
|
|
9890
|
+
for (const offer of offers) {
|
|
9891
|
+
const receipt = this.#receipts.receipt(mount.workspace, admittedBase, offer.changeUsda);
|
|
9892
|
+
if (!receipt) continue;
|
|
9893
|
+
receipt.commitOid = offer.commitOid;
|
|
9894
|
+
const records = sessions.get(offer.session) ?? [];
|
|
9895
|
+
records.push(receipt);
|
|
9896
|
+
sessions.set(offer.session, records);
|
|
9897
|
+
}
|
|
9898
|
+
let delta = custodyReturnDelta(
|
|
9899
|
+
this.#kernel,
|
|
9900
|
+
mount,
|
|
9901
|
+
request.requestId,
|
|
9902
|
+
command.baseHead,
|
|
9903
|
+
admittedBase,
|
|
9904
|
+
admittedBase,
|
|
9905
|
+
command.observedHead
|
|
9906
|
+
);
|
|
9907
|
+
if (command.baseHead && command.observedHead !== admittedBase && this.#receipts.covers(mount.workspace, admittedBase, command.baseHead)) {
|
|
9908
|
+
try {
|
|
9909
|
+
delta = {
|
|
9910
|
+
resultBase: command.baseHead,
|
|
9911
|
+
resultPack: this.#kernel.packDelta(mount, request.requestId, admittedBase, command.baseHead),
|
|
9912
|
+
recoveryRequired: false
|
|
9913
|
+
};
|
|
9914
|
+
} catch {
|
|
9915
|
+
}
|
|
9916
|
+
}
|
|
9757
9917
|
return create31(CustodyAdmissionSchema, {
|
|
9758
9918
|
main: admittedBase,
|
|
9759
|
-
...
|
|
9760
|
-
|
|
9761
|
-
mount,
|
|
9762
|
-
request.requestId,
|
|
9763
|
-
command.baseHead,
|
|
9764
|
-
admittedBase,
|
|
9765
|
-
admittedBase,
|
|
9766
|
-
command.observedHead
|
|
9767
|
-
)
|
|
9919
|
+
sessions: [...sessions].map(([session, intents]) => create31(CustodySessionAdmissionSchema, { session, intents })),
|
|
9920
|
+
...delta
|
|
9768
9921
|
});
|
|
9769
9922
|
}
|
|
9770
9923
|
let main = admittedBase;
|
|
9771
9924
|
const heldSessions = /* @__PURE__ */ new Map();
|
|
9925
|
+
const receipts = [];
|
|
9772
9926
|
for (const offer of offers) {
|
|
9773
9927
|
const heldBehind = heldSessions.get(offer.session);
|
|
9774
9928
|
const verdict = heldBehind === void 0 ? this.#offer(request, mount, offer) : create31(OfferResponseSchema, { outcome: { case: "blockedOnDependency", value: {
|
|
@@ -9778,7 +9932,9 @@ var CustodyAdmissionDesk = class {
|
|
|
9778
9932
|
heldSessions.set(offer.session, verdict.outcome.value.offerId || offer.commitOid);
|
|
9779
9933
|
}
|
|
9780
9934
|
const records = sessions.get(offer.session) ?? [];
|
|
9781
|
-
|
|
9935
|
+
const receipt = this.#record(offer, verdict);
|
|
9936
|
+
records.push(receipt);
|
|
9937
|
+
receipts.push({ change: offer.changeUsda, receipt });
|
|
9782
9938
|
sessions.set(offer.session, records);
|
|
9783
9939
|
if (verdict.outcome.case === "admitted") {
|
|
9784
9940
|
main = verdict.outcome.value.head;
|
|
@@ -9794,6 +9950,9 @@ var CustodyAdmissionDesk = class {
|
|
|
9794
9950
|
}
|
|
9795
9951
|
}
|
|
9796
9952
|
}
|
|
9953
|
+
if (receipts.some((entry) => entry.receipt.outcome.case === "admitted")) {
|
|
9954
|
+
this.#receipts.record(mount.workspace, admittedBase, main, receipts);
|
|
9955
|
+
}
|
|
9797
9956
|
return create31(CustodyAdmissionSchema, {
|
|
9798
9957
|
main,
|
|
9799
9958
|
sessions: [...sessions].map(
|
|
@@ -10739,7 +10898,7 @@ var ApplicationReadinessDesk = class {
|
|
|
10739
10898
|
};
|
|
10740
10899
|
|
|
10741
10900
|
// ../peer-office/src/runtime/authentication_readiness_desk.ts
|
|
10742
|
-
import { create as create39, fromBinary as
|
|
10901
|
+
import { create as create39, fromBinary as fromBinary21, toBinary as toBinary19 } from "@bufbuild/protobuf";
|
|
10743
10902
|
var AuthenticationReadinessDesk = class {
|
|
10744
10903
|
#waiting = /* @__PURE__ */ new Map();
|
|
10745
10904
|
#sequence = 0;
|
|
@@ -10755,7 +10914,7 @@ var AuthenticationReadinessDesk = class {
|
|
|
10755
10914
|
begin(request, input) {
|
|
10756
10915
|
if (![AuthenticationReadinessCriterion.ENROLLED_DEVICE, AuthenticationReadinessCriterion.PROVIDER_TOKEN, AuthenticationReadinessCriterion.BIRTH_EVIDENCE].includes(input.criterion)) throw new Error("authentication readiness requires a criterion");
|
|
10757
10916
|
if (!input.session) throw new Error("authentication readiness requires a session");
|
|
10758
|
-
const command =
|
|
10917
|
+
const command = fromBinary21(AwaitAuthenticationRequestSchema, toBinary19(AwaitAuthenticationRequestSchema, input));
|
|
10759
10918
|
const now = this.#now();
|
|
10760
10919
|
for (const [id2, work2] of this.#waiting) if (work2.expiresAt <= now) this.#waiting.delete(id2);
|
|
10761
10920
|
const work = {
|
|
@@ -11504,7 +11663,7 @@ var ResidencyPins = class {
|
|
|
11504
11663
|
};
|
|
11505
11664
|
|
|
11506
11665
|
// ../peer-office/src/runtime/subscription_manager.ts
|
|
11507
|
-
import { clone, create as create44, toBinary as
|
|
11666
|
+
import { clone, create as create44, toBinary as toBinary20 } from "@bufbuild/protobuf";
|
|
11508
11667
|
var sameBytes = (left, right) => {
|
|
11509
11668
|
if (!left || left.byteLength !== right.byteLength) return false;
|
|
11510
11669
|
for (let index = 0; index < right.byteLength; index += 1) {
|
|
@@ -11632,7 +11791,7 @@ var SubscriptionManager = class {
|
|
|
11632
11791
|
const groups = [];
|
|
11633
11792
|
for (const subscription of this.#subscriptions.values()) {
|
|
11634
11793
|
if (!matches(subscription) || !subscription.request.query) continue;
|
|
11635
|
-
const declaration =
|
|
11794
|
+
const declaration = toBinary20(QueryRequestSchema, subscription.request.query);
|
|
11636
11795
|
const session = subscription.request.session;
|
|
11637
11796
|
const group = groups.find((group2) => group2.session === session && sameBytes(group2.declaration, declaration));
|
|
11638
11797
|
if (group) group.watches.push(subscription);
|
|
@@ -12757,8 +12916,8 @@ var short = (oid) => oid.slice(0, 12);
|
|
|
12757
12916
|
// ../peer-office/src/runtime/preserved_copies_desk.ts
|
|
12758
12917
|
import { create as create46, fromJsonString, toJsonString } from "@bufbuild/protobuf";
|
|
12759
12918
|
var PRESERVED_COPIES_NAMESPACE = "nomos.peer-desk.preserved-local-copies/v1";
|
|
12760
|
-
var
|
|
12761
|
-
var
|
|
12919
|
+
var encoder2 = new TextEncoder();
|
|
12920
|
+
var decoder2 = new TextDecoder();
|
|
12762
12921
|
var PreservedCopiesDesk = class {
|
|
12763
12922
|
#store;
|
|
12764
12923
|
constructor(store) {
|
|
@@ -12767,7 +12926,7 @@ var PreservedCopiesDesk = class {
|
|
|
12767
12926
|
list(workspace) {
|
|
12768
12927
|
const record = this.#store.list(PRESERVED_COPIES_NAMESPACE).find((entry) => entry.key === workspace);
|
|
12769
12928
|
if (!record) return [];
|
|
12770
|
-
const values = JSON.parse(
|
|
12929
|
+
const values = JSON.parse(decoder2.decode(record.value));
|
|
12771
12930
|
if (!Array.isArray(values)) {
|
|
12772
12931
|
throw new Error(`corrupt preserved-copy record for '${workspace}' at revision ${record.revision}`);
|
|
12773
12932
|
}
|
|
@@ -12781,14 +12940,14 @@ var PreservedCopiesDesk = class {
|
|
|
12781
12940
|
PRESERVED_COPIES_NAMESPACE,
|
|
12782
12941
|
copy3.workspace,
|
|
12783
12942
|
current?.revision,
|
|
12784
|
-
|
|
12943
|
+
encoder2.encode(`[${next.map((entry) => toJsonString(PreservedLocalCopySchema, entry)).join(",")}]`)
|
|
12785
12944
|
);
|
|
12786
12945
|
if (!stored) throw new Error(`preserved copy of '${copy3.workspace}' was not recorded`);
|
|
12787
12946
|
}
|
|
12788
12947
|
};
|
|
12789
12948
|
|
|
12790
12949
|
// ../peer-office/src/runtime/office_seat.ts
|
|
12791
|
-
import { fromBinary as
|
|
12950
|
+
import { fromBinary as fromBinary22 } from "@bufbuild/protobuf";
|
|
12792
12951
|
function officeSeat(profile) {
|
|
12793
12952
|
const origins = /* @__PURE__ */ new Set();
|
|
12794
12953
|
const add = (url) => {
|
|
@@ -12798,7 +12957,7 @@ function officeSeat(profile) {
|
|
|
12798
12957
|
add(profile.liveRelayOrigin);
|
|
12799
12958
|
if (profile.custodianPlacement !== void 0 && profile.custodianPlacement.byteLength > 0) {
|
|
12800
12959
|
try {
|
|
12801
|
-
for (const remote of
|
|
12960
|
+
for (const remote of fromBinary22(CustodyPlacementPolicySchema, profile.custodianPlacement).remotes) {
|
|
12802
12961
|
add(remote.url);
|
|
12803
12962
|
}
|
|
12804
12963
|
} catch {
|
|
@@ -12824,9 +12983,9 @@ var LOCAL_ONLY_NAMESPACES = /* @__PURE__ */ new Set([
|
|
|
12824
12983
|
]);
|
|
12825
12984
|
var SEAT_PREFIX = "nomos-office-seat/v1:";
|
|
12826
12985
|
var SEAT_DIGEST_HEX = 64;
|
|
12827
|
-
var
|
|
12828
|
-
var
|
|
12829
|
-
var header2 = (digest) =>
|
|
12986
|
+
var encoder3 = new TextEncoder();
|
|
12987
|
+
var decoder3 = new TextDecoder();
|
|
12988
|
+
var header2 = (digest) => encoder3.encode(`${SEAT_PREFIX}${digest}
|
|
12830
12989
|
`);
|
|
12831
12990
|
var QuarantineReason = Object.freeze({
|
|
12832
12991
|
/** Another office's seat: a copied state directory, or a store lifted from another peer. */
|
|
@@ -12837,7 +12996,7 @@ var QuarantineReason = Object.freeze({
|
|
|
12837
12996
|
function readSeal(value) {
|
|
12838
12997
|
const headerLength = SEAT_PREFIX.length + SEAT_DIGEST_HEX + 1;
|
|
12839
12998
|
if (value.byteLength < headerLength) return void 0;
|
|
12840
|
-
const text2 =
|
|
12999
|
+
const text2 = decoder3.decode(value.subarray(0, headerLength));
|
|
12841
13000
|
if (!text2.startsWith(SEAT_PREFIX) || !text2.endsWith("\n")) return void 0;
|
|
12842
13001
|
const seat = text2.slice(SEAT_PREFIX.length, headerLength - 1);
|
|
12843
13002
|
if (!/^[0-9a-f]{64}$/.test(seat)) return void 0;
|
|
@@ -12861,44 +13020,44 @@ var SeatedPeerDeskStore = class {
|
|
|
12861
13020
|
this.#seat = seat;
|
|
12862
13021
|
this.#report = report;
|
|
12863
13022
|
}
|
|
12864
|
-
list(
|
|
12865
|
-
if (LOCAL_ONLY_NAMESPACES.has(
|
|
13023
|
+
list(namespace2) {
|
|
13024
|
+
if (LOCAL_ONLY_NAMESPACES.has(namespace2)) return this.#inner.list(namespace2);
|
|
12866
13025
|
const kept = [];
|
|
12867
|
-
for (const record of this.#inner.list(
|
|
13026
|
+
for (const record of this.#inner.list(namespace2)) {
|
|
12868
13027
|
const sealed = readSeal(record.value);
|
|
12869
13028
|
if (sealed?.seat === this.#seat.digest) {
|
|
12870
13029
|
kept.push({ ...record, value: sealed.value.slice() });
|
|
12871
13030
|
continue;
|
|
12872
13031
|
}
|
|
12873
|
-
this.#quarantine(
|
|
13032
|
+
this.#quarantine(namespace2, record, sealed?.seat);
|
|
12874
13033
|
}
|
|
12875
13034
|
return kept;
|
|
12876
13035
|
}
|
|
12877
|
-
compareExchange(
|
|
12878
|
-
if (LOCAL_ONLY_NAMESPACES.has(
|
|
12879
|
-
return this.#inner.compareExchange(
|
|
13036
|
+
compareExchange(namespace2, key, expectedRevision, value) {
|
|
13037
|
+
if (LOCAL_ONLY_NAMESPACES.has(namespace2)) {
|
|
13038
|
+
return this.#inner.compareExchange(namespace2, key, expectedRevision, value);
|
|
12880
13039
|
}
|
|
12881
13040
|
const stored = this.#inner.compareExchange(
|
|
12882
|
-
|
|
13041
|
+
namespace2,
|
|
12883
13042
|
key,
|
|
12884
13043
|
expectedRevision,
|
|
12885
13044
|
value === void 0 ? void 0 : seal(this.#seat.digest, value)
|
|
12886
13045
|
);
|
|
12887
13046
|
if (stored === void 0) return void 0;
|
|
12888
13047
|
const sealed = readSeal(stored.value);
|
|
12889
|
-
if (!sealed) throw new Error(`peer desk record '${
|
|
13048
|
+
if (!sealed) throw new Error(`peer desk record '${namespace2}/${key}' lost its office seat`);
|
|
12890
13049
|
return { ...stored, value: sealed.value.slice() };
|
|
12891
13050
|
}
|
|
12892
13051
|
/** Preserve the foreign record under the quarantine namespace, then free the slot. */
|
|
12893
|
-
#quarantine(
|
|
12894
|
-
const key = `${
|
|
13052
|
+
#quarantine(namespace2, record, recordedSeat) {
|
|
13053
|
+
const key = `${namespace2}\0${record.key}\0${record.revision}`;
|
|
12895
13054
|
try {
|
|
12896
13055
|
this.#inner.compareExchange(QUARANTINED_BINDINGS_NAMESPACE, key, void 0, record.value);
|
|
12897
13056
|
} catch {
|
|
12898
13057
|
}
|
|
12899
|
-
this.#inner.compareExchange(
|
|
13058
|
+
this.#inner.compareExchange(namespace2, record.key, record.revision, void 0);
|
|
12900
13059
|
this.#report(create47(QuarantinedBindingSchema, {
|
|
12901
|
-
namespace,
|
|
13060
|
+
namespace: namespace2,
|
|
12902
13061
|
key: record.key,
|
|
12903
13062
|
reason: recordedSeat === void 0 ? QuarantineReason.Unseated : QuarantineReason.ForeignSeat,
|
|
12904
13063
|
recordedSeat: recordedSeat ?? "",
|
|
@@ -12948,6 +13107,7 @@ var ReplicaInventoryDesk = class _ReplicaInventoryDesk {
|
|
|
12948
13107
|
const undiscovered = /* @__PURE__ */ new Set();
|
|
12949
13108
|
for (const restored of this.#follows.recover()) {
|
|
12950
13109
|
following.set(restored.workspace, restored.delayMillis);
|
|
13110
|
+
followed.add(restored.workspace);
|
|
12951
13111
|
}
|
|
12952
13112
|
if (!this.#bootstrapped) {
|
|
12953
13113
|
this.#bootstrapped = true;
|
|
@@ -12985,6 +13145,7 @@ var ReplicaInventoryDesk = class _ReplicaInventoryDesk {
|
|
|
12985
13145
|
stopped.delete(workspace);
|
|
12986
13146
|
} else if (reconciliation.changed) {
|
|
12987
13147
|
following.delete(workspace);
|
|
13148
|
+
followed.delete(workspace);
|
|
12988
13149
|
stopped.add(workspace);
|
|
12989
13150
|
}
|
|
12990
13151
|
} catch (error) {
|
|
@@ -13032,7 +13193,7 @@ var ReplicaInventoryDesk = class _ReplicaInventoryDesk {
|
|
|
13032
13193
|
};
|
|
13033
13194
|
|
|
13034
13195
|
// ../peer-office/src/runtime/placement_discovery_desk.ts
|
|
13035
|
-
import { create as create48, toBinary as
|
|
13196
|
+
import { create as create48, toBinary as toBinary21 } from "@bufbuild/protobuf";
|
|
13036
13197
|
|
|
13037
13198
|
// ../peer-office/src/runtime/correspondence_work_registry.ts
|
|
13038
13199
|
var CorrespondenceWorkRegistry = class {
|
|
@@ -13177,7 +13338,7 @@ var PlacementDiscoveryDesk = class {
|
|
|
13177
13338
|
return {
|
|
13178
13339
|
workspace: next.workspace,
|
|
13179
13340
|
nextAfterMillis: 0,
|
|
13180
|
-
frame:
|
|
13341
|
+
frame: toBinary21(RuntimeRequestSchema, create48(RuntimeRequestSchema, {
|
|
13181
13342
|
protocolVersion: 2,
|
|
13182
13343
|
requestId,
|
|
13183
13344
|
command: { case: "workspacePlacement", value: {
|
|
@@ -13262,7 +13423,7 @@ var PlacementDiscoveryDesk = class {
|
|
|
13262
13423
|
};
|
|
13263
13424
|
|
|
13264
13425
|
// ../peer-office/src/runtime/live_correspondence_desk.ts
|
|
13265
|
-
import { create as create49, fromBinary as
|
|
13426
|
+
import { create as create49, fromBinary as fromBinary23, toBinary as toBinary22 } from "@bufbuild/protobuf";
|
|
13266
13427
|
var MAX_LIVE_FRAME_BYTES = 25 * 1024 * 1024;
|
|
13267
13428
|
var PLACEMENT_REF3 = "refs/nomos/placement";
|
|
13268
13429
|
var PRESENCE_PEER_TOKEN_HEX = 32;
|
|
@@ -13317,7 +13478,7 @@ var LiveCorrespondenceDesk = class {
|
|
|
13317
13478
|
wasResident: this.kernel.isResident(binding.workspace) !== false
|
|
13318
13479
|
};
|
|
13319
13480
|
this.#links.set(binding.workspace, link);
|
|
13320
|
-
if (link.wasResident) this.#open(link);
|
|
13481
|
+
if (!link.publisher || link.wasResident) this.#open(link);
|
|
13321
13482
|
}
|
|
13322
13483
|
changed(workspace) {
|
|
13323
13484
|
const link = this.#links.get(workspace);
|
|
@@ -13339,11 +13500,14 @@ var LiveCorrespondenceDesk = class {
|
|
|
13339
13500
|
this.#effect(link, { case: "openUrl", value: `${endpoint}/v2/workspaces/${encodeURIComponent(link.binding.workspace)}/subscribe?${subscribeQuery(link)}` });
|
|
13340
13501
|
}
|
|
13341
13502
|
#send(link, message) {
|
|
13342
|
-
const bytes =
|
|
13503
|
+
const bytes = toBinary22(LiveOfferFrameSchema, create49(LiveOfferFrameSchema, { message }));
|
|
13343
13504
|
if (bytes.byteLength > MAX_LIVE_FRAME_BYTES) return;
|
|
13344
13505
|
this.#effect(link, { case: "send", value: bytes });
|
|
13345
13506
|
}
|
|
13346
13507
|
export(binding, base, requestId) {
|
|
13508
|
+
if (this.kernel.isResident(binding.workspace) === false) {
|
|
13509
|
+
return create49(CustodyOfferBatchRequestSchema, { protocolVersion: 2 });
|
|
13510
|
+
}
|
|
13347
13511
|
const mount = workspaceMount(binding.workspace);
|
|
13348
13512
|
const head = this.kernel.head(mount, requestId);
|
|
13349
13513
|
if (!base || !head || base === head) return create49(CustodyOfferBatchRequestSchema, { protocolVersion: 2 });
|
|
@@ -13389,7 +13553,7 @@ var LiveCorrespondenceDesk = class {
|
|
|
13389
13553
|
if (!bytes.byteLength || bytes.byteLength > MAX_LIVE_FRAME_BYTES) return;
|
|
13390
13554
|
let frame;
|
|
13391
13555
|
try {
|
|
13392
|
-
frame =
|
|
13556
|
+
frame = fromBinary23(LiveOfferFrameSchema, bytes);
|
|
13393
13557
|
} catch {
|
|
13394
13558
|
let ring;
|
|
13395
13559
|
try {
|
|
@@ -13404,6 +13568,7 @@ var LiveCorrespondenceDesk = class {
|
|
|
13404
13568
|
}
|
|
13405
13569
|
if (frame.message.case === "frontier") {
|
|
13406
13570
|
this.#announced(link, frame.message.value.head);
|
|
13571
|
+
if (this.kernel.isResident(link.binding.workspace) === false) return;
|
|
13407
13572
|
if (!frame.message.value.response) {
|
|
13408
13573
|
this.#send(link, { case: "frontier", value: {
|
|
13409
13574
|
head: this.kernel.head(workspaceMount(link.binding.workspace), ++this.#requestId) ?? "",
|
|
@@ -13420,6 +13585,10 @@ var LiveCorrespondenceDesk = class {
|
|
|
13420
13585
|
if (frame.message.case !== "offers") return;
|
|
13421
13586
|
const batch = frame.message.value;
|
|
13422
13587
|
if (batch.protocolVersion !== 2 || !batch.requestId || batch.source.case !== "inline" || !batch.source.value.offers.length) return;
|
|
13588
|
+
if (this.kernel.isResident(link.binding.workspace) === false) {
|
|
13589
|
+
this.remoteAdvanced?.(link.binding.workspace);
|
|
13590
|
+
return;
|
|
13591
|
+
}
|
|
13423
13592
|
if ([...this.#pending.values()].some((pending) => pending.link === link && pending.bytes.length === bytes.length && pending.bytes.every((byte, index) => byte === bytes[index]))) return;
|
|
13424
13593
|
if (this.#pending.size >= 32) return;
|
|
13425
13594
|
this.#pending.set(request.requestId, { link, bytes });
|
|
@@ -13427,7 +13596,16 @@ var LiveCorrespondenceDesk = class {
|
|
|
13427
13596
|
protocolVersion: 2,
|
|
13428
13597
|
requestId: request.requestId,
|
|
13429
13598
|
target: { workspace: link.binding.workspace, session: link.binding.replicaId },
|
|
13430
|
-
|
|
13599
|
+
// HTTP sender reconciliation controls are not part of a live proposal.
|
|
13600
|
+
// Keeping fastForwardOnly while removing baseHead silently skips every
|
|
13601
|
+
// offer against a nonempty local head. The Kernel judges sealed causality;
|
|
13602
|
+
// live receivers neither ask for a return archive nor confirm the sender.
|
|
13603
|
+
command: { case: "admitCustodyOffers", value: create49(CustodyOfferBatchRequestSchema, {
|
|
13604
|
+
...batch,
|
|
13605
|
+
baseHead: void 0,
|
|
13606
|
+
observedHead: void 0,
|
|
13607
|
+
fastForwardOnly: false
|
|
13608
|
+
}) }
|
|
13431
13609
|
});
|
|
13432
13610
|
}
|
|
13433
13611
|
/** Upstream news is a frontier this replica has NEVER seen: neither its own head nor the
|
|
@@ -13436,6 +13614,10 @@ var LiveCorrespondenceDesk = class {
|
|
|
13436
13614
|
#announced(link, head) {
|
|
13437
13615
|
if (!head || link.lastAnnounced === head) return;
|
|
13438
13616
|
link.lastAnnounced = head;
|
|
13617
|
+
if (this.kernel.isResident(link.binding.workspace) === false) {
|
|
13618
|
+
this.remoteAdvanced?.(link.binding.workspace);
|
|
13619
|
+
return;
|
|
13620
|
+
}
|
|
13439
13621
|
const mount = workspaceMount(link.binding.workspace);
|
|
13440
13622
|
if (head === this.kernel.head(mount, ++this.#requestId) || head === this.kernel.resolveRef(mount, ++this.#requestId, "refs/remotes/nomos/main")) return;
|
|
13441
13623
|
this.remoteAdvanced?.(link.binding.workspace);
|
|
@@ -13445,6 +13627,10 @@ var LiveCorrespondenceDesk = class {
|
|
|
13445
13627
|
#placementAnnounced(link, frontier) {
|
|
13446
13628
|
if (!frontier || link.lastPlacementAnnounced === frontier) return;
|
|
13447
13629
|
link.lastPlacementAnnounced = frontier;
|
|
13630
|
+
if (this.kernel.isResident(link.binding.workspace) === false) {
|
|
13631
|
+
this.placementAdvanced?.(link.binding.workspace);
|
|
13632
|
+
return;
|
|
13633
|
+
}
|
|
13448
13634
|
const mount = workspaceMount(link.binding.workspace);
|
|
13449
13635
|
if (frontier === this.kernel.resolveRef(mount, ++this.#requestId, PLACEMENT_REF3)) return;
|
|
13450
13636
|
this.placementAdvanced?.(link.binding.workspace);
|
|
@@ -13461,11 +13647,13 @@ var LiveCorrespondenceDesk = class {
|
|
|
13461
13647
|
disconnect(workspace) {
|
|
13462
13648
|
const link = this.#links.get(workspace);
|
|
13463
13649
|
if (!link) return;
|
|
13650
|
+
if (link.state === "open") this.linkClosed?.(workspace);
|
|
13464
13651
|
this.#effect(link, { case: "close", value: true });
|
|
13465
13652
|
this.#links.delete(workspace);
|
|
13466
13653
|
for (const [id, pending] of this.#pending) if (pending.link === link) this.#pending.delete(id);
|
|
13467
13654
|
}
|
|
13468
13655
|
#hello(link) {
|
|
13656
|
+
if (this.kernel.isResident(link.binding.workspace) === false) return;
|
|
13469
13657
|
const head = this.kernel.head(workspaceMount(link.binding.workspace), ++this.#requestId);
|
|
13470
13658
|
this.#send(link, { case: "frontier", value: { head: head ?? "" } });
|
|
13471
13659
|
}
|
|
@@ -13473,19 +13661,20 @@ var LiveCorrespondenceDesk = class {
|
|
|
13473
13661
|
const now = this.clock.monotonicNanoseconds();
|
|
13474
13662
|
let wake;
|
|
13475
13663
|
for (const link of this.#links.values()) {
|
|
13476
|
-
|
|
13664
|
+
const resident = this.kernel.isResident(link.binding.workspace) !== false;
|
|
13665
|
+
if (link.publisher && !resident) {
|
|
13477
13666
|
if (link.wasResident) this.disconnect(link.binding.workspace);
|
|
13478
13667
|
else wake = wake === void 0 || wake > 250n ? 250n : wake;
|
|
13479
13668
|
continue;
|
|
13480
13669
|
}
|
|
13481
|
-
link.wasResident = true;
|
|
13670
|
+
if (resident) link.wasResident = true;
|
|
13482
13671
|
if (link.state === "opening" && now >= link.due) {
|
|
13483
13672
|
this.#effect(link, { case: "close", value: true });
|
|
13484
13673
|
link.state = "closed";
|
|
13485
13674
|
}
|
|
13486
13675
|
if (link.state === "closed" && now >= link.due) this.#open(link);
|
|
13487
13676
|
if (link.state === "open") {
|
|
13488
|
-
if (link.dirty) {
|
|
13677
|
+
if (link.dirty && resident) {
|
|
13489
13678
|
link.dirty = false;
|
|
13490
13679
|
try {
|
|
13491
13680
|
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");
|
|
@@ -13504,8 +13693,7 @@ var LiveCorrespondenceDesk = class {
|
|
|
13504
13693
|
return wake;
|
|
13505
13694
|
}
|
|
13506
13695
|
close() {
|
|
13507
|
-
for (const
|
|
13508
|
-
this.#links.clear();
|
|
13696
|
+
for (const workspace of [...this.#links.keys()]) this.disconnect(workspace);
|
|
13509
13697
|
this.#pending.clear();
|
|
13510
13698
|
}
|
|
13511
13699
|
};
|
|
@@ -13636,9 +13824,9 @@ var RecordsDesk = class {
|
|
|
13636
13824
|
command.namespace === void 0 ? {} : { "custody.children_namespace": command.namespace },
|
|
13637
13825
|
() => this.#kernel.childWorkspaces(mount, request.requestId)
|
|
13638
13826
|
);
|
|
13639
|
-
const
|
|
13640
|
-
const selected =
|
|
13641
|
-
(child) => child.status === ChildWorkspaceLifecycleStatus.ACTIVE && isKeyedBirthOf(
|
|
13827
|
+
const namespace2 = command.namespace;
|
|
13828
|
+
const selected = namespace2 === void 0 ? result.children : result.children.filter(
|
|
13829
|
+
(child) => child.status === ChildWorkspaceLifecycleStatus.ACTIVE && isKeyedBirthOf(namespace2, child.workspace)
|
|
13642
13830
|
);
|
|
13643
13831
|
return create51(ChildWorkspaceListSchema, {
|
|
13644
13832
|
children: selected.map((child) => create51(ChildWorkspaceSchema, {
|
|
@@ -14004,41 +14192,7 @@ var RecoveryDesk = class {
|
|
|
14004
14192
|
};
|
|
14005
14193
|
|
|
14006
14194
|
// ../peer-office/src/runtime/correspondence_desk.ts
|
|
14007
|
-
import { create as create64, toBinary as
|
|
14008
|
-
|
|
14009
|
-
// ../peer-office/src/runtime/peer_desk_store.ts
|
|
14010
|
-
var recordId = (namespace, key) => `${namespace.length}:${namespace}${key}`;
|
|
14011
|
-
var copy2 = (record) => ({
|
|
14012
|
-
...record,
|
|
14013
|
-
value: record.value.slice()
|
|
14014
|
-
});
|
|
14015
|
-
var MemoryPeerDeskStore = class {
|
|
14016
|
-
#records = /* @__PURE__ */ new Map();
|
|
14017
|
-
list(namespace) {
|
|
14018
|
-
return [...this.#records.values()].filter((record) => record.namespace === namespace).sort((left, right) => left.key.localeCompare(right.key)).map(copy2);
|
|
14019
|
-
}
|
|
14020
|
-
compareExchange(namespace, key, expectedRevision, value) {
|
|
14021
|
-
const id = recordId(namespace, key);
|
|
14022
|
-
const current = this.#records.get(id);
|
|
14023
|
-
if (current?.revision !== expectedRevision) {
|
|
14024
|
-
throw new Error(
|
|
14025
|
-
`peer desk record '${namespace}/${key}' changed at revision ${current?.revision ?? "absent"}`
|
|
14026
|
-
);
|
|
14027
|
-
}
|
|
14028
|
-
if (value === void 0) {
|
|
14029
|
-
this.#records.delete(id);
|
|
14030
|
-
return void 0;
|
|
14031
|
-
}
|
|
14032
|
-
const next = Object.freeze({
|
|
14033
|
-
namespace,
|
|
14034
|
-
key,
|
|
14035
|
-
revision: (current?.revision ?? 0n) + 1n,
|
|
14036
|
-
value: value.slice()
|
|
14037
|
-
});
|
|
14038
|
-
this.#records.set(id, next);
|
|
14039
|
-
return copy2(next);
|
|
14040
|
-
}
|
|
14041
|
-
};
|
|
14195
|
+
import { create as create64, toBinary as toBinary26 } from "@bufbuild/protobuf";
|
|
14042
14196
|
|
|
14043
14197
|
// ../peer-office/src/runtime/correspondence_recovery.ts
|
|
14044
14198
|
import { create as create55 } from "@bufbuild/protobuf";
|
|
@@ -14126,7 +14280,7 @@ var CorrespondenceRecoveryWork = class {
|
|
|
14126
14280
|
};
|
|
14127
14281
|
|
|
14128
14282
|
// ../peer-office/src/runtime/workspace_sync.ts
|
|
14129
|
-
import { create as create59, fromBinary as
|
|
14283
|
+
import { create as create59, fromBinary as fromBinary25 } from "@bufbuild/protobuf";
|
|
14130
14284
|
|
|
14131
14285
|
// ../peer-office/src/runtime/placement_fetch.ts
|
|
14132
14286
|
import { create as create56 } from "@bufbuild/protobuf";
|
|
@@ -14206,7 +14360,7 @@ function resolveCustodyDisagreement(kernel, mount, requestId, policy, verdict) {
|
|
|
14206
14360
|
}
|
|
14207
14361
|
|
|
14208
14362
|
// ../peer-office/src/runtime/custody_offer.ts
|
|
14209
|
-
import { create as create58, fromBinary as
|
|
14363
|
+
import { create as create58, fromBinary as fromBinary24, toBinary as toBinary23 } from "@bufbuild/protobuf";
|
|
14210
14364
|
var CUSTODY_OFFER_MEDIA_TYPE = "application/vnd.nomos.custody-offer-batch+protobuf";
|
|
14211
14365
|
var CUSTODY_OFFER_RESULT_MEDIA_TYPE = "application/vnd.nomos.custody-offer-result+protobuf";
|
|
14212
14366
|
function settleCustodyOfferExchange(awaiting, response) {
|
|
@@ -14238,7 +14392,7 @@ function settleCustodyOfferExchange(awaiting, response) {
|
|
|
14238
14392
|
}
|
|
14239
14393
|
}
|
|
14240
14394
|
function encodeInlineCustodyOffer(args) {
|
|
14241
|
-
return
|
|
14395
|
+
return toBinary23(CustodyOfferBatchRequestSchema, create58(CustodyOfferBatchRequestSchema, {
|
|
14242
14396
|
protocolVersion: 2,
|
|
14243
14397
|
requestId: args.requestId,
|
|
14244
14398
|
source: {
|
|
@@ -14258,7 +14412,7 @@ function encodeInlineCustodyOffer(args) {
|
|
|
14258
14412
|
}));
|
|
14259
14413
|
}
|
|
14260
14414
|
function decodeCustodyOffer(bytes, requestId) {
|
|
14261
|
-
const response =
|
|
14415
|
+
const response = fromBinary24(CustodyOfferBatchResponseSchema, bytes);
|
|
14262
14416
|
if (response.protocolVersion !== 2 || response.requestId !== requestId) {
|
|
14263
14417
|
throw new Error("custody offer returned a mismatched generated response");
|
|
14264
14418
|
}
|
|
@@ -14425,6 +14579,7 @@ var WorkspaceSyncWork = class {
|
|
|
14425
14579
|
#offerSequence = 0;
|
|
14426
14580
|
#lastStep;
|
|
14427
14581
|
#probeOnly;
|
|
14582
|
+
#liveConnected;
|
|
14428
14583
|
/** Set when this round adopted the upstream's own head as its base (see #establishBase). */
|
|
14429
14584
|
#establishedBase;
|
|
14430
14585
|
#receiveState;
|
|
@@ -14457,6 +14612,7 @@ var WorkspaceSyncWork = class {
|
|
|
14457
14612
|
this.#directoryAnswered = args.directoryAnswered;
|
|
14458
14613
|
this.#placementFetched = args.placementFetched;
|
|
14459
14614
|
this.#probeOnly = args.probeOnly ?? false;
|
|
14615
|
+
this.#liveConnected = args.liveConnected === true;
|
|
14460
14616
|
this.#receiveState = args.receiveState;
|
|
14461
14617
|
this.#completeHistory = args.completeHistory === true;
|
|
14462
14618
|
this.#repairMissingCommit = args.repairMissingCommit === true;
|
|
@@ -14527,6 +14683,9 @@ var WorkspaceSyncWork = class {
|
|
|
14527
14683
|
#openRound() {
|
|
14528
14684
|
if (this.#receiveState || this.#replaceLocalHead !== void 0) return this.#leaseEffect();
|
|
14529
14685
|
if (!this.#localHead) return this.#leaseEffect();
|
|
14686
|
+
if (this.#liveConnected && !this.#probeOnly && this.#holdsLocalWork() && this.#previousHead) {
|
|
14687
|
+
return this.#offerOrReconcile();
|
|
14688
|
+
}
|
|
14530
14689
|
const requestId = `${this.#binding.replicaId}:${this.#requestId}:${this.workId}:frontier`;
|
|
14531
14690
|
return this.#beginOffer(encodeInlineCustodyOffer({
|
|
14532
14691
|
session: this.#binding.replicaId,
|
|
@@ -14758,6 +14917,18 @@ var WorkspaceSyncWork = class {
|
|
|
14758
14917
|
return this.#finishOfferOutcome(false);
|
|
14759
14918
|
}
|
|
14760
14919
|
const admission = outcome.value;
|
|
14920
|
+
globalThis.__nomosSyncDiagnostic?.("sync.admission", {
|
|
14921
|
+
workspace: this.#mount.workspace,
|
|
14922
|
+
phase: state.phase,
|
|
14923
|
+
local: this.#localHead,
|
|
14924
|
+
tracked: this.#previousHead,
|
|
14925
|
+
remote: admission.main,
|
|
14926
|
+
sealed: admission.sealedMain,
|
|
14927
|
+
resultBase: admission.resultBase,
|
|
14928
|
+
resultBytes: admission.resultPack.byteLength,
|
|
14929
|
+
recoveryRequired: admission.recoveryRequired,
|
|
14930
|
+
summary: summarizeCustodyAdmission(admission)
|
|
14931
|
+
});
|
|
14761
14932
|
this.#desiredHead = admission.main || void 0;
|
|
14762
14933
|
if (!this.#desiredHead) return this.#transportFailure("resident peer returned no admitted frontier", false);
|
|
14763
14934
|
this.#candidateDurable = admission.sealedMain === this.#desiredHead;
|
|
@@ -15032,7 +15203,7 @@ var WorkspaceSyncWork = class {
|
|
|
15032
15203
|
#acceptLawProducts(response) {
|
|
15033
15204
|
if (response.status !== 200 || response.contentType?.split(";")[0]?.trim() !== LAW_PRODUCTS_MEDIA_TYPE2) return;
|
|
15034
15205
|
try {
|
|
15035
|
-
const exported =
|
|
15206
|
+
const exported = fromBinary25(ExportLawProductsResponseSchema, response.body);
|
|
15036
15207
|
this.#fetchedLawProducts = { head: exported.head, products: exported.products };
|
|
15037
15208
|
} catch {
|
|
15038
15209
|
}
|
|
@@ -15374,6 +15545,19 @@ var WorkspaceSyncWork = class {
|
|
|
15374
15545
|
return step;
|
|
15375
15546
|
}
|
|
15376
15547
|
#finish(value) {
|
|
15548
|
+
globalThis.__nomosSyncDiagnostic?.("sync.finished", {
|
|
15549
|
+
workspace: value.workspace,
|
|
15550
|
+
previous: value.previousHead,
|
|
15551
|
+
current: value.currentHead,
|
|
15552
|
+
stillAhead: value.stillAhead,
|
|
15553
|
+
deferred: String(value.deferred),
|
|
15554
|
+
admitted: String(value.admitted),
|
|
15555
|
+
reconnect: value.reconnectRequired,
|
|
15556
|
+
directOfferDeferred: value.directOfferDeferred,
|
|
15557
|
+
pushFailed: value.pushFailed,
|
|
15558
|
+
failure: value.pushError?.message,
|
|
15559
|
+
wallMs: elapsedMillis(this.#clock, this.#started)
|
|
15560
|
+
});
|
|
15377
15561
|
this.#state = { phase: WorkspaceSyncPhase.Done };
|
|
15378
15562
|
this.#current = void 0;
|
|
15379
15563
|
return this.#remember({ case: "synced", value });
|
|
@@ -15430,6 +15614,10 @@ var WorkspaceDependencySyncWork = class {
|
|
|
15430
15614
|
this.#plan = [this.#args.root];
|
|
15431
15615
|
return this.#advance();
|
|
15432
15616
|
}
|
|
15617
|
+
if (this.#args.liveConnected && this.#args.kernel.resolveRef(this.#args.root.mount, this.#args.requestId, trackedMain2)) {
|
|
15618
|
+
this.#plan = this.#planDependencies();
|
|
15619
|
+
return this.#advance();
|
|
15620
|
+
}
|
|
15433
15621
|
this.#current = this.#work(this.#args.root, `${this.workId}:frontier`, true);
|
|
15434
15622
|
return this.#accept(this.#current.start());
|
|
15435
15623
|
}
|
|
@@ -15702,7 +15890,7 @@ var CorrespondenceRetrySchedule = class {
|
|
|
15702
15890
|
};
|
|
15703
15891
|
|
|
15704
15892
|
// ../peer-office/src/runtime/workspace_effect_delivery.ts
|
|
15705
|
-
import { create as create61, fromBinary as
|
|
15893
|
+
import { create as create61, fromBinary as fromBinary26, toBinary as toBinary24 } from "@bufbuild/protobuf";
|
|
15706
15894
|
|
|
15707
15895
|
// ../adapter/workspace_effect_outcome.ts
|
|
15708
15896
|
function workspaceEffectOutcome(response) {
|
|
@@ -16107,7 +16295,7 @@ var RemoteWorkspaceEffectDeliveryWork = class {
|
|
|
16107
16295
|
}
|
|
16108
16296
|
let status;
|
|
16109
16297
|
try {
|
|
16110
|
-
status =
|
|
16298
|
+
status = fromBinary26(WorkspaceEffectStatusResponseSchema, observation.body);
|
|
16111
16299
|
} catch {
|
|
16112
16300
|
return this.#transportFailed("mailbox returned an invalid effect observation");
|
|
16113
16301
|
}
|
|
@@ -16122,7 +16310,7 @@ var RemoteWorkspaceEffectDeliveryWork = class {
|
|
|
16122
16310
|
return this.#advance(this.#delivery.next(response2, this.#settlement));
|
|
16123
16311
|
}
|
|
16124
16312
|
if (receipt.outcome.value.status === 202 && (receipt.outcome.value.contentType ?? "").includes(WORKSPACE_EFFECT_DEFERRED)) {
|
|
16125
|
-
const deferred =
|
|
16313
|
+
const deferred = fromBinary26(WorkspaceEffectDeferredSchema, receipt.outcome.value.body);
|
|
16126
16314
|
this.#deferredRetryAfterMillis = Math.max(
|
|
16127
16315
|
this.#deferredRetryAfterMillis ?? 0,
|
|
16128
16316
|
Number(deferred.retryAfterMillis)
|
|
@@ -16147,7 +16335,7 @@ var RemoteWorkspaceEffectDeliveryWork = class {
|
|
|
16147
16335
|
}
|
|
16148
16336
|
let applied;
|
|
16149
16337
|
try {
|
|
16150
|
-
applied =
|
|
16338
|
+
applied = fromBinary26(OfferResponseSchema, receipt.outcome.value.body);
|
|
16151
16339
|
} catch {
|
|
16152
16340
|
return this.#transportFailed("remote workspace returned an invalid offer response");
|
|
16153
16341
|
}
|
|
@@ -16269,7 +16457,7 @@ var RemoteWorkspaceEffectDeliveryWork = class {
|
|
|
16269
16457
|
url: this.#mailboxUrl,
|
|
16270
16458
|
contentType: WORKSPACE_EFFECT_STATUS,
|
|
16271
16459
|
accept: WORKSPACE_EFFECT_STATUS_RESPONSE,
|
|
16272
|
-
body:
|
|
16460
|
+
body: toBinary24(WorkspaceEffectStatusRequestSchema, create61(WorkspaceEffectStatusRequestSchema, {
|
|
16273
16461
|
sourceWorkspaceGenesis: offer.sourceWorkspaceGenesis,
|
|
16274
16462
|
effectDigest: offer.effectDigest
|
|
16275
16463
|
}))
|
|
@@ -16296,7 +16484,7 @@ var RemoteWorkspaceEffectDeliveryWork = class {
|
|
|
16296
16484
|
url: this.#mailboxUrl,
|
|
16297
16485
|
contentType: CARRIED_OFFER,
|
|
16298
16486
|
accept: CARRIED_OFFER_RESPONSE,
|
|
16299
|
-
body:
|
|
16487
|
+
body: toBinary24(OfferRequestSchema, body)
|
|
16300
16488
|
});
|
|
16301
16489
|
this.#pending = create61(CorrespondencePendingSchema, {
|
|
16302
16490
|
workId: this.workId,
|
|
@@ -16307,7 +16495,7 @@ var RemoteWorkspaceEffectDeliveryWork = class {
|
|
|
16307
16495
|
};
|
|
16308
16496
|
|
|
16309
16497
|
// ../peer-office/src/runtime/replica_follow_lane.ts
|
|
16310
|
-
import { create as create62, toBinary as
|
|
16498
|
+
import { create as create62, toBinary as toBinary25 } from "@bufbuild/protobuf";
|
|
16311
16499
|
var ReplicaFollowLane = class {
|
|
16312
16500
|
#controller;
|
|
16313
16501
|
#clock;
|
|
@@ -16381,7 +16569,7 @@ var ReplicaFollowLane = class {
|
|
|
16381
16569
|
if (action === ReplicaFollowAction.RefreshCredential) {
|
|
16382
16570
|
return {
|
|
16383
16571
|
workspace,
|
|
16384
|
-
frame:
|
|
16572
|
+
frame: toBinary25(RuntimeRequestSchema, create62(RuntimeRequestSchema, {
|
|
16385
16573
|
protocolVersion: 2,
|
|
16386
16574
|
requestId,
|
|
16387
16575
|
command: {
|
|
@@ -16396,7 +16584,7 @@ var ReplicaFollowLane = class {
|
|
|
16396
16584
|
const replaceLocalHead = this.#controller.replacementHead(workspace);
|
|
16397
16585
|
return {
|
|
16398
16586
|
workspace,
|
|
16399
|
-
frame:
|
|
16587
|
+
frame: toBinary25(RuntimeRequestSchema, create62(RuntimeRequestSchema, {
|
|
16400
16588
|
protocolVersion: 2,
|
|
16401
16589
|
requestId,
|
|
16402
16590
|
command: {
|
|
@@ -16613,6 +16801,7 @@ var CorrespondenceDesk = class {
|
|
|
16613
16801
|
#onSyncCompleted;
|
|
16614
16802
|
#onPlacementFetched;
|
|
16615
16803
|
#onShallowMount;
|
|
16804
|
+
#onOutboxHistoryRequired;
|
|
16616
16805
|
#remoteOffers = new CorrespondenceWorkRegistry();
|
|
16617
16806
|
#recoveries = new CorrespondenceWorkRegistry();
|
|
16618
16807
|
#deliveries = new CorrespondenceWorkRegistry();
|
|
@@ -16659,6 +16848,7 @@ var CorrespondenceDesk = class {
|
|
|
16659
16848
|
this.#onSyncCompleted = args.onSyncCompleted;
|
|
16660
16849
|
this.#onPlacementFetched = args.onPlacementFetched;
|
|
16661
16850
|
this.#onShallowMount = args.onShallowMount;
|
|
16851
|
+
this.#onOutboxHistoryRequired = args.onOutboxHistoryRequired;
|
|
16662
16852
|
this.#clock = args.clock;
|
|
16663
16853
|
this.#outboxClock = new OutboxObservationClock(args.clock, args.peerIdentity);
|
|
16664
16854
|
this.#executesCustodianObligations = args.executesCustodianObligations ?? false;
|
|
@@ -16822,6 +17012,15 @@ var CorrespondenceDesk = class {
|
|
|
16822
17012
|
this.#followLane.dependencyAdvanced(workspace);
|
|
16823
17013
|
this.reportFollows();
|
|
16824
17014
|
}
|
|
17015
|
+
/** Received custody can release correspondence and foreign-read dependencies,
|
|
17016
|
+
* but is not newly authored work to send back to its upstream. Recovery is
|
|
17017
|
+
* driven separately by missing history, reconnects and provider announcements.
|
|
17018
|
+
* In particular an optimistic relay is not a durable upstream receipt. */
|
|
17019
|
+
receivedFrontierChanged(workspace) {
|
|
17020
|
+
this.wakeOutbox(workspace);
|
|
17021
|
+
this.#followLane.dependencyAdvanced(workspace);
|
|
17022
|
+
this.reportFollows();
|
|
17023
|
+
}
|
|
16825
17024
|
/**
|
|
16826
17025
|
* Tell a workspace's sessions what its durable follow ALREADY knows.
|
|
16827
17026
|
*
|
|
@@ -17058,8 +17257,16 @@ var CorrespondenceDesk = class {
|
|
|
17058
17257
|
)
|
|
17059
17258
|
);
|
|
17060
17259
|
} catch (error) {
|
|
17260
|
+
if (error instanceof KernelHistoryRequired && this.#onOutboxHistoryRequired) {
|
|
17261
|
+
const retry = this.#onOutboxHistoryRequired(workspace, binding.credentialCapability);
|
|
17262
|
+
this.#outboxDueAt.set(workspace, now + Math.max(250, retry));
|
|
17263
|
+
return { nextAfterMillis: 0 };
|
|
17264
|
+
}
|
|
17061
17265
|
const format = localCopyFormatRefusal(error);
|
|
17062
|
-
if (format === void 0)
|
|
17266
|
+
if (format === void 0) {
|
|
17267
|
+
this.#outboxDueAt.set(workspace, now + 3e4);
|
|
17268
|
+
return { nextAfterMillis: 0 };
|
|
17269
|
+
}
|
|
17063
17270
|
this.#readability.mark(workspace, void 0, format);
|
|
17064
17271
|
this.#outboxDueAt.delete(workspace);
|
|
17065
17272
|
return { nextAfterMillis: 0 };
|
|
@@ -17140,7 +17347,7 @@ var CorrespondenceDesk = class {
|
|
|
17140
17347
|
};
|
|
17141
17348
|
return {
|
|
17142
17349
|
workspace,
|
|
17143
|
-
frame:
|
|
17350
|
+
frame: toBinary26(RuntimeRequestSchema, create64(RuntimeRequestSchema, {
|
|
17144
17351
|
protocolVersion: 2,
|
|
17145
17352
|
requestId,
|
|
17146
17353
|
target: { workspace, session: binding.session },
|
|
@@ -17339,6 +17546,7 @@ var CorrespondenceDesk = class {
|
|
|
17339
17546
|
requestId: request.requestId,
|
|
17340
17547
|
workId: id,
|
|
17341
17548
|
probeOnly,
|
|
17549
|
+
liveConnected: this.#openLinks.has(target3.mount.workspace),
|
|
17342
17550
|
...beforeConverge === void 0 ? {} : { beforeConverge },
|
|
17343
17551
|
...target3.receiveState === void 0 ? {} : { receiveState: target3.receiveState },
|
|
17344
17552
|
...target3.offerHead === void 0 ? {} : { offerHead: target3.offerHead },
|
|
@@ -17366,6 +17574,7 @@ var CorrespondenceDesk = class {
|
|
|
17366
17574
|
root,
|
|
17367
17575
|
work,
|
|
17368
17576
|
outbound: command.admit,
|
|
17577
|
+
liveConnected: this.#openLinks.has(mount.workspace),
|
|
17369
17578
|
dependency: (workspace, source, acquire2 = false) => {
|
|
17370
17579
|
if (this.#roundInFlight(workspace, workId2)) return void 0;
|
|
17371
17580
|
const existing = this.#follows.bindingForWorkspace(workspace);
|
|
@@ -17820,7 +18029,7 @@ var IdentityWitnessCache = class {
|
|
|
17820
18029
|
};
|
|
17821
18030
|
|
|
17822
18031
|
// ../peer-office/src/runtime/identity_witness_read.ts
|
|
17823
|
-
import { create as create67, fromBinary as
|
|
18032
|
+
import { create as create67, fromBinary as fromBinary27, toBinary as toBinary27 } from "@bufbuild/protobuf";
|
|
17824
18033
|
function prepareWitnessRead(args) {
|
|
17825
18034
|
if (args.reception.workspace !== args.rootWorkspace) {
|
|
17826
18035
|
throw new Error("identity-provider witness route addresses another workspace");
|
|
@@ -17858,7 +18067,7 @@ function prepareWitnessRead(args) {
|
|
|
17858
18067
|
contentType: "application/vnd.nomos.runtime-request+protobuf",
|
|
17859
18068
|
accept: "application/vnd.nomos.runtime-response+protobuf",
|
|
17860
18069
|
bearerToken: args.bearerToken.slice(),
|
|
17861
|
-
body:
|
|
18070
|
+
body: toBinary27(RuntimeRequestSchema, request),
|
|
17862
18071
|
// Opening provider custody from cold storage can exceed 30 seconds.
|
|
17863
18072
|
timeoutMillis: 5 * 6e4
|
|
17864
18073
|
})
|
|
@@ -17888,7 +18097,7 @@ function acceptWitnessResponse(pending, receipt) {
|
|
|
17888
18097
|
`identity-provider witness receipt '${receipt.effectId}' does not answer '${pending.effectId}'`
|
|
17889
18098
|
);
|
|
17890
18099
|
}
|
|
17891
|
-
const response =
|
|
18100
|
+
const response = fromBinary27(RuntimeResponseSchema, responseBody2(receipt));
|
|
17892
18101
|
if (response.protocolVersion !== RUNTIME_V2_PROTOCOL_VERSION) {
|
|
17893
18102
|
throw new Error("identity-provider root returned an incompatible runtime response");
|
|
17894
18103
|
}
|
|
@@ -18214,8 +18423,8 @@ var AdmissionDurabilityDesk = class {
|
|
|
18214
18423
|
};
|
|
18215
18424
|
|
|
18216
18425
|
// ../peer-office/src/runtime/identity_recovery_desk.ts
|
|
18217
|
-
import { create as create71, fromBinary as
|
|
18218
|
-
var cloneCall = (call) =>
|
|
18426
|
+
import { create as create71, fromBinary as fromBinary28, toBinary as toBinary28 } from "@bufbuild/protobuf";
|
|
18427
|
+
var cloneCall = (call) => fromBinary28(CallRequestSchema, toBinary28(CallRequestSchema, call));
|
|
18219
18428
|
var IdentityRecoveryDesk = class {
|
|
18220
18429
|
#identity;
|
|
18221
18430
|
#application;
|
|
@@ -18233,7 +18442,7 @@ var IdentityRecoveryDesk = class {
|
|
|
18233
18442
|
if (!command.request || !["query", "offer"].includes(command.request.operation.case ?? "")) {
|
|
18234
18443
|
throw new Error("identity-provider recovery demand did not originate from an application call");
|
|
18235
18444
|
}
|
|
18236
|
-
const originalCall =
|
|
18445
|
+
const originalCall = toBinary28(CallRequestSchema, command.request);
|
|
18237
18446
|
const step = this.#identity.execute(
|
|
18238
18447
|
runtimeRequest,
|
|
18239
18448
|
create71(IdentityProviderWitnessRequestSchema, {
|
|
@@ -18313,7 +18522,7 @@ var IdentityRecoveryDesk = class {
|
|
|
18313
18522
|
}
|
|
18314
18523
|
}
|
|
18315
18524
|
#adoptAndRetry(runtimeRequest, command, originalCall, requirement, ready) {
|
|
18316
|
-
const original =
|
|
18525
|
+
const original = fromBinary28(CallRequestSchema, originalCall);
|
|
18317
18526
|
const query = original.operation.case === "query" ? original.operation.value : void 0;
|
|
18318
18527
|
const offer = original.operation.case === "offer" ? original.operation.value : void 0;
|
|
18319
18528
|
const target3 = query?.target ?? offer?.target;
|
|
@@ -18361,7 +18570,7 @@ var IdentityRecoveryDesk = class {
|
|
|
18361
18570
|
const retryCommand = create71(KernelCallRequestSchema, {
|
|
18362
18571
|
session: command.session,
|
|
18363
18572
|
credentialUse: command.credentialUse,
|
|
18364
|
-
request: cloneCall(
|
|
18573
|
+
request: cloneCall(fromBinary28(CallRequestSchema, originalCall))
|
|
18365
18574
|
});
|
|
18366
18575
|
const retried = this.#application.call(runtimeRequest, retryCommand);
|
|
18367
18576
|
if (retried.outcome.case === "failure" && retried.outcome.value.identityProviderWitnessRequired) {
|
|
@@ -18427,7 +18636,7 @@ var PeerMaintenanceScheduler = class {
|
|
|
18427
18636
|
};
|
|
18428
18637
|
|
|
18429
18638
|
// ../peer-office/src/runtime/peer_background_scheduler.ts
|
|
18430
|
-
import { create as create72, toBinary as
|
|
18639
|
+
import { create as create72, toBinary as toBinary29 } from "@bufbuild/protobuf";
|
|
18431
18640
|
var BACKGROUND_CONTINUATION_YIELD_MILLIS = 20;
|
|
18432
18641
|
function yielding(paper) {
|
|
18433
18642
|
if (paper.frame !== void 0 || paper.nextAfterMillis === void 0 || paper.nextAfterMillis > 0) return paper;
|
|
@@ -18461,7 +18670,7 @@ var PeerBackgroundScheduler = class {
|
|
|
18461
18670
|
const recovery = retentionOnly ? {} : this.#subscriptions.nextRecovery(id, excludedWorkspaces);
|
|
18462
18671
|
if (recovery.request) {
|
|
18463
18672
|
return {
|
|
18464
|
-
frame:
|
|
18673
|
+
frame: toBinary29(RuntimeRequestSchema, recovery.request),
|
|
18465
18674
|
nextAfterMillis: 0,
|
|
18466
18675
|
workspace: recovery.request.target.workspace
|
|
18467
18676
|
};
|
|
@@ -18469,7 +18678,7 @@ var PeerBackgroundScheduler = class {
|
|
|
18469
18678
|
const retention = this.#residency.nextRetention();
|
|
18470
18679
|
if (retention.request !== void 0) {
|
|
18471
18680
|
return {
|
|
18472
|
-
frame:
|
|
18681
|
+
frame: toBinary29(RuntimeRequestSchema, create72(RuntimeRequestSchema, {
|
|
18473
18682
|
protocolVersion: 2,
|
|
18474
18683
|
requestId: id,
|
|
18475
18684
|
command: {
|
|
@@ -18486,7 +18695,7 @@ var PeerBackgroundScheduler = class {
|
|
|
18486
18695
|
const convergence = this.#receivingGroup.nextBackgroundPaper(id, excludedWorkspaces);
|
|
18487
18696
|
if (convergence.frame !== void 0) {
|
|
18488
18697
|
return {
|
|
18489
|
-
frame:
|
|
18698
|
+
frame: toBinary29(RuntimeRequestSchema, convergence.frame),
|
|
18490
18699
|
nextAfterMillis: 0,
|
|
18491
18700
|
...convergence.workspace === void 0 ? {} : { workspace: convergence.workspace }
|
|
18492
18701
|
};
|
|
@@ -18547,7 +18756,7 @@ var PeerBackgroundScheduler = class {
|
|
|
18547
18756
|
const recovery = this.#subscriptions.nextRecovery(id, excluded);
|
|
18548
18757
|
if (recovery.request) {
|
|
18549
18758
|
return {
|
|
18550
|
-
frame:
|
|
18759
|
+
frame: toBinary29(RuntimeRequestSchema, recovery.request),
|
|
18551
18760
|
nextAfterMillis: 0,
|
|
18552
18761
|
workspace: recovery.request.target.workspace
|
|
18553
18762
|
};
|
|
@@ -18555,7 +18764,7 @@ var PeerBackgroundScheduler = class {
|
|
|
18555
18764
|
const convergence = this.#receivingGroup.nextBackgroundPaper(id, excluded);
|
|
18556
18765
|
if (convergence.frame !== void 0) {
|
|
18557
18766
|
return {
|
|
18558
|
-
frame:
|
|
18767
|
+
frame: toBinary29(RuntimeRequestSchema, convergence.frame),
|
|
18559
18768
|
nextAfterMillis: 0,
|
|
18560
18769
|
...convergence.workspace === void 0 ? {} : { workspace: convergence.workspace }
|
|
18561
18770
|
};
|
|
@@ -18840,7 +19049,7 @@ var RuntimeResponseFactory = class {
|
|
|
18840
19049
|
};
|
|
18841
19050
|
|
|
18842
19051
|
// ../peer-office/src/runtime/history_acquisition_desk.ts
|
|
18843
|
-
import { create as create74, toBinary as
|
|
19052
|
+
import { create as create74, toBinary as toBinary30 } from "@bufbuild/protobuf";
|
|
18844
19053
|
|
|
18845
19054
|
// ../peer-office/src/runtime/history_acquisition_state.ts
|
|
18846
19055
|
var HistoryAcquisitionPhase = Object.freeze({
|
|
@@ -18901,15 +19110,15 @@ function reduceHistoryAcquisition(state, event) {
|
|
|
18901
19110
|
var HISTORY_ACQUISITION_NAMESPACE = "nomos.peer-desk.history-acquisition/v1";
|
|
18902
19111
|
var HISTORY_BACKGROUND_START_MILLIS = 1e4;
|
|
18903
19112
|
var SLICE_ANSWER_MILLIS = 5 * 6e4;
|
|
18904
|
-
var
|
|
18905
|
-
var
|
|
19113
|
+
var encoder4 = new TextEncoder();
|
|
19114
|
+
var decoder4 = new TextDecoder();
|
|
18906
19115
|
var workId = (workspace) => `history-acquisition:${workspace}`;
|
|
18907
19116
|
var effectId = (workspace, attempt) => `history-acquisition:${workspace}:${HistoryAcquisitionPhase.Acquiring}:${attempt}`;
|
|
18908
19117
|
var encode2 = (work) => {
|
|
18909
19118
|
if (!work.credentialCapability) {
|
|
18910
19119
|
throw new Error(`history acquisition for '${work.workspace}' has not restored its credential capability`);
|
|
18911
19120
|
}
|
|
18912
|
-
return
|
|
19121
|
+
return encoder4.encode(JSON.stringify({
|
|
18913
19122
|
version: 2,
|
|
18914
19123
|
workspace: work.workspace,
|
|
18915
19124
|
credentialCapability: work.credentialCapability,
|
|
@@ -18918,7 +19127,7 @@ var encode2 = (work) => {
|
|
|
18918
19127
|
};
|
|
18919
19128
|
var upgraded = (state) => state.case === "backoff" ? { case: HistoryAcquisitionPhase.Paced, attempt: state.attempt, delayMillis: state.delayMillis, failed: true } : state;
|
|
18920
19129
|
var decode2 = (record) => {
|
|
18921
|
-
const value = JSON.parse(
|
|
19130
|
+
const value = JSON.parse(decoder4.decode(record.value));
|
|
18922
19131
|
if (!value || typeof value !== "object") throw corrupt2(record, "not an object");
|
|
18923
19132
|
const candidate = value;
|
|
18924
19133
|
if (candidate.version !== 1 && candidate.version !== 2 || candidate.workspace !== record.key || !candidate.state) {
|
|
@@ -18981,6 +19190,21 @@ var HistoryAcquisitionDesk = class {
|
|
|
18981
19190
|
this.#ensure(workspace, credentialCapability);
|
|
18982
19191
|
this.#dueAt.set(workspace, this.#now() + HISTORY_BACKGROUND_START_MILLIS);
|
|
18983
19192
|
}
|
|
19193
|
+
/** A background kernel read needs an omitted ancestor now. Queue one bounded
|
|
19194
|
+
* slice on the existing history lane; a failed slice keeps its retry pace. */
|
|
19195
|
+
requestFromBackground(workspace, credentialCapability) {
|
|
19196
|
+
if (!workspace) throw new Error("kernel history requirement names no workspace");
|
|
19197
|
+
this.#ensure(workspace, credentialCapability);
|
|
19198
|
+
const work = this.#get(workspace);
|
|
19199
|
+
const now = this.#now();
|
|
19200
|
+
if (work.state.case === HistoryAcquisitionPhase.Paced && work.state.failed) {
|
|
19201
|
+
const due2 = this.#dueAt.get(workspace) ?? now + work.state.delayMillis;
|
|
19202
|
+
this.#dueAt.set(workspace, due2);
|
|
19203
|
+
if (due2 > now) return due2 - now;
|
|
19204
|
+
}
|
|
19205
|
+
this.#dueAt.set(workspace, now);
|
|
19206
|
+
return 250;
|
|
19207
|
+
}
|
|
18984
19208
|
/** An operation needs history this custody lacks: its next slice now, joining one in flight. */
|
|
18985
19209
|
begin(workspace, credentialCapability) {
|
|
18986
19210
|
if (!workspace) throw new Error("kernel history requirement names no workspace");
|
|
@@ -19077,7 +19301,7 @@ var HistoryAcquisitionDesk = class {
|
|
|
19077
19301
|
return {
|
|
19078
19302
|
workspace: next.workspace,
|
|
19079
19303
|
nextAfterMillis: 0,
|
|
19080
|
-
frame:
|
|
19304
|
+
frame: toBinary30(RuntimeRequestSchema, create74(RuntimeRequestSchema, {
|
|
19081
19305
|
protocolVersion: 2,
|
|
19082
19306
|
requestId,
|
|
19083
19307
|
target: { workspace: next.workspace, session: `history-materialisation:${next.workspace}` },
|
|
@@ -19289,7 +19513,7 @@ var PeerOffice = class {
|
|
|
19289
19513
|
this.#trace,
|
|
19290
19514
|
this.#readability
|
|
19291
19515
|
);
|
|
19292
|
-
this.#custodyAdmission = new CustodyAdmissionDesk(this.#kernel, this.#custody);
|
|
19516
|
+
this.#custodyAdmission = new CustodyAdmissionDesk(this.#kernel, this.#custody, new CustodyReceipts(seatedStore));
|
|
19293
19517
|
this.#queries = new KernelQueries(this.#kernel, this.#credentials);
|
|
19294
19518
|
this.#follows = new ReplicaFollowController(
|
|
19295
19519
|
new ReplicaFollowDesk(seatedStore),
|
|
@@ -19451,6 +19675,7 @@ var PeerOffice = class {
|
|
|
19451
19675
|
// Lazy history: a head-only mount materialises its history in the background, never on
|
|
19452
19676
|
// the path of an operation (architecture/lazy_history.md).
|
|
19453
19677
|
onShallowMount: (workspace, credentialCapability) => this.#historyAcquisition.materialise(workspace, credentialCapability),
|
|
19678
|
+
onOutboxHistoryRequired: (workspace, credentialCapability) => this.#historyAcquisition.requestFromBackground(workspace, credentialCapability),
|
|
19454
19679
|
onSyncCompleted: (session, event) => {
|
|
19455
19680
|
if (event.result?.workspace) {
|
|
19456
19681
|
this.#replicaInventory.placementMayHaveChanged(event.result.workspace);
|
|
@@ -19800,7 +20025,7 @@ var PeerOffice = class {
|
|
|
19800
20025
|
this.#origins.observeReceipt(request);
|
|
19801
20026
|
const response = this.#fenced(this.#handleRequest(request));
|
|
19802
20027
|
this.#paperSlots.answered(request, response, (session) => this.#sessions.bindingIfPresent(session)?.workspace);
|
|
19803
|
-
return { responseProtobuf:
|
|
20028
|
+
return { responseProtobuf: toBinary31(RuntimeResponseSchema, response) };
|
|
19804
20029
|
}
|
|
19805
20030
|
/** Every response leaving the office passes the origin fence (see fenceEffects). */
|
|
19806
20031
|
#fenced(response) {
|
|
@@ -19917,8 +20142,8 @@ var PeerOffice = class {
|
|
|
19917
20142
|
this.#replicaInventory.placementMayHaveChanged(workspace);
|
|
19918
20143
|
}
|
|
19919
20144
|
}
|
|
19920
|
-
/** Execute a typed paper after the access desk
|
|
19921
|
-
*
|
|
20145
|
+
/** Execute a typed paper after the access desk. Custody admission addresses a
|
|
20146
|
+
* workspace by replica identity; application calls retain session binding. */
|
|
19922
20147
|
#dispatchRequest(request) {
|
|
19923
20148
|
validateRuntimeV2Request(request);
|
|
19924
20149
|
try {
|
|
@@ -19932,18 +20157,20 @@ var PeerOffice = class {
|
|
|
19932
20157
|
if (!request.target.workspace || !request.target.session) {
|
|
19933
20158
|
throw new Error("addressed runtime request requires workspace and session");
|
|
19934
20159
|
}
|
|
19935
|
-
|
|
19936
|
-
|
|
19937
|
-
if (binding
|
|
19938
|
-
|
|
19939
|
-
|
|
19940
|
-
|
|
20160
|
+
if (request.command.case !== "admitCustodyOffers") {
|
|
20161
|
+
const binding = this.#sessions.bindingIfPresent(request.target.session);
|
|
20162
|
+
if (binding !== void 0) {
|
|
20163
|
+
if (binding.workspace !== request.target.workspace) {
|
|
20164
|
+
throw new Error(
|
|
20165
|
+
`session '${request.target.session}' is bound to workspace '${binding.workspace}', not '${request.target.workspace}'`
|
|
20166
|
+
);
|
|
20167
|
+
}
|
|
20168
|
+
} else {
|
|
20169
|
+
this.#bindInteraction(create75(BindSessionRequestSchema, {
|
|
20170
|
+
session: request.target.session,
|
|
20171
|
+
workspace: request.target.workspace
|
|
20172
|
+
}));
|
|
19941
20173
|
}
|
|
19942
|
-
} else {
|
|
19943
|
-
this.#bindInteraction(create75(BindSessionRequestSchema, {
|
|
19944
|
-
session: request.target.session,
|
|
19945
|
-
workspace: request.target.workspace
|
|
19946
|
-
}));
|
|
19947
20174
|
}
|
|
19948
20175
|
}
|
|
19949
20176
|
switch (request.command.case) {
|
|
@@ -20140,7 +20367,7 @@ var PeerOffice = class {
|
|
|
20140
20367
|
ReadMaintenanceCause.ADMITTED_OFFER
|
|
20141
20368
|
);
|
|
20142
20369
|
this.#subscriptions.refreshWorkspace(request.target.workspace);
|
|
20143
|
-
this.#correspondence.
|
|
20370
|
+
this.#correspondence.receivedFrontierChanged(request.target.workspace);
|
|
20144
20371
|
}
|
|
20145
20372
|
return this.#birthCustodyResponse(
|
|
20146
20373
|
request,
|
|
@@ -20707,7 +20934,7 @@ var peerOffice = {
|
|
|
20707
20934
|
};
|
|
20708
20935
|
|
|
20709
20936
|
// ../peer-office/src/runtime/frame_runner.ts
|
|
20710
|
-
import { fromBinary as
|
|
20937
|
+
import { fromBinary as fromBinary29 } from "@bufbuild/protobuf";
|
|
20711
20938
|
|
|
20712
20939
|
// ../peer-office/src/runtime/background_lanes.ts
|
|
20713
20940
|
var defaultSetTimer = (callback, delayMillis) => {
|
|
@@ -20726,6 +20953,15 @@ function createBackgroundLanes(options) {
|
|
|
20726
20953
|
const correspondenceNotBefore = /* @__PURE__ */ new Map();
|
|
20727
20954
|
let retention = 0;
|
|
20728
20955
|
let closed = false;
|
|
20956
|
+
let selectionFailures = 0;
|
|
20957
|
+
const selectionFault = (error) => {
|
|
20958
|
+
try {
|
|
20959
|
+
options.onSelectionError?.(error);
|
|
20960
|
+
} catch {
|
|
20961
|
+
}
|
|
20962
|
+
selectionFailures += 1;
|
|
20963
|
+
wake(Math.min(3e4, 250 * 2 ** Math.min(selectionFailures - 1, 7)));
|
|
20964
|
+
};
|
|
20729
20965
|
const wake = (delayMillis = 0) => {
|
|
20730
20966
|
if (closed) return;
|
|
20731
20967
|
const delay = Math.max(0, Math.ceil(delayMillis));
|
|
@@ -20736,53 +20972,58 @@ function createBackgroundLanes(options) {
|
|
|
20736
20972
|
}
|
|
20737
20973
|
wakeAt = at;
|
|
20738
20974
|
timer = setTimer(() => {
|
|
20739
|
-
|
|
20740
|
-
|
|
20741
|
-
|
|
20742
|
-
|
|
20743
|
-
|
|
20744
|
-
|
|
20745
|
-
|
|
20746
|
-
|
|
20747
|
-
|
|
20748
|
-
|
|
20749
|
-
|
|
20750
|
-
|
|
20751
|
-
if (
|
|
20752
|
-
|
|
20753
|
-
|
|
20754
|
-
|
|
20755
|
-
|
|
20975
|
+
try {
|
|
20976
|
+
timer = void 0;
|
|
20977
|
+
wakeAt = void 0;
|
|
20978
|
+
if (closed) return;
|
|
20979
|
+
const now = options.monotonicNanoseconds();
|
|
20980
|
+
for (const [workspace2, at2] of correspondenceNotBefore) {
|
|
20981
|
+
if (at2 <= now) correspondenceNotBefore.delete(workspace2);
|
|
20982
|
+
}
|
|
20983
|
+
const backoffMillis = correspondenceNotBefore.size ? Math.min(...[...correspondenceNotBefore.values()].map((at2) => Number((at2 - now + 999999n) / 1000000n))) : void 0;
|
|
20984
|
+
const retentionOnly = correspondenceInFlight;
|
|
20985
|
+
const next = options.nextPaper(retentionOnly, new Set(correspondenceNotBefore.keys()));
|
|
20986
|
+
selectionFailures = 0;
|
|
20987
|
+
if (next.frame === void 0) {
|
|
20988
|
+
const delays = [next.nextAfterMillis, backoffMillis].filter((delay2) => delay2 !== void 0);
|
|
20989
|
+
if (delays.length) wake(Math.min(...delays));
|
|
20990
|
+
return;
|
|
20991
|
+
}
|
|
20992
|
+
if (options.isRetention(next.frame)) {
|
|
20993
|
+
retention += 1;
|
|
20994
|
+
void options.drive(next.frame).then(
|
|
20995
|
+
() => {
|
|
20996
|
+
retention -= 1;
|
|
20997
|
+
wake(0);
|
|
20998
|
+
},
|
|
20999
|
+
() => {
|
|
21000
|
+
retention -= 1;
|
|
21001
|
+
wake(0);
|
|
21002
|
+
}
|
|
21003
|
+
);
|
|
21004
|
+
wake(next.nextAfterMillis ?? 0);
|
|
21005
|
+
return;
|
|
21006
|
+
}
|
|
21007
|
+
if (retentionOnly) throw new Error("background desk reserved correspondence while its lane was unavailable");
|
|
21008
|
+
const workspace = next.workspace;
|
|
21009
|
+
if (!workspace) throw new Error("background correspondence has no source workspace");
|
|
21010
|
+
if (correspondenceNotBefore.has(workspace)) throw new Error("background desk bypassed a workspace's physical backoff");
|
|
21011
|
+
correspondenceInFlight = true;
|
|
20756
21012
|
void options.drive(next.frame).then(
|
|
20757
21013
|
() => {
|
|
20758
|
-
|
|
20759
|
-
wake(0);
|
|
21014
|
+
correspondenceInFlight = false;
|
|
21015
|
+
wake(next.nextAfterMillis ?? 0);
|
|
20760
21016
|
},
|
|
20761
21017
|
() => {
|
|
20762
|
-
|
|
21018
|
+
correspondenceInFlight = false;
|
|
21019
|
+
correspondenceNotBefore.set(workspace, options.monotonicNanoseconds() + BigInt(failureBackoffMillis) * 1000000n);
|
|
20763
21020
|
wake(0);
|
|
20764
21021
|
}
|
|
20765
21022
|
);
|
|
20766
|
-
wake(
|
|
20767
|
-
|
|
21023
|
+
wake(0);
|
|
21024
|
+
} catch (error) {
|
|
21025
|
+
selectionFault(error);
|
|
20768
21026
|
}
|
|
20769
|
-
if (retentionOnly) throw new Error("background desk reserved correspondence while its lane was unavailable");
|
|
20770
|
-
const workspace = next.workspace;
|
|
20771
|
-
if (!workspace) throw new Error("background correspondence has no source workspace");
|
|
20772
|
-
if (correspondenceNotBefore.has(workspace)) throw new Error("background desk bypassed a workspace's physical backoff");
|
|
20773
|
-
correspondenceInFlight = true;
|
|
20774
|
-
void options.drive(next.frame).then(
|
|
20775
|
-
() => {
|
|
20776
|
-
correspondenceInFlight = false;
|
|
20777
|
-
wake(next.nextAfterMillis ?? 0);
|
|
20778
|
-
},
|
|
20779
|
-
() => {
|
|
20780
|
-
correspondenceInFlight = false;
|
|
20781
|
-
correspondenceNotBefore.set(workspace, options.monotonicNanoseconds() + BigInt(failureBackoffMillis) * 1000000n);
|
|
20782
|
-
wake(0);
|
|
20783
|
-
}
|
|
20784
|
-
);
|
|
20785
|
-
wake(0);
|
|
20786
21027
|
}, delay);
|
|
20787
21028
|
};
|
|
20788
21029
|
return {
|
|
@@ -20818,7 +21059,7 @@ function createPeerOfficeFrameRunner(kernel, credentials, profile, observations,
|
|
|
20818
21059
|
const event = peer.nextEvent();
|
|
20819
21060
|
if (event === void 0) return;
|
|
20820
21061
|
if (maintenanceSettled !== void 0) {
|
|
20821
|
-
const decoded =
|
|
21062
|
+
const decoded = fromBinary29(RuntimeEventSchema, event);
|
|
20822
21063
|
if (decoded.event.case === "maintenanceProgress" && decoded.event.value.kernel && !decoded.event.value.kernel.maintenancePending) {
|
|
20823
21064
|
maintenanceSettled(decoded.event.value);
|
|
20824
21065
|
}
|
|
@@ -20853,11 +21094,12 @@ function createPeerOfficeFrameRunner(kernel, credentials, profile, observations,
|
|
|
20853
21094
|
return paper;
|
|
20854
21095
|
},
|
|
20855
21096
|
drive: (frame) => driveBackground(frame).catch((error) => {
|
|
20856
|
-
peer.backgroundPaperAbandoned(
|
|
21097
|
+
peer.backgroundPaperAbandoned(fromBinary29(RuntimeRequestSchema, frame).requestId);
|
|
20857
21098
|
throw error;
|
|
20858
21099
|
}),
|
|
20859
|
-
isRetention: (frame) =>
|
|
20860
|
-
monotonicNanoseconds: () => observations.monotonicNanoseconds()
|
|
21100
|
+
isRetention: (frame) => fromBinary29(RuntimeRequestSchema, frame).command.case === "retainFrontier",
|
|
21101
|
+
monotonicNanoseconds: () => observations.monotonicNanoseconds(),
|
|
21102
|
+
onSelectionError: (error) => console.error("Nomos background paper selection failed", error)
|
|
20861
21103
|
});
|
|
20862
21104
|
const scheduleCorrespondence = (delayMillis = 0) => {
|
|
20863
21105
|
lanes?.wake(delayMillis);
|
|
@@ -20866,7 +21108,7 @@ function createPeerOfficeFrameRunner(kernel, credentials, profile, observations,
|
|
|
20866
21108
|
handleFrame(frame) {
|
|
20867
21109
|
const response = peer.invoke(frame).responseProtobuf;
|
|
20868
21110
|
drainEvents();
|
|
20869
|
-
if (
|
|
21111
|
+
if (fromBinary29(RuntimeRequestSchema, frame).command.case !== "workspaceStatus") {
|
|
20870
21112
|
scheduleMaintenance();
|
|
20871
21113
|
scheduleCorrespondence();
|
|
20872
21114
|
}
|
|
@@ -20919,7 +21161,7 @@ function createPeerOfficeFrameRunner(kernel, credentials, profile, observations,
|
|
|
20919
21161
|
}
|
|
20920
21162
|
|
|
20921
21163
|
// ../peer-office/src/runtime/platform_effect_driver.ts
|
|
20922
|
-
import { create as create76, fromBinary as
|
|
21164
|
+
import { create as create76, fromBinary as fromBinary30, toBinary as toBinary32 } from "@bufbuild/protobuf";
|
|
20923
21165
|
var externalPeerEffect = Symbol("nomos.externalPeerEffect");
|
|
20924
21166
|
var openKernelResidency = (runner, protocolVersion, requestId, workspace) => {
|
|
20925
21167
|
runner.openLocalCustody(workspace, requestId);
|
|
@@ -20952,7 +21194,7 @@ var acquireKernelCustody = async (runner, custody, protocolVersion, requestId, w
|
|
|
20952
21194
|
var correspondenceWakeups = /* @__PURE__ */ new WeakMap();
|
|
20953
21195
|
var deliveryIdentity = (requestFrame) => {
|
|
20954
21196
|
try {
|
|
20955
|
-
const request =
|
|
21197
|
+
const request = fromBinary30(RuntimeRequestSchema, requestFrame);
|
|
20956
21198
|
if (request.command.case !== "deliverWorkspaceEffects") return void 0;
|
|
20957
21199
|
const command = request.command.value;
|
|
20958
21200
|
return `${command.sourceSession}\0${command.targetWorkspace}\0${command.sourceCommit ?? ""}`;
|
|
@@ -20963,7 +21205,7 @@ var deliveryIdentity = (requestFrame) => {
|
|
|
20963
21205
|
var arrangeCorrespondenceWakeup = (runner, requestFrame, responseFrame, fetchImpl) => {
|
|
20964
21206
|
const identity = deliveryIdentity(requestFrame);
|
|
20965
21207
|
if (!identity) return;
|
|
20966
|
-
const response =
|
|
21208
|
+
const response = fromBinary30(RuntimeResponseSchema, responseFrame);
|
|
20967
21209
|
const retryAt = response.outcome.case === "workspaceEffectsDelivered" ? response.outcome.value.retryAtMillis : void 0;
|
|
20968
21210
|
const wakeups = correspondenceWakeups.get(runner) ?? /* @__PURE__ */ new Map();
|
|
20969
21211
|
correspondenceWakeups.set(runner, wakeups);
|
|
@@ -21088,13 +21330,19 @@ var candidateSessionReference = async (identity) => {
|
|
|
21088
21330
|
};
|
|
21089
21331
|
var executeGitFetchWithAlongside = async (effect, fetchImpl) => {
|
|
21090
21332
|
if (!effect.alongside) return executeGitFetchEffect(effect, fetchImpl);
|
|
21091
|
-
const
|
|
21092
|
-
|
|
21093
|
-
|
|
21094
|
-
|
|
21095
|
-
|
|
21333
|
+
const cancelAlongside = new AbortController();
|
|
21334
|
+
let alongside;
|
|
21335
|
+
void executeHttpEffect(effect.alongside, (input, init) => fetchImpl(input, {
|
|
21336
|
+
...init,
|
|
21337
|
+
signal: init?.signal ? AbortSignal.any([init.signal, cancelAlongside.signal]) : cancelAlongside.signal
|
|
21338
|
+
})).then((receipt) => {
|
|
21339
|
+
alongside = receipt;
|
|
21340
|
+
});
|
|
21341
|
+
const fetched = await executeGitFetchEffect(effect, fetchImpl);
|
|
21342
|
+
if (fetched.outcome.case === "gitFetch" && alongside?.outcome.case === "response") {
|
|
21096
21343
|
fetched.outcome.value.alongside = alongside.outcome.value;
|
|
21097
21344
|
}
|
|
21345
|
+
cancelAlongside.abort();
|
|
21098
21346
|
return fetched;
|
|
21099
21347
|
};
|
|
21100
21348
|
var executeGitPushEffect = async (effect, fetchImpl) => {
|
|
@@ -21156,14 +21404,14 @@ async function drivePeerFrame(runner, initialFrame, fetchImpl = globalThis.fetch
|
|
|
21156
21404
|
const satisfied = /* @__PURE__ */ new Set();
|
|
21157
21405
|
const resendable = (() => {
|
|
21158
21406
|
try {
|
|
21159
|
-
return
|
|
21407
|
+
return fromBinary30(RuntimeRequestSchema, initialFrame).command.case !== "continueCorrespondence";
|
|
21160
21408
|
} catch {
|
|
21161
21409
|
return false;
|
|
21162
21410
|
}
|
|
21163
21411
|
})();
|
|
21164
21412
|
let historyRetries = 0;
|
|
21165
21413
|
for (; ; ) {
|
|
21166
|
-
const response =
|
|
21414
|
+
const response = fromBinary30(RuntimeResponseSchema, responseFrame);
|
|
21167
21415
|
if (response.outcome.case === "historyAcquired" && resendable && historyRetries < 32) {
|
|
21168
21416
|
historyRetries += 1;
|
|
21169
21417
|
responseFrame = runner.handleFrame(initialFrame);
|
|
@@ -21173,7 +21421,7 @@ async function drivePeerFrame(runner, initialFrame, fetchImpl = globalThis.fetch
|
|
|
21173
21421
|
if (yieldLocalReadToCaller) return responseFrame;
|
|
21174
21422
|
const pending2 = response.outcome.value;
|
|
21175
21423
|
await new Promise((resolve4) => setTimeout(resolve4, pending2.resumeAfterMillis));
|
|
21176
|
-
responseFrame = runner.handleFrame(
|
|
21424
|
+
responseFrame = runner.handleFrame(toBinary32(RuntimeRequestSchema, create76(RuntimeRequestSchema, {
|
|
21177
21425
|
protocolVersion: response.protocolVersion,
|
|
21178
21426
|
requestId: response.requestId,
|
|
21179
21427
|
command: { case: "continueLocalRead", value: create76(ContinueLocalReadRequestSchema, { workId: pending2.workId }) }
|
|
@@ -21273,7 +21521,7 @@ async function drivePeerFrame(runner, initialFrame, fetchImpl = globalThis.fetch
|
|
|
21273
21521
|
outcome: { case: "failure", value: { reason: PeerEffectFailureReason.TRANSPORT, message: error instanceof Error ? error.message : String(error) } }
|
|
21274
21522
|
});
|
|
21275
21523
|
}
|
|
21276
|
-
responseFrame = runner.handleFrame(
|
|
21524
|
+
responseFrame = runner.handleFrame(toBinary32(RuntimeRequestSchema, create76(RuntimeRequestSchema, {
|
|
21277
21525
|
protocolVersion: response.protocolVersion,
|
|
21278
21526
|
requestId: response.requestId,
|
|
21279
21527
|
command: { case: "continueCorrespondence", value: { workId: pending.workId, receipt: receipt2 } }
|
|
@@ -21301,7 +21549,7 @@ async function drivePeerFrame(runner, initialFrame, fetchImpl = globalThis.fetch
|
|
|
21301
21549
|
}) : 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) : (() => {
|
|
21302
21550
|
throw new Error(`correspondence work '${pending.workId}' has no effect`);
|
|
21303
21551
|
})();
|
|
21304
|
-
responseFrame = runner.handleFrame(
|
|
21552
|
+
responseFrame = runner.handleFrame(toBinary32(RuntimeRequestSchema, create76(RuntimeRequestSchema, {
|
|
21305
21553
|
protocolVersion: response.protocolVersion,
|
|
21306
21554
|
requestId: response.requestId,
|
|
21307
21555
|
command: {
|
|
@@ -21373,11 +21621,11 @@ async function executeDeviceIdentityEffect(effect, store) {
|
|
|
21373
21621
|
await store.save(effect.identity, effect.operation.value.secret.slice());
|
|
21374
21622
|
} else if (effect.operation.case === "loadRecovery") {
|
|
21375
21623
|
const bytes = await store.load(`nomos-device-recovery-v1|${effect.identity}`);
|
|
21376
|
-
if (bytes !== void 0) recovery =
|
|
21624
|
+
if (bytes !== void 0) recovery = fromBinary30(DeviceRecoveryRecordSchema, bytes);
|
|
21377
21625
|
} else if (effect.operation.case === "saveRecovery") {
|
|
21378
21626
|
const record = effect.operation.value.record;
|
|
21379
21627
|
if (!record) throw new Error("device recovery save contains no record");
|
|
21380
|
-
await store.save(`nomos-device-recovery-v1|${effect.identity}`,
|
|
21628
|
+
await store.save(`nomos-device-recovery-v1|${effect.identity}`, toBinary32(DeviceRecoveryRecordSchema, record));
|
|
21381
21629
|
} else throw new Error("device identity effect has no operation");
|
|
21382
21630
|
return create76(PeerEffectReceiptSchema, { effectId: effect.effectId, outcome: {
|
|
21383
21631
|
case: "deviceIdentity",
|
|
@@ -21450,25 +21698,26 @@ async function executeRetainFrontierEffect(effect, custody) {
|
|
|
21450
21698
|
}
|
|
21451
21699
|
|
|
21452
21700
|
// ../platform-shells/shared/socket_effects.ts
|
|
21453
|
-
import { create as create77, fromBinary as
|
|
21701
|
+
import { create as create77, fromBinary as fromBinary31, toBinary as toBinary33 } from "@bufbuild/protobuf";
|
|
21454
21702
|
function socketEffects(invoke2, permits = () => true) {
|
|
21455
21703
|
const sockets = /* @__PURE__ */ new Map();
|
|
21456
21704
|
let sequence = 50000000000n;
|
|
21457
21705
|
let closed = false;
|
|
21458
21706
|
const receipt = (connectionId, observation) => {
|
|
21459
21707
|
if (closed) return;
|
|
21460
|
-
const frame =
|
|
21708
|
+
const frame = toBinary33(RuntimeRequestSchema, create77(RuntimeRequestSchema, {
|
|
21461
21709
|
protocolVersion: 2,
|
|
21462
21710
|
requestId: ++sequence,
|
|
21463
21711
|
command: { case: "socketReceipt", value: create77(PeerSocketReceiptSchema, { connectionId, observation }) }
|
|
21464
21712
|
}));
|
|
21465
|
-
void Promise.resolve().then(() => invoke2(frame)).catch(() => {
|
|
21713
|
+
void Promise.resolve().then(() => invoke2(frame)).catch((error) => {
|
|
21714
|
+
console.warn("[nomos-socket] receipt failed", { connectionId, error });
|
|
21466
21715
|
sockets.get(connectionId)?.close();
|
|
21467
21716
|
});
|
|
21468
21717
|
};
|
|
21469
21718
|
return {
|
|
21470
21719
|
consume(frame) {
|
|
21471
|
-
const event =
|
|
21720
|
+
const event = fromBinary31(RuntimeEventSchema, frame);
|
|
21472
21721
|
if (event.event.case !== "socketEffect") return false;
|
|
21473
21722
|
const effect = event.event.value;
|
|
21474
21723
|
const id = effect.connectionId;
|
|
@@ -21484,6 +21733,7 @@ function socketEffects(invoke2, permits = () => true) {
|
|
|
21484
21733
|
socket.onopen = () => receipt(id, { case: "opened", value: true });
|
|
21485
21734
|
socket.onmessage = (message) => {
|
|
21486
21735
|
if (message.data instanceof ArrayBuffer) receipt(id, { case: "received", value: new Uint8Array(message.data) });
|
|
21736
|
+
else if (typeof message.data === "string") receipt(id, { case: "received", value: new TextEncoder().encode(message.data) });
|
|
21487
21737
|
};
|
|
21488
21738
|
socket.onclose = () => {
|
|
21489
21739
|
if (sockets.get(id) === socket) sockets.delete(id);
|
|
@@ -21516,17 +21766,17 @@ function socketEffects(invoke2, permits = () => true) {
|
|
|
21516
21766
|
}
|
|
21517
21767
|
|
|
21518
21768
|
// ../platform-shells/shared/credential_effects.ts
|
|
21519
|
-
import { create as create78, fromBinary as
|
|
21769
|
+
import { create as create78, fromBinary as fromBinary32, toBinary as toBinary34 } from "@bufbuild/protobuf";
|
|
21520
21770
|
function credentialEffects(invoke2, provider) {
|
|
21521
21771
|
return { consume(frame) {
|
|
21522
|
-
const event =
|
|
21772
|
+
const event = fromBinary32(RuntimeEventSchema, frame);
|
|
21523
21773
|
if (event.event.case !== "credentialRefreshRequested" || provider === externalPeerEffect) return false;
|
|
21524
21774
|
const pending = event.event.value.pending;
|
|
21525
21775
|
if (pending?.effect.case !== "refreshCredential") throw new Error("credential refresh event omitted its physical effect");
|
|
21526
21776
|
const effect = pending.effect.value;
|
|
21527
21777
|
void Promise.resolve().then(async () => {
|
|
21528
21778
|
const receipt = await executeCredentialRefreshEffect(effect, provider);
|
|
21529
|
-
const response =
|
|
21779
|
+
const response = fromBinary32(RuntimeResponseSchema, await invoke2(toBinary34(RuntimeRequestSchema, create78(RuntimeRequestSchema, {
|
|
21530
21780
|
protocolVersion: 2,
|
|
21531
21781
|
requestId: event.sequence,
|
|
21532
21782
|
command: { case: "continueCorrespondence", value: create78(ContinueCorrespondenceRequestSchema, { workId: pending.workId, receipt }) }
|
|
@@ -21541,7 +21791,7 @@ function credentialEffects(invoke2, provider) {
|
|
|
21541
21791
|
|
|
21542
21792
|
// ../platform-shells/shared/peer_office_host.ts
|
|
21543
21793
|
var targetOf = (frame) => {
|
|
21544
|
-
const target3 =
|
|
21794
|
+
const target3 = fromBinary33(RuntimeRequestSchema, frame).target;
|
|
21545
21795
|
return {
|
|
21546
21796
|
...target3?.session === void 0 ? {} : { session: target3.session },
|
|
21547
21797
|
...target3?.workspace === void 0 ? {} : { workspace: target3.workspace }
|
|
@@ -21595,7 +21845,7 @@ function openPeerOfficeHost(kernel, shell, fetchImpl = globalThis.fetch, mainten
|
|
|
21595
21845
|
);
|
|
21596
21846
|
const providerOrigins = [...configuredOrigins];
|
|
21597
21847
|
if (providerOrigins.length > 0) {
|
|
21598
|
-
const configured =
|
|
21848
|
+
const configured = fromBinary33(RuntimeResponseSchema, runner.handleFrame(toBinary35(
|
|
21599
21849
|
RuntimeRequestSchema,
|
|
21600
21850
|
create79(RuntimeRequestSchema, {
|
|
21601
21851
|
protocolVersion: 2,
|
|
@@ -21609,7 +21859,7 @@ function openPeerOfficeHost(kernel, shell, fetchImpl = globalThis.fetch, mainten
|
|
|
21609
21859
|
}
|
|
21610
21860
|
return {
|
|
21611
21861
|
async invoke(args) {
|
|
21612
|
-
const request =
|
|
21862
|
+
const request = fromBinary33(RuntimeRequestSchema, args.requestBytes);
|
|
21613
21863
|
if (request.protocolVersion !== 2) {
|
|
21614
21864
|
throw new Error(`unsupported Nomos runtime protocol ${request.protocolVersion}`);
|
|
21615
21865
|
}
|
|
@@ -21696,21 +21946,21 @@ var SqlitePeerDeskStore = class {
|
|
|
21696
21946
|
}
|
|
21697
21947
|
return this.#opened = database;
|
|
21698
21948
|
}
|
|
21699
|
-
list(
|
|
21949
|
+
list(namespace2) {
|
|
21700
21950
|
const rows = this.#database().prepare(`
|
|
21701
21951
|
SELECT record_key AS key, revision, value
|
|
21702
21952
|
FROM peer_desk_record
|
|
21703
21953
|
WHERE namespace = ?
|
|
21704
21954
|
ORDER BY record_key
|
|
21705
|
-
`).all(
|
|
21955
|
+
`).all(namespace2);
|
|
21706
21956
|
return rows.map((row) => ({
|
|
21707
|
-
namespace,
|
|
21957
|
+
namespace: namespace2,
|
|
21708
21958
|
key: row.key,
|
|
21709
21959
|
revision: BigInt(row.revision),
|
|
21710
21960
|
value: Uint8Array.from(row.value)
|
|
21711
21961
|
}));
|
|
21712
21962
|
}
|
|
21713
|
-
compareExchange(
|
|
21963
|
+
compareExchange(namespace2, key, expectedRevision, value) {
|
|
21714
21964
|
const expected = expectedRevision === void 0 ? void 0 : Number(expectedRevision);
|
|
21715
21965
|
if (expected !== void 0 && (!Number.isSafeInteger(expected) || expected <= 0)) {
|
|
21716
21966
|
throw new Error(`peer desk revision ${expectedRevision} cannot be represented by SQLite`);
|
|
@@ -21723,8 +21973,8 @@ var SqlitePeerDeskStore = class {
|
|
|
21723
21973
|
const removed = database.prepare(`
|
|
21724
21974
|
DELETE FROM peer_desk_record
|
|
21725
21975
|
WHERE namespace = ? AND record_key = ? AND revision = ?
|
|
21726
|
-
`).run(
|
|
21727
|
-
if (removed.changes !== 1) this.#conflict(
|
|
21976
|
+
`).run(namespace2, key, expected);
|
|
21977
|
+
if (removed.changes !== 1) this.#conflict(namespace2, key);
|
|
21728
21978
|
return this.#commit(void 0);
|
|
21729
21979
|
}
|
|
21730
21980
|
const bytes = Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
@@ -21736,14 +21986,14 @@ var SqlitePeerDeskStore = class {
|
|
|
21736
21986
|
INSERT INTO peer_desk_record(namespace, record_key, revision, value)
|
|
21737
21987
|
VALUES (?, ?, 1, ?)
|
|
21738
21988
|
ON CONFLICT(namespace, record_key) DO NOTHING
|
|
21739
|
-
`).run(
|
|
21989
|
+
`).run(namespace2, key, bytes) : database.prepare(`
|
|
21740
21990
|
UPDATE peer_desk_record
|
|
21741
21991
|
SET revision = ?, value = ?
|
|
21742
21992
|
WHERE namespace = ? AND record_key = ? AND revision = ?
|
|
21743
|
-
`).run(nextRevision, bytes,
|
|
21744
|
-
if (changed.changes !== 1) this.#conflict(
|
|
21993
|
+
`).run(nextRevision, bytes, namespace2, key, expected);
|
|
21994
|
+
if (changed.changes !== 1) this.#conflict(namespace2, key);
|
|
21745
21995
|
return this.#commit({
|
|
21746
|
-
namespace,
|
|
21996
|
+
namespace: namespace2,
|
|
21747
21997
|
key,
|
|
21748
21998
|
revision: BigInt(nextRevision),
|
|
21749
21999
|
value: value.slice()
|
|
@@ -21761,12 +22011,12 @@ var SqlitePeerDeskStore = class {
|
|
|
21761
22011
|
this.#database().exec("COMMIT");
|
|
21762
22012
|
return value;
|
|
21763
22013
|
}
|
|
21764
|
-
#conflict(
|
|
22014
|
+
#conflict(namespace2, key) {
|
|
21765
22015
|
const current = this.#database().prepare(`
|
|
21766
22016
|
SELECT revision FROM peer_desk_record WHERE namespace = ? AND record_key = ?
|
|
21767
|
-
`).get(
|
|
22017
|
+
`).get(namespace2, key);
|
|
21768
22018
|
throw new Error(
|
|
21769
|
-
`peer desk record '${
|
|
22019
|
+
`peer desk record '${namespace2}/${key}' changed at revision ${current?.revision ?? "absent"}`
|
|
21770
22020
|
);
|
|
21771
22021
|
}
|
|
21772
22022
|
};
|
|
@@ -22187,7 +22437,7 @@ async function startDevCloud(options = {}) {
|
|
|
22187
22437
|
classes: ["cloud"],
|
|
22188
22438
|
warmResidencyMillis: 600000n,
|
|
22189
22439
|
servedOrigin: origin,
|
|
22190
|
-
custodianPlacement:
|
|
22440
|
+
custodianPlacement: toBinary36(CustodyPlacementPolicySchema, create82(CustodyPlacementPolicySchema, {
|
|
22191
22441
|
declaration: "local-development-custodian-v1",
|
|
22192
22442
|
adoptedBy: `peer:local-custodian:${origin}`,
|
|
22193
22443
|
reason: "The development cloud retains born workspaces and publishes local-first placement for its clients",
|
|
@@ -22219,8 +22469,8 @@ async function startDevCloud(options = {}) {
|
|
|
22219
22469
|
if (ringPlacement) {
|
|
22220
22470
|
try {
|
|
22221
22471
|
const advanced = placementAdvance(
|
|
22222
|
-
|
|
22223
|
-
|
|
22472
|
+
fromBinary34(RuntimeRequestSchema, args.requestBytes),
|
|
22473
|
+
fromBinary34(RuntimeResponseSchema, bytes)
|
|
22224
22474
|
);
|
|
22225
22475
|
if (advanced) ringPlacement(advanced.workspace, advanced.frontier);
|
|
22226
22476
|
} catch (error) {
|
|
@@ -22243,7 +22493,7 @@ async function startDevCloud(options = {}) {
|
|
|
22243
22493
|
const timer = setTimeout(() => {
|
|
22244
22494
|
admissionTimers.delete(key);
|
|
22245
22495
|
const requestId = ++requestSequence;
|
|
22246
|
-
const frame =
|
|
22496
|
+
const frame = toBinary36(RuntimeRequestSchema, create82(RuntimeRequestSchema, {
|
|
22247
22497
|
protocolVersion: 2,
|
|
22248
22498
|
requestId,
|
|
22249
22499
|
target: { workspace, session: `custody-admission:${workspace}` },
|
|
@@ -22260,7 +22510,7 @@ async function startDevCloud(options = {}) {
|
|
|
22260
22510
|
}
|
|
22261
22511
|
}));
|
|
22262
22512
|
void observedInvoke({ workspace, requestBytes: frame }).then((bytes) => {
|
|
22263
|
-
const response =
|
|
22513
|
+
const response = fromBinary34(RuntimeResponseSchema, bytes);
|
|
22264
22514
|
if (response.outcome.case !== "custodyOffersAdmitted") {
|
|
22265
22515
|
console.error(`[local-peer] admission ${key}: ${response.outcome.case || "empty"}`);
|
|
22266
22516
|
}
|
|
@@ -22406,7 +22656,7 @@ async function startDevCloud(options = {}) {
|
|
|
22406
22656
|
"cache-control": "no-store",
|
|
22407
22657
|
...discovery.frontier ? { etag: `"${discovery.frontier}"` } : {}
|
|
22408
22658
|
});
|
|
22409
|
-
response.end(Buffer.from(
|
|
22659
|
+
response.end(Buffer.from(toBinary36(DiscoveredWorkspacePlacementSchema, discovery)));
|
|
22410
22660
|
return;
|
|
22411
22661
|
}
|
|
22412
22662
|
if (remainder.length === 1 && await carriage.respond(request, response, workspace, remainder[0])) return;
|
|
@@ -22425,7 +22675,7 @@ async function startDevCloud(options = {}) {
|
|
|
22425
22675
|
return;
|
|
22426
22676
|
}
|
|
22427
22677
|
const answer = await answerLawProducts(
|
|
22428
|
-
async (paper) =>
|
|
22678
|
+
async (paper) => fromBinary34(RuntimeResponseSchema, await observedInvoke({ workspace, requestBytes: paper })),
|
|
22429
22679
|
workspace,
|
|
22430
22680
|
knownLawIdentities(url)
|
|
22431
22681
|
);
|
|
@@ -22463,7 +22713,7 @@ async function startDevCloud(options = {}) {
|
|
|
22463
22713
|
"content-type": "application/vnd.nomos.git-read-lease+protobuf",
|
|
22464
22714
|
"cache-control": "private, no-store"
|
|
22465
22715
|
});
|
|
22466
|
-
response.end(Buffer.from(
|
|
22716
|
+
response.end(Buffer.from(toBinary36(GitReadLeaseSchema, lease)));
|
|
22467
22717
|
return;
|
|
22468
22718
|
}
|
|
22469
22719
|
if (await carriage.respondReport(request, response, workspace, remainder)) return;
|