feat(web): add source-first Python autopilot and optimize provider waits
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-09-08 10:59:49 +08:00
parent a69e41457a
commit edcf0fef9a
29 changed files with 10149 additions and 412 deletions

View File

@@ -12,7 +12,7 @@ const arg = (name, fallback = null) => {
return index >= 0 ? process.argv[index + 1] : fallback;
};
if (process.argv.includes("--help")) {
process.stdout.write("usage: node tools/web/search-wbv2-batch-source.mjs [--task <task-id>] --pattern <text> [--runtime <path> ...] or --list\n");
process.stdout.write("usage: node tools/web/search-wbv2-batch-source.mjs [--task <task-id>] --pattern <text> [--unit <source-unit-id> ...] [--runtime <path> ...] [--max-hits <count>] or --list\n");
process.exit(0);
}
const task = arg("--task") ?? read("docs/EXECUTION_QUEUE.md").match(/\| 当前任务 \| `([^`]+)` \|/u)?.[1];
@@ -32,6 +32,21 @@ for (const artifact of Object.values(manifest?.artifacts ?? {})) {
for (const source of taskRecord?.module?.sourcePaths ?? []) {
if (source.startsWith("blender-5.2.0/source/blender/")) sourcePaths.add(source);
}
const selectedUnits = [];
for (let i = 0; i < process.argv.length; i += 1) {
if (process.argv[i] === "--unit") selectedUnits.push(process.argv[++i]);
}
if (selectedUnits.length > 16) throw new Error("source context is limited to 16 explicit unit IDs");
if (selectedUnits.length) {
const inventory = json("tests/golden/WBV2/dynamic-inventory.json");
for (const id of selectedUnits) {
const unit = inventory.units.find((item) => item.id === id);
if (!unit) throw new Error(`unknown source unit: ${id}`);
for (const location of unit.locations ?? []) {
if (location.path.startsWith("blender-5.2.0/source/blender/")) sourcePaths.add(location.path);
}
}
}
const runtimeAllowlist = new Set([
"tools/web/run-wbv2-module-task.mjs",
"tools/web/run-wbv2-continuous.mjs",
@@ -78,6 +93,17 @@ const runtimeAllowlist = new Set([
"blender-5.2.0/source/blender/web_engine/web_engine_main_state.h",
]);
const runtimePaths = [];
// Product workflows are bounded subtasks of the current authoritative task.
const backlogPath = abs("tests/golden/WBV2/web-product-backlog.json");
if (fs.existsSync(backlogPath)) {
const backlog = JSON.parse(fs.readFileSync(backlogPath, "utf8"));
if (backlog.queueTask === task) {
for (const job of backlog.tasks ?? []) {
for (const file of job.ownedPaths ?? []) runtimeAllowlist.add(file);
}
}
}
for (const file of ["tools/web/deployment-http-server.mjs", "my-tools/wbv2_autopilot.py", "my-tools/run_web_product_migration.py", "tools/web/run-wbv2-scheduler.mjs", "tools/web/run-wbv2-guardian.mjs", "tools/web/check-wbv2-module-execution.mjs"]) runtimeAllowlist.add(file);
for (let index = 0; index < process.argv.length; index += 1) {
if (process.argv[index] === "--runtime") {
const file = process.argv[index + 1];
@@ -101,4 +127,6 @@ if (result.error) throw result.error;
if (result.status !== 0 && result.status !== 1) throw new Error(`batch search failed with exit ${result.status}`);
const output = result.stdout ?? "";
const hits = output ? output.trimEnd().split("\n").filter(Boolean) : [];
process.stdout.write(`${JSON.stringify({ schemaVersion: 1, task, scope: "batch", pattern, sourcePathCount: sourcePaths.size, runtimePathCount: runtimePaths.length, hitCount: hits.length, hits }, null, 2)}\n`);
const maxHits = Number(arg("--max-hits", "60"));
if (!Number.isSafeInteger(maxHits) || maxHits < 1 || maxHits > 200) throw new Error("--max-hits must be between 1 and 200");
process.stdout.write(`${JSON.stringify({ schemaVersion: 1, task, scope: "batch", pattern, selectedUnits, sourcePathCount: sourcePaths.size, runtimePathCount: runtimePaths.length, hitCount: hits.length, truncated: hits.length > maxHits, hits: hits.slice(0, maxHits) }, null, 2)}\n`);