Files
hmbown--codewhale/scripts/measure-tool-catalog.py
CodeWhale Bot e54b8043df fix(gates): measure the library runtime contract
Run each ignored receipt test against its exact library path and reject Cargo's successful zero-test result explicitly. Keep the standalone tool-catalog measurement and current verification guidance on the same target, with hermetic command and failure regressions wired into CI.

The repaired measurement exposed a real duplicate AGENTS.md injection from the bounded fragment importer. Keep canonical project-context sources single-owned while still importing additional rule formats through the typed, capped fragment boundary; this restores the checked-in prompt identity without raising the budget.

Verified with the full 55-metric runtime-contract checker, focused core and TUI regressions, both Python harness suites, cargo fmt, and all-target clippy for codewhale-core and codewhale-tui.
2026-08-07 21:56:00 -07:00

51 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
"""Measure canonical production-built tool catalogs by visible mode.
This delegates to an ignored Rust test that runs the production registry,
catalog, and active-request planner with inert wiring. Token counts are
deterministic estimates using ceil(serialized_bytes/4).
"""
from __future__ import annotations
import json
import subprocess
import sys
MARKER = "TOOL_CATALOG_METRICS "
def main() -> int:
cmd = [
"cargo",
"test",
"--locked",
"-p",
"codewhale-tui",
"--lib",
"core::engine::tests::print_mode_tool_catalog_metrics",
"--",
"--ignored",
"--exact",
"--nocapture",
"--test-threads=1",
]
proc = subprocess.run(cmd, text=True, capture_output=True, check=False)
sys.stderr.write(proc.stderr)
combined = proc.stdout.splitlines() + proc.stderr.splitlines()
for line in combined:
if MARKER in line:
metrics = json.loads(line.split(MARKER, 1)[1])
print(json.dumps(metrics, indent=2, sort_keys=True))
return proc.returncode
sys.stdout.write(proc.stdout)
sys.stderr.write("missing TOOL_CATALOG_METRICS marker\n")
return proc.returncode or 1
if __name__ == "__main__":
raise SystemExit(main())