← Projects

Toast — Behavioral Diffing For AI-Generated Pull Requests

Active
Python 3.12HypothesisRichGit worktreesHatchlingGitHub Actionspytest
View Repository →
▶Product demo

Problem

AI-written code is often almost right but not quite, and that kind of bug reads as correct, so a human review does not catch it. A 500-line AI pull request leaves a reviewer reading everything by hand, or trusting it.

Business Impact

Toast is for teams that merge AI-generated pull requests and want something firmer than a read-through. It sorts every changed function into identical, diverged, or could-not-be-checked, so the report accounts for the whole diff. A reviewer can start with the diverged functions and the exact inputs that break, instead of rereading all of it.

System Approach

  • Git is the oracle: the base commit is loaded through a temporary git worktree and compared with the head version.
  • Each changed function is called with the same generated inputs in sandboxed subprocesses, and any difference in return value or raised exception is recorded.
  • Inputs are mined in order from literals in the function (plus and minus one, to catch off-by-one changes), literal arguments from the project's own tests, Hypothesis strategies built from type hints, and a corpus of gnarly values.
  • Changed functions are risk-ranked into a reading order using signals such as comparison changes, removed returns or raises, error-path edits, and risky identifiers.
  • Output is a terminal report, with --json and --markdown modes, and a GitHub Action that posts the brief as a PR comment.

Key Decisions & Trade-offs

  • Every changed function lands in exactly one bucket (identical, diverged, unverifiable), so nothing is skipped silently.
  • Functions that do I/O or use nondeterminism are detected with the AST and gated, not run, because running them would have side effects.
  • Output says 'identical across N probes' and prints N, and never says 'verified', since probing is evidence and not proof.
  • Methods, async functions and nested functions are reported unverifiable with a reason instead of being guessed at.
  • Runs are deterministic for a given --seed, so a finding can be reproduced.
  • The CI gate (--fail-on diverged) is off by default, so the tool starts out informational.

Current Status

Version 0.1.0, MIT licensed, with a pytest suite covering boundary flips, dropped exception handlers, pure refactors, I/O gating and bucket accounting. Install with uv tool install toastcheck or pip install toastcheck, then run toast check --base main inside any git repo.

Roadmap

  • Support methods, async functions and nested functions, which are reported unverifiable today
  • Support languages other than Python
  • Offer stronger isolation than subprocess plus timeout

What I'd Improve Next

  • Python only, and only module-level functions in v1. Anything else is reported unverifiable.
  • The sandbox is a subprocess with a timeout and is not a security boundary, so it should not be run on code you do not trust to execute.

Explore More