Inspiration
AI coding agents write good code fast. But they often solve a problem the project already solves, just in a new place. The tests stay green, the build stays clean, the reviewer approves. One copy is harmless. Hundreds of them turn a codebase into many parallel answers to the same question, and every later change gets more expensive: developers and agents first have to work out which version is the real one, and then find all the others.
The challenge put it plainly: build a gate that keeps the codebase readable and easy to change as AI writes more of it. It must be deterministic, state which rule was broken, and block the merge even when every functional test passes. We liked that a passing CI can be technically true and practically misleading, hence the name: Green CI Lies.
What it does
A project declares its rules in one file, quality.yml. For example: "dispatch eligibility lives in app/policy.py::can_dispatch, at most one definition". On every pull request, gcl gate compares the patch with its merge base and returns PASS (exit 0) or FAIL (exit 1). A FAIL names the rule, every file:line where it is broken, the normalized form of the condition, and the fix.
The verdict is a pure function of its inputs:
$$ \text{verdict} = \operatorname{gate}\big(\text{code at SHA},\ \operatorname{sha256}(\texttt{quality.yml}),\ \text{engine image digest}\big) $$
No LLM, no network and no clock take part in it.
For a rule $r$ with canonical owner $o_r$, RULE-SPREAD fires when
$$ \Big|{\, \ell \in L \;:\; \operatorname{norm}(c_\ell) = \operatorname{norm}(c_{o_r}) \,}\Big| > m_r $$
where $L$ is the set of conditions in the patched code, $c_\ell$ is the condition at location $\ell$, $m_r$ is max_definitions from quality.yml, and $\operatorname{norm}$ maps a condition to a canonical form. Renamed locals, reordered and operands, and not (a == b) versus a != b all collapse to the same fingerprint.
In the demo, patch B copies the dispatch rule into the portal, the API and the batch job, each time with different variable names. The gate still finds all three: app/api.py:5, app/batch.py:2, app/portal.py:2.
How we built it
Engine (Python 3.12,
ast+libcst)- Parses Python, normalizes conditions and indexes the base branch.
- Five rules:
RULE-SPREAD,DUP-RULE,DUP-HELPER,NON-CANONICAL,PROTECTED-FILE. - Writes a canonical, hashed
report.json, areport.mdfor people and LLMs, and SARIF 2.1.0 for GitHub code scanning.
Determinism by construction
- Locked dependencies,
PYTHONHASHSEED=0, sorted output. - An engine image pinned by digest.
gcl verify --repeat 10checks that $h_1 = h_2 = \dots = h_{10}$ for the report hash.
- Locked dependencies,
Probe measures what a copy costs. It injects a new requirement ("every order needs a shipping label") at each location, runs the acceptance tests per entry point, and finds the smallest set of edits $S$ that covers every path:
$$ S^{*} = \arg\min_{S \subseteq L} |S| \quad \text{s.t.} \quad \forall e \in E:\ \operatorname{pass}(e, S) $$
where $L$ is the set of candidate locations and $E$ is the set of entry points (portal, API, batch). The answer: $|S^{}| = 1$ for patch A and $|S^{}| = 3$ for patch B.
Server: FastAPI, PostgreSQL, Redis/Arq. Workers run the engine in a sandbox with
--network none --read-only --cap-drop ALLas an unprivileged user, post thegcl/gatestatus to GitHub, and stream live updates over SSE.AI fixer turns a failed report into a prompt for an LLM, gets a unified diff back, and pre-checks it with the same gate, up to three attempts. A person then approves that exact patch, bound to its SHA-256, and the gate runs again on the new commit. Approval never bypasses the gate.
Console: React + TypeScript, with types generated from our OpenAPI contract: runs, findings, fix review, A/B comparison, rules and the audit log.
Process: seven people, a protected trunk-based monorepo, and contracts frozen in the first two hours. The gate runs on its own repository in CI, so our code had to pass it too.
Built With
- alembic
- arq
- caddy
- ci-cd
- code-quality
- docker
- fastapi
- ghcr
- github-actions
- libcst
- postgresql
- python
- react
- redis
- ruff
- sarif
- semgrep
- sqlalchemy
- static-analysis
- tanstack-query
- typescript
- uv
- vite

