102 lines
3.4 KiB
Python
102 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Independent re-verification of sol-profile-triage-2026-11-02.json.
|
|
|
|
Re-derives the daily triage from the LIVE sol profile (not from the artifact)
|
|
using its OWN rule table written separately from the generator, then checks the
|
|
committed artifact entry-by-entry. Exit 0 = correct, nonzero = wrong.
|
|
|
|
Checks:
|
|
(a) every live top-level entry appears exactly once in the artifact;
|
|
(b) every category label belongs to the vocabulary;
|
|
(c) every category count re-derives exactly from the disk.
|
|
"""
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
PROFILE = "/root/.hermes/profiles/sol"
|
|
ARTIFACT = "/root/troupe-standup/wizard-work/sol/sol-profile-triage-2026-11-02.json"
|
|
VOCAB = {"identity", "config", "state_db", "soul", "cache", "sessions", "skills",
|
|
"plugins", "logs", "backups", "vault", "extension_dir", "script",
|
|
"config_data", "other"}
|
|
|
|
|
|
def classify(name, full):
|
|
# independent table: config-set names, exact-name specials, then suffix rules
|
|
if name in (".env", ".env.bak-20261014T165715Z"):
|
|
return "identity"
|
|
if name in (".env.lock", "config.yaml", "config.yaml.bak-20261014T165715Z"):
|
|
return "config"
|
|
if name in ("auth.json", "auth.lock", "models_dev_cache.etag", "models_dev_cache.json",
|
|
"state.db", "state.db-shm", "state.db-wal",
|
|
"state.db.auto-maintenance.lock", "state.db.fts_rebuild.lock",
|
|
"state.db.quarantine.lock"):
|
|
return "state_db"
|
|
if name == "SOUL.md":
|
|
return "soul"
|
|
if name in ("audio_cache", "cache", "image_cache"):
|
|
return "cache"
|
|
if name == "sessions":
|
|
return "sessions"
|
|
if name == "skills":
|
|
return "skills"
|
|
if name in ("plugin-update-checks", "plugins"):
|
|
return "plugins"
|
|
if name == "logs":
|
|
return "logs"
|
|
if name == "backups":
|
|
return "backups"
|
|
if name == "vault":
|
|
return "vault"
|
|
if os.path.isdir(full):
|
|
return "extension_dir"
|
|
if name.endswith(".py"):
|
|
return "script"
|
|
if name.endswith((".yaml", ".json")):
|
|
return "config_data"
|
|
return "other"
|
|
|
|
|
|
def main():
|
|
errs = []
|
|
try:
|
|
with open(ARTIFACT, encoding="utf-8") as fh:
|
|
art = json.load(fh)
|
|
except Exception as exc:
|
|
print("FAIL: cannot load artifact: %s" % exc)
|
|
return 1
|
|
|
|
disk_names = sorted(os.listdir(PROFILE))
|
|
art_names = sorted(e["name"] for e in art.get("entries", []))
|
|
if disk_names != art_names:
|
|
errs.append("names mismatch: live=%d artifact=%d"
|
|
% (len(disk_names), len(art_names)))
|
|
|
|
if not all(e["category"] in VOCAB for e in art.get("entries", [])):
|
|
errs.append("category label outside vocabulary")
|
|
|
|
live_counts = {}
|
|
for name in disk_names:
|
|
c = classify(name, os.path.join(PROFILE, name))
|
|
live_counts[c] = live_counts.get(c, 0) + 1
|
|
if art.get("categories") != live_counts:
|
|
errs.append("categories mismatch: artifact=%r live=%r"
|
|
% (art.get("categories"), live_counts))
|
|
|
|
if art.get("total_entries") != len(disk_names):
|
|
errs.append("total_entries mismatch: %r" % art.get("total_entries"))
|
|
|
|
if errs:
|
|
print("CHECK FAIL")
|
|
for e in errs:
|
|
print(" -", e)
|
|
return 1
|
|
|
|
print("CHECK OK: %d live top-level entries re-derived; artifact matches disk exactly"
|
|
% len(disk_names))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|