82 lines
2.9 KiB
Bash
Executable File
82 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# CHECK -- sol: sol-profile-triage re-derives the classification from the live
|
|
# profile dir and verifies the committed JSON against it on disk. Exit 0 iff.
|
|
set -u
|
|
python3 - <<'PY'
|
|
import os, json, sys
|
|
PROFILE = "/root/.hermes/profiles/sol"
|
|
WIZ_JSON = "/root/.hermes/wizard-outputs/sol/sol-profile-triage-2026-10-31.json"
|
|
REPO_JSON = "/root/troupe-standup/wizard-work/sol/sol-profile-triage-2026-10-31.json"
|
|
|
|
def classify(name, is_dir):
|
|
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"},
|
|
}
|
|
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(p):
|
|
with open(p, encoding="utf-8") as fh:
|
|
return json.load(fh)
|
|
|
|
fails = []
|
|
for p in (WIZ_JSON, REPO_JSON):
|
|
if not os.path.isfile(p):
|
|
fails.append("missing artifact: " + p)
|
|
if not fails:
|
|
disk_cats = expected()
|
|
for label, jpath in (("wizard-outputs", WIZ_JSON), ("repo", REPO_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 load(WIZ_JSON).get("entries", []):
|
|
if e.get("category") != classify(e["name"], e.get("type") == "dir"):
|
|
fails.append("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)
|
|
PY
|
|
EXIT=$?
|
|
if [ $EXIT -ne 0 ]; then
|
|
echo "CHECK FAILED (exit $EXIT)"
|
|
fi
|
|
exit $EXIT
|