46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
# CHECK -- sol-profile-file-class-reverify-2026-10-31 (verdict = exit code).
|
|
# Re-derives ACTIVE/STALE/ARTIFACT/TOTAL from the live filesystem and exits 0
|
|
# iff every count matches the committed re-verify record.
|
|
import os
|
|
import sys
|
|
import time
|
|
|
|
ROOT = "/root/.hermes/profiles/sol"
|
|
ARTIFACT_EXTS = {".db", ".sqlite", ".lock", ".pyc", ".bak", ".orig", ".tmp", ".gz", ".zip", ".dump", ".log"}
|
|
ARTIFACT_DIRS = {"lock", "db", "cache", "backup", "__pycache__", "backups", "bin", "hooks", "keys",
|
|
".pytest_cache", ".ruff_cache", ".mypy_cache", ".tox", "node_modules"}
|
|
|
|
def classify(rel):
|
|
if any(rel == d or rel.startswith(d + os.sep) for d in ARTIFACT_DIRS):
|
|
return "ARTIFACT"
|
|
if os.path.splitext(rel)[1].lower() in ARTIFACT_EXTS:
|
|
return "ARTIFACT"
|
|
age_h = (time.time() - os.path.getmtime(os.path.join(ROOT, rel))) / 3600
|
|
return "ACTIVE" if age_h <= 45 * 24 else "STALE"
|
|
|
|
counts = {"ACTIVE": 0, "STALE": 0, "ARTIFACT": 0}
|
|
for dirpath, dirnames, filenames in os.walk(ROOT):
|
|
for f in filenames:
|
|
rel = os.path.relpath(os.path.join(dirpath, f), ROOT)
|
|
counts[classify(rel)] += 1
|
|
total = counts["ACTIVE"] + counts["STALE"] + counts["ARTIFACT"]
|
|
|
|
expected = {
|
|
"ACTIVE": 7961,
|
|
"STALE": 267,
|
|
"ARTIFACT": 133,
|
|
"TOTAL_REGULAR_FILES": 8361,
|
|
}
|
|
|
|
print("re-derived:", {"ACTIVE": counts["ACTIVE"], "STALE": counts["STALE"], "ARTIFACT": counts["ARTIFACT"], "TOTAL": total})
|
|
print("expected: ", expected)
|
|
ok = True
|
|
for k, want in expected.items():
|
|
got = counts[k] if k in counts else total
|
|
match = got == want
|
|
ok = ok and match
|
|
print(f" {'OK ' if match else 'FAIL'} {k}: re-derived={got} expected={want}")
|
|
print("VERDICT: PASS" if ok else "VERDICT: FAIL")
|
|
sys.exit(0 if ok else 1)
|