HEL-892: apply user exclusion to the 155-workflow delivery scope

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
leefer
2026-10-29 22:15:30 +08:00
co-authored by multica-agent
parent ddf56714ad
commit b01809cf8c
42 changed files with 80725 additions and 35 deletions
@@ -12,6 +12,8 @@ import json
from collections import Counter
from pathlib import Path
from calliope.comfyui.delivery_scope import exclusion_for
def graph_rows(graph: dict, pointer: str = "", scope: str = ""):
(
@@ -127,7 +129,7 @@ RULES = {
}
def inventory(repo: Path) -> dict:
def inventory(repo: Path, *, historical: bool = False) -> dict:
docs = repo / "docs/hel-892"
manifest = json.loads((docs / "offline/manifest.json").read_text(encoding="utf-8"))
cases = json.loads((docs / "golden-cases.json").read_text(encoding="utf-8"))["cases"]
@@ -332,7 +334,7 @@ def inventory(repo: Path) -> dict:
}
assert len(files) == len(actual_ui) == 146
assert {f["path"] for f in files} == actual_ui
return {
report = {
"schema_version": 1,
"files": files,
"total_ui_files": len(files),
@@ -347,6 +349,22 @@ def inventory(repo: Path) -> dict:
"negative_finding_limit": "未命中命名候选或静态环不证明没有插件隐藏循环/虚拟语义",
}
if not historical:
excluded = [f for f in files if exclusion_for(f["path"])]
active = [f for f in files if not exclusion_for(f["path"])]
for row in files:
row["delivery_status"] = "user_excluded" if exclusion_for(row["path"]) else "in_scope"
report.update(
inventory_scope="all_source_files_with_current_delivery_scope",
source_files=len(manifest), target_files=len(manifest) - len(excluded),
target_ui_files=len(active), user_excluded=len(excluded),
remaining_reliable_conversions=len(active),
historical_exact_golden_candidates=report["exact_golden_candidates"],
exact_golden_candidates=sum(bool(f["golden_case_ids"]) for f in active),
exclusions=[{"path": f["path"], **exclusion_for(f["path"])} for f in excluded],
)
return report
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
@@ -9,6 +9,8 @@ import json
from collections import Counter
from pathlib import Path
from calliope.comfyui.delivery_scope import exclusion_for
def audit(repo: Path, directory: Path) -> dict:
manifest = json.loads((directory / "manifest.json").read_text(encoding="utf-8"))
@@ -17,8 +19,12 @@ def audit(repo: Path, directory: Path) -> dict:
for p in (repo / "example_ComfyUI_workflows").rglob("*")
if p.is_file()
}
assert {e["path"] for e in manifest} == sources
assert len(manifest) == len(sources)
manifest_paths = {e["path"] for e in manifest}
# Old immutable reports still audit against their historical full source set.
historical = manifest_paths == sources
target_sources = {p for p in sources if not exclusion_for(p)}
assert manifest_paths == (sources if historical else target_sources)
assert len(manifest) == len(manifest_paths)
files = []
for entry in manifest:
raw = (repo / entry["path"]).read_bytes()
@@ -126,6 +132,10 @@ def audit(repo: Path, directory: Path) -> dict:
return {
"files": files,
"total": len(files),
"audit_scope": "historical_source_inventory" if historical else "current_delivery",
"source_files": len(sources),
"target_files": len(target_sources),
"user_excluded": len(sources - target_sources),
"source_structure_purpose_partially_reviewed": len(files),
"full_documents_completed": 0,
"files_with_selected_named_fields_reviewed": sum(
@@ -9,6 +9,7 @@ from collections import Counter
from pathlib import Path
from calliope.comfyui.companions import load_companions, resolve_companion
from calliope.comfyui.delivery_scope import exclusion_for
from calliope.comfyui.library import _json
from calliope.db import get_db
@@ -20,6 +21,23 @@ def audit(repo: Path, manifest: Path, db: Path, output: Path):
output.mkdir(parents=True, exist_ok=True)
try:
for path, record in records.items():
excluded = exclusion_for(path)
if excluded:
history = conn.execute(
"SELECT id FROM workflows WHERE source_repo_path=?", (path,)
).fetchone()
rows.append(
{
"id": record["binding"]["id"],
"source_path": path,
"state": "user_excluded",
"adopted": False,
"new_api_literal_params": 0,
"exclusion": excluded,
"historical_row_preserved": history is not None,
}
)
continue
raw = (repo / path).read_bytes()
prompt, evidence, issues = resolve_companion(record, path, raw, json.loads(raw))
row = conn.execute(
@@ -82,6 +100,9 @@ def audit(repo: Path, manifest: Path, db: Path, output: Path):
report = {
"cases": rows,
"adopted": sum(r["adopted"] for r in rows),
"user_excluded": sum(r["state"] == "user_excluded" for r in rows),
"source_files": 156,
"target_files": 155,
"general_conversion_verified": 0,
"execution_verified": 0,
"new_api_literal_params": sum(r["new_api_literal_params"] for r in rows),
@@ -11,6 +11,7 @@ import hashlib
import json
from pathlib import Path
from calliope.comfyui.delivery_scope import exclusion_for
from calliope.comfyui.library import load_snapshot
from calliope.comfyui.ui2api import convert
@@ -86,6 +87,9 @@ def preserved_fields(expected, actual, pointer=""):
def compare_case(repo, exports, case, snapshot=None):
row = {**case, "executable": False, "execution_verified": False}
excluded = exclusion_for(case["source_path"])
if excluded:
return {**row, "status": "user_excluded", "exclusion": excluded}
try:
raw = (repo / case["source_path"]).read_bytes()
if hashlib.sha1(raw).hexdigest() != case["source_sha"]:
@@ -103,9 +107,9 @@ def compare_case(repo, exports, case, snapshot=None):
"missing": missing,
"cannot_check": case["comparison"],
"node_definitions_available": bool(snapshot),
"missing_definitions": [] if snapshot else [
"未提供可信节点定义;UI位置控件和插件行为不能仅凭源文件确认"
],
"missing_definitions": []
if snapshot
else ["未提供可信节点定义;UI位置控件和插件行为不能仅凭源文件确认"],
}
export_raw = (exports / case["export_file"]).read_bytes()
binding = json.loads((exports / case["binding_file"]).read_text(encoding="utf-8"))
@@ -191,10 +195,15 @@ def main():
else:
rows = [compare_case(args.repo, args.exports, case, snapshot) for case in cases]
report = {
"status": "equal"
if rows and all(r["status"] == "equal" for r in rows)
"status": "user_excluded"
if rows and all(r["status"] == "user_excluded" for r in rows)
else "equal"
if any(r["status"] != "user_excluded" for r in rows)
and all(r["status"] in ("equal", "user_excluded") for r in rows)
else "not_ready",
"cases": rows,
"active_cases": sum(r["status"] != "user_excluded" for r in rows),
"user_excluded": sum(r["status"] == "user_excluded" for r in rows),
"execution_verified": False,
"snapshot_source": (snapshot or {}).get("source_url"),
"snapshot_captured_at": (snapshot or {}).get("captured_at"),
@@ -212,7 +221,7 @@ def main():
ensure_ascii=False,
)
)
return 0 if report["status"] == "equal" else 1
return 0 if report["status"] in ("equal", "user_excluded") else 1
if __name__ == "__main__":