Architecture
How zn-gate is built. Three checkpoints around every agent action, and the principles behind them.
zn-gate is a small checkpoint that runs on your machine, between your coding agent and everything it reads and runs. It looks at three moments of every action and stays out of the way the rest of the time. This page explains the layout and the principles behind it. For the pieces in detail, see How zn-gate works.
Three checkpoints
| Step | Checkpoint | When | What it does |
|---|---|---|---|
| 1 | analyze_prompt |
Before the agent acts on a prompt or on content | Looks for prompt injection, jailbreaks and secrets pasted into the text |
| 2 | check_tool_call |
Before a tool runs | Checks the arguments for injection, exfiltration patterns and sensitive paths. A blocked call never reaches the tool. Secrets in the arguments are masked |
| 3 | check_tool_result |
After the tool runs, before the model reads the output | Redacts secrets and neutralizes indirect prompt injection. A result that carries an injection is replaced by a short notice |
Each checkpoint answers allow or block and names the rule and the reason that decided it. The same three checks work in each of the ways zn-gate can be set up: agent hooks, the MCP server, or zn-gate shield in front of your other MCP servers. The setups and what each one covers are in How zn-gate works.
Principles
- Few dependencies. The Python package uses only the standard library. The npm package has one runtime dependency,
age-encryption(with its@nobleand@scurelibraries), which encrypts the secret vault. It is bundled in the package at the versions pinned inpackage-lock.json, and nothing is compiled on your machine. - Local and predictable first. The checks run on your machine with fixed rules: pattern matching plus normalization of look-alike characters, zero-width characters and encoded text. The same input gives the same answer, and every answer names its rule. The last 2,048 results are cached, so repeated text is checked once. Measured times are on the Performance page.
- An optional second opinion from the cloud. Only prompt analysis can ask the cloud classifier, and only after you turn it on: set both
ZN_API_KEYandZN_CLOUD=1, or runzn-gate connect.ZN_LOCAL_ONLY=trueturns it off again. Text the local rules already block is never sent, and secrets in the text are removed on your machine before anything is sent (personal data is not). Tool arguments, tool output and tool descriptions never leave your machine, in any setting. Details: What leaves your machine. - A tamper-evident local log. Each decision recorded by
zn-gate shieldand the SDKs is added to~/.zn/evidence.jsonlwith a SHA-256 hash that links it to the previous one, with a redacted preview and never the secret itself.zn-gate evidence --verifychecks the chain. It detects accidental or partial edits, but it is not proof against someone who can write to the file, because they can recompute it. See Evidence.
What this layout does not do
- It is one boundary, not your whole security model. Keep least-privilege tool scopes and human review for high-impact actions.
- What the checkpoints can see depends on how zn-gate is set up and on the agent. An MCP server alone only sees the calls your agent chooses to send it. The hooks also cover the agent's built-in tools, to the extent each agent allows. See Threat model.
- The local rules are not a semantic classifier: paraphrased attacks can get through.