Srijan Guchhait

A merge gate that does not trust the agent

How a lead session, per-task lanes and an evidence-carrying ready command keep a multi-agent coding harness honest.

  • agents
  • tooling
  • typescript

I use coding agents every day. The failure I fear most is a confident "done" that nobody checked. I built a harness to make that claim hard to make. One rule does most of the work: a task is finished when the world agrees, not when the agent says so.

The three roles

The harness runs on two pieces of third-party software. One is a terminal runtime that gives me workspaces, tabs and panes. It reports whether each pane is idle, working, blocked or done. The other is an open-source coding agent. My part is a TypeScript program on Bun that coordinates them. It has no runtime dependencies.

Each role is an agent session in a pane.

  • The lead is the only session that talks to me. It turns a request into a brief, opens work, reads the results and decides on merges.
  • A lane is one session for one task. It runs in its own tab, starts from a written brief and reports its progress.
  • The duty session watches the lanes. It never talks to me.

A brief states the goal, the inputs, the deliverable, the stop condition and the constraints. The stop condition matters most. If a lane cannot say how it will know it is done, it should not start.

Ready needs evidence

A lane finishes with the ready command. The command refuses to run without an evidence link. That changes what the agent writes. "Fixed the flaky test" becomes "Fixed the root cause in this pull request, checks green", with the link attached.

The lead does not trust the link by itself. It checks the claim against live state. Is the pull request merged? Is the issue closed? Is the version published? Does the command pass? Does the URL answer? A claim that fails the check goes back to the lane as not done. A lane with unpushed work cannot close.

The gate

Merging is where an unchecked claim does the most damage, so the gate is strict. A merge needs two things at once.

  1. A review receipt that says CLEAR. A fresh reviewer session writes it, pinned to the exact head commit.
  2. Green checks.

Two details carry the weight. First, the receipt belongs to a commit SHA. If anyone pushes after the review, the receipt no longer matches and the merge is refused. Second, an empty list of checks is never green. A repository with no CI has passed nothing. Treating "no failures" as "success" is the quiet mistake this gate prevents.

The final merge command passes the reviewed SHA to GitHub. If the branch moved after the review, GitHub refuses the merge as well.

A refused merge

The lead can rehearse a merge before it commits to one. The dry run prints either an OK line or a refusal with the reason.

gate merge my-org/my-repo#12 --dry-run
# MERGE_OK ... (dry run)
# or: MERGE_REFUSED <why>, exit code 2

The gate fails closed. A refusal has its own exit code and a plain reason. The lead has to fix the reason. It cannot step around the gate.

One voice

Only the lead reports to me, and it reports a code change after the merge. It sends the pull request and the merge commit in one short message. Lanes and the duty session stay silent toward me. I made this rule because several automated reporters turn a chat into noise within a day.

State on disk

The harness keeps lanes, inboxes, briefs and review receipts as JSON files. A restart reads them back. There is no database. I can inspect any decision with cat, and I can repair a bad state by editing a file.

What I would copy

If you build a harness of your own, start with four rules.

  • Make every done claim point at something you can check.
  • Tie every approval to an exact commit, not a branch name.
  • Treat an empty set of checks as a failure.
  • Let exactly one session talk to the human.

With these rules in place, a wrong "done" fails at the gate instead of reaching main.

← All posts