Advance deduplicated object rename coverage
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

This commit is contained in:
mes123456
2026-08-28 16:14:21 +08:00
parent ec46223aba
commit 69fc086b12
40 changed files with 2204 additions and 20 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,63 @@
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-P21-001";
const parentPath = "tests/golden/WBV2-P21-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 planPath = `${out}/rename-task-plan.json`;
const reportPath = `${out}/object-rename-selection-report.json`;
const candidatePath = `${out}/object-rename-candidate-set.json`;
const manifestPath = `${out}/manifest.json`;
const statusPath = "docs/status/WBV2-P21-001.md";
const parent = json(parentPath);
const inventory = json(inventoryPath);
assert.equal(parent.status, "done");
assert.equal(parent.nextTask, "WBV2-P21-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), /renameId/);
assert.match(read(protocolPath), /renameId/);
const target = inventory.entries.find((entry) => entry.id === "operator:object.add_named");
assert.ok(target);
assert.equal(target.legacyState, "pending");
const behavior = { capability: "OBJECT_OPERATIONS.RENAME", operation: "renameId", positive: ["object-name-change", "undo", "redo", "save-reopen"], negative: ["empty-name", "missing-id"], browser: "chromium", engine: "compiled-WASM-WebEngine-Main" };
const behaviorHash = digest(JSON.stringify(behavior));
const candidate = { schemaVersion: 1, task: "WBV2-P21-001", operation: "OBJECT_RENAME_CANDIDATE_SELECTION", status: "READY", source: { inventory: inventoryPath, inventorySha256: sha(inventoryPath), api: apiPath, apiSha256: sha(apiPath), protocol: protocolPath, protocolSha256: sha(protocolPath) }, candidate: { capabilityId: "OBJECT_OPERATIONS.RENAME", legacyId: target.id, legacyTask: target.evidence.legacyTask, behavior, behaviorHash, dedupeKey: `OBJECT_OPERATIONS.RENAME|${behaviorHash}|${sha(apiPath)}|${sha(protocolPath)}`, sourceBacked: true, chromiumProductionReady: true, fullFamilyParity: false }, inventory: { matchedEntries: 1, pending: 1, total: 6900, basePending: 6618, effectivePending: 6612, 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-P21-001", operation: "SELECT_OBJECT_RENAME_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-P21-002" };
if (!process.argv.includes("--write")) { console.log(`wbv2-rename-selection-ok task=WBV2-P21-001 legacyId=${target.id} behaviorHash=${behaviorHash} pending=6612 repeatedRuns=0 next=WBV2-P21-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-P21-001 status\n\n- task: \`WBV2-P21-001\`; parent: \`WBV2-P21-000\`; status: \`done\`\n- selected behavior: \`renameId\`; exact candidate: \`operator:object.add_named\`\n- base inventory: \`6900\` total, \`6618\` pending; effective carried overlay: \`6612\` pending\n- behavior hash: \`${behaviorHash}\`; duplicate validation: \`forbidden\`\n- nextTask: \`WBV2-P21-002\`\n`);
const previousPlan = json("tests/golden/WBV2-P21-000/rename-task-plan.json");
const nextPlan = structuredClone(previousPlan);
nextPlan.parentRecoveryPlan = { path: "tests/golden/WBV2-P21-000/rename-task-plan.json", sha256: sha("tests/golden/WBV2-P21-000/rename-task-plan.json") };
nextPlan.tasks = nextPlan.tasks.map((task) => task.id === "WBV2-P21-001" ? { ...task, status: "done", ready: false } : task.id === "WBV2-P21-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-P21-002.md"), read("docs/tasks/WBV2-P21-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-P21-001", "--write"], { cwd: root, stdio: "inherit" });
const artifactPaths = { parentManifest: parentPath, inventory: inventoryPath, api: apiPath, protocol: protocolPath, candidate: candidatePath, report: reportPath, generator: "tools/web/generate-wbv2-rename-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-P21-001", parentTask: "WBV2-P21-000", operation: "SELECT_OBJECT_RENAME_BATCH", status: "done", enablingTask: true, parityStateChange: false, runtime: "READ_ONLY_SOURCE_CANDIDATE_SELECTION", artifacts, assertions: { legacyId: target.id, inventoryTotal: 6900, basePending: 6618, effectivePending: 6612, sourceApiBound: true, representativeSliceOnly: true, fullFamilyParity: false, repeatedBlenderRuns: 0, repeatedChromiumRuns: 0, duplicateValidationAvoided: true, deterministic: true, historicalReproduction: false }, nextTask: "WBV2-P21-002" }, null, 2)}\n`);
let queue = read("docs/EXECUTION_QUEUE.md");
queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, "| 当前任务 | `WBV2-P21-002` |").replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P21-001/manifest.json` |").replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P21-002.md`](tasks/WBV2-P21-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-P21-002` |").replace(/\| Current task state \| `[^`]+` \|/u, "| Current task state | `in_progress` |").replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P21-001/manifest.json` |").replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P21-002.md` |").replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `WBV2-P21-003` |").replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `npm --prefix web run test:e2e -- --workers=1 tests/e2e/wbv2-object-rename-production.spec.ts` |");
fs.writeFileSync(abs("nextTask.md"), nextTask);
console.log(`wbv2-rename-selection-written task=WBV2-P21-001 legacyId=${target.id} behaviorHash=${behaviorHash} next=WBV2-P21-002 artifacts=${Object.keys(artifacts).length}`);