123 lines
4.5 KiB
Python
123 lines
4.5 KiB
Python
#!/usr/bin/env python3
|
|
"""CHECK -- verify the 2026-10-28 sol daily ledger record against real disk.
|
|
|
|
Independently re-derives the sol profile classification and the sol-lane daily
|
|
status straight from the filesystem and diffs them against the committed
|
|
artifact sol-2026-10-28-<ts>.json. Exit code 0 == record matches disk.
|
|
|
|
Single bare shell command whose exit code is the verdict:
|
|
python3 /root/troupe-standup/wizard-work/sol/check_2026-10-28_sol_ledger.py
|
|
"""
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
REPO = "/root/troupe-standup/wizard-work/sol"
|
|
PROFILE = "/root/.hermes/profiles/sol"
|
|
WIZARD_OUT = "/root/.hermes/wizard-outputs"
|
|
|
|
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", "context_length_cache.yaml"},
|
|
"sessions": {"sessions"},
|
|
"skills": {"skills"},
|
|
"plugins": {"plugins", "plugin-update-checks"},
|
|
"logs": {"logs"},
|
|
"backups": {"backups"},
|
|
"vault": {"vault"},
|
|
}
|
|
|
|
|
|
def categorize(name, is_dir):
|
|
if name in EXACT["identity"]:
|
|
return "identity"
|
|
if name in EXACT["soul"]:
|
|
return "soul"
|
|
if name in EXACT["config"]:
|
|
return "config"
|
|
if name in EXACT["state_db"]:
|
|
return "state_db"
|
|
if name in EXACT["cache"]:
|
|
return "cache"
|
|
if name in EXACT["sessions"]:
|
|
return "sessions"
|
|
if name in EXACT["skills"]:
|
|
return "skills"
|
|
if name in EXACT["plugins"]:
|
|
return "plugins"
|
|
if name in EXACT["logs"]:
|
|
return "logs"
|
|
if name in EXACT["backups"]:
|
|
return "backups"
|
|
if name in EXACT["vault"]:
|
|
return "vault"
|
|
if is_dir:
|
|
return "extension_dir"
|
|
if name.endswith(".py"):
|
|
return "script"
|
|
if name.endswith(".yaml") or name.endswith(".json"):
|
|
return "config_data"
|
|
return "other"
|
|
|
|
|
|
def main():
|
|
jpaths = sorted(f for f in os.listdir(REPO) if f.startswith("sol-2026-10-28-") and f.endswith(".json"))
|
|
if len(jpaths) != 1:
|
|
print("FAIL: expected exactly one sol-2026-10-28-*.json, found %r" % jpaths)
|
|
sys.exit(1)
|
|
artifact = json.load(open(os.path.join(REPO, jpaths[0])))
|
|
|
|
# Independent re-derivation from real disk.
|
|
names = sorted(os.listdir(PROFILE))
|
|
counts = {}
|
|
for n in names:
|
|
counts[categorize(n, os.path.isdir(os.path.join(PROFILE, n)))] = counts.get(categorize(n, os.path.isdir(os.path.join(PROFILE, n))), 0) + 1
|
|
|
|
# Independent sol-lane status from real mtimes.
|
|
latest_log = None
|
|
latest_mtime = None
|
|
for f in os.listdir(WIZARD_OUT):
|
|
if f.startswith("sol-") and f.endswith(".txt"):
|
|
m = os.path.getmtime(os.path.join(WIZARD_OUT, f))
|
|
if latest_mtime is None or m > latest_mtime:
|
|
latest_log, latest_mtime = f, m
|
|
now = __import__("time").time()
|
|
age = (now - latest_mtime) / 3600.0 if latest_log else None
|
|
status = "ACTIVE" if (age is not None and age < 24) else ("WATCH" if age is not None and age <= 168 else ("STALE" if latest_log else "NO_LOG"))
|
|
|
|
problems = []
|
|
if artifact.get("profile_entries") != len(names):
|
|
problems.append("profile_entries %r != disk %d" % (artifact.get("profile_entries"), len(names)))
|
|
if artifact.get("profile_counts") != counts:
|
|
problems.append("profile_counts %r != recomputed %r" % (artifact.get("profile_counts"), counts))
|
|
if artifact.get("profile_counts_sum") != sum(counts.values()):
|
|
problems.append("profile_counts_sum %r != %d" % (artifact.get("profile_counts_sum"), sum(counts.values())))
|
|
if latest_log != artifact.get("sol_latest_log"):
|
|
problems.append("sol_latest_log %r != artifact %r" % (latest_log, artifact.get("sol_latest_log")))
|
|
if artifact.get("sol_status") != status:
|
|
problems.append("sol_status %r != recomputed %r" % (artifact.get("sol_status"), status))
|
|
|
|
if problems:
|
|
print("FAIL")
|
|
for p in problems:
|
|
print(" -", p)
|
|
sys.exit(1)
|
|
|
|
print("PASS: sol daily ledger record verified against live disk")
|
|
print("profile_entries=%d profile_counts=%s" % (len(names), json.dumps(counts)))
|
|
print("sol_status=%s sol_latest_log=%s" % (status, latest_log))
|
|
sys.exit(0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|