The full write-up
Overview
The question. Can the same set of safety rules for a lending vault be checked twice, once by a fuzzer before deployment and once by a monitor against live chain state, without the two drifting apart?
The answer. In this repo, yes, for a teaching vault on a test network. A Foundry harness asserts 12 invariants after every random call, and a TypeScript monitor re-checks the same 12 against a demo vault on Base Sepolia, a test network that holds no real value. A CI job fails if the two copies drift.
How it differs from my 2024 project. The Smart Contract Invariant Monitor & Guardian was a Rust tool that replayed the Euler exploit against mainnet history, while Guardian Pipeline is a separate 2026 codebase that writes its own Solidity vault, fuzzes its invariants in Foundry CI and mirrors them in a TypeScript monitor.
Scope. Independent research demo, with no affiliation with Base, Coinbase or any protocol named in the replays. Vault.sol is a teaching example with a permissionless mock oracle, no bad-debt reserve and no governance.
How it works
src/Vault.solis an interest-bearing, over-collateralized lending vault with two assets. Lenders supply the debt asset, and borrowers post a separate collateral asset priced by an oracle.- A Foundry invariant harness drives the vault with eight handlers (deposit, collateral, borrow, time warp, liquidate, donation, oracle moves and reentrancy) and asserts the 12 invariants after each call. INV-01, protocol solvency, says idle cash plus debt owed must cover everything lenders can claim.
guardian/src/evaluator.tshas one check per invariant. The monitor runs it per block as a daemon, or once from a scheduled GitHub Actions workflow, and writes violations to Supabase.- A React dashboard reads Supabase and shows invariant health, alerts and the assurance panels.
- The assurance layer computes the Assurance Methodology Coverage (AMC) score from coverage, the exploit replays and the finding bindings. CI fails if it drops below 80.
Results
- 92 Foundry tests. 39 unit and boundary, 8 parameterized fuzz, 13 invariant, 9 differential, 10 exploit replays and 13 mutation tests. The mutation tests break the vault on purpose and assert that the matching invariant catches each break.
- A real bug found. The solvency invariant caught a full-close repayment that eroded the solvency margin by one wei during development. The self-review records it as GUA-02, High, Resolved.
- 10 mechanism replays, 10 prevented, 0 missed. Each test requires the attack to drain a deliberately weakened copy of the vault and to fail against the real
Vault.sol. These are rebuilt mechanisms, not replays of mainnet transactions. - Coverage.
Vault.solhas 100% line coverage (130 of 130 lines, 28 of 31 branches), observed on 2026-10-21. - Self-review. 8 findings, GUA-01 to GUA-08: 3 resolved and 5 acknowledged. All 8 are bound to a re-runnable check.
- AMC score. 94/100 (grade A) on 2026-06-10. It is self-graded. The same author writes the invariants, picks the exploit set, binds the findings and grades the result.
How it was checked
The README records forge test passing all 92 test functions on 2026-10-21, plus 50 of 50 assurance tests and 66 of 66 monitor tests. The CI invariant campaign runs 2,000 runs at depth 150 on every push and pull request to main. On 2026-10-21 that campaign made 300,000 handler calls in 135 seconds, and all 13 invariant functions passed. CI has 7 jobs, including a harness-to-monitor parity check and Slither and Aderyn static analysis.
Limits and next steps
- The security review is a self-review, not a third-party audit.
- Fuzzing does not prove the invariants. No Certora or Halmos proof exists yet, and the invariant docs name INV-01, INV-04 and INV-06 as candidates for one.
- The monitor is a best-effort reference implementation with no uptime promise. Its scheduled workflow last ran on 2026-08-23, and GitHub has since disabled it for inactivity. On 2026-10-21 the live dashboard showed “Guardian down” and no recent checks, so this page doesn’t link it as a demo.
- The staged demo is not an exploit. It forces an INV-01 violation so the monitor has something to catch.
Links
Completed: October 21, 2026
