Inspiration

We asked ChatGPT and Claude to add a CSV import and a webhook to a small order service. The service already had validate_order(). One of the patches did not use it and wrote its own checks in two new places. All tests were green. When we then changed the rule (qty must be 1 to 100) in validate_order(), the CSV import and the webhook still accepted qty 101. CI had no way to notice.

What it does

Veridiffy checks an AI patch against the rules of the project (verdiff.toml) and returns ALLOW or BLOCK. For every problem it shows the rule, the file, the line and the reason. BLOCK exits with code 1, so the pull request cannot be merged.

There are 55 rules. 30 of them come from Clean Code (duplication, small functions, error handling, tests, names) and always run. The others are off until a team turns them on, so a small patch is checked in a few seconds. Some rules only read the code, for example "every entry point must call validate_order()" or "no second copy of the check". Others run it: we apply the next requirement once in the validator and send test orders through every entry point (API, CSV, webhook, CLI) to see which ones still let a bad order in. Each rule is BLOCK or WARN and has a weight, and the weights add up to a risk score.

The result does not depend on luck. The gate uses no AI and no network, so the same code and the same rules always give the same report and the same hash. The app runs the gate twice and shows that the hashes match.

We tested it on 8 real patches from ChatGPT, Claude and models on the PERUN supercomputer (DeepSeek, GLM, gpt-oss). 7 of them pass all tests, 1 passes the gate.

How we built it

The gate is Python with only the standard library. It parses the code with ast, compares conditions part by part to find copies of the rule (also ones with a different operator, like >= 1 instead of > 0), and runs each entry point in a separate process on a temporary copy of the project. A GitHub Actions workflow runs it on every pull request.

The app is React, TypeScript and Tailwind, packaged with Electron. In the Demo tab you send the same task and the same code to Claude, ChatGPT and the PERUN models, and each answer opens as a pull request page: what to fix, where, and the flagged lines. You can edit a file and check it again, or let an AI model fix the broken rules. You see every step live (gate, model, gate again), and a saved fix can be replayed in seconds, with the gate checking it again for real.

Challenges we ran into

Getting exactly the same result twice took work: separate processes, a fixed hash seed and a hashed report. The other hard part was telling a real copy of the rule from code that only looks similar.

We also did not want a model to get past the gate by writing the same mistake differently. So we wrote each mistake in several other ways (other names, a helper function, reversed comparisons, except Exception, contextlib.suppress) and made the rules catch all of them, while correct code written differently stays clean.

Accomplishments that we're proud of

When the models saw only part of the project, every one of them rewrote the validation instead of using it. Their tests still passed. The gate blocked all of them and pointed to the exact lines. An AI model can also fix a blocked patch: in our run it went from BLOCK to ALLOW in 45 seconds, and the gate checked every answer before it counted.

What we learned

Green tests only tell you that today's behaviour works. They do not tell you how many places you will have to change tomorrow.

What's next

A simple setup for any project, more languages and a GitHub App that posts the result as a comment on the pull request.

Built With

Share this project:

Updates

Submission history