Files
troupe-standup/wizard-work/sol/verify_sol_profile_triage.py

91 lines
3.0 KiB
Python

#!/usr/bin/env python3
"""verify_sol_profile_triage.py -- re-derives the classification of
/root/.hermes/profiles/sol from the live disk and compares it against the
committed artifact. Exit code 0 = PASS, nonzero = FAIL."""
import json
import os
import sys
PROFILE = "/root/.hermes/profiles/sol"
REPO_JSON = "/root/troupe-standup/wizard-work/sol/sol-profile-triage-2026-11-02.json"
WIZ_JSON = "/root/.hermes/wizard-outputs/sol/sol-profile-triage-2026-11-02.json"
EXACT = {
"identity": {".env", ".env.bak-20261014T165715Z"},
"soul": {"SOUL.md"},
"config": {".env.lock", "config.yaml", "config.yaml.bak-20261014T165715Z"},
"state_db": {
"state.db", "state.db-shm", "state.db-wal",
"state.db.auto-maintenance.lock", "state.db.fts_rebuild.lock",
"state.db.quarantine.lock",
"auth.json", "auth.lock", ".skills_prompt_snapshot.json",
"models_dev_cache.json", "models_dev_cache.etag",
},
"cache": {"cache", "audio_cache", "image_cache"},
"sessions": {"sessions"},
"skills": {"skills"},
"plugins": {"plugins", "plugin-update-checks"},
"logs": {"logs"},
"backups": {"backups"},
"vault": {"vault"},
}
def classify(name, is_dir):
for cat, names in EXACT.items():
if name in names:
return cat
if is_dir:
return "extension_dir"
if name.endswith(".py"):
return "script"
if name.endswith((".yaml", ".json")):
return "config_data"
return "other"
def expected():
exp = {}
for name in os.listdir(PROFILE):
p = os.path.join(PROFILE, name)
cat = classify(name, os.path.isdir(p))
exp[cat] = exp.get(cat, 0) + 1
return exp
def load(path):
with open(path, encoding="utf-8") as fh:
return json.load(fh)
def main():
fails = []
for p in (REPO_JSON, WIZ_JSON):
if not os.path.isfile(p):
fails.append("missing artifact: " + p)
if not fails:
disk_cats = expected()
for label, jpath in (("repo", REPO_JSON), ("wizard-outputs", WIZ_JSON)):
d = load(jpath)
if d.get("total_entries") != len(os.listdir(PROFILE)):
fails.append("[" + label + "] total_entries mismatch")
if d.get("categories") != disk_cats:
fails.append("[" + label + "] categories mismatch (got %s, want %s)"
% (d.get("categories"), disk_cats))
for e in d.get("entries", []):
if not os.path.lexists(e.get("path", "")):
fails.append("[" + label + "] referenced path no longer exists: "
+ str(e.get("path")))
for e in d.get("entries", []):
if e.get("category") != classify(e["name"], e.get("type") == "dir"):
fails.append("[" + label + "] entry category mismatch: " + e["name"])
print("PASS" if not fails else "FAIL")
for f in fails:
print(" -", f)
sys.exit(1 if fails else 0)
if __name__ == "__main__":
main()