Files
workinf_Blender_Wasm/tools/web/generate-wbv2-object-root.mjs
mes123456 625a960198
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
Advance deduplicated object operation coverage
2026-08-28 14:18:45 +08:00

24 lines
14 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 absolute = (file) => path.join(root, file); const read = (file) => fs.readFileSync(absolute(file), "utf8"); const json = (file) => JSON.parse(read(file)); const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(absolute(file))).digest("hex");
const p16ManifestPath = "tests/golden/WBV2-P16-003/manifest.json"; const p16ReportPath = "tests/golden/WBV2-P16-003/paint-gate-report.json"; const p16StatusPath = "docs/status/WBV2-P16-003.md"; const rootDir = "tests/golden/WBV2-P17-000"; const planPath = `${rootDir}/object-task-plan.json`; const reportPath = `${rootDir}/object-root-report.json`; const manifestPath = `${rootDir}/manifest.json`; const statusPath = "docs/status/WBV2-P17-000.md"; const inventoryPath = "tests/golden/WBV2-P0-002/parity-map.json"; const sourceApiPath = "blender-5.2.0/source/blender/web_engine/web_engine_api.cpp"; const sourceClientPath = "web/app/src/engine-client/WebEngineClient.ts";
const p16 = json(p16ManifestPath); const p16Report = json(p16ReportPath); const inventory = json(inventoryPath); assert.equal(p16.task, "WBV2-P16-003"); assert.equal(p16.status, "done"); assert.ok(p16.nextTask === null || p16.nextTask === "WBV2-P17-000"); assert.equal(p16Report.status, "PASS"); assert.equal(p16Report.decision.effectivePending, 6616); assert.equal(inventory.summary.inventoryEntries, 6900); for (const artifact of Object.values(p16.artifacts ?? {})) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path); assert.match(read(sourceApiPath), /duplicateObject/); assert.match(read(sourceClientPath), /applyCommand/);
const tasks = [
{ id: "WBV2-P17-000", phase: "P17", title: "authorize_object_operations_continuation", kind: "enabling", owner: "PROGRAM", dependsOn: ["WBV2-P16-003"], parityId: null, implementationClass: "LOCAL_BOUNDED", parallelGroup: "p17-governance", gate: "G2", card: "docs/tasks/WBV2-P17-000.md", behavior: "Authorize one Object Operations behavior after the P16 paint overlay.", outputs: ["continuation root", "candidate scope", "hash boundary"], acceptance: ["P16 overlay remains hash-bound", "duplicateObject API is present", "one production task is active"], status: "done", ready: false, queueMutationAllowed: true },
{ id: "WBV2-P17-001", phase: "P17", title: "select_object_duplicate_batch", kind: "enabling", owner: "PARITY", dependsOn: ["WBV2-P17-000"], parityId: "OBJECT_OPERATIONS.DUPLICATE", implementationClass: "LOCAL_BOUNDED", parallelGroup: "p17-selection", gate: "G2", card: "docs/tasks/WBV2-P17-001.md", behavior: "Select the duplicateObject behavior and one exact legacy operator binding.", outputs: ["candidate report", "behavior hash", "dedupe key"], acceptance: ["source command is hash-bound", "existing Scene/Object evidence is not rerun", "candidate remains one behavior"], status: "in_progress", ready: true, queueMutationAllowed: false },
{ id: "WBV2-P17-002", phase: "P17", title: "object_duplicate_engine_receipt", kind: "feature", owner: "OBJECT", dependsOn: ["WBV2-P17-001"], parityId: "OBJECT_OPERATIONS.DUPLICATE", implementationClass: "LOCAL_EXACT", parallelGroup: "p17-object", gate: "G2", card: "docs/tasks/WBV2-P17-002.md", behavior: "Bind duplicateObject, undo/redo, malformed rejection, and exact save/reopen to compiled WASM Main in Chromium.", outputs: ["object production report", "object receipt", "manifest"], acceptance: ["duplicate creates a distinct object", "undo/redo revisions are sequential", "malformed object ID fails closed", "save/reopen is exact"], status: "planned", ready: false, queueMutationAllowed: false },
{ id: "WBV2-P17-003", phase: "P17", title: "close_object_duplicate_gate", kind: "enabling", owner: "RELEASE", dependsOn: ["WBV2-P17-002"], parityId: null, implementationClass: "LOCAL_BOUNDED", parallelGroup: "p17-release", gate: "G5", card: "docs/tasks/WBV2-P17-003.md", behavior: "Close the duplicateObject gate and graduate only the exact operator binding.", outputs: ["object gate", "completion overlay", "manifest"], acceptance: ["only duplicateObject is claimed", "inventory remainder remains explicit", "no duplicate validation or historical over-claim"], status: "planned", ready: false, queueMutationAllowed: false },
];
const plan = { schemaVersion: 1, planId: "BLENDER_WEB_PARITY_V2_OBJECT_EPOCH_1", status: "ACTIVE_OBJECT_QUEUE", authority: "queue_reactivated_after_p16_paint_gate", sourcePlan: "docs/BLENDER_WEB_PARITY_TASK_PLAN_V2.json", executionPointer: "docs/EXECUTION_QUEUE.md", runtimePolicy: { blenderSource: "blender-5.2.0", browserEvidence: ["chromium"], forbiddenBrowsers: ["firefox", "webkit"], mainAuthority: "blender_main", reusePolicy: "source_hash_and_behavior_hash_deduplication" }, parentPaint: { manifest: p16ManifestPath, report: p16ReportPath, basePending: 6618, effectivePending: 6616, duplicateValidationAvoided: true }, tasks };
fs.mkdirSync(absolute(rootDir), { recursive: true }); fs.writeFileSync(absolute(planPath), `${JSON.stringify(plan, null, 2)}\n`); const report = { schemaVersion: 1, task: "WBV2-P17-000", operation: "AUTHORIZE_OBJECT_OPERATIONS_CONTINUATION", status: "PASS", parent: { task: p16.task, manifest: p16ManifestPath, manifestSha256: sha256(p16ManifestPath), report: p16ReportPath, reportSha256: sha256(p16ReportPath), previousDecision: p16Report.decision.status, effectivePending: 6616 }, continuation: { root: "WBV2-P17-000", firstTask: "WBV2-P17-001", plannedTasks: 4, candidate: "OBJECT_OPERATIONS.DUPLICATE", sourceApi: sourceApiPath, browser: "chromium", noRepeatedExecution: true }, policy: { p16EvidencePreserved: true, sourceHistoryReadOnly: true, representativeSliceOnly: true, duplicateValidationAvoided: true, authorizedRebaselineOnly: true, fullHistoricalReproduction: false }, nextTask: "WBV2-P17-001" }; fs.writeFileSync(absolute(reportPath), `${JSON.stringify(report, null, 2)}\n`);
const cards = { "WBV2-P17-001": `# WBV2-P17-001: select_object_duplicate_batch\n\n- task: WBV2-P17-001\n- parent: WBV2-P17-000\n- status: in_progress\n- gap: capability:OBJECT_OPERATIONS.DUPLICATE\n- ownerFamily: PARITY\n- targetImplementationClass: LOCAL_BOUNDED\n\n## 目标\n\nSelect the duplicateObject behavior and one exact legacy operator binding.\n\n## 输入与范围\n\n- Focused source: \`blender-5.2.0/source/blender/web_engine/web_engine_api.cpp\`\n- Existing client: \`web/app/src/engine-client/WebEngineClient.ts\`\n- Inventory: \`tests/golden/WBV2-P0-002/parity-map.json\`\n- Production entrypoint: \`node tools/web/generate-wbv2-object-selection.mjs --write\`\n\n## 验收\n\n- source command is hash-bound\n- existing Scene/Object visibility and transform evidence is not rerun\n- candidate remains one behavior\n- malformed, hash-drift, unsupported, or false-completion input keeps in_progress\n- \`node tools/web/check-task-context.mjs --task WBV2-P17-001 --write\`\n\n## 交付与回滚\n\n- Reports: \`tests/golden/WBV2-P17-001/\`\n- Status: \`docs/status/WBV2-P17-001.md\`\n- Manifest: \`tests/golden/WBV2-P17-001/manifest.json\`\n- Rollback: restore P17-000 as queue parent.\n`, "WBV2-P17-002": `# WBV2-P17-002: object_duplicate_engine_receipt\n\n- task: WBV2-P17-002\n- parent: WBV2-P17-001\n- status: planned\n- gap: capability:OBJECT_OPERATIONS.DUPLICATE\n- ownerFamily: OBJECT\n- targetImplementationClass: LOCAL_EXACT\n\n## 目标\n\nBind duplicateObject, undo/redo, malformed rejection, and exact save/reopen to compiled WASM Main in Chromium.\n\n## 输入与范围\n\n- Focused source: \`tests/golden/WBV2-P17-001/object-selection-report.json\`\n- Production test: \`web/tests/e2e/wbv2-object-duplicate-production.spec.ts\`\n- Production entrypoint: \`npm --prefix web run test:e2e -- --workers=1 tests/e2e/wbv2-object-duplicate-production.spec.ts\`\n\n## 验收\n\n- duplicate creates a distinct object\n- undo/redo revisions are sequential\n- malformed object ID fails closed without Main mutation\n- save/reopen is exact and deterministic\n- Chromium is the only browser\n- \`node tools/web/check-task-context.mjs --task WBV2-P17-002 --write\`\n\n## 交付与回滚\n\n- Reports: \`tests/golden/WBV2-P17-002/\`\n- Status: \`docs/status/WBV2-P17-002.md\`\n- Manifest: \`tests/golden/WBV2-P17-002/manifest.json\`\n- Rollback: restore P17-001 as queue parent.\n`, "WBV2-P17-003": `# WBV2-P17-003: close_object_duplicate_gate\n\n- task: WBV2-P17-003\n- parent: WBV2-P17-002\n- status: planned\n- gap: workflow:close_object_duplicate_gate\n- ownerFamily: RELEASE\n- targetImplementationClass: LOCAL_BOUNDED\n\n## 目标\n\nClose the duplicateObject gate and graduate only the exact operator binding.\n\n## 输入与范围\n\n- Focused receipt: \`tests/golden/WBV2-P17-002/object-duplicate-receipt-report.json\`\n- Paint overlay: \`tests/golden/WBV2-P16-003/inventory-completion-overlay.json\`\n- Production entrypoint: \`node tools/web/generate-wbv2-object-gate.mjs --write\`\n\n## 验收\n\n- only duplicateObject is claimed\n- effective pending remains explicit\n- duplicate validation remains zero\n- malformed, hash-drift, unsupported, or false-completion input keeps in_progress\n- historical reproduction remains false\n- \`node tools/web/check-task-context.mjs --task WBV2-P17-003 --write\`\n\n## 交付与回滚\n\n- Reports: \`tests/golden/WBV2-P17-003/\`\n- Status: \`docs/status/WBV2-P17-003.md\`\n- Manifest: \`tests/golden/WBV2-P17-003/manifest.json\`\n- Rollback: restore P17-002 as queue parent.\n` };
for (const [id, card] of Object.entries(cards)) fs.writeFileSync(absolute(`docs/tasks/${id}.md`), `${card}\n`); fs.writeFileSync(absolute(statusPath), `# WBV2-P17-000 status\n\n- task: \`WBV2-P17-000\`; parent: \`WBV2-P16-003\`; status: \`done\`\n- candidate: \`OBJECT_OPERATIONS.DUPLICATE\`; source API is present\n- effective inventory carried forward: \`283\` completed, \`6616\` pending\n- duplicate validation: \`forbidden\`; representative slice only\n- nextTask: \`WBV2-P17-001\`\n`);
p16Report.nextTask = "WBV2-P17-000"; p16Report.policy = { ...(p16Report.policy ?? {}), terminalQueuePointer: false, authorizedContinuation: "WBV2-P17-000" }; fs.writeFileSync(absolute(p16ReportPath), `${JSON.stringify(p16Report, null, 2)}\n`); const p16Status = read(p16StatusPath).trim(); fs.writeFileSync(absolute(p16StatusPath), p16Status.includes("authorized continuation") ? `${p16Status}\n` : `${p16Status}\n- authorized continuation: \`WBV2-P17-000\`\n\nObject Operations may continue under a new root without changing the P16 paint overlay.\n`); p16.nextTask = "WBV2-P17-000"; p16.continuation = { authorized: true, root: "WBV2-P17-000", scope: "OBJECT_OPERATIONS_DUPLICATE" }; fs.writeFileSync(absolute(p16ManifestPath), `${JSON.stringify(p16, null, 2)}\n`); execFileSync(process.execPath, [absolute("tools/web/check-task-context.mjs"), "--task", "WBV2-P16-003", "--write"], { cwd: root, stdio: "pipe" }); p16.artifacts = Object.fromEntries(Object.entries(p16.artifacts).map(([name, artifact]) => [name, { ...artifact, sha256: sha256(artifact.path) }])); fs.writeFileSync(absolute(p16ManifestPath), `${JSON.stringify(p16, null, 2)}\n`); report.parent.manifestSha256 = sha256(p16ManifestPath); report.parent.reportSha256 = sha256(p16ReportPath); fs.writeFileSync(absolute(reportPath), `${JSON.stringify(report, null, 2)}\n`);
const artifactPaths = { parentManifest: p16ManifestPath, parentReport: p16ReportPath, inventory: inventoryPath, sourceApi: sourceApiPath, sourceClient: sourceClientPath, plan: planPath, report: reportPath, rootCard: "docs/tasks/WBV2-P17-000.md", rootStatus: statusPath }; const artifacts = Object.fromEntries(Object.entries(artifactPaths).map(([name, file]) => [name, { path: file, sha256: sha256(file) }])); const manifest = { schemaVersion: 1, task: "WBV2-P17-000", parentTask: "WBV2-P16-003", operation: "AUTHORIZE_OBJECT_OPERATIONS_CONTINUATION", status: "done", enablingTask: true, parityStateChange: false, runtime: "READ_ONLY_OBJECT_CONTINUATION_ROOT", artifacts, assertions: { p16EvidencePreserved: true, sourceApiBound: true, inventoryTotal: 6900, effectiveCompleted: 283, effectivePending: 6616, duplicateValidationAvoided: true, representativeSliceOnly: true, authorizedRebaselineOnly: true, fullHistoricalReproduction: false }, nextTask: "WBV2-P17-001" }; fs.writeFileSync(absolute(manifestPath), `${JSON.stringify(manifest, null, 2)}\n`);
execFileSync(process.execPath, [absolute("tools/web/generate-v2-task-index.mjs"), "--plan-path", absolute(planPath)], { cwd: root, stdio: "inherit" }); let queue = read("docs/EXECUTION_QUEUE.md"); queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, "| 当前任务 | `WBV2-P17-001` |").replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P17-000/manifest.json` |").replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P17-001.md`](tasks/WBV2-P17-001.md) |"); fs.writeFileSync(absolute("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-P17-001` |").replace(/\| Current task state \| `[^`]+` \|/u, "| Current task state | `in_progress` |").replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P17-000/manifest.json` |").replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P17-001.md` |").replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `WBV2-P17-002` |").replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `node tools/web/generate-wbv2-object-selection.mjs --write` |"); fs.writeFileSync(absolute("nextTask.md"), nextTask); process.stdout.write("wbv2-object-root-written root=WBV2-P17-000 next=WBV2-P17-001 candidate=OBJECT_OPERATIONS.DUPLICATE effectivePending=6616\n");