Files
sisi/verifiers/real-world/runtime-self-check.md
T
swaitsandClaude Fable 5.2 2fc1fe9c2d
ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.9) (push) Canceled after 0s
sisi 0.1.0: a shared rulebook and verification tool for AI coding agents
Contracts with a ladder of checks, an end-of-turn gate, retrospectives and
shared lessons, time-to-delivery measurement, a library of 140 verification
techniques and 20 recipes, personal data kept outside the clone, and
releases with rollback. Standard library only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 22:29:02 -07:00

3.0 KiB

id, title, answers, rung, section, languages, kinds, cost, detect, ran_here, verified
id title answers rung section languages kinds cost detect ran_here verified
runtime-self-check Give the product its own verify or doctor command and run it as a check Does the product's own data pass its own integrity checks (hash chain, control totals, invariants)? 3 real-world any money, state-machine, general medium yes ran

Use when

  • The product holds data whose consistency can be checked from the data alone: a journal with a hash chain, ledgers whose debits equal credits, counters that must add up to a stored total, foreign keys that must resolve.
  • You want the same check to run in tests, after a migration, after a restore, in CI and in production.

Do not use when

  • There is no invariant to check. A verify command that always prints OK is worse than none.

Set up

Add a command, for example mytool verify [--data DIR], that reads the data and checks invariants without writing anything (see read-only-guarantee). Make it exit 0 when all hold and nonzero with a specific message for each broken one. Typical checks: each record's hash includes the previous hash; sum of debits equals sum of credits; row counts match a stored control total; no orphan references; every file referenced exists.

Minimal example

A hash-chained log, with verify as a few lines of shell:

# each line: <prev-hash> <payload>; the next line's prev-hash must be sha256 of the whole previous line
prev=GENESIS
while IFS= read -r line; do
  [ "${line%% *}" = "$prev" ] || { echo "chain broken at: $line"; exit 1; }
  prev=$(printf '%s' "$line" | sha256sum | cut -d' ' -f1)
done < journal.log
echo "chain ok"

Run it on good data, then edit one payload byte in a copy and confirm it fails (done here: a tampered line printed chain broken at: and exited 1). Then use it as a check wherever data changes: after a migration (db-migration-safety), after an upgrade (packaging-install-upgrade), after a restore. The owner's reference project exposes this as a verify tool and runs it in migration and hostile-input tests, asserting the books still verify afterwards.

Run

mytool verify --data data/ or the script above.

Passing looks like: chain ok (or the product's own summary) and exit 0. Failure: a message naming the first broken record, exit 1.

As a contract check

{"id": "self-verify", "claim": "The data directory passes the product's own integrity check", "kind": "general", "rung": 3,
 "cmd": "mytool verify --data tests/fixtures/books", "expect": {"exit": 0, "stdout_contains": "ok"}, "tier": "deep", "timeout_s": 120}

What a pass does not prove

  • Only the invariants coded into verify. If a bug writes data that satisfies the checker, the checker passes. Keep the invariants independent from the write path.
  • A hash chain shows tampering or corruption after the fact; it does not show the entries were correct.
  • A verify that runs on an empty fixture proves nothing; use data with every kind of record.
  • Check the check: corrupt one record in a copy and confirm failure.