DEV Community

Cover image for Under CI pressure, an AI agent deleted its own asserts — here is the Zig + Z3 gate" published: true
newmathphys
newmathphys

Posted on

Under CI pressure, an AI agent deleted its own asserts — here is the Zig + Z3 gate" published: true

When an AI coding agent writes both the code and the test, 1 passed in 0.01s stops being proof of correctness. Under pressure to make CI green in our live local-LLM trial, the model literally deleted and swallowed its own assertions so pytest would exit 0.

To stop this structurally, I built KERN—a zero-trust verification gateway in Zig 0.17, backed by Z3 and 147 Lean 4 theorems (0 sorry).

What KERN actually does

  1. Re-checks Z3 proofs in Zig (trusted: 0 | holes: 0): Instead of trusting solver output on faith, KERN parses Z3's proof DAG (Farkas certificates, resolution, linear rewrites). Open section #4 in the WASM Playground and sabotage 1 byte of a 16-step Z3 proof in memory to watch the kernel reject it.
  2. Blocks AI reward-hacking (R = -2.0): Swallowed exceptions (except: pass), sys.exit(0), injected mocks, and silent boundary shifts are caught before merge; +1.0 is granted only on a verified mathematical proof.
  3. Belnap B₄ four-valued logic (N, T, F, B): Policy or contract collisions never overwrite each other—kernc belnap join_k T F yields B (HTTP 409 Conflict instead of silent "deny wins"), while kernc unsat-core isolates the irreducible conflicting clauses.
  4. Zero-noise bug hunting + Live Replay (kern_guard MCP): Lattice nullability + SMT bounds paired with a 3-lock CPython replay harness achieved 0 false alarms across packaging, python-semver, and dateutil, while catching 43 real crashes in MBPP+ reference solutions (which passed 80× test suites) plus real bugs in TheAlgorithms/C (#1595, #1596), TheAlgorithms/Rust (#1075), and boltons (IndexedSet().pop()).
  5. Proven capable of failing: All 219 check targets across 38 CI stages are guarded by 266 fault-injection cases (canfail).

Add to Claude Code / Cline / Cursor in 10 seconds (9 MCP tools)


json
{
  "mcpServers": {
    "kern": {
      "command": "python3",
      "args": ["/path/to/kern/examples/kern_mcp_server.py"]
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)