Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
206 lines
8.6 KiB
Python
206 lines
8.6 KiB
Python
"""Menivor parity recount from test results (Wave Q QM1.0 steward).
|
|
|
|
Prints DONE / PARTIAL / MISSING for Higgsfield H1-H24 and Muvi OTT U1-U47
|
|
(rows and gaps in ``rows.py``) from pytest results, never by hand.
|
|
|
|
# run the evidence tests, then recount
|
|
python tools/parity/recount.py --run
|
|
# recount from JUnit XML you already have
|
|
python tools/parity/recount.py --junit var/parity/menivor-junit.xml
|
|
# check the method against the 2026-09-30 baseline, without running tests
|
|
python tools/parity/recount.py --self-test
|
|
|
|
Exit status: 0, or 1 with ``--check-baseline`` when the totals differ from the
|
|
2026-09-30 baseline (11 / 10 / 3 and 21 / 21 / 5), or when ``--self-test``
|
|
fails.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
from collections import defaultdict
|
|
from collections.abc import Callable, Iterable
|
|
from pathlib import Path
|
|
from typing import Optional
|
|
from xml.etree import ElementTree as ET
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
|
|
from rows import BASELINE, GROUPS, Row # noqa: E402
|
|
|
|
REPO = Path(__file__).resolve().parents[2]
|
|
DONE, PARTIAL, MISSING = "DONE", "PARTIAL", "MISSING"
|
|
PASSED, FAILED, SKIPPED = "passed", "failed", "skipped"
|
|
|
|
|
|
class Results:
|
|
"""Per-test outcomes keyed by ``path::name`` (parametrised cases folded into their test)."""
|
|
|
|
def __init__(self, outcomes: Optional[dict[str, list[str]]] = None,
|
|
exists: Optional[Callable[[str], bool]] = None) -> None:
|
|
self.outcomes: dict[str, list[str]] = defaultdict(list, outcomes or {})
|
|
self._exists = exists or (lambda path: (REPO / path).is_file())
|
|
|
|
def add(self, node: str, outcome: str) -> None:
|
|
self.outcomes[node].append(outcome)
|
|
|
|
def exists(self, path: str) -> bool:
|
|
return self._exists(path)
|
|
|
|
def passed(self, ref: str) -> bool:
|
|
"""A file passes when it exists, ran, and nothing in it failed; a test when it ran and passed."""
|
|
path, _, name = ref.partition("::")
|
|
if not self.exists(path):
|
|
return False
|
|
if name:
|
|
got = self.outcomes.get(f"{path}::{name}", [])
|
|
return bool(got) and FAILED not in got and PASSED in got
|
|
got = [o for node, outs in self.outcomes.items() if node.split("::", 1)[0] == path for o in outs]
|
|
return bool(got) and FAILED not in got and PASSED in got
|
|
|
|
|
|
def _node_path(classname: str, file_attr: str) -> str:
|
|
if file_attr:
|
|
return file_attr.replace(os.sep, "/")
|
|
parts = classname.split(".")
|
|
# A class inside a module (``tests.reelforge.test_x.TestY``) keeps the module path.
|
|
for cut in range(len(parts), 0, -1):
|
|
candidate = "/".join(parts[:cut]) + ".py"
|
|
if (REPO / candidate).is_file():
|
|
return candidate
|
|
return "/".join(parts) + ".py"
|
|
|
|
|
|
def parse_junit(paths: Iterable[Path], results: Optional[Results] = None) -> Results:
|
|
results = results or Results()
|
|
for path in paths:
|
|
for case in ET.parse(path).getroot().iter("testcase"):
|
|
file_path = _node_path(case.get("classname", ""), case.get("file", ""))
|
|
name = case.get("name", "").split("[", 1)[0]
|
|
if case.find("failure") is not None or case.find("error") is not None:
|
|
outcome = FAILED
|
|
elif case.find("skipped") is not None:
|
|
outcome = SKIPPED
|
|
else:
|
|
outcome = PASSED
|
|
results.add(f"{file_path}::{name}", outcome)
|
|
return results
|
|
|
|
|
|
def status(row: Row, results: Results) -> tuple[str, list[str]]:
|
|
"""The row's status and why it is not DONE."""
|
|
if row.missing:
|
|
return MISSING, [row.missing]
|
|
why = [f"evidence {ref} not passing" for ref in row.evidence if not results.passed(ref)]
|
|
for gap in row.gaps:
|
|
if not gap.closed_by or not all(results.passed(ref) for ref in gap.closed_by):
|
|
why.append(f"{gap.id}: {gap.text}")
|
|
if not row.evidence and not row.gaps:
|
|
why.append("no evidence test")
|
|
return (PARTIAL if why else DONE), why
|
|
|
|
|
|
def recount(results: Results) -> dict[str, dict]:
|
|
report: dict[str, dict] = {}
|
|
for group, rows in GROUPS.items():
|
|
lines = []
|
|
totals = {DONE: 0, PARTIAL: 0, MISSING: 0}
|
|
for row in rows:
|
|
state, why = status(row, results)
|
|
totals[state] += 1
|
|
lines.append({"id": row.id, "name": row.name, "status": state, "open": why})
|
|
report[group] = {"rows": lines, "totals": (totals[DONE], totals[PARTIAL], totals[MISSING])}
|
|
return report
|
|
|
|
|
|
def all_refs() -> list[str]:
|
|
refs = set()
|
|
for rows in GROUPS.values():
|
|
for row in rows:
|
|
refs.update(r.split("::", 1)[0] for r in row.evidence)
|
|
for gap in row.gaps:
|
|
refs.update(r.split("::", 1)[0] for r in gap.closed_by)
|
|
return sorted(refs)
|
|
|
|
|
|
def run_tests(junit: Path) -> int:
|
|
files = [f for f in all_refs() if (REPO / f).is_file()]
|
|
cmd = [sys.executable, "-m", "pytest", "-q", "-p", "no:cacheprovider", "-W", "ignore",
|
|
f"--junitxml={junit}", "-o", "junit_family=xunit1", *files]
|
|
return subprocess.call(cmd, cwd=REPO)
|
|
|
|
|
|
def print_report(report: dict[str, dict], out=sys.stdout) -> None:
|
|
for group, body in report.items():
|
|
print(f"== {group}", file=out)
|
|
for line in body["rows"]:
|
|
detail = f" ({'; '.join(line['open'])})" if line["open"] else ""
|
|
print(f"{line['id']:<4} {line['status']:<8} {line['name']}{detail}", file=out)
|
|
done, partial, missing = body["totals"]
|
|
print(f"{group}: {done} / {partial} / {missing} (DONE / PARTIAL / MISSING)", file=out)
|
|
|
|
|
|
def self_test() -> list[str]:
|
|
"""Method checks with synthetic results; returns the failures (empty when fine)."""
|
|
problems = []
|
|
evidence = {r for rows in GROUPS.values() for row in rows for r in row.evidence}
|
|
main_like = Results({f"{ref}::test_ok": [PASSED] for ref in evidence},
|
|
exists=lambda p: "test_wq_" not in p)
|
|
got = {g: body["totals"] for g, body in recount(main_like).items()}
|
|
if got != BASELINE:
|
|
problems.append(f"main-like results give {got}, baseline is {BASELINE}")
|
|
broken = Results({**{f"{ref}::test_ok": [PASSED] for ref in evidence},
|
|
"tests/reelforge/test_routing.py::test_ok": [PASSED, FAILED]},
|
|
exists=lambda p: "test_wq_" not in p)
|
|
if recount(broken)["higgsfield"]["rows"][1]["status"] != PARTIAL:
|
|
problems.append("a failing evidence test did not make H2 PARTIAL")
|
|
row = next(r for r in GROUPS["muvi"] if r.id == "U30")
|
|
closed = Results({**{f"{ref}::test_ok": [PASSED] for ref in row.evidence},
|
|
**{ref: [PASSED] for gap in row.gaps for ref in gap.closed_by}}, exists=lambda p: True)
|
|
if status(row, closed)[0] != DONE:
|
|
problems.append("U30 did not reach DONE with every gap test passing")
|
|
skipped = Results({ref: [SKIPPED] for gap in row.gaps for ref in gap.closed_by}, exists=lambda p: True)
|
|
if all(skipped.passed(ref) for gap in row.gaps for ref in gap.closed_by):
|
|
problems.append("a skipped test closed a gap")
|
|
return problems
|
|
|
|
|
|
def main(argv: Optional[list[str]] = None) -> int:
|
|
parser = argparse.ArgumentParser(description="Menivor parity recount from test results")
|
|
parser.add_argument("--run", action="store_true", help="run the evidence and gap tests first")
|
|
parser.add_argument("--junit", action="append", default=[], help="JUnit XML to read (repeatable)")
|
|
parser.add_argument("--json", help="write the report as JSON to this path")
|
|
parser.add_argument("--check-baseline", action="store_true", help="exit 1 unless totals equal the baseline")
|
|
parser.add_argument("--self-test", action="store_true", help="check the method without running tests")
|
|
args = parser.parse_args(argv)
|
|
if args.self_test:
|
|
problems = self_test()
|
|
for problem in problems:
|
|
print(f"SELF-TEST FAIL: {problem}")
|
|
print("self-test ok" if not problems else "self-test failed")
|
|
return 1 if problems else 0
|
|
junits = [Path(p) for p in args.junit]
|
|
if args.run:
|
|
tmp = Path(tempfile.mkdtemp(prefix="menivor-recount-")) / "junit.xml"
|
|
run_tests(tmp)
|
|
junits.append(tmp)
|
|
if not junits:
|
|
parser.error("pass --run or --junit (or --self-test)")
|
|
report = recount(parse_junit(junits))
|
|
print_report(report)
|
|
if args.json:
|
|
Path(args.json).write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8")
|
|
if args.check_baseline:
|
|
got = {g: tuple(body["totals"]) for g, body in report.items()}
|
|
return 0 if got == BASELINE else 1
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|