#!/usr/bin/env python3 """Row counts per store, read over IPC. Runs on homesrv. The eval's first artifact. Read before any probe writes, and again after, so what the probes added is attributable. Not the sqlite file: the point is to measure the contract, and the plaintext copy in tmpfs bypasses it. """ import json import subprocess import sys C = "maven-mavend-1" S = "/run/maven/mavend.sock" BIN = "/tmp/e2eprobe" # command, argv, and whether the reply is capped by a limit e2eprobe hardcodes. READS = [ ("facts", ["facts", "100000"], False), ("notes", ["notes", "100000"], False), ("reminders", ["reminders", "100000"], False), ("pending_reminders", ["pending-reminders", "100000"], False), ("tasks_live", ["tasks"], False), ("nudges", ["nudges", "100000"], False), ("tools", ["tools"], False), ("decisions", ["decisions", "100000"], False), ("events", ["events", "100000"], False), ("eco_traces", ["eco-traces", "100000"], False), ("delivery_attempts", ["delivery-attempts"], True), # capped at 200 in e2eprobe ] def main(): out = {} for name, argv, capped in READS: p = subprocess.run(["docker", "exec", C, BIN, "-sock", S] + argv, capture_output=True, text=True, timeout=180) if p.returncode != 0: out[name] = {"error": (p.stderr or p.stdout).strip()[:300]} continue try: d = json.loads(p.stdout) except json.JSONDecodeError: out[name] = {"error": "not json", "raw": p.stdout.strip()[:300]} continue if d is None: out[name] = {"count": 0} elif isinstance(d, list): r = {"count": len(d)} if capped and len(d) >= 200: r["note"] = "at e2eprobe's hardcoded 200 cap, true count is >= 200" out[name] = r else: out[name] = {"value": d} json.dump(out, sys.stdout, ensure_ascii=False, indent=2) print() if __name__ == "__main__": main()