Match provider child record contract

This commit is contained in:
Meta Vens 2026-07-10 12:42:44 +01:00
commit 63a8a1039b
2 changed files with 4 additions and 4 deletions

View file

@ -190,7 +190,7 @@ function normalizeTarget(value) {
return { providerId: String(value.providerId || ""), advertisementRecordRef: String(value.advertisementRecordRef), peerId: String(value.peerId || "provider"), verseId: String(value.verseId || "provider"), role: String(value.role || "provider"), endpoints: Array.isArray(value.endpoints) ? value.endpoints.map(String) : [] };
}
function childRecordRef(parent, child) { return `${String(parent).replace(/\/$/u, "")}/${encodeURIComponent(child)}`; }
function childRecordRef(parent, child) { return `${String(parent).replace(/[:/]$/u, "")}:${String(child)}`; }
function field(value, name, slot) { return value && typeof value === "object" ? (value[name] ?? value[slot]) : undefined; }
function stringField(value, name, slot) { const result = field(value, name, slot); return typeof result === "string" ? result : ""; }
function numberField(value, name, slot) { const result = field(value, name, slot); return typeof result === "number" && Number.isFinite(result) ? result : 0; }

View file

@ -14,7 +14,7 @@ const surface = ["surface-state", "gamecult.eve.surface.v1", "test-provider", "d
function harness() {
const sent = [];
const records = new Map([["records/provider", advertisement], ["records/world", surface], ["records/receipts/cmd-1", { state: "accepted" }]]);
const records = new Map([["records/provider", advertisement], ["records/world", surface], ["records/receipts:cmd-1", { state: "accepted" }]]);
const peer = { send: message => sent.push(message), close() {}, on() {} };
const mesh = {
createPeerCatalog: () => ({ upsert() {} }), createAuthorityLeaseCatalog: () => ({ upsert() {} }),
@ -42,9 +42,9 @@ test("follows provider-advertised record references", async () => {
test("submits at the advertised command boundary and reads the advertised receipt", async () => {
const { client, sent } = harness();
const submission = await client.submitCommand({ surfaceId: "world", command: "move", commandId: "cmd-1", payload: { x: 1 } });
assert.equal(sent[0].document.recordKey, "records/commands/cmd-1");
assert.equal(sent[0].document.recordKey, "records/commands:cmd-1");
assert.equal(sent[0].document.sourceRole, "eve-runtime");
assert.equal(submission.receiptRecordRef, "records/receipts/cmd-1");
assert.equal(submission.receiptRecordRef, "records/receipts:cmd-1");
assert.deepEqual(await client.receipt(submission), { state: "accepted" });
});