Overview
The Tools Gateway (also called the IO Service) is the only permitted path for executing side effects in Allternit. It runs as a standalone Axum service that receives tool execution requests, enforces policy, journals every call to the history ledger, and dispatches to the correct adapter. Every tool call that performs IO, invokes an external system, or mutates state must flow through this gateway. Kernel services and runners remain pure logic layers; the gateway owns execution.The gateway binds to
127.0.0.1 by default and is intended for internal use. Direct exposure to the public internet is not recommended.Responsibilities
Base URL
The gateway is mounted on its own port:Running the gateway
Build and run the service from the crate root:io-service identity.
Endpoints
Health check
Execute a tool
POST /v1/tools/execute is the only permitted side-effect path. The gateway validates the request, checks policy, derives a filesystem write scope from run_id, executes the tool, writes a receipt, and appends the result to the history ledger.
Request body
Response body
Error shape
Register a tool
POST /v1/tools registers a ToolDefinition with the gateway. Tools must declare their adapter type, input/output schemas, side effects, safety tier, and resource limits.
Tool types
The gateway dispatches each tool to an adapter based ontool_type:
Tool definition fields
List registered tools
The current handler returns an empty array. The underlying
ToolGateway::list_tools() method is implemented and can be wired to the REST surface as the registry expands.Policy and sandboxing
Before any tool runs, the gateway builds aPolicyRequest and asks the policy engine for a decision:
identity_id:io-serviceresource:tool:{tool_id}action:executerequested_tier: the tool’s declaredsafety_tier
Deny, execution aborts and the caller receives a TOOL_EXECUTION_FAILED error with the policy reason.
Filesystem sandbox
The REST handler derives aWriteScope from run_id:
/.allternit/artifacts/{run_id}/**/.allternit/receipts/{run_id}/**
/.allternit/, targets denied paths, or touches another run’s receipts.
Idempotency and receipts
Tools that declare side effects require anidempotency_key. The REST surface supplies correlation_id as the idempotency key.
After each execution the gateway writes a receipt under /.allternit/receipts/{run_id}/ containing hashes of the tool definition, policy decision, inputs, outputs, and execution metadata. This enables deterministic replay and audit trails per LAW-ONT-008.
MCP bridge
The gateway includes an MCP bridge that connects to MCP servers over stdio or SSE and registers their tools under prefixed names:Error handling
Common
TOOL_EXECUTION_FAILED messages: