How Tripwire works
Tripwire is a local MCP server plus a loopback operator console. An agent sends structured file actions to the server; the gateway decides whether each one runs now, waits for the owner, or is refused.
Parts
| Part | Code | Role |
|---|---|---|
| Owner profile | tripwire/gateway/profiles.py | The task, capability policy and fusion settings. Lives outside the workspace. Agents cannot edit it. |
| Capability policy | tripwire/gateway/capabilities.py | Which paths can be read or written, byte limits, protected paths, and which write roots are automatic. Authoritative. |
| Fusion | tripwire/gateway/fusion.py | Combines the policy decision with advisory risk signals. Signals can only raise a decision to review. |
| Local model | tripwire/gateway/local_model.py | Portable TF-IDF + logistic regression, run in pure Python from a JSON export. Advisory. |
| Liquid advice | tripwire/gateway/decision_models.py | Optional remote model (Liquid d1.1 via OpenRouter). Off by default. |
| Runner | tripwire/gateway/runtime.py | Reads, writes and patches files, applies change sets all-or-nothing with a recovery journal, runs owner-defined commands without a shell, issues and consumes approvals, writes the audit record. |
| Gateway | tripwire/gateway/approvals.py | Proposal lifecycle and status, tickets and their expiry, resume, cross-process locking, profile invalidation, change-set recovery on start. |
| MCP proxy | tripwire/gateway/proxy.py | Relays any MCP server's traffic; logs (shadow) or enforces tool-name rules for each tools/call. |
| Rehearsal | tripwire/gateway/rehearsal.py | Replays saved proposals and scenario files against a draft profile; executes nothing. |
| MCP server | tripwire/gateway/mcp_server.py | stdio tools the agent sees. |
| Operator console | tripwire/gateway/operator_console.py | Loopback web UI: inbox, policies, activity. |
Life of an action
- The agent calls an MCP tool, for example
tripwire_patch_file(path, expected_sha256, edits). - Policy evaluates the action:
allow,needs_approvalorblock. A block ends here. - Fusion adds advisory signals. The local model's block probability, and (if the profile requires it) the Liquid model's
1 - task_relevantandsuspicious_instructions, are combined bymax. If the result reaches the profile'sreview_atthreshold, or an enabled signal is unavailable, an otherwise allowed action goes to review. Signals never lower a decision. - Allowed actions run through the runner immediately (for example a write under an automatic scratch root).
- Needs approval: the gateway stores a proposal and returns its id. The owner opens the inbox, sees the exact patch, and approves or rejects it.
- The agent can wait with
tripwire_proposal_statusand then calltripwire_resume, which re-runs the stored action (retrying the same action is equivalent). The gateway checks the request against the approval (same task, context, action, profile), consumes the single-use ticket, and only then touches the file. An expired approval sends the proposal back to the inbox. - The runner resolves the path without following links, checks the file digest for patches, writes atomically, and records tool, path and outcome in the audit log. A change set (
tripwire_propose_changes) is one proposal for up to ten files: every precondition is checked first, the originals are journaled in the state directory, and a failure restores them (ADR-0017).
Decisions
| Source | Can allow | Can raise to review | Can block |
|---|---|---|---|
| Capability policy | yes | yes | yes |
| Local TF-IDF model | no | yes | no |
| Liquid advice | no | yes | no |
| Owner approval | turns one review into one execution | n/a | owner rejection is final for that proposal |
The learned models are deliberately weak authorities because their measured limits justify it: see the evaluation. On the benchmark it was trained for, the default threshold blocks only 7% of attacks with goals it has not seen. On a probe of file actions over real project files it raised none of 66 risky actions the policy allowed (its scores rank them, AUC 0.885, but stay below the threshold), so the policy, not the model, is what protects: see the evaluation.
Approval binding
A review hash covers the task, supplied context, exact action and the active profile digest. An approval expires after at most five minutes and is consumed before any file I/O. Replaying a completed or failed request is denied. Changing the profile invalidates pending proposals and tickets, including when an old profile is restored. resubmit asks for a fresh review of the same request; a rejected proposal cannot be resubmitted.
Every one of these properties has a named test: see Security.
State
| Location | Contents |
|---|---|
--profile file | Owner profile (JSON). Keep outside the workspace. |
--state-dir | Proposals, tickets, audit log, console login file, and the change-set journal while a set is being applied. Keep private. |
| Workspace | The files the agent works on. Only these are readable or writable through the gateway. |
Also in the repository
The same package contains the code that produced and measured the classifier: importers, labelling, splits, evaluation and training scripts, under tripwire/research/, plus an HTTP check service under tripwire/guard/ for scoring tool calls in a trusted application. Neither is needed to run the gateway. See Research.