Files
hmbown--codewhale/scripts/measure-tool-catalog.py
wehub-resource-sync d68f003000
CI / Change detection (push) Has been cancelled
CI / Version drift (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Workflow RLM cache (push) Has been cancelled
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / npm wrapper smoke (push) Has been cancelled
CI / Mobile runtime smoke (push) Has been cancelled
CI / Workflow lint (push) Has been cancelled
CI / Documentation (push) Has been cancelled
Web Frontend / Lint & Type Check (push) Failing after 1s
Auto-close harvested PRs / close (push) Failing after 1s
cargo-deny / cargo-deny (bans licenses sources) (push) Failing after 1s
Security audit / cargo-audit (push) Failing after 1s
Sync to CNB / sync (push) Failing after 1s
cargo-deny / cargo-deny (advisories) (push) Failing after 3s
Web Frontend / Deploy to Cloudflare (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:08:23 +08:00

47 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
"""Measure serialized tool catalog size before and after default deferral.
This delegates catalog construction to an ignored Rust test so the measurement
uses the same tool definitions, JSON serialization, and deferral policy as the
runtime. 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",
"-p",
"codewhale-tui",
"print_agent_tool_catalog_metrics",
"--",
"--ignored",
"--nocapture",
"--test-threads=1",
]
proc = subprocess.run(cmd, text=True, capture_output=True, check=False)
sys.stderr.write(proc.stderr)
for line in proc.stdout.splitlines():
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())