Architecture
The package is the engine of the Shield: what must work without Datalayer's runtimes lives here; the runtimes host it.
The policy
One document per scope — organization, team, session — with rules, limits, a fetch allow-list and the MCP servers lent. The strictest scope decides first and the first decision wins; a scope that says nothing passes the action down; nothing a rule names falls to ask me first. Every action is classed — read, write, send, buy, delete, execute — from ACP's tool kinds (other fails closed to write). Limits are stateful: a soft threshold asks once, a hard one refuses each call that would cross it and says what would let the session go on.
agent_shield.policy.decide(action, context, policies) is pure and returns the verdict, a sentence, and the scope and rule that decided. The schema is published as schema/policy.schema.json.
Three levels: on Datalayer the organization's document comes from IAM, the Appspec's Rules are the team's, the session's is the default plus what a person allows or tightens while it runs. The engine gives the strictest answer in every order the documents are given; a lower document may only tighten — agent_shield.policy.widening(lower, above) says in sentences where it would permit more (a rule that permits more than an overlapping rule above, a limit above, a fetch host, an MCP server or a harness the scope above does not list, a credentials rule not kept), and IAM refuses a team document, the runtime a session rule, with them.
The model limits: limits.model_tokens (the budget) and limits.spend (credits, 100 a USD), soft then hard like the others; decide_budget(context, policies, tokens=, cost=) decides the next model request against them alone, and a hard limit's sentence says what would let the session go on.
The harnesses: harnesses.admit names the harnesses a scope admits, harnesses.credentials whose key runs them (account, the person's own declared secret, is the default).
Managed from the SaaS
agent_shield.saas.ManagedPolicies pulls the documents of an account from IAM — GET /mcp-policies/shield/accounts/{account_uid}, the organization's and the teams' shield documents, each with its version and an expires stamped at the serve — keeps them until expires, takes one pushed over a socket, and polls every 30 s while a watcher runs, so an administrator's change reaches a running Shield within a minute. It fails closed: with IAM unreachable and no unexpired copy, PolicyUnavailable names IAM in a sentence; at creation the harness is refused with it, while running every further action is. No policy lives only in a pod, a file or an environment variable.
The proxy
agent-shield run -- <command>: an ACP agent on the Shield's stdio in front of the agent it launched. Permissions are decided by the policy; the agent's tool calls are classed and limited; fs/* and terminal/* are answered against the workspace (a path outside it is refused; a command runs with a trimmed environment); mcpServers are rewritten to the allow-list; every action is written to ~/.agent-shield/audit.jsonl with credentials redacted. allow_always chosen by a person becomes a rule for the session, gone with it.
The proxy passes the ACP Test Compatibility Kit in front of the test agent (VERDICT: CONFORMANT, 15 October 2026).
The register
The harness catalogue and the register live in agentspecs (harnesses/): each harness with its adapter, the version pinned, licence, terms, credential kind, whether serving it to third parties is permitted, and tier restrictions. The Shield reads them and refuses what the register forbids.
The server
agent-shield serve is the proxy as a server (see serve and registration): one listener, WebSocket and ACP Streamable HTTP on /acp, a ShieldProxy per connection, the token in the header or the first message; --bridge the same listener with no Shield, for the sidecar; agent-shield connect the mirror for clients that start commands.
Built and not built
Built: in 0.1.2 the policy engine with the three levels, the model limits and the harnesses section, the SaaS client pulling policies from IAM and failing closed, the register, the stdio and WebSocket client channels, the normaliser, the proxy with session rules while running, the audit, the command, the TypeScript types; in 0.1.3 serve over both transports, connect, the bridge, the OTEL export from a standalone Shield, registration with Datalayer, the generated TypeScript types, the diff and terminal displays and the report renderer. Since: the conformance report with the Shield section, in Validate (0.1.6 to 0.2.5); in 0.2.6 PAP lent by a registered run --pap. Not built: the Shield section's what changed comparing two kept reports; IAM serving a service agent's organization documents, which a registered standalone Shield waits on.