Local audit log
zn-gate records each shield decision in a hash-chained local log that you can verify, browse and export.
zn-gate shield appends each decision to ~/.zn/evidence.jsonl: time, tool, verdict, rule, latency, a SHA-256 of the payload and a secret-redacted preview. The log stays on your machine.
When an agent hook blocks something or hides a secret in a tool result, that also appears here as an event: the agent, the kind of event, the tool name, the rule name and the kinds of secret, never a value, a command, a path or prompt text. Calls that were allowed are not written. A problem with the log never turns a block into an allow.
Records are chained with SHA-256, so verification detects accidental or partial edits. It is not tamper-proof: someone with write access to the file can recompute the whole chain.
Commands
# Verify the chain from the first record to the last
npx -y zn-gate evidence --verify
# Show totals and the last 20 decisions
npx -y zn-gate evidence --tail 20
# Open a local dashboard on http://localhost:3100
npx -y zn-gate evidence --ui
# Export (JSONL by default, or CSV)
npx -y zn-gate evidence --export --format csv --output audit-report.csv
zn-gate logs is an alias of zn-gate evidence.
Explain a block with zn why
npx -y zn-gate why
npx -y zn-gate why <id>
zn why explains, in plain words, the last block in your decision log, or the record with the id you give it (the id field of a record from zn-gate evidence --export). It says what was stopped (the tool and the short preview the log already holds, with secrets removed), which rule fired, why that matters, and the command you can run in your own terminal to go on, when there is one. For a rule that cannot be bypassed it says so and who decides.
It only reads the log: it changes nothing and uses no network. If the log does not hold enough to explain a record, it says what is missing instead of guessing. It exits with 0 when it explained a record, 1 when there is nothing to explain (no log, no block, an id that is not in the log, or a log that cannot be read) and 2 for wrong usage. zn why is in the npm package only. Six block messages now also name the rule, say why it matters and give the one command to run.
From Python
from zn_gate import log_evidence, verify_evidence_ledger, get_evidence_stats
log_evidence({"agent": "my-agent", "phase": "tool-call", "tool_name": "bash",
"payload": "cat ~/.ssh/id_rsa", "verdict": "block", "rule": "path:sensitive_file"})
report = verify_evidence_ledger()
print(report["valid"], report["total"])
print(get_evidence_stats())
Node.js and Python write the same format, so either can verify a log written by the other.
Damaged or busy log
If the log holds unreadable bytes or a cut-off last line, evidence --verify reports it as corrupted with the line number (non-zero exit). A damaged log is never used to start a new chain: the event is not written, a warning is shown (the first time, then at most every 5 minutes) and your command or agent carries on. To recover, move the file aside so the old one stays for review; the next event starts a new chain. From 1.17.0, evidence --verify says when the last record is incomplete, cut off by a crash or a full disk or removed by someone. It is not called tampering, because zn cannot tell the two apart, but it is never shown as harmless: the log still counts as not verified and the output explains how to start a new log. Any other unreadable last line, and any record changed in the middle of the log, is still reported as tampering. A new record is written on its own line even when the file does not end with a newline, and a full disk no longer leaves empty lock files that make later records wait.
mv ~/.zn/evidence.jsonl ~/.zn/evidence.damaged.jsonl
On Windows, in cmd: move %USERPROFILE%\.zn\evidence.jsonl %USERPROFILE%\.zn\evidence.damaged.jsonl; in PowerShell: Move-Item $env:USERPROFILE\.zn\evidence.jsonl $env:USERPROFILE\.zn\evidence.damaged.jsonl.
Several processes can write to the same log at once, for example two agents in one project, or the Node.js and Python packages together. Each write takes a short lock (~/.zn/evidence.jsonl.lock) so the chain stays in one line. If the lock stays busy for 2 seconds, or the log cannot be written (for example, no permission), that event is skipped with a warning and the command carries on. A lock left by a crashed process is removed after 10 seconds.
Cloud evidence
Requests to the optional zn Cloud API return an evidence_id that you can look up in the dashboard. Retention depends on your plan (see pricing and the privacy policy).