tool-gate is a small Rust library and CLI for deciding whether an autonomous
agent should run a tool invocation. It does not execute tools. It accepts
caller-supplied JSON metadata, evaluates explicit policy rules, and emits a
machine-readable decision receipt: allow, deny, or review_required.
The crate is intentionally data-source agnostic. Tool catalogs, queues, agent
frameworks, storage layers, and LLM providers all remain outside the core. Bring
your own adapter, pass in a ToolMetadata plus an InvocationEnvelope, and use
the receipt to gate execution in your application.
tool-gate is the ARDA safety boundary between an agent's proposed action and a
runtime's permission to execute it. It makes tool decisions deterministic,
auditable, and portable: every invocation is reduced to explicit metadata,
policy checks, and a machine-readable receipt before side effects happen.
git clone https://github.com/dward1502/Arda-tool-gate.git
cd Arda-tool-gate
cargo run -- check examples/readonly-tool.metadata.json examples/readonly-tool.invocation.json
cargo testUse the CLI against local metadata and invocation JSON first. Production systems should feed the resulting decision receipt into their own execution runtime rather than letting agents bypass the gate.
flowchart TB
Agent[Autonomous Agent] --> Intent[Tool Invocation Intent]
Intent --> Envelope[Invocation Envelope]
Catalog[Tool Metadata Catalog] --> Gate[tool-gate Policy Engine]
Envelope --> Gate
Gate --> Decision{Decision Receipt}
Decision -->|allow| Runtime[Execution Runtime]
Decision -->|review_required| Operator[Human Review]
Decision -->|deny| Audit[Denied Action Log]
Runtime --> Audit[Audit Receipts]
Operator --> Audit
Tool Gate is ARDA's pre-execution policy boundary. Agent Loop can propose work, Council can deliberate on risk, and HUD can expose review surfaces, but Tool Gate is the deterministic receipt-producing layer that says whether a requested tool invocation is allowed, denied, or requires human review.
Active Rust library and CLI. The core is intentionally adapter-free: callers bring tool catalogs, queue integrations, storage, sandboxing, and authentication.
Autonomous systems often need a simple boundary between "the agent wants to do
something" and "the system is allowed to do it." tool-gate gives that boundary
an auditable shape:
- explicit risk levels for tools;
- target-scope checks before execution;
- trace requirements for mutating or reviewable actions;
- idempotency checks for state-changing tools;
- deterministic JSON receipts that are easy to log, test, or review.
git clone <your-fork-or-repo-url> tool-gate
cd tool-gate
cargo build --releaseRun from source during development:
cargo run -- check examples/readonly-tool.metadata.json examples/readonly-tool.invocation.jsontool-gate check <tool-metadata.json> <invocation-envelope.json>
tool-gate schema tool-metadata
tool-gate schema invocation-envelope
tool-gate schema decision-receiptExit codes:
| Code | Meaning |
|---|---|
0 |
Invocation is allowed. |
2 |
Invocation is valid, but human review is required. |
3 |
Invocation is denied by policy. |
64 |
CLI usage error. |
65 |
Invalid input JSON or schema mismatch. |
70 |
Internal error. |
{
"schema_version": "tool-gate.decision.v1",
"decision": "allow",
"reason": "invocation passed policy checks",
"risk_level": "low",
"requires_review": false,
"trace_id": "trace-readonly-001",
"policy_checks": [
{
"check_id": "input_valid",
"status": "pass",
"message": "metadata and invocation are structurally valid"
},
{
"check_id": "target_allowed",
"status": "pass",
"message": "target matches allowed scope"
}
]
}use tool_gate::{evaluate_invocation, GatePolicy, InvocationEnvelope, ToolMetadata};
let metadata: ToolMetadata = serde_json::from_str(metadata_json)?;
let invocation: InvocationEnvelope = serde_json::from_str(invocation_json)?;
let receipt = evaluate_invocation(&metadata, &invocation, &GatePolicy::default());
println!("{}", serde_json::to_string_pretty(&receipt)?);The default policy is conservative for actions that can change state:
- validate the metadata and invocation envelope;
- check that the invocation target matches the tool's allowed target patterns;
- require trace evidence for mutating or reviewable actions;
- require mutating tools to be declared idempotent;
- require review for explicitly reviewable or critical-risk tools.
tool-gate is deliberately not a sandbox. It is a deterministic pre-execution
policy gate that should be paired with your own authentication, authorization,
sandboxing, and execution runtime.
The examples/ directory includes:
readonly-tool.metadata.jsonandreadonly-tool.invocation.jsonfor an allowed read-only action;mutating-idempotent.metadata.jsonandmissing-trace-denied.invocation.jsonfor a denied mutating action.
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test
cargo doc --no-depsLicensed under either of Apache License, Version 2.0 or MIT license at your option.