q
This commit is contained in:
parent
810ad6f5cb
commit
de7c6c32bd
123 changed files with 13201 additions and 6213 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { Worker } from "node:worker_threads";
|
||||
import { performance } from "node:perf_hooks";
|
||||
import { generateMap } from "../src/mapPipeline.js";
|
||||
|
|
@ -9,15 +10,16 @@ const baseline = createWorldMap(initial);
|
|||
const rect = { x0: 20, y0: 120, x1: 180, y1: 230 };
|
||||
const terrainType = initial.terrainTemplate?.terrainType || initial.terrainDebug?.terrainType || "auto";
|
||||
|
||||
function runWorkerCase(patchMode, id) {
|
||||
function runWorkerCase(patchMode, id, overrides = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const worker = new Worker(new URL("./browser-worker-node-shim.mjs", import.meta.url), { type: "module" });
|
||||
const timer = setTimeout(async () => {
|
||||
try { await worker.terminate(); } catch {}
|
||||
reject(new Error(`${patchMode} coverage regression timed out`));
|
||||
}, 60_000);
|
||||
}, overrides.timeoutMs ?? 90_000);
|
||||
const startedAt = performance.now();
|
||||
const seed = 123;
|
||||
const seed = overrides.seed ?? 123;
|
||||
const candidatePlan = overrides.candidatePlan || [{ candidateId: `coverage-${patchMode}:0`, candidateOrdinal: 1, variant: 0, seed }];
|
||||
worker.on("error", reject);
|
||||
worker.on("message", async (message) => {
|
||||
if (message.id !== id || message.type === "progress") return;
|
||||
|
|
@ -35,7 +37,7 @@ function runWorkerCase(patchMode, id) {
|
|||
variant: 0,
|
||||
seed,
|
||||
maxQualityRetries: 0,
|
||||
qualityTerrainAttempts: 1,
|
||||
qualityTerrainAttempts: candidatePlan.length,
|
||||
acceptBestAvailableQuality: false,
|
||||
includeSeamVisualization: false,
|
||||
},
|
||||
|
|
@ -45,16 +47,46 @@ function runWorkerCase(patchMode, id) {
|
|||
committedRevision: 1,
|
||||
workerEpoch: 1,
|
||||
executionAttempt: 1,
|
||||
totalCandidateCount: 1,
|
||||
candidatePlan: [{ candidateId: `coverage-${patchMode}:0`, candidateOrdinal: 1, variant: 0, seed }],
|
||||
totalCandidateCount: candidatePlan.length,
|
||||
candidatePlan,
|
||||
...(overrides.search || {}),
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const bestOfPlan = [0, 1, 2].map((variant, index) => ({
|
||||
candidateId: `coverage-bestof:${variant}`,
|
||||
candidateOrdinal: index + 1,
|
||||
variant,
|
||||
seed: (123 + variant) >>> 0,
|
||||
}));
|
||||
const { message: bestOfMessage } = await runWorkerCase("expansion", 3, {
|
||||
candidatePlan: bestOfPlan,
|
||||
search: {
|
||||
draftSelection: true,
|
||||
selectBestCandidate: true,
|
||||
parallelDrafts: false,
|
||||
resolvedPatchMode: "expansion",
|
||||
},
|
||||
});
|
||||
assert.equal(bestOfMessage.ok, true, bestOfMessage.error || bestOfMessage.code || "best-of worker failed");
|
||||
const bestOfResult = bestOfMessage.result || {};
|
||||
assert.equal(bestOfResult.ok, true, bestOfResult.reason || bestOfResult.code || "best-of candidate search failed");
|
||||
assert.equal(bestOfResult.searchStatus, "succeeded");
|
||||
assert.equal(bestOfResult.bestOfCandidates, true, "best-of selection remains enabled");
|
||||
assert.equal(bestOfResult.draftSelection?.enabled, true, "Branch-and-Bound ranking remains enabled");
|
||||
assert.equal(Number(bestOfResult.candidateUnmappedActiveCells || 0), 0, "best candidate covers every active write cell");
|
||||
assert.ok((bestOfResult.searchAttempts || []).length >= bestOfPlan.length, "every planned candidate remains visible to selection");
|
||||
assert.equal((bestOfResult.searchAttempts || []).some((attempt) => attempt.code === "candidate-execution-error" && /did not cover/i.test(attempt.reason || "")), false,
|
||||
"parent operation context never leaks into the canonical internal tile");
|
||||
|
||||
for (const [index, patchMode] of ["auto", "expansion"].entries()) {
|
||||
const { message, elapsedMs } = await runWorkerCase(patchMode, index + 1);
|
||||
const result = message.result || {};
|
||||
const topology = result.candidateQuality?.finalMerge?.transportTopology;
|
||||
const prefectureCoherence = result.candidateQuality?.finalMerge?.prefectureCoherence;
|
||||
const demandedTopologyConnected = Object.values(topology?.byClass || {}).every((entry) => entry?.hardPass !== false);
|
||||
const ok = message.ok === true
|
||||
&& result.ok === true
|
||||
&& result.searchStatus === "succeeded"
|
||||
|
|
@ -62,7 +94,10 @@ for (const [index, patchMode] of ["auto", "expansion"].entries()) {
|
|||
&& result.tiledExpansion === true
|
||||
&& Number(result.tileCount) === 1
|
||||
&& Number(result.candidateUnmappedActiveCells || 0) === 0
|
||||
&& result.seamDiagnostics?.hardPass === true;
|
||||
&& result.seamDiagnostics?.hardPass === true
|
||||
&& topology?.hardPass === true
|
||||
&& demandedTopologyConnected
|
||||
&& prefectureCoherence?.hardPass === true;
|
||||
console.log(JSON.stringify({
|
||||
patchMode,
|
||||
ok,
|
||||
|
|
@ -75,6 +110,9 @@ for (const [index, patchMode] of ["auto", "expansion"].entries()) {
|
|||
tileCount: Number(result.tileCount || 0),
|
||||
candidateUnmappedActiveCells: Number(result.candidateUnmappedActiveCells || 0),
|
||||
seamPass: result.seamDiagnostics?.hardPass === true,
|
||||
transportTopologyPass: topology?.hardPass === true,
|
||||
transportTopology: topology?.byClass || null,
|
||||
prefectureCoherencePass: prefectureCoherence?.hardPass === true,
|
||||
reason: result.reason || message.error || null,
|
||||
}, null, 2));
|
||||
if (!ok) process.exitCode = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue