Files
orangecat/scripts/systemd/orangecat-data-invariants.timer
f3a649980b feat(ops): nightly data-invariant gate — test the rows prod has, not the rows mocks imagine (#574)
Every test in this repo runs against mocks, and that is precisely why the
shared-wallet disclosure shipped wrong three times today with a fully green
suite. The mocks encoded the data shape we assumed — one address per wallet
row, links pointing at live entities — while production held a different one:
the same address spread across 2 to 11 wallet rows, and 8 of 10 entity_wallets
links pointing at deleted entities. No amount of unit testing finds that class.
Only reading production does, so this puts the reading on a schedule.

Four invariants, each a claim the product makes to a user about their money:
- entity_wallets links point at entities that still exist (the orphan class
  fixed in #573 — this is its regression guard)
- no entity has two primary links (resolveLinkedEntityWallet has no tiebreaker,
  so duplicates make payment routing nondeterministic)
- every active wallet has some usable receiving rail
- every paid intent carries a settlement timestamp (status written outside
  claimPaidTransition is money-state divergence)

An unknown entity_type is reported rather than skipped, so a new entity type
cannot quietly opt out of the orphan check. A check that throws is recorded as
a finding — an exception must never read as "invariant holds".

Wired into deploy-selfhost.sh alongside the existing nightly gates, 05:00 UTC
so the three never overlap, with OnFailure notification like its siblings.

Verified against production both ways: passes clean on real data, and with a
deliberately inserted orphan row it correctly failed with exit 1 and named the
offending link (row removed afterwards; entity_wallets back to 2).

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-02 19:30:23 +02:00

13 lines
351 B
SYSTEMD

# SSOT: repo scripts/systemd/ — installed by deploy-selfhost.sh.
# Runs at 05:00, after the 04:30 judgment eval and 04:45 outcome gate, so the
# three nightly gates never overlap on the box.
[Unit]
Description=OrangeCat nightly data-invariant gate (05:00 UTC)
[Timer]
OnCalendar=*-*-* 05:00:00 UTC
Persistent=true
[Install]
WantedBy=timers.target