chore: add migration progress dashboard and prevent planner idle
This commit is contained in:
53
my-tools/view_wbv2_progress.py
Normal file
53
my-tools/view_wbv2_progress.py
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only WBV2 migration progress dashboard.
|
||||
|
||||
The dashboard deliberately separates implementation, build, and verification;
|
||||
build receipts never count as completed business behavior.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse, json, re
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
def read(path, default=None):
|
||||
try: return json.loads((ROOT / path).read_text(encoding="utf-8"))
|
||||
except (OSError, json.JSONDecodeError): return default
|
||||
|
||||
def snapshot():
|
||||
queue = (ROOT / "docs/EXECUTION_QUEUE.md").read_text(encoding="utf-8")
|
||||
task = re.search(r"\| 当前任务 \| `([^`]+)`", queue)
|
||||
parent = re.search(r"\| parent manifest \| `([^`]+)`", queue)
|
||||
backlog = read("tests/golden/WBV2/web-product-backlog.json", {}) or {}
|
||||
state = read("tests/golden/WBV2/autopilot/state.json", {}) or {}
|
||||
assignments = read("tests/golden/WBV2/autopilot/local-task-assignments.json", {}) or {}
|
||||
jobs = state.get("jobs", {})
|
||||
tasks = backlog.get("tasks", [])
|
||||
counts = {}
|
||||
for item in tasks: counts[item.get("status", "unknown")] = counts.get(item.get("status", "unknown"), 0) + 1
|
||||
needs = [a for a in assignments.get("assignments", []) if a.get("state") == "needs_implementation"]
|
||||
builds = {k: v for k, v in jobs.items() if v.get("state") == "built_pending_verification"}
|
||||
verified = [k for k, v in jobs.items() if v.get("state") == "verified"]
|
||||
return {"task": task.group(1) if task else None, "parentManifest": parent.group(1) if parent else None,
|
||||
"runner": {"state": state.get("state"), "pid": state.get("pid"), "activeJob": state.get("activeJob"),
|
||||
"verificationTiming": state.get("verificationTiming")},
|
||||
"backlog": {"total": len(tasks), "byStatus": counts, "needsImplementation": [x.get("id") for x in tasks if x.get("status") == "pending"]},
|
||||
"business": {"needsImplementation": [x.get("job") for x in needs], "readyForValidation": len(builds), "verified": verified},
|
||||
"builds": {"pendingVerification": sorted(builds), "stale": sum(1 for v in jobs.values() if v.get("state") == "stale")},
|
||||
"recommendations": [f"实现并绑定: {x.get('job')}" for x in needs] or ["没有新的本地实现缺口;由代理优先完成自动验证"]}
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="查看 Blender Web 移植真实进度")
|
||||
parser.add_argument("--json", action="store_true", help="输出机器可读 JSON")
|
||||
args = parser.parse_args()
|
||||
data = snapshot()
|
||||
if args.json:
|
||||
print(json.dumps(data, ensure_ascii=False, indent=2)); return
|
||||
print(f"WBV2 task: {data['task']} parent: {data['parentManifest']}")
|
||||
print(f"Runner: {data['runner']['state']} pid={data['runner']['pid']} active={data['runner']['activeJob'] or '-'} verification={data['runner']['verificationTiming']}")
|
||||
print("Backlog: " + ", ".join(f"{k}={v}" for k, v in sorted(data['backlog']['byStatus'].items())) + f" total={data['backlog']['total']}")
|
||||
print(f"Business: needs_implementation={len(data['business']['needsImplementation'])} ready_for_validation={data['business']['readyForValidation']} verified={len(data['business']['verified'])}")
|
||||
print(f"Builds: pending_verification={len(data['builds']['pendingVerification'])} stale={data['builds']['stale']}")
|
||||
for item in data["recommendations"]: print(f"Next: {item}")
|
||||
|
||||
if __name__ == "__main__": main()
|
||||
106
my-tools/wbv2_local_planner.py
Normal file
106
my-tools/wbv2_local_planner.py
Normal file
@@ -0,0 +1,106 @@
|
||||
"""Deterministic local task admission; never invokes a model or invents receipts."""
|
||||
import copy
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
from wbv2_task_dispatch import prepared_contract
|
||||
from wbv2_preparation import prepare_module
|
||||
|
||||
|
||||
class LocalPlanner:
|
||||
def __init__(self, root, directory):
|
||||
self.root = Path(root).resolve()
|
||||
self.directory = Path(directory)
|
||||
|
||||
def _path(self, relative):
|
||||
path = (self.root / relative).resolve()
|
||||
if not path.is_relative_to(self.root):
|
||||
raise ValueError("planner path escapes repository")
|
||||
return path
|
||||
|
||||
def _write(self, path, value):
|
||||
from wbv2_autopilot import read_json, write_json
|
||||
if path.is_file() and read_json(path) == value:
|
||||
return False
|
||||
write_json(path, value)
|
||||
return True
|
||||
|
||||
def refresh(self, context, jobs, verified_jobs):
|
||||
from wbv2_autopilot import read_json, sha
|
||||
verified_jobs = set(verified_jobs)
|
||||
backlog = read_json(self.root / "tests/golden/WBV2/web-product-backlog.json", {})
|
||||
backlog_status = {item.get("id"): item.get("status") for item in backlog.get("tasks", []) if isinstance(item, dict)}
|
||||
assignments = []
|
||||
created = []
|
||||
for job in jobs:
|
||||
identifier = job["id"]
|
||||
destination = self.directory / "local-plans" / (identifier + ".json")
|
||||
candidate, admission_findings = prepared_contract(self.root, context, job)
|
||||
existing = read_json(destination) if destination.is_file() else None
|
||||
# A pending backlog item is a business gap even when an old local
|
||||
# plan or build receipt exists. Do not let compilation history
|
||||
# promote it to runnable work.
|
||||
if backlog_status.get(identifier) == "pending":
|
||||
preparation = prepare_module(self.root, self.directory, job)
|
||||
assignments.append({"job": identifier, "module": job.get("module"),
|
||||
"state": "needs_implementation",
|
||||
"reason": "backlog task remains pending",
|
||||
"ownedPaths": job.get("ownedPaths", []),
|
||||
"admissionFindings": admission_findings,
|
||||
"preparation": preparation})
|
||||
continue
|
||||
if candidate and (existing is None or existing.get("generator") == "local-contract-admission-v1"):
|
||||
if self._write(destination, candidate):
|
||||
created.append(identifier)
|
||||
verified_jobs.discard(identifier)
|
||||
if identifier in verified_jobs:
|
||||
state, reason = "verified", None
|
||||
elif destination.is_file():
|
||||
state, reason = "ready", None
|
||||
elif identifier == "SERVER-OPERATOR-SCHEMA-PALETTE":
|
||||
prerequisite = "SERVER-OPERATOR-HTTP-PROVIDER"
|
||||
test_path = "web/tests/e2e/server-operator-schema-palette.spec.ts"
|
||||
base = self.directory / "local-plans" / (prerequisite + ".json")
|
||||
if prerequisite not in verified_jobs or not base.is_file():
|
||||
state, reason = "waiting_dependency", prerequisite
|
||||
elif not self._path(test_path).is_file():
|
||||
state, reason = "needs_test_entrypoint", test_path
|
||||
else:
|
||||
contract = read_json(base)
|
||||
if contract["task"] != context["task"] or contract["parentSha256"] != context["parentSha256"]:
|
||||
raise ValueError("local recipe parent mismatch")
|
||||
result = copy.deepcopy(contract["result"])
|
||||
result["workflow"] = "F3 selects a native operator, loads RNA properties, executes Add Object, and preserves native Main history"
|
||||
result["summary"] = "Local UI/schema contract prepared; completion requires independent Chromium and native Main evidence"
|
||||
for check in result["checks"]:
|
||||
if check["id"] == "chromium-main":
|
||||
check["id"] = "chromium-schema-palette"
|
||||
check["argv"].append("tests/e2e/server-operator-schema-palette.spec.ts")
|
||||
check["timeoutSeconds"] = 180
|
||||
check["cacheInputs"] = sorted(set(check.get("cacheInputs", result["dependencies"]) + [test_path]))
|
||||
for case in result["cases"]:
|
||||
if case["checkId"] == "chromium-main":
|
||||
case["checkId"] = "chromium-schema-palette"
|
||||
result["dependencies"] = sorted(set(result["dependencies"] + [test_path, "my-tools/wbv2_local_planner.py"]))
|
||||
result["changedFiles"] = [test_path]
|
||||
candidate = {"schemaVersion": 1, "task": context["task"], "job": identifier, "parentSha256": context["parentSha256"], "generator": "schema-palette-v1", "sourceContract": {"path": str(base.relative_to(self.root)), "sha256": sha(base)}, "acceptance": "pending local behavior verification", "result": result}
|
||||
if self._write(destination, candidate):
|
||||
created.append(identifier)
|
||||
state, reason = "ready", None
|
||||
else:
|
||||
state, reason = "needs_local_recipe", "executable checks and source-bound behavior cases are not defined"
|
||||
if state == "ready":
|
||||
dependencies = job.get("dependsOn", [])
|
||||
if not isinstance(dependencies, list) or not all(isinstance(value, str) for value in dependencies):
|
||||
state, reason = "invalid_dependencies", "task dependencies must be a list of job IDs"
|
||||
elif any(value not in verified_jobs for value in dependencies):
|
||||
state, reason = "waiting_dependency", ", ".join(value for value in dependencies if value not in verified_jobs)
|
||||
preparation = prepare_module(self.root, self.directory, job) if state == "needs_local_recipe" else None
|
||||
assignments.append({"job": identifier, "module": job.get("module"), "state": state, "reason": reason, "ownedPaths": job.get("ownedPaths", []), "admissionFindings": admission_findings, "preparation": preparation})
|
||||
if (candidate or existing or {}).get("result", {}).get("contractKind") == "compilation_only":
|
||||
assignments[-1]["contractKind"] = "compilation_only"
|
||||
assignments[-1]["verificationDeferred"] = True
|
||||
report = {"schemaVersion": 1, "task": context["task"], "parentSha256": context["parentSha256"], "executionMode": "local_only", "assignments": assignments, "readyCount": sum(item["state"] == "ready" for item in assignments), "verifiedCount": sum(item["state"] == "verified" for item in assignments), "blockedCount": sum(item["state"] not in {"ready", "verified"} for item in assignments)}
|
||||
report["compilationReadyCount"] = sum(item["state"] == "ready" and item.get("contractKind") == "compilation_only" for item in assignments)
|
||||
changed = self._write(self.directory / "local-task-assignments.json", report)
|
||||
return {"created": created, "changed": changed, "readyCount": report["readyCount"], "blockedCount": report["blockedCount"]}
|
||||
Reference in New Issue
Block a user