How Rehearsal works

Rehearsal is a safety layer between an AI agent and an existing app. It never edits the app and never trusts the agent: it watches what the agent's tool calls would actually do to the data, and lets a person decide.

The architecture

One Synapse generated MCP server, launched twice. The only difference between the two copies is the address they call.

Rehearsal architecture The agent calls tools through Rehearsal. During a rehearsal, calls go through the Synapse generated MCP server to a shadow copy of the app. After a person approves, the recorded writes replay through the same generated server against the live app, and Rehearsal verifies the result. AI agent free model chain Rehearsal argument guard recorder and diff risk rules and audit Synapse MCP server ENDPOINT_BASE_URL = shadow Synapse MCP server ENDPOINT_BASE_URL = live Shadow copy app plus copied database Live app never edited 1. rehearse 3. replay after approval 2. row level diff for review

1. Rehearse on a shadow copy

When a task starts, Rehearsal takes a consistent snapshot of the live database using SQLite's online backup, so it is safe even while the app is busy. It starts a second instance of the app on that copy and launches the Synapse generated MCP server against it. Every tool call the agent makes, read or write, goes to the shadow and is recorded.

Before a call leaves Rehearsal, its arguments are checked against the tool's real types, taken from the app's own OpenAPI spec. Synapse types every argument as Any and pastes path arguments into URLs, so an injected order_id of 1/orders or ../admin could otherwise reach a different route. Rehearsal blocks it.

2. Review the exact changes

When the agent stops, Rehearsal compares the shadow database with the snapshot, row by row and table by table. Each changed row is traced through foreign keys to the customer it belongs to. The reviewer sees plain sentences such as Order 5003: status from delivered to partially refunded, grouped by table, alongside the money involved.

Every proposed action has a Why? button. Rehearsal notes which rows each tool call changed on the shadow, and where each id the call acted on first appeared: the reviewer's own request, a field in the app's records, or somewhere inside free text. On the demo attack it opens straight onto the sentence in the customer's message that named the order, with the number highlighted.

What the agent says is checked too. Its summary and its reply to the customer are compared with the payments actually in the changes. When the words and the data disagree, the console sets them side by side: "Processed the billing corrections" against pay out 3,428.00 USD.

Risk rules, not guesses

Flags come from simple, explainable rules rather than another model:

Risk rules
FlagLevelWhy it matters
Touches more than one customerHighA single support task almost always concerns one customer. Twelve is a red flag.
Payment above the approval limitHighLarge refunds or credits need a manager, whatever the agent was told.
Acts on records named only inside message textHighEvery id an action works on is traced to where the agent first saw it. An order number that only ever appeared inside a customer's message, never in the app's own records, could have been planted by anyone.
A summary or reply reports money that is not in the changesHighThe agent says it refunded 350 dollars, but no such refund would happen. A chatbot that promises money the business never pays is a real legal risk.
Deletes recordsHighDeleted rows cannot be recovered from inside the app.
Agent read text that looks like a prompt injectionHighLlama Prompt Guard 2 scans everything the agent reads. Advisory only.
Moves money out of the businessMediumShows the total and the number of payments at a glance.
Bulk change in one tableMediumMany rows changing in one task deserves a closer look.
The summary leaves out the moneyMediumThe agent's own account of its work is checked against the changes. "Processed the billing corrections" hides twelve refunds.
Acts on records it never looked up, or a reply that skips a paymentMediumGuessed ids and customers who are not told about money moving on their account both deserve a look.
Blocked or failed tool callsMedium or lowShows the agent tried something that did not fit or did not work.
A reply that carries other customers' personal dataHighNames and email addresses of anyone but the customer on the ticket should never leave in a reply.
Looked at other customers' recordsLowNot harmful on its own, but it means a person reads the result instead of the trust policy applying it.
Breaks one of your own rulesHighColumns that must never change, protected customers, a money ceiling per task, or a daily limit per customer that counts every task applied that day, written in rehearsal.toml.

3. Decide, then verify

Approving replays only the recorded writes that succeeded, in order, through the same generated MCP server pointed at the live app. Before replaying, Rehearsal checks that live data has not changed since the snapshot; if it has, it refuses and asks for a fresh rehearsal. After replaying, it diffs live against a snapshot taken just before approval and checks the result matches the rehearsal exactly. If anything differs, or any call fails, live data is restored and the restore itself is verified.

Rejecting discards the shadow. Undo restores the pre approval snapshot and checks the result, but only when nobody else has changed live data since, so it can never erase other people's work. If a restore ever cannot be confirmed, the snapshot is kept outside the session folder so it survives a restart.

Restarting Rehearsal loses nothing a person still needs. Reviews waiting for a decision, and applied work that can still be undone, are saved with their database copies and come back with their conversation. The changed rows are worked out again from those copies, so they always match what is on disk.

Only interrupt people when it matters

Approving every click wears reviewers out, so Rehearsal has a trust policy. Work that raises no flag at all, such as a reply or a ticket status change for one customer, is applied without asking. It goes through exactly the same verified replay, the audit log records the policy as the decider, and it can be undone. Money, more than one customer, or anything unusual always waits for a person.

4. Every step is on the record

Each rehearsal, tool call and decision is appended to an audit log in which every entry carries the hash of the one before it. Editing an entry, or removing one from the middle, breaks the chain, and the console shows whether the chain is intact. Set REHEARSAL_AUDIT_KEY, kept away from the log, and the hashes are keyed, so nobody can recompute the chain after an edit.

Works with the app you already have

Nothing about Rehearsal is specific to the demo store. A short rehearsal.toml file says how to start the app, which environment variable points it at a database, and which tables represent money and owners. Point it at another Synapse built app and the same shadow, review and replay cycle applies.

Today the shadow copy works with apps backed by SQLite. Postgres support would use template databases or branching, with the same review and replay cycle on top.