106 lines
9.4 KiB
JavaScript
106 lines
9.4 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import crypto from "node:crypto";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { execFileSync } from "node:child_process";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
const write = process.argv.includes("--write");
|
|
const absolute = (file) => path.join(root, file);
|
|
const read = (file) => fs.readFileSync(absolute(file), "utf8");
|
|
const readJson = (file) => JSON.parse(read(file));
|
|
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(absolute(file))).digest("hex");
|
|
const outputRoot = "tests/golden/WBV2-P11-002";
|
|
const productionPath = `${outputRoot}/modifier-parameter-production.json`;
|
|
const secondProductionPath = `${outputRoot}/modifier-parameter-production.second.json`;
|
|
const reportPath = `${outputRoot}/modifier-parameter-receipt-report.json`;
|
|
const statusPath = "docs/status/WBV2-P11-002.md";
|
|
const planPath = `${outputRoot}/module-expansion-task-plan.json`;
|
|
const manifestPath = `${outputRoot}/manifest.json`;
|
|
const parentPath = "tests/golden/WBV2-P11-001/manifest.json";
|
|
const sourceManifestPath = "tests/golden/WBV2-P4-001/manifest.json";
|
|
const sourceReportPath = "tests/golden/WBV2-P4-001/modifier-report.json";
|
|
const engineReceiptPath = "tests/golden/WBV2-P10-002/native-engine-receipt-report.json";
|
|
|
|
const parent = readJson(parentPath);
|
|
assert.equal(parent.task, "WBV2-P11-001");
|
|
assert.equal(parent.status, "done");
|
|
assert.equal(parent.nextTask, "WBV2-P11-002");
|
|
for (const artifact of Object.values(parent.artifacts ?? {})) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
|
const sourceManifest = readJson(sourceManifestPath);
|
|
const sourceReport = readJson(sourceReportPath);
|
|
assert.equal(sourceManifest.status, "done");
|
|
assert.equal(sourceReport.desktop.status, "EXACT");
|
|
assert.equal(sourceReport.wasm.status, "EXACT");
|
|
assert.equal(sourceReport.wasm.saveReopen, "EXACT");
|
|
const sourceBound = Object.values(sourceManifest.artifacts ?? {}).find((artifact) => artifact.path === sourceReportPath);
|
|
assert.ok(sourceBound);
|
|
assert.equal(sourceBound.sha256, sha256(sourceReportPath));
|
|
const engineReceipt = readJson(engineReceiptPath);
|
|
assert.equal(engineReceipt.status, "PASS");
|
|
assert.equal(engineReceipt.assertions.realEngineMainMutation, true);
|
|
|
|
assert.equal(sha256(productionPath), sha256(secondProductionPath));
|
|
const production = readJson(productionPath);
|
|
assert.equal(production.task, "WBV2-P11-002");
|
|
assert.equal(production.browser, "chromium");
|
|
assert.equal(production.queueMutation, false);
|
|
assert.equal(production.disabledRevision, 4);
|
|
assert.equal(production.appliedRevision, 5);
|
|
assert.equal(production.simplify.status, "applied");
|
|
assert.ok(production.after.vertexCount < production.before.vertexCount);
|
|
assert.ok(production.after.triangleCount < production.before.triangleCount);
|
|
assert.equal(production.exactSaveReopen, true);
|
|
assert.deepEqual(production.afterStale, production.after);
|
|
assert.deepEqual(production.afterMalformed, production.after);
|
|
assert.notEqual(production.stale.code, "NO_ERROR");
|
|
assert.notEqual(production.malformed.code, "NO_ERROR");
|
|
|
|
const receipt = {
|
|
schemaVersion: 1,
|
|
task: "WBV2-P11-002",
|
|
operation: "MODIFIER_PARAMETER_APPLY_FAMILY_RECEIPT",
|
|
status: "PASS",
|
|
browser: "chromium",
|
|
queueMutation: false,
|
|
source: { task: "WBV2-P4-001", manifest: sourceManifestPath, manifestSha256: sha256(sourceManifestPath), report: sourceReportPath, reportSha256: sha256(sourceReportPath), desktopExact: true, wasmExact: true, sourceSaveReopenExact: true },
|
|
engine: { receipt: engineReceiptPath, receiptSha256: sha256(engineReceiptPath), compiledWasmBound: engineReceipt.assertions.compiledWasmBound, realEngineMainMutation: engineReceipt.assertions.realEngineMainMutation },
|
|
production: { report: productionPath, reportSha256: sha256(productionPath), secondReport: secondProductionPath, secondReportSha256: sha256(secondProductionPath), deterministic: true, meshId: production.meshId, modifierUuid: production.modifierUuid, disabledRevision: production.disabledRevision, appliedRevision: production.appliedRevision, profile: { mode: production.simplify.mode, ratio: production.simplify.ratio, attributePolicy: "PRESERVE" }, before: production.before, after: production.after, reopened: production.reopened, exactSaveReopen: production.exactSaveReopen, stale: production.stale, malformed: production.malformed },
|
|
assertions: { parameterMutation: "DECIMATE_COLLAPSE", evaluatedApply: true, mainMutation: "CHANGED", revisionDelta: 1, saveReopenExact: true, dependencyBlockHandled: true, staleProfileRejected: true, malformedProfileRejected: true, historicalReproduction: false },
|
|
nextTask: "WBV2-P11-003",
|
|
};
|
|
if (!write) {
|
|
process.stdout.write("wbv2-modifier-parameter-receipt-ok task=WBV2-P11-002 apply=EXACT saveReopen=EXACT negatives=2 deterministic=true next=WBV2-P11-003\n");
|
|
process.exit(0);
|
|
}
|
|
fs.mkdirSync(absolute(outputRoot), { recursive: true });
|
|
fs.writeFileSync(absolute(reportPath), `${JSON.stringify(receipt, null, 2)}\n`);
|
|
fs.writeFileSync(absolute(statusPath), `# WBV2-P11-002 status\n\n- task: \`WBV2-P11-002\`; parent: \`WBV2-P11-001\`; status: \`done\`\n- dependency preparation: all active modifiers disabled; revision: \`1 -> 4\`\n- DECIMATE apply: revision \`4 -> 5\`; vertex/triangle counts reduced\n- save/reopen: \`EXACT\`; stale profile and malformed ratio rejected\n- nextTask: \`WBV2-P11-003\`\n\nThe bounded Modifier parameter/apply operation executes through the compiled WebEngine WASM Main. The dependency block is handled explicitly before apply; failed profile inputs leave the applied Main unchanged. This remains an engine-bound capability slice and does not claim complete modifier inventory parity or historical byte reproduction.\n`);
|
|
const previousPlan = readJson("tests/golden/WBV2-P11-001/module-expansion-task-plan.json");
|
|
const nextPlan = structuredClone(previousPlan);
|
|
nextPlan.parentRecoveryPlan = { path: "tests/golden/WBV2-P11-001/module-expansion-task-plan.json", sha256: sha256("tests/golden/WBV2-P11-001/module-expansion-task-plan.json") };
|
|
nextPlan.tasks = nextPlan.tasks.map((task) => task.id === "WBV2-P11-002" ? { ...task, status: "done", ready: false } : task.id === "WBV2-P11-003" ? { ...task, status: "in_progress", ready: true } : { ...task, ready: false });
|
|
fs.writeFileSync(absolute(planPath), `${JSON.stringify(nextPlan, null, 2)}\n`);
|
|
const nextCardPath = "docs/tasks/WBV2-P11-003.md";
|
|
fs.writeFileSync(absolute(nextCardPath), read(nextCardPath).replace("- status: planned", "- status: in_progress"));
|
|
execFileSync(process.execPath, [absolute("tools/web/generate-v2-task-index.mjs"), "--plan-path", absolute(planPath)], { cwd: root, stdio: "inherit" });
|
|
execFileSync(process.execPath, [absolute("tools/web/check-task-context.mjs"), "--task", "WBV2-P11-002", "--write"], { cwd: root, stdio: "inherit" });
|
|
const artifactPaths = { parentManifest: parentPath, sourceManifest: sourceManifestPath, sourceReport: sourceReportPath, engineReceipt: engineReceiptPath, production: productionPath, productionSecond: secondProductionPath, e2e: "web/tests/e2e/wbv2-modifier-parameter-production.spec.ts", protocol: "blender-5.2.0/source/blender/web_engine/web_engine_api.cpp", client: "web/app/src/engine-client/WebEngineClient.ts", generator: "tools/web/generate-wbv2-modifier-parameter-receipt.mjs", report: reportPath, status: statusPath, parityPlan: planPath, taskContext: `${outputRoot}/task-context.json` };
|
|
const artifacts = Object.fromEntries(Object.entries(artifactPaths).map(([name, file]) => [name, { path: file, sha256: sha256(file) }]));
|
|
const manifest = { schemaVersion: 1, task: "WBV2-P11-002", parentTask: "WBV2-P11-001", operation: "MODIFIER_PARAMETER_APPLY_FAMILY_RECEIPT", status: "done", enablingTask: false, parityStateChange: true, runtime: "PLAYWRIGHT_CHROMIUM_WEBENGINE_WASM", artifacts, assertions: { parameterMutation: "DECIMATE_COLLAPSE", evaluatedApply: true, realEngineMainMutation: true, saveReopen: "EXACT", negativeCases: 2, dependencyBlockHandled: true, deterministic: true, historicalReproduction: false }, nextTask: "WBV2-P11-003" };
|
|
fs.writeFileSync(absolute(manifestPath), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
let queue = read("docs/EXECUTION_QUEUE.md");
|
|
queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, "| 当前任务 | `WBV2-P11-003` |")
|
|
.replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P11-002/manifest.json` |")
|
|
.replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P11-003.md`](tasks/WBV2-P11-003.md) |");
|
|
fs.writeFileSync(absolute("docs/EXECUTION_QUEUE.md"), queue);
|
|
let nextTaskFile = read("nextTask.md");
|
|
nextTaskFile = nextTaskFile.replace(/\| Current task when this file was written \| `[^`]+` \|/u, "| Current task when this file was written | `WBV2-P11-003` |")
|
|
.replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P11-002/manifest.json` |")
|
|
.replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P11-003.md` |")
|
|
.replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `WBV2-P11-004` |")
|
|
.replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `npm --prefix web run test:e2e -- --workers=1 tests/e2e/wbv2-asset-link-override-production.spec.ts` |");
|
|
fs.writeFileSync(absolute("nextTask.md"), nextTaskFile);
|
|
process.stdout.write(`wbv2-modifier-parameter-receipt-written task=WBV2-P11-002 apply=EXACT saveReopen=EXACT negatives=2 deterministic=true next=WBV2-P11-003 artifacts=${Object.keys(artifacts).length}\n`);
|