Add EveElectron semantic capture artifact

This commit is contained in:
Meta Vens 2026-07-09 15:29:57 +01:00
commit 3f7e381ea8
10 changed files with 292 additions and 20 deletions

View file

@ -0,0 +1,113 @@
import { mkdirSync, writeFileSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { EveElectronShell } from "../../runtimes/incubating/eve-electron/src/eve-electron-shell.mjs";
import { buildElectronCaptureRequest, loadJsonFile, writeCaptureRequest } from "./eveelectron-capture-contract.mjs";
export function buildElectronCaptureArtifact({
advertisement,
capabilityManifest,
surfaceDocument,
advertisementPath = "",
capabilityManifestPath = "",
stamp = "latest",
} = {}) {
const request = buildElectronCaptureRequest({
advertisement,
capabilityManifest,
advertisementPath,
capabilityManifestPath,
stamp,
});
const shell = new EveElectronShell();
const projection = shell.lowerSurface(surfaceDocument, advertisement, request.surfaceId);
validateProjectionArtifact(projection, request);
return {
request,
projection: {
...projection,
runtimeId: request.runtimeId,
artifactKind: "json-projection",
captureKind: "electron-shell-projection-json",
sourceAdvertisementPath: request.sourceAdvertisementPath,
sourceCapabilityManifestPath: request.sourceCapabilityManifestPath,
issuedAtUtc: request.issuedAtUtc,
},
};
}
export function writeElectronCaptureArtifact({ request, projection }, { outputPath, requestOutputPath = "" } = {}) {
if (!outputPath) throw new Error("outputPath is required");
mkdirSync(path.dirname(outputPath), { recursive: true });
writeFileSync(outputPath, `${JSON.stringify(projection, null, 2)}\n`, "utf8");
if (requestOutputPath) {
writeCaptureRequest(request, requestOutputPath);
}
}
function validateProjectionArtifact(projection, request) {
if (projection.schema !== "gamecult.eve.electron_shell_projection.v1") {
throw new Error(`Unexpected Electron projection schema: ${projection.schema || ""}`);
}
for (const [field, expected] of [
["providerId", request.providerId],
["surfaceId", request.surfaceId],
["projectionKind", request.projectionKind],
["commandBoundary", request.commandBoundary],
["receiptSchema", request.receiptSchema],
]) {
if ((projection[field] || "") !== (expected || "")) {
throw new Error(`Electron projection ${field} expected ${expected || ""} got ${projection[field] || ""}`);
}
}
if (!projection.root || !projection.root.id) {
throw new Error("Electron projection artifact must contain a root shell node");
}
}
function parseArgs(argv) {
const args = {};
for (let index = 0; index < argv.length; index += 1) {
const value = argv[index];
if (!value.startsWith("--")) continue;
const key = value.slice(2);
const next = argv[index + 1];
if (!next || next.startsWith("--")) {
args[key] = true;
} else {
args[key] = next;
index += 1;
}
}
return args;
}
function runCli() {
const args = parseArgs(process.argv.slice(2));
for (const required of ["advertisement", "capability", "surface", "output"]) {
if (!args[required]) {
throw new Error(`missing required --${required}`);
}
}
const stamp = args.stamp || "latest";
const artifact = buildElectronCaptureArtifact({
advertisement: loadJsonFile(args.advertisement),
capabilityManifest: loadJsonFile(args.capability),
surfaceDocument: loadJsonFile(args.surface),
advertisementPath: args.advertisement,
capabilityManifestPath: args.capability,
stamp,
});
writeElectronCaptureArtifact(artifact, {
outputPath: args.output,
requestOutputPath: args["request-output"] || "",
});
process.stdout.write(`${args.output}\n`);
}
const invokedPath = process.argv[1] ? path.resolve(process.argv[1]) : "";
const modulePath = fileURLToPath(import.meta.url);
if (invokedPath === modulePath) {
runCli();
}

View file

@ -0,0 +1,30 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
import { buildElectronCaptureArtifact } from "./eveelectron-capture-artifact.mjs";
const advertisement = JSON.parse(readFileSync(new URL("../../web/fixtures/aetheria.provider-advertisement.json", import.meta.url), "utf8"));
const capabilityManifest = JSON.parse(readFileSync(new URL("../../runtimes/incubating/eve-electron/eve-runtime-capability.json", import.meta.url), "utf8"));
const surfaceDocument = JSON.parse(readFileSync(new URL("../../web/fixtures/aetheria-world-surface.json", import.meta.url), "utf8"));
test("builds Electron shell projection capture artifact from provider advertisement and surface", () => {
const { request, projection } = buildElectronCaptureArtifact({
advertisement,
capabilityManifest,
surfaceDocument,
advertisementPath: "web/fixtures/aetheria.provider-advertisement.json",
capabilityManifestPath: "runtimes/incubating/eve-electron/eve-runtime-capability.json",
stamp: "smoke",
});
assert.equal(request.artifactPath, "artifacts/eveelectron-capture/smoke/electron-shell.png");
assert.equal(projection.schema, "gamecult.eve.electron_shell_projection.v1");
assert.equal(projection.runtimeId, "electron-shell");
assert.equal(projection.providerId, "aetheria");
assert.equal(projection.surfaceId, "aetheria.daemon.game");
assert.equal(projection.commandBoundary, "aetheria.daemon.commands");
assert.equal(projection.receiptSchema, "aetheria.eve_command_acceptance_status.v1");
assert.equal(projection.artifactKind, "json-projection");
assert.equal(projection.captureKind, "electron-shell-projection-json");
assert.equal(projection.root.id, "aetheria.daemon.game.root");
});

View file

@ -676,7 +676,7 @@
"pendingProofs": [
"Electron shell runtime body graduates to EveElectron outside Aetheria product code.",
"Electron renders embedded Eve documents in a packaged Electron window.",
"Electron capture artifacts are attached to conformance output."
"Electron packaged window PNG capture artifacts are attached to conformance output."
]
},
{
@ -782,10 +782,13 @@
"scripts/run-eveelectron-provider-shell-smoke.ps1",
"scripts/run-eveelectron-release-contract-smoke.ps1",
"scripts/run-eveelectron-capture-contract-smoke.ps1",
"scripts/run-eveelectron-capture-smoke.ps1",
"tools/eveelectron/eveelectron-release-contract.mjs",
"tools/eveelectron/eveelectron-release-contract.test.mjs",
"tools/eveelectron/eveelectron-capture-contract.mjs",
"tools/eveelectron/eveelectron-capture-contract.test.mjs"
"tools/eveelectron/eveelectron-capture-contract.test.mjs",
"tools/eveelectron/eveelectron-capture-artifact.mjs",
"tools/eveelectron/eveelectron-capture-artifact.test.mjs"
],
"expectedSourceSymbols": [
{
@ -804,6 +807,14 @@
"path": "tools/eveelectron/eveelectron-capture-contract.test.mjs",
"contains": ["builds Electron shell capture request from provider advertisement", "rejects capture request when the surface does not advertise Electron shell", "electron-shell", "aetheria.daemon.commands"]
},
{
"path": "tools/eveelectron/eveelectron-capture-artifact.mjs",
"contains": ["buildElectronCaptureArtifact", "EveElectronShell", "gamecult.eve.electron_shell_projection.v1", "json-projection", "writeElectronCaptureArtifact", "request-output"]
},
{
"path": "tools/eveelectron/eveelectron-capture-artifact.test.mjs",
"contains": ["builds Electron shell projection capture artifact", "gamecult.eve.electron_shell_projection.v1", "electron-shell-projection-json"]
},
{
"path": "tools/eveelectron/eveelectron-release-contract.mjs",
"contains": ["buildElectronReleaseRequest", "gamecult.eve.runtime_release_request.v1", "eveelectron-release", "writeReleaseRequest"]
@ -814,8 +825,20 @@
}
],
"capture": {
"status": "missing",
"note": "Electron capture is a split blocker until EveElectron attaches provider-agnostic shell window artifacts."
"status": "json-projection",
"note": "Electron attaches a provider-advertisement-backed gamecult.eve.electron_shell_projection.v1 JSON projection artifact; packaged window PNG capture remains an EveElectron split blocker.",
"artifacts": [
{
"kind": "json-projection",
"schema": "gamecult.eve.electron_shell_projection.v1",
"path": "artifacts/eveelectron-capture/latest/electron-shell-projection.json",
"runtimeId": "electron-shell",
"providerId": "aetheria",
"surfaceId": "aetheria.daemon.game",
"sourceSurfacePath": "web/fixtures/aetheria-world-surface.json",
"requestPath": "artifacts/eveelectron-capture/latest/capture-request.json"
}
]
}
},
{