43 lines
8.2 KiB
JavaScript
43 lines
8.2 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 abs = (file) => path.join(root, file);
|
|
const read = (file) => fs.readFileSync(abs(file), "utf8");
|
|
const json = (file) => JSON.parse(read(file));
|
|
const sha = (file) => crypto.createHash("sha256").update(fs.readFileSync(abs(file))).digest("hex");
|
|
const digest = (value) => crypto.createHash("sha256").update(value).digest("hex");
|
|
const out = "tests/golden/WBV2-P24-001";
|
|
const parentPath = "tests/golden/WBV2-P24-000/manifest.json";
|
|
const inventoryPath = "tests/golden/WBV2-P0-002/parity-map.json";
|
|
const apiPath = "blender-5.2.0/source/blender/web_engine/web_engine_api.cpp";
|
|
const protocolPath = "web/protocol/web-engine.ts";
|
|
const fixturePath = "tests/files/web/generated/WBV2-P24-001-OBJECT_OPERATIONS.MOVE_COLLECTION.blend";
|
|
const planPath = `${out}/move-task-plan.json`;
|
|
const reportPath = `${out}/object-move-selection-report.json`;
|
|
const candidatePath = `${out}/object-move-candidate-set.json`;
|
|
const manifestPath = `${out}/manifest.json`;
|
|
const statusPath = "docs/status/WBV2-P24-001.md";
|
|
|
|
const parent = json(parentPath); const inventory = json(inventoryPath);
|
|
assert.equal(parent.status, "done"); assert.equal(parent.nextTask, "WBV2-P24-001");
|
|
for (const artifact of Object.values(parent.artifacts ?? {})) assert.equal(sha(artifact.path), artifact.sha256, artifact.path);
|
|
assert.equal(inventory.summary.inventoryEntries, 6900); assert.match(read(apiPath), /moveObjectToCollection/); assert.match(read(protocolPath), /moveObjectToCollection/); assert.ok(fs.existsSync(abs(fixturePath)));
|
|
const target = inventory.entries.find((entry) => entry.id === "operator:object.move_to_collection"); assert.ok(target); assert.equal(target.legacyState, "pending");
|
|
const behavior = { capability: "OBJECT_OPERATIONS.MOVE_COLLECTION", operation: "moveObjectToCollection", positive: ["collection-membership-change", "undo", "redo", "save-reopen"], negative: ["missing-object-id", "missing-collection-id"], browser: "chromium", engine: "compiled-WASM-WebEngine-Main" };
|
|
const behaviorHash = digest(JSON.stringify(behavior));
|
|
const candidate = { schemaVersion: 1, task: "WBV2-P24-001", operation: "OBJECT_MOVE_COLLECTION_CANDIDATE_SELECTION", status: "READY", source: { inventory: inventoryPath, inventorySha256: sha(inventoryPath), api: apiPath, apiSha256: sha(apiPath), protocol: protocolPath, protocolSha256: sha(protocolPath), fixture: fixturePath, fixtureSha256: sha(fixturePath) }, candidate: { capabilityId: "OBJECT_OPERATIONS.MOVE_COLLECTION", legacyId: target.id, legacyTask: target.evidence.legacyTask, behavior, behaviorHash, dedupeKey: `OBJECT_OPERATIONS.MOVE_COLLECTION|${behaviorHash}|${sha(apiPath)}|${sha(protocolPath)}|${sha(fixturePath)}`, sourceBacked: true, chromiumProductionReady: true, fullFamilyParity: false }, inventory: { matchedEntries: 1, pending: 1, total: 6900, basePending: 6618, effectivePending: 6609, remainderExplicit: true }, entries: [{ id: target.id, sourceTask: target.sourceTask, legacyState: target.legacyState, targetImplementationClass: target.targetImplementationClass }], policy: { sourceHistoryReadOnly: true, representativeSliceOnly: true, noRepeatedExecution: true, duplicateValidationAvoided: true, fullHistoricalReproduction: false } };
|
|
const report = { schemaVersion: 1, task: "WBV2-P24-001", operation: "SELECT_OBJECT_MOVE_COLLECTION_BATCH", status: "PASS", candidate: candidate.candidate, inventory: candidate.inventory, source: candidate.source, matchedEntryDigest: digest(target.id), efficiency: { oneEntryScan: true, existingEvidenceReused: true, repeatedBlenderRuns: 0, repeatedChromiumRuns: 0, duplicateValidationAvoided: true }, nextTask: "WBV2-P24-002" };
|
|
if (!process.argv.includes("--write")) { console.log(`wbv2-move-selection-ok task=WBV2-P24-001 legacyId=${target.id} behaviorHash=${behaviorHash} pending=6609 repeatedRuns=0 next=WBV2-P24-002`); process.exit(0); }
|
|
fs.mkdirSync(abs(out), { recursive: true }); fs.writeFileSync(abs(candidatePath), `${JSON.stringify(candidate, null, 2)}\n`); fs.writeFileSync(abs(reportPath), `${JSON.stringify(report, null, 2)}\n`);
|
|
fs.writeFileSync(abs(statusPath), `# WBV2-P24-001 status\n\n- task: \`WBV2-P24-001\`; parent: \`WBV2-P24-000\`; status: \`done\`\n- selected behavior: \`moveObjectToCollection\`; exact candidate: \`operator:object.move_to_collection\`\n- fixture: \`${fixturePath}\`; base inventory: \`6900\` total, \`6618\` pending; effective carried overlay: \`6609\` pending\n- behavior hash: \`${behaviorHash}\`; duplicate validation: \`forbidden\`\n- nextTask: \`WBV2-P24-002\`\n`);
|
|
const previousPlan = json("tests/golden/WBV2-P24-000/move-task-plan.json"); const nextPlan = structuredClone(previousPlan); nextPlan.parentRecoveryPlan = { path: "tests/golden/WBV2-P24-000/move-task-plan.json", sha256: sha("tests/golden/WBV2-P24-000/move-task-plan.json") }; nextPlan.tasks = nextPlan.tasks.map((task) => task.id === "WBV2-P24-001" ? { ...task, status: "done", ready: false } : task.id === "WBV2-P24-002" ? { ...task, status: "in_progress", ready: true } : { ...task, ready: false }); fs.writeFileSync(abs(planPath), `${JSON.stringify(nextPlan, null, 2)}\n`); fs.writeFileSync(abs("docs/tasks/WBV2-P24-002.md"), read("docs/tasks/WBV2-P24-002.md").replace("- status: planned", "- status: in_progress")); execFileSync(process.execPath, [abs("tools/web/generate-v2-task-index.mjs"), "--plan-path", abs(planPath)], { cwd: root, stdio: "inherit" }); execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", "WBV2-P24-001", "--write"], { cwd: root, stdio: "inherit" });
|
|
const artifactPaths = { parentManifest: parentPath, inventory: inventoryPath, api: apiPath, protocol: protocolPath, fixture: fixturePath, candidate: candidatePath, report: reportPath, generator: "tools/web/generate-wbv2-move-selection.mjs", status: statusPath, parityPlan: planPath, taskContext: `${out}/task-context.json` }; const artifacts = Object.fromEntries(Object.entries(artifactPaths).map(([name, file]) => [name, { path: file, sha256: sha(file) }])); fs.writeFileSync(abs(manifestPath), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P24-001", parentTask: "WBV2-P24-000", operation: "SELECT_OBJECT_MOVE_COLLECTION_BATCH", status: "done", enablingTask: true, parityStateChange: false, runtime: "READ_ONLY_SOURCE_CANDIDATE_SELECTION", artifacts, assertions: { legacyId: target.id, inventoryTotal: 6900, basePending: 6618, effectivePending: 6609, sourceApiBound: true, fixtureBound: true, representativeSliceOnly: true, fullFamilyParity: false, repeatedBlenderRuns: 0, repeatedChromiumRuns: 0, duplicateValidationAvoided: true, deterministic: true, historicalReproduction: false }, nextTask: "WBV2-P24-002" }, null, 2)}\n`);
|
|
let queue = read("docs/EXECUTION_QUEUE.md"); queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, "| 当前任务 | `WBV2-P24-002` |").replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P24-001/manifest.json` |").replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P24-002.md`](tasks/WBV2-P24-002.md) |"); fs.writeFileSync(abs("docs/EXECUTION_QUEUE.md"), queue);
|
|
let nextTask = read("nextTask.md"); nextTask = nextTask.replace(/\| Current task when this file was written \| `[^`]+` \|/u, "| Current task when this file was written | `WBV2-P24-002` |").replace(/\| Current task state \| `[^`]+` \|/u, "| Current task state | `in_progress` |").replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P24-001/manifest.json` |").replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P24-002.md` |").replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `WBV2-P24-003` |").replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `npm --prefix web run test:e2e -- --workers=1 tests/e2e/wbv2-object-move-production.spec.ts` |"); fs.writeFileSync(abs("nextTask.md"), nextTask);
|
|
console.log(`wbv2-move-selection-written task=WBV2-P24-001 legacyId=${target.id} behaviorHash=${behaviorHash} next=WBV2-P24-002 artifacts=${Object.keys(artifacts).length}`);
|