Files
workinf_Blender_Wasm/tools/web/generate-wbv2-collection-root.mjs
mes123456 ec46223aba
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 collection creation coverage
2026-08-28 15:16:11 +08:00

4 lines
13 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=f=>path.join(root,f);const read=f=>fs.readFileSync(abs(f),"utf8");const json=f=>JSON.parse(read(f));const sha=f=>crypto.createHash("sha256").update(fs.readFileSync(abs(f))).digest("hex");const p19Path="tests/golden/WBV2-P19-003/manifest.json",p19ReportPath="tests/golden/WBV2-P19-003/object-parent-gate-report.json",p19StatusPath="docs/status/WBV2-P19-003.md",out="tests/golden/WBV2-P20-000",planPath=`${out}/collection-task-plan.json`,reportPath=`${out}/collection-root-report.json`,manifestPath=`${out}/manifest.json`,statusPath="docs/status/WBV2-P20-000.md",inventoryPath="tests/golden/WBV2-P0-002/parity-map.json",apiPath="blender-5.2.0/source/blender/web_engine/web_engine_api.cpp",clientPath="web/app/src/engine-client/WebEngineClient.ts";const p19=json(p19Path),p19Report=json(p19ReportPath),inventory=json(inventoryPath);assert.equal(p19.status,"done");assert.ok(p19.nextTask===null||p19.nextTask==="WBV2-P20-000");assert.equal(p19Report.status,"PASS");assert.equal(p19Report.decision.effectivePending,6613);assert.equal(inventory.summary.inventoryEntries,6900);for(const a of Object.values(p19.artifacts??{}))assert.equal(sha(a.path),a.sha256,a.path);assert.match(read(apiPath),/createCollection/);assert.match(read(clientPath),/applyCommand/);
const tasks=[{id:"WBV2-P20-000",phase:"P20",title:"authorize_collection_create_continuation",kind:"enabling",owner:"PROGRAM",dependsOn:["WBV2-P19-003"],parityId:null,implementationClass:"LOCAL_BOUNDED",parallelGroup:"p20-governance",gate:"G2",card:"docs/tasks/WBV2-P20-000.md",behavior:"Authorize one Collection Add behavior after the P19 parent overlay.",outputs:["continuation root","candidate scope","hash boundary"],acceptance:["P19 overlay remains hash-bound","createCollection API is present","one production task is active"],status:"done",ready:false,queueMutationAllowed:true},{id:"WBV2-P20-001",phase:"P20",title:"select_collection_create_batch",kind:"enabling",owner:"PARITY",dependsOn:["WBV2-P20-000"],parityId:"OBJECT_OPERATIONS.COLLECTION_CREATE",implementationClass:"LOCAL_BOUNDED",parallelGroup:"p20-selection",gate:"G2",card:"docs/tasks/WBV2-P20-001.md",behavior:"Select createCollection as one unique Object Operations behavior.",outputs:["candidate report","behavior hash","dedupe key"],acceptance:["source command is hash-bound","parent/create/duplicate evidence is not rerun","one legacy operator binding is selected"],status:"in_progress",ready:true,queueMutationAllowed:false},{id:"WBV2-P20-002",phase:"P20",title:"collection_create_engine_receipt",kind:"feature",owner:"OBJECT",dependsOn:["WBV2-P20-001"],parityId:"OBJECT_OPERATIONS.COLLECTION_CREATE",implementationClass:"LOCAL_EXACT",parallelGroup:"p20-object",gate:"G2",card:"docs/tasks/WBV2-P20-002.md",behavior:"Bind createCollection, undo/redo, malformed rejection, and exact save/reopen to compiled WASM Main in Chromium.",outputs:["collection production report","collection receipt","manifest"],acceptance:["collection is created","undo/redo revisions are sequential","malformed collection fails closed","save/reopen is exact"],status:"planned",ready:false,queueMutationAllowed:false},{id:"WBV2-P20-003",phase:"P20",title:"close_collection_create_gate",kind:"enabling",owner:"RELEASE",dependsOn:["WBV2-P20-002"],parityId:null,implementationClass:"LOCAL_BOUNDED",parallelGroup:"p20-release",gate:"G5",card:"docs/tasks/WBV2-P20-003.md",behavior:"Close the createCollection gate and graduate only the exact operator binding.",outputs:["collection gate","completion overlay","manifest"],acceptance:["only collection add is claimed","effective inventory remains explicit","no duplicate validation or historical over-claim"],status:"planned",ready:false,queueMutationAllowed:false}];const plan={schemaVersion:1,planId:"BLENDER_WEB_PARITY_V2_COLLECTION_CREATE_EPOCH_1",status:"ACTIVE_COLLECTION_CREATE_QUEUE",authority:"queue_reactivated_after_p19_parent_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"},parentParent:{manifest:p19Path,report:p19ReportPath,basePending:6618,effectivePending:6613,duplicateValidationAvoided:true},tasks};fs.mkdirSync(abs(out),{recursive:true});fs.writeFileSync(abs(planPath),`${JSON.stringify(plan,null,2)}\n`);const report={schemaVersion:1,task:"WBV2-P20-000",operation:"AUTHORIZE_COLLECTION_CREATE_CONTINUATION",status:"PASS",parent:{task:p19.task,manifest:p19Path,manifestSha256:sha(p19Path),report:p19ReportPath,reportSha256:sha(p19ReportPath),previousDecision:p19Report.decision.status,effectivePending:6613},continuation:{root:"WBV2-P20-000",firstTask:"WBV2-P20-001",plannedTasks:4,candidate:"OBJECT_OPERATIONS.COLLECTION_CREATE",sourceApi:apiPath,browser:"chromium",noRepeatedExecution:true},policy:{p19EvidencePreserved:true,sourceHistoryReadOnly:true,representativeSliceOnly:true,duplicateValidationAvoided:true,authorizedRebaselineOnly:true,fullHistoricalReproduction:false},nextTask:"WBV2-P20-001"};fs.writeFileSync(abs(reportPath),`${JSON.stringify(report,null,2)}\n`);fs.writeFileSync(abs("docs/tasks/WBV2-P20-000.md"),"# WBV2-P20-000: collection create continuation root\n\n- task: WBV2-P20-000\n- parent: WBV2-P19-003\n- status: done\n- gap: workflow:authorize_collection_create_continuation\n- ownerFamily: PROGRAM\n- targetImplementationClass: LOCAL_BOUNDED\n\n## 目标\n\nAuthorize one source-backed Collection Add behavior after the P19 parent overlay.\n\n## 验收\n\n- `node tools/web/generate-wbv2-collection-root.mjs`\n- `node tools/web/check-execution-control-plane.mjs`\n\n## 交付与回滚\n\n- Reports: `tests/golden/WBV2-P20-000/`\n- Manifest: `tests/golden/WBV2-P20-000/manifest.json`\n- Rollback: restore P19-003 as queue parent.\n");fs.writeFileSync(abs("docs/tasks/WBV2-P20-001.md"),"# WBV2-P20-001: select_collection_create_batch\n\n- task: WBV2-P20-001\n- parent: WBV2-P20-000\n- status: in_progress\n- gap: capability:OBJECT_OPERATIONS.COLLECTION_CREATE\n- ownerFamily: PARITY\n- targetImplementationClass: LOCAL_BOUNDED\n\n## 目标\n\nSelect createCollection as one unique Object Operations behavior.\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-collection-selection.mjs --write`\n\n## 验收\n\n- source command is hash-bound\n- parent/create/duplicate evidence is not rerun\n- one legacy operator binding is selected\n- malformed, hash-drift, unsupported, or false-completion input keeps in_progress\n- `node tools/web/check-task-context.mjs --task WBV2-P20-001 --write`\n\n## 交付与回滚\n\n- Reports: `tests/golden/WBV2-P20-001/`\n- Status: `docs/status/WBV2-P20-001.md`\n- Manifest: `tests/golden/WBV2-P20-001/manifest.json`\n- Rollback: restore P20-000 as queue parent.\n");fs.writeFileSync(abs("docs/tasks/WBV2-P20-002.md"),"# WBV2-P20-002: collection create engine receipt\n\n- task: WBV2-P20-002\n- parent: WBV2-P20-001\n- status: planned\n- gap: capability:OBJECT_OPERATIONS.COLLECTION_CREATE\n- ownerFamily: OBJECT\n- targetImplementationClass: LOCAL_EXACT\n\n## 目标\n\nBind createCollection, undo/redo, malformed rejection, and exact save/reopen to compiled WASM Main in Chromium.\n\n## 输入与范围\n\n- Focused source: `tests/golden/WBV2-P20-001/collection-selection-report.json`\n- Production test: `web/tests/e2e/wbv2-collection-create-production.spec.ts`\n- Production entrypoint: `npm --prefix web run test:e2e -- --workers=1 tests/e2e/wbv2-collection-create-production.spec.ts`\n\n## 验收\n\n- collection is created\n- undo/redo revisions are sequential\n- malformed collection 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-P20-002 --write`\n\n## 交付与回滚\n\n- Reports: `tests/golden/WBV2-P20-002/`\n- Status: `docs/status/WBV2-P20-002.md`\n- Manifest: `tests/golden/WBV2-P20-002/manifest.json`\n- Rollback: restore P20-001 as queue parent.\n");fs.writeFileSync(abs("docs/tasks/WBV2-P20-003.md"),"# WBV2-P20-003: close collection create gate\n\n- task: WBV2-P20-003\n- parent: WBV2-P20-002\n- status: planned\n- gap: workflow:close_collection_create_gate\n- ownerFamily: RELEASE\n- targetImplementationClass: LOCAL_BOUNDED\n\n## 目标\n\nClose the createCollection gate and graduate only the exact operator binding.\n\n## 输入与范围\n\n- Focused receipt: `tests/golden/WBV2-P20-002/collection-create-receipt-report.json`\n- Previous overlay: `tests/golden/WBV2-P19-003/inventory-completion-overlay.json`\n- Production entrypoint: `node tools/web/generate-wbv2-collection-gate.mjs --write`\n\n## 验收\n\n- only collection add is claimed\n- effective inventory 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-P20-003 --write`\n\n## 交付与回滚\n\n- Reports: `tests/golden/WBV2-P20-003/`\n- Status: `docs/status/WBV2-P20-003.md`\n- Manifest: `tests/golden/WBV2-P20-003/manifest.json`\n- Rollback: restore P20-002 as queue parent.\n");fs.writeFileSync(abs(statusPath),"# WBV2-P20-000 status\n\n- task: `WBV2-P20-000`; parent: `WBV2-P19-003`; status: `done`\n- candidate: `OBJECT_OPERATIONS.COLLECTION_CREATE`; source API is present\n- effective inventory carried forward: `286` completed, `6613` pending\n- duplicate validation: `forbidden`; representative slice only\n- nextTask: `WBV2-P20-001`\n");p19Report.nextTask="WBV2-P20-000";p19Report.policy={...(p19Report.policy??{}),terminalQueuePointer:false,authorizedContinuation:"WBV2-P20-000"};fs.writeFileSync(abs(p19ReportPath),`${JSON.stringify(p19Report,null,2)}\n`);const p19Status=read(p19StatusPath).trim();fs.writeFileSync(abs(p19StatusPath),p19Status.includes("authorized continuation")?`${p19Status}\n`:`${p19Status}\n- authorized continuation: \`WBV2-P20-000\`\n\nCollection Add may continue under a new root without changing the P19 overlay.\n`);p19.nextTask="WBV2-P20-000";p19.continuation={authorized:true,root:"WBV2-P20-000",scope:"OBJECT_OPERATIONS_COLLECTION_CREATE"};fs.writeFileSync(abs(p19Path),`${JSON.stringify(p19,null,2)}\n`);execFileSync(process.execPath,[abs("tools/web/check-task-context.mjs"),"--task","WBV2-P19-003","--write"],{cwd:root,stdio:"pipe"});p19.artifacts=Object.fromEntries(Object.entries(p19.artifacts).map(([n,a])=>[n,{...a,sha256:sha(a.path)}]));fs.writeFileSync(abs(p19Path),`${JSON.stringify(p19,null,2)}\n`);report.parent.manifestSha256=sha(p19Path);report.parent.reportSha256=sha(p19ReportPath);fs.writeFileSync(abs(reportPath),`${JSON.stringify(report,null,2)}\n`);const paths={parentManifest:p19Path,parentReport:p19ReportPath,inventory:inventoryPath,sourceApi:apiPath,sourceClient:clientPath,plan:planPath,report:reportPath,rootCard:"docs/tasks/WBV2-P20-000.md",rootStatus:statusPath};const artifacts=Object.fromEntries(Object.entries(paths).map(([n,f])=>[n,{path:f,sha256:sha(f)}]));fs.writeFileSync(abs(manifestPath),`${JSON.stringify({schemaVersion:1,task:"WBV2-P20-000",parentTask:"WBV2-P19-003",operation:"AUTHORIZE_COLLECTION_CREATE_CONTINUATION",status:"done",enablingTask:true,parityStateChange:false,runtime:"READ_ONLY_COLLECTION_CREATE_CONTINUATION_ROOT",artifacts,assertions:{p19EvidencePreserved:true,sourceApiBound:true,inventoryTotal:6900,effectiveCompleted:286,effectivePending:6613,duplicateValidationAvoided:true,representativeSliceOnly:true,authorizedRebaselineOnly:true,fullHistoricalReproduction:false},nextTask:"WBV2-P20-001"},null,2)}\n`);execFileSync(process.execPath,[abs("tools/web/generate-v2-task-index.mjs"),"--plan-path",abs(planPath)],{cwd:root,stdio:"inherit"});let q=read("docs/EXECUTION_QUEUE.md");q=q.replace(/\| 当前任务 \| `[^`]+` \|/u,"| 当前任务 | `WBV2-P20-001` |").replace(/\| parent manifest \| `[^`]+` \|/u,"| parent manifest | `tests/golden/WBV2-P20-000/manifest.json` |").replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u,"| 任务卡 | [`tasks/WBV2-P20-001.md`](tasks/WBV2-P20-001.md) |");fs.writeFileSync(abs("docs/EXECUTION_QUEUE.md"),q);let n=read("nextTask.md");n=n.replace(/\| Current task when this file was written \| `[^`]+` \|/u,"| Current task when this file was written | `WBV2-P20-001` |").replace(/\| Current task state \| `[^`]+` \|/u,"| Current task state | `in_progress` |").replace(/\| Parent manifest \| `[^`]+` \|/u,"| Parent manifest | `tests/golden/WBV2-P20-000/manifest.json` |").replace(/\| Current task card \| `[^`]+` \|/u,"| Current task card | `docs/tasks/WBV2-P20-001.md` |").replace(/\| Current task-context nextTask \| `[^`]+` \|/u,"| Current task-context nextTask | `WBV2-P20-002` |").replace(/\| Focused command \| `[^`]+` \|/u,"| Focused command | `node tools/web/generate-wbv2-collection-selection.mjs --write` |");fs.writeFileSync(abs("nextTask.md"),n);console.log("wbv2-collection-root-written root=WBV2-P20-000 next=WBV2-P20-001 candidate=OBJECT_OPERATIONS.COLLECTION_CREATE effectivePending=6613");