79 lines
2.7 KiB
Bash
79 lines
2.7 KiB
Bash
#!/usr/bin/env bash
|
|
# CHECK -- sol: sol-profile-triage-2026-11-01 re-derives the classification
|
|
# from the live profile dir and verifies the committed JSON against disk.
|
|
# Exit code 0 iff the committed artifact is correct; nonzero otherwise.
|
|
set -u
|
|
python3 - <<'PY'
|
|
import os, json, sys
|
|
PROFILE = "/root/.hermes/profiles/sol"
|
|
REPO_JSON = "/root/troupe-standup/wizard-work/sol/sol-profile-triage-2026-11-01.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):
|
|
exp[classify(name, os.path.isdir(os.path.join(PROFILE, name)))] = exp.get(classify(name, os.path.isdir(os.path.join(PROFILE, name))), 0) + 1
|
|
return exp
|
|
|
|
def load(p):
|
|
with open(p, encoding="utf-8") as fh:
|
|
return json.load(fh)
|
|
|
|
fails = []
|
|
if not os.path.isfile(REPO_JSON):
|
|
fails.append("missing committed artifact: " + REPO_JSON)
|
|
else:
|
|
disk_cats = expected()
|
|
d = load(REPO_JSON)
|
|
if d.get("total_entries") != len(os.listdir(PROFILE)):
|
|
fails.append("total_entries mismatch: %r vs %d" % (d.get("total_entries"), len(os.listdir(PROFILE))))
|
|
if d.get("categories") != disk_cats:
|
|
fails.append("categories mismatch: %r vs %r" % (d.get("categories"), disk_cats))
|
|
for e in d.get("entries", []):
|
|
if not os.path.lexists(e.get("path", "")):
|
|
fails.append("entry 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("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
|