84 lines
2.8 KiB
Python
84 lines
2.8 KiB
Python
"""Coverage ledger: verified/function_count per program, read live off re/*_rvadb.json.
|
|
|
|
Every run re-reads the databases from disk, so the numbers never go stale
|
|
between a worker's commit and this report. The nine-module roster is the
|
|
IN-SCOPE table in docs/companion-inventory.md; a roster entry with no
|
|
matching database on disk prints as "pending export".
|
|
"""
|
|
# /// script
|
|
# requires-python = ">=3.11"
|
|
# dependencies = []
|
|
# ///
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
from pathlib import Path
|
|
from typing import Final
|
|
|
|
from rvadb import REPO_ROOT, ProgramDatabase, discover_databases, load_database
|
|
|
|
ROSTER: Final[tuple[tuple[str, str, bool], ...]] = (
|
|
("libavs-win32.dll", "libavs", False),
|
|
("libavs-win32-ea3.dll", "libavs-ea3", False),
|
|
("libafp-win32.dll", "libafp", False),
|
|
("libafputils-win32.dll", "libafputils", False),
|
|
("ess.dll", "ess", False),
|
|
("libacio.dll", "libacio", False),
|
|
("arkkdm.dll", "arkkdm", False),
|
|
("arkkdmtest.dll", "arkkdmtest", False),
|
|
("gamekdm.dll", "gamekdm", True),
|
|
)
|
|
|
|
|
|
def checkpoint_bucket(verified: int, total: int, buckets: int) -> str:
|
|
if total <= 0:
|
|
return "n/a"
|
|
fraction = verified / total
|
|
index = min(int(fraction * buckets), buckets - 1)
|
|
lo = index * 100 // buckets
|
|
hi = (index + 1) * 100 // buckets
|
|
return f"{index + 1}/{buckets} [{lo}%,{hi}%)"
|
|
|
|
|
|
def format_line(short: str, db: ProgramDatabase, is_primary: bool) -> str:
|
|
verified = db.verified_count()
|
|
total = db.function_count
|
|
pct = (verified / total * 100) if total else 0.0
|
|
buckets = 10 if is_primary else 4
|
|
kind = "decile" if is_primary else "quartile"
|
|
bucket = checkpoint_bucket(verified, total, buckets)
|
|
return f"{short} {verified}/{total} ({pct:.2f}%) {kind}={bucket}"
|
|
|
|
|
|
def report(root: Path = REPO_ROOT) -> tuple[str, ...]:
|
|
discovered: dict[str, ProgramDatabase] = {}
|
|
for db_path in discover_databases(root):
|
|
db = load_database(db_path)
|
|
discovered[db.program] = db
|
|
|
|
lines: list[str] = []
|
|
rostered_programs = {program for program, _, _ in ROSTER}
|
|
for program, short, is_primary in ROSTER:
|
|
if program in discovered:
|
|
lines.append(format_line(short, discovered[program], is_primary))
|
|
else:
|
|
lines.append(f"{short} pending export")
|
|
for program, db in discovered.items():
|
|
if program not in rostered_programs:
|
|
lines.append(format_line(program, db, is_primary=False))
|
|
return tuple(lines)
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description="Print verified/function_count per program.")
|
|
parser.add_argument("--root", type=Path, default=REPO_ROOT)
|
|
args = parser.parse_args()
|
|
for line in report(args.root):
|
|
print(line)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|