129 lines
4.6 KiB
Python
129 lines
4.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Independent re-verification of the sol-profile triage artifact.
|
|
|
|
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
|
|
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"
|
|
VOCAB = {"identity", "config", "state_db", "soul", "cache", "sessions", "skills",
|
|
"plugins", "logs", "backups", "vault", "extension_dir", "script",
|
|
"config_data", "other"}
|
|
|
|
# Independent table: exact-name specials, then suffix / dir rules.
|
|
SPECIAL = {
|
|
".env", ".env.bak-20261014T165715Z", ".env.lock",
|
|
"config.yaml", "config.yaml.bak-20261014T165715Z",
|
|
"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", "SOUL.md", "gateway.lock", "projects.db",
|
|
"context_length_cache.yaml", "context_length_cache.yaml.lock",
|
|
}
|
|
CACHE_DIRS = {"audio_cache", "cache", "image_cache"}
|
|
PLUGIN_DIRS = {"plugin-update-checks", "plugins"}
|
|
EXT_DIRS = {"bin", "cron", "forge", "home", "hooks", "keys", "lsp", "memories",
|
|
"pairing", "plans", "platforms", "runtime", "sandboxes", "skins",
|
|
"source-checks", "state", "wizard-outputs", "workspace"}
|
|
|
|
|
|
def classify(name, full):
|
|
if name in SPECIAL:
|
|
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", "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 == "models_dev_cache.etag" or name == "models_dev_cache.json":
|
|
return "state_db"
|
|
if name == "SOUL.md":
|
|
return "soul"
|
|
if name == "gateway.lock" or name == "projects.db":
|
|
return "other"
|
|
if name == "context_length_cache.yaml":
|
|
return "config_data"
|
|
if name == "context_length_cache.yaml.lock":
|
|
return "other"
|
|
return "other"
|
|
if name in CACHE_DIRS:
|
|
return "cache"
|
|
if name in PLUGIN_DIRS:
|
|
return "plugins"
|
|
if name == "logs":
|
|
return "logs"
|
|
if name == "backups":
|
|
return "backups"
|
|
if name == "vault":
|
|
return "vault"
|
|
if name == "sessions":
|
|
return "sessions"
|
|
if name == "skills":
|
|
return "skills"
|
|
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():
|
|
artifact = sys.argv[1] if len(sys.argv) > 1 else os.path.join(
|
|
os.path.dirname(os.path.abspath(__file__)),
|
|
"Triage-sol-profile-2026-11-02.json")
|
|
|
|
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.get("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.get("category") in VOCAB for e in art.get("entries", [])):
|
|
errs.append("category label outside vocabulary")
|
|
|
|
live_counts = {}
|
|
for name in disk_names:
|
|
live_counts[classify(name, os.path.join(PROFILE, name))] = \
|
|
live_counts.get(classify(name, os.path.join(PROFILE, name)), 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"
|
|
% len(disk_names))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|