sec0-sdk/instrumentation turns your application methods into audited Sec0 hops. It loads hop metadata from sec0.config.yaml, injects an AgentManager into decorated methods, propagates canonical agent state, and can apply hop-level policy enforcement on top of the underlying business logic.
Startup Paths
Choose one of these initialization paths before any decorators execute:
loadStandardConfig() for the standard app shape
This loads sec0.config.yaml, initializes local Sec0 directories, and registers every hop in app.hops.
initializeSec0App() when you only need the registered config
initSec0() for low-level bootstrapping
loadStandardConfig(), initializeSec0App(), or initSec0() must run before decorated methods execute.
sec0.config.yaml
The standard config defines application identity, hop metadata, gateway defaults, and local paths:
See Instrumentation Config Reference for the full schema.
Hop Key Resolution
Decorators resolve their hop configuration by key:
- Explicit:
@sec0.agent("MyCustomKey")
- Inferred:
@sec0.agent() resolves to ClassName.methodName
The inferred key must match an entry in app.hops.
Decorators
Every decorated method receives an AgentManager as its last parameter.
@sec0.agent() and @sec0.orchestrator()
Use these for reasoning and coordination hops:
@sec0.gateway()
Gateway hops are the cleanest way to centralize bridge defaults in sec0.config.yaml:
Use the remaining decorators when you want audit and state tracking on specific execution layers:
AgentManager
AgentManager is the primary integration surface inside a decorated method.
Cross-Hop Invocation
If the target hop has remoteUrl, the SDK issues an HTTPS POST. Otherwise, register a local handler:
Hop Automation Flags
Each hop can enable automation flags for common cross-cutting concerns:
Hop-Level Policy Enforcement
Decorators can now enforce policy directly from hop config. This is useful when the hop itself returns or throws a policy outcome and you want consistent deny and escalation handling in the audit layer.
Example:
With this enabled, decorated hops can trigger policy outcomes by:
- returning
policy_breaches: string[]
- returning
policy_violation: string
- throwing an error that carries
denial_reason
The decorator converts the outcome into a POLICY_DENIED error, appends the signed audit envelope, and includes escalation_id and escalation_status when escalation is configured.
Utility Functions