174 lines
10 KiB
JavaScript
174 lines
10 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-P9-002";
|
|
const chromiumPath = `${outputRoot}/chromium-modifier-production.json`;
|
|
const chromiumSecondPath = `${outputRoot}/chromium-modifier-production.second.json`;
|
|
const reportPath = `${outputRoot}/modifier-receipt-report.json`;
|
|
const statusPath = "docs/status/WBV2-P9-002.md";
|
|
const planPath = `${outputRoot}/feature-parity-task-plan.json`;
|
|
const manifestPath = `${outputRoot}/manifest.json`;
|
|
const parentManifestPath = "tests/golden/WBV2-P9-001/manifest.json";
|
|
const sourceManifestPath = "tests/golden/corrective/C4-001/manifest.json";
|
|
const sourceReportPath = "tests/golden/corrective/C4-001/receipt-report.json";
|
|
|
|
const parent = readJson(parentManifestPath);
|
|
assert.equal(parent.task, "WBV2-P9-001");
|
|
assert.equal(parent.status, "done");
|
|
assert.equal(parent.nextTask, "WBV2-P9-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.task, "C4-001");
|
|
assert.equal(sourceManifest.status, "done");
|
|
assert.equal(sourceReport.task, "C4-001");
|
|
assert.equal(sourceReport.browser, "chromium");
|
|
assert.equal(sourceReport.queueMutation, false);
|
|
assert.equal(sourceReport.parity, true);
|
|
assert.equal(sourceReport.positive.desktop.status, "FINISHED");
|
|
assert.equal(sourceReport.positive.wasm.status, "FINISHED");
|
|
assert.equal(sourceReport.persistence.reopened.dirty, false);
|
|
const sourceBound = Object.values(sourceManifest.artifacts ?? {}).find((artifact) => artifact.path === sourceReportPath);
|
|
assert.ok(sourceBound, "C4-001 source report is not manifest-bound");
|
|
assert.equal(sourceBound.sha256, sha256(sourceReportPath));
|
|
|
|
assert.equal(sha256(chromiumPath), sha256(chromiumSecondPath), "Chromium Modifier report is not deterministic");
|
|
const chromium = readJson(chromiumPath);
|
|
assert.equal(chromium.task, "WBV2-P9-002");
|
|
assert.equal(chromium.operation, "MODIFIER_PRODUCTION_CHROMIUM");
|
|
assert.equal(chromium.browser, "chromium");
|
|
assert.equal(chromium.queueMutation, false);
|
|
assert.equal(chromium.positive.parity, true);
|
|
for (const surface of ["desktop", "wasm"]) {
|
|
const result = chromium.positive[surface];
|
|
assert.equal(result.status, "FINISHED");
|
|
assert.equal(result.code, "OK");
|
|
assert.equal(result.mainRevisionBefore, 7);
|
|
assert.equal(result.mainRevisionAfter, 8);
|
|
assert.equal(result.mainMutation, "CHANGED");
|
|
assert.deepEqual(result.delta, { modifierUuid: "modifier:bevel", previousEnabled: false, enabled: true });
|
|
}
|
|
assert.deepEqual(chromium.positive.desktop, chromium.positive.wasm);
|
|
assert.equal(chromium.persistence.exact, true);
|
|
assert.deepEqual(chromium.persistence.reopened, chromium.persistence.saved);
|
|
assert.equal(chromium.negative.malformed.code, "COMMAND_MALFORMED");
|
|
assert.equal(chromium.negative.stale.code, "REVISION_CONFLICT");
|
|
assert.equal(chromium.negative.unknown.code, "COMMAND_UNSUPPORTED");
|
|
assert.equal(chromium.negative.rollbackMain.revision, 7);
|
|
assert.equal(chromium.negative.rollbackMain.dirty, false);
|
|
assert.deepEqual(chromium.negative.rollbackMain.value.modifiers, [{ uuid: "modifier:bevel", name: "Pilot Bevel", type: "BEVEL", enabled: false, showViewport: true, showRender: true }]);
|
|
|
|
const receipt = {
|
|
schemaVersion: 1,
|
|
task: "WBV2-P9-002",
|
|
operation: "MODIFIER_PRODUCTION_CHROMIUM_RECEIPT",
|
|
status: "PASS",
|
|
browser: "chromium",
|
|
queueMutation: false,
|
|
source: {
|
|
task: "C4-001",
|
|
manifest: sourceManifestPath,
|
|
manifestSha256: sha256(sourceManifestPath),
|
|
report: sourceReportPath,
|
|
reportSha256: sha256(sourceReportPath),
|
|
exactChromiumPilot: true,
|
|
exactSaveReopen: true,
|
|
},
|
|
chromium: {
|
|
report: chromiumPath,
|
|
reportSha256: sha256(chromiumPath),
|
|
secondReport: chromiumSecondPath,
|
|
secondReportSha256: sha256(chromiumSecondPath),
|
|
deterministic: true,
|
|
surfaces: ["DESKTOP", "WASM"],
|
|
positive: { desktop: chromium.positive.desktop, wasm: chromium.positive.wasm, parity: chromium.positive.parity },
|
|
negative: { malformed: chromium.negative.malformed, stale: chromium.negative.stale, unknown: chromium.negative.unknown },
|
|
persistence: { exact: chromium.persistence.exact, saved: chromium.persistence.saved, reopened: chromium.persistence.reopened },
|
|
},
|
|
assertions: {
|
|
realModifierSetEnabled: true,
|
|
desktopWasmDeltaMatch: true,
|
|
saveReopenExact: true,
|
|
failureMatrixClosed: true,
|
|
featureParityClaim: "CAP-MODIFIER-STATE-MUTATION",
|
|
historicalReproduction: false,
|
|
},
|
|
nextTask: "WBV2-P9-003",
|
|
};
|
|
|
|
if (!write) {
|
|
process.stdout.write("wbv2-modifier-receipt-ok task=WBV2-P9-002 deterministic=true next=WBV2-P9-003\n");
|
|
process.exit(0);
|
|
}
|
|
|
|
fs.mkdirSync(absolute(outputRoot), { recursive: true });
|
|
fs.writeFileSync(absolute(reportPath), `${JSON.stringify(receipt, null, 2)}\n`);
|
|
const status = `# WBV2-P9-002 status\n\n- task: \`WBV2-P9-002\`; parent: \`WBV2-P9-001\`; status: \`done\`\n- Modifier Chromium receipt: \`DESKTOP + WASM\`\n- enabled transition: \`false -> true\`; revision: \`7 -> 8\`\n- save/reopen: \`EXACT\`\n- nextTask: \`WBV2-P9-003\`\n\nThe production Chromium receipt executes the existing Modifier Main transaction on both browser surfaces. Malformed, stale-revision, and unknown-modifier commands are rejected without mutating the Main. This is a bounded current implementation claim and does not assert historical byte reproduction.\n`;
|
|
fs.writeFileSync(absolute(statusPath), status);
|
|
|
|
const previousPlan = readJson("tests/golden/WBV2-P9-001/feature-parity-task-plan.json");
|
|
const nextPlan = structuredClone(previousPlan);
|
|
nextPlan.parentRecoveryPlan = { path: "tests/golden/WBV2-P9-001/feature-parity-task-plan.json", sha256: sha256("tests/golden/WBV2-P9-001/feature-parity-task-plan.json") };
|
|
nextPlan.tasks = nextPlan.tasks.map((task) => task.id === "WBV2-P9-002"
|
|
? { ...task, status: "done", ready: false }
|
|
: task.id === "WBV2-P9-003"
|
|
? { ...task, status: "in_progress", ready: true }
|
|
: { ...task, ready: false });
|
|
fs.writeFileSync(absolute(planPath), `${JSON.stringify(nextPlan, null, 2)}\n`);
|
|
|
|
const nextCard = `# WBV2-P9-003: Asset Catalog production Chromium receipt\n\n- task: WBV2-P9-003\n- parent: WBV2-P9-002\n- status: in_progress\n- gap: workflow:asset_catalog_production_chromium_receipt\n- ownerFamily: ASSET\n- targetImplementationClass: LOCAL_EXACT\n\n## 目标\n\nBind the real Asset Catalog Main transaction and resource resolver to a production Chromium desktop/WASM/save-reopen receipt using the existing source implementation.\n\n## 输入与范围\n\n- Existing Asset Catalog protocol: \`web/protocol/corrective-asset-catalog-command.ts\`\n- Existing resource resolver: \`web/protocol/corrective-resource-provider.ts\`\n- Existing exact pilot: \`tests/golden/corrective/C3-003/receipt-report.json\`\n- Chromium test: \`web/tests/e2e/wbv2-asset-catalog-production.spec.ts\`\n\n## 验收\n\n- \`npm --prefix web run test:e2e -- --workers=1 tests/e2e/wbv2-asset-catalog-production.spec.ts\`\n- \`node tools/web/generate-wbv2-asset-catalog-receipt.mjs --write\`\n- \`node tools/web/check-task-context.mjs --task WBV2-P9-003 --write\`\n\nMalformed, stale-revision, unknown-asset, missing-resource, non-Chromium, or non-exact save/reopen cases must keep in_progress and must not advance nextTask.\n\n## 交付与回滚\n\n- Reports: \`tests/golden/WBV2-P9-003/\`\n- Status: \`docs/status/WBV2-P9-003.md\`\n- Manifest: \`tests/golden/WBV2-P9-003/manifest.json\`\n- Rollback: restore P9-002 as queue parent without modifying Modifier, Mesh, or P8 evidence.\n`;
|
|
fs.writeFileSync(absolute("docs/tasks/WBV2-P9-003.md"), nextCard);
|
|
|
|
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-P9-002", "--write"], { cwd: root, stdio: "inherit" });
|
|
|
|
const artifactPaths = {
|
|
parentManifest: parentManifestPath,
|
|
sourceManifest: sourceManifestPath,
|
|
sourceReport: sourceReportPath,
|
|
chromiumReport: chromiumPath,
|
|
chromiumSecondReport: chromiumSecondPath,
|
|
e2e: "web/tests/e2e/wbv2-modifier-production.spec.ts",
|
|
protocol: "web/protocol/corrective-modifier-command.ts",
|
|
bridge: "web/app/src/corrective-pilot-bridge.ts",
|
|
generator: "tools/web/generate-wbv2-modifier-receipt.mjs",
|
|
report: reportPath,
|
|
status: statusPath,
|
|
featureParityPlan: 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-P9-002",
|
|
parentTask: "WBV2-P9-001",
|
|
operation: "MODIFIER_PRODUCTION_CHROMIUM_RECEIPT",
|
|
status: "done",
|
|
enablingTask: false,
|
|
parityStateChange: true,
|
|
runtime: "PLAYWRIGHT_CHROMIUM_DESKTOP_AND_WASM",
|
|
artifacts,
|
|
assertions: { capabilityId: "CAP-MODIFIER-STATE-MUTATION", browser: "chromium", surfaces: 2, deterministic: true, saveReopen: "EXACT", negativeCases: 3, historicalReproduction: false },
|
|
nextTask: "WBV2-P9-003",
|
|
};
|
|
fs.writeFileSync(absolute(manifestPath), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
|
|
let queue = read("docs/EXECUTION_QUEUE.md");
|
|
queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, "| 当前任务 | `WBV2-P9-003` |")
|
|
.replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P9-002/manifest.json` |")
|
|
.replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P9-003.md`](tasks/WBV2-P9-003.md) |");
|
|
fs.writeFileSync(absolute("docs/EXECUTION_QUEUE.md"), queue);
|
|
execFileSync(process.execPath, [absolute("tools/web/check-v2-task-index.mjs")], { cwd: root, stdio: "pipe" });
|
|
process.stdout.write(`wbv2-modifier-receipt-written task=WBV2-P9-002 surfaces=2 deterministic=true next=WBV2-P9-003 artifacts=${Object.keys(artifacts).length}\n`);
|