Skip to main content

Hops

A hop is any unit of work in an agentic runtime that Sec0 instruments. Every hop gets a consistent identity, audit trail, and state propagation envelope. Sec0 supports seven hop types:
Hop TypeDescriptionDecorator
agentAn AI agent performing inference or work@sec0.agent()
orchestratorA coordinator that plans and delegates to agents/tools@sec0.orchestrator()
gatewayA network-boundary router that forwards to upstream servers@sec0.gateway()
serverA tool server (MCP or otherwise)@sec0.server()
middlewareAn enforcement layer wrapping tool execution@sec0.middleware()
toolA specific tool invocation on a server@sec0.tool()
skillA versioned agent skill/package invocation@sec0.skill()
Each hop is registered in sec0.config.yaml under app.hops with its type, nodeId, and type-specific metadata. Decorators resolve their configuration from this registry automatically. For package installation and import paths, see Installation (and use the Quickstart for an end-to-end setup).

Custody Chain

Sec0 maintains a custody chain, an unbroken, signed audit trail across every hop in a request graph. This is achieved through:
  1. Trace propagation: W3C-compatible traceId and spanId flow through every hop
  2. Agent state headers: Canonical state (x-node-id, x-agent-ref, x-agent-state) propagated via HTTP headers
  3. Signed audit envelopes: Each hop emits an Ed25519-signed NDJSON record with input/output integrity hashes
  4. Cause linking: Parent traceId/spanId are recorded as cause_trace_id/cause_span_id for graph reconstruction

Architecture

Sec0 enforces security at two distinct boundaries:

In-Device Security

These controls run within your application process:
ControlPackageWhat It Does
Hop decoratorssec0-sdk/instrumentationAudit trails, state propagation, trace linking for every hop
Agent statesec0-sdk/agent-stateCanonical encoding/decoding of agent state across hops
Middleware enforcementsec0-sdk/middlewareWraps tool execution with policy, audit, and runtime decision hooks
Guard APIsec0-sdk/guardApp-level allow, redact, block, and escalate checks for outbound messages, tool calls, and APIs
Agent Guardsec0-sdk/middlewareInline scanning for prompt injection, PII, secrets, toxic content, malicious code
Registry freezesec0-sdk/middlewarePrevents handler swaps and registry mutation after initialization
Source hashingsec0-sdk/middlewareDetects code changes in tool handlers and server code
SASTsec0-sdk/middlewareStatic analysis triggered on handler code/version change; blocks until scan passes
DASTsec0-sdk/middlewareDynamic analysis triggered on code/version change; generates runtime block rules with TTL

Network Boundary Security

These controls enforce policy when execution crosses process or network boundaries:
ControlPackageWhat It Does
Policy enforcementsec0-sdk/middlewareTool allowlists, version pinning, deny rules on every invocation
Bridge clientsec0-sdk/middlewarePreserves custody, trace, idempotency, and agent-state continuity across gateway calls
Gateway authsec0-sdk/gatewayOIDC JWT validation at the network edge
Entitlementssec0-sdk/gatewayPer-tenant/per-user tool allowlists and limits
Quotassec0-sdk/gatewayRate limits and daily call limits per tenant/tool
Vendor token brokeringsec0-sdk/gatewayInject upstream API keys without exposing them to agents
Idempotency/dedupesec0-sdk/gatewayReplay or reject duplicate side-effect calls
Boundary guardrailssec0-sdk/gatewayEgress allowlists, filesystem allowlists, payload limits
AP2 mandatessec0-sdk/mandate-ap2Multi-hop intent/cart verification for authorized actions

How It Works

In-Device Security

Decorators instrument each hop in your application process. The middleware wraps your tool server to enforce policy and emit signed audit logs. Each layer is decorated independently:
DecoratorWhat it instruments
@sec0.orchestrator()Coordinates agents, tracks plan vs. execution
@sec0.agent()Performs reasoning, sets objectives and state
@sec0.tool()Individual tool invocations
sec0SecurityMiddleware()Wraps the tool server with policy enforcement, Agent Guard, and registry freeze
On every tool invocation the middleware computes a source hash of the handler. When the hash changes (code update or version change), Security Hook scans (Claude Security/SAST/DAST) are triggered automatically. Execution can be blocked until the scan passes, based on configured severity thresholds. Every decorated hop emits a signed audit envelope to the append-only audit log.

Network Boundary Security

When tool calls cross a network boundary, the gateway enforces auth, quotas, and custody at the edge.

Tool call via gateway

The agent calls callToolViaGateway() with the server name, tool@version, arguments, auth header, trace context, and agent state. The gateway validates auth, checks entitlements and quotas, injects vendor tokens, enforces idempotency, then forwards to the remote tool server. See Gateway Bridge for client usage and Network Gateway for gateway setup, endpoints, and enforcement options.

Agent-to-agent via gateway

callToolViaGatewayWithAgent() is a convenience wrapper that attaches the calling agent’s nodeId, runId, variables, and metadata so the receiving agent has full context about who is calling and why. The gateway also exposes POST /a2a/invoke for agent-to-agent routing where the target server and tool are specified in the request body. For a complete gateway capability breakdown and configuration examples, see Network Gateway and the Gateway Config Reference.

Agent State

Agent state is the canonical runtime context that flows through every hop. It carries the executing nodeId, a runId reference for correlation, and scoped variables/metadata that downstream hops can use for contextual policy enforcement. When crossing process/network boundaries, agent state is transported via three canonical headers:
  • x-node-id
  • x-agent-ref
  • x-agent-state
For the full schema, encoding/decoding utilities, and analytics conventions, see Agent State.

Policy

Sec0 policies are YAML documents that define runtime governance controls: tool allowlists, scanning, privacy/retention, side-effects, and enforcement behavior. Policies can be loaded locally or fetched dynamically, and can be scoped per agent (nodeId). Start in observe mode (enforcement.deny_on: []) and progressively enable enforcement by adding deny_on reasons and optional escalate_on reasons for escalation workflows. See the Policy Guide and the Policy Schema Reference.

Audit Trail

Every hop emits a signed audit envelope (append-only NDJSON) containing trace/span context, hop identity, policy decision, and integrity hashes. This yields an end-to-end custody chain across your runtime graph. See Audit & Custody for envelope schema, file layout, and uploads.