Files
troupe-standup/wizard-work/sol/_verify_triage_profiles.py
T

66 lines
2.1 KiB
Python

#!/usr/bin/env python3
"""Independent re-check for sol's profile-census triage artifact.
Recomputes the ACTIVE/STALE/PLACEHOLDER split straight from
/root/.hermes/profiles (config.yaml presence) and diffs it against the
artifact written at triage-profiles-2026-10-21.json. Exit 0 = correct.
"""
import json
import os
import re
import sys
PROFILES = "/root/.hermes/profiles"
ARTIFACT = "/root/.hermes/wizard-outputs/sol/triage-profiles-2026-10-21.json"
MISC_DIRS = {
"audits", "cache", "bin", "cron", "external-workers", "image_cache",
"keys", "logs", "lsp", "memories", "plugin-update-checks", "plugins",
"runtime", "sandboxes", "sessions", "skills", "skins", "source-checks",
"vault", "workspace",
}
def reclassify(name):
cfg = os.path.join(PROFILES, name, "config.yaml")
if not os.path.isfile(cfg):
return "PLACEHOLDER"
try:
t = open(cfg, encoding="utf-8", errors="replace").read()
m = re.search(r"model:\s*\n\s*default:\s*(.+)", t)
if not m:
m = re.search(r"default:\s*(.+)", t)
return "ACTIVE" if (m and not m.group(1).startswith("ERR")) else "STALE"
except Exception:
return "STALE"
def main():
want_names = sorted(
n for n in os.listdir(PROFILES)
if os.path.isdir(os.path.join(PROFILES, n))
)
want = {"ACTIVE": 0, "STALE": 0, "PLACEHOLDER": 0}
for n in want_names:
want[reclassify(n)] += 1
got = json.load(open(ARTIFACT, encoding="utf-8"))
if got.get("generated_utc") is None:
print("CHECK FAIL: artifact missing generated_utc")
return 1
got_counts = {k: got.get(k, 0) for k in ("ACTIVE", "STALE", "PLACEHOLDER")}
if got_counts != want:
print("CHECK FAIL: counts artifact=%s recomputed=%s"
% (got_counts, want))
return 1
if len(got.get("entries", [])) != len(want_names):
print("CHECK FAIL: entries=%d want %d"
% (len(got.get("entries", [])), len(want_names)))
return 1
print("CHECK OK: %d profiles -> %s" % (len(want_names), want))
return 0
if __name__ == "__main__":
sys.exit(main())