Skip to main content

Crate typesec

Crate typesec 

Source
Expand description

§typesec

Type-level security capabilities for Rust agents.

This facade crate re-exports the core capability model by default and exposes the policy engines, agent API, and macros behind feature flags.

Modules§

agent
Agent executor API.
capability
Capability — the unforgeable proof token
combinator
Policy Combinator
glob
Shared glob pattern matching for subjects, resources, and policy targets.
lattice
Capability Lattice
macros
Procedural macros.
odrl
ODRL policy engine.
permissions
Permission marker traits
policy
Policy engine trait and audit trail types.
rbac
RBAC policy engine.
resource
Resource trait — the thing a capability grants access to.
role
Role abstraction — a named collection of permissions.
secure_value
Opaque labeled values for information-flow style data handling.
typestate
Agent typestate

Structs§

Agent
An agent with a typestate parameter S and an attached policy engine.
AgentBuilder
Builder for SecureAgent — convenient when wiring multiple engines together.
AiCanExfiltrate
Permission for an AI agent to exfiltrate (export/transmit) data.
AiCanInfer
Permission for an AI agent to run inference over a resource.
AiCanTrain
Permission for an AI agent to use a resource as training data.
AuditEvent
A structured record of every policy decision.
Authenticated
Authenticated state. Policy checks and capability requests become available.
CanDeclassify
Permission to intentionally lower the security label of protected data.
CanDelegate
Permission to delegate capabilities to other agents.
CanDelete
Permission to delete a resource.
CanExecute
Permission to execute code or invoke actions on a resource.
CanRead
Permission to read a resource (non-sensitive).
CanReadInternal
Permission to read internal resources.
CanReadSensitive
Permission to read sensitive resources (PII, credentials, etc.).
CanWrite
Permission to write (create or update) a resource.
CanWriteSensitive
Permission to write sensitive resources.
Capability
An unforgeable proof that subject subject holds permission P on resource R.
CapabilityId
Stable identity for one minted capability within this process.
CapabilityRevocationList
Per-capability revocation list.
ComposedEngine
A multi-engine policy combinator with configurable strategy.
Credentials
Credentials used to authenticate an agent.
DelegationReason
Structured explanation for an unresolved policy decision.
FallbackEngine
A two-engine fallback: tries primary first, then fallback on delegation.
GenericResource
A generic, string-keyed resource for use in tests and the CLI simulator.
Internal
Internal data: not public, but below sensitive and secret data.
LatticeEngine
Runtime lattice engine wrapper.
MintOptions
Lease parameters for capability minting.
OdrlEngine
An ODRL policy engine.
PolicyEngineBuilder
Builder for ComposedEngine.
ProtectedTool
A tool that cannot run unless the caller supplies a matching capability.
Public
Public data: safe to reveal without a capability.
RbacEngine
A compiled, fast-lookup RBAC engine.
RequestContext
Runtime context attached to a policy decision request.
ResourceId
Stable identifier for one protected resource instance.
RevocationEpoch
A shared revocation epoch for live capability invalidation.
Secret
Secret data such as credentials or highly restricted model inputs.
SecureAgent
A secure agent that ties together typestate, policy engines, and capabilities.
SecureValue
Data protected by a type-level privacy label and resource type.
Sensitive
Sensitive data such as PII or confidential business records.
SubjectId
Stable identifier for a policy subject or agent identity.
Token
A bearer secret (API key, signed JWT, etc.) that must not leak into logs.
ToolRegistry
Registry for named capability-protected tools.
ToolSpec
Metadata describing the authorization boundary for a protected tool.
TracingAuditSink
Default AuditSink that emits events via tracing::info!.
Unauthenticated
The initial agent state. No policy operations are available yet.

Enums§

AgentError
Error types for agent operations.
CapabilityError
Error type for capability acquisition failures.
CapabilityUseError
Error returned when a capability is no longer valid for use.
CombineStrategy
How to combine multiple policy engine verdicts into a single decision.
GlobPattern
A compiled glob pattern, with the literal "*" special-cased to match everything (including across / separators).
PolicyResult
The verdict returned by a policy engine.
SecureAccessError
Error returned when a capability does not authorize access to a protected value.
SecureValueError
Error returned when protected values cannot be safely combined.
TaskError
Error type for task execution failures.

Constants§

DEFAULT_CAPABILITY_TTL
Default lease duration for minted capabilities.

Traits§

AgentState
Sealed state trait for the Agent typestate machine.
AsyncPolicyEngine
Async companion interface for policy engines.
AuditSink
Destination for audit events.
Authenticator
Verifies credentials and returns the canonical subject identity.
Implies
Trait encoding the permission lattice.
Join
Type-level least upper bound for two privacy labels.
Permission
A marker trait for permissions.
PolicyEngine
The core runtime policy interface.
PrivacyLevel
A type-level privacy label.
Resource
A resource that can be protected by a Capability.
Role
A role is a named collection of permissions.

Functions§

format_audit_timestamp
Format an audit timestamp as RFC 3339 with millisecond precision.
is_glob_pattern
Returns true if value contains any glob metacharacter (*, ?, [).
mint_capability
Mint a Capability by running a policy check.
mint_capability_async
Async variant of mint_capability.
mint_capability_for_id
Mint a capability for a resource identified only by its id string.
mint_capability_for_id_async
Async variant of mint_capability_for_id.
mint_capability_with
Like mint_capability, but with explicit lease parameters.
mint_capability_with_async
Async variant of mint_capability_with.
set_audit_sink
Install a process-wide audit sink, replacing the previous one.

Type Aliases§

AuditFuture
Boxed async audit-recording future.
AuditTimestamp
UTC timestamp used in audit records.
PolicyFuture
Boxed async policy-decision future.
TaskResult
The result type for task execution.
ToolFuture
Boxed future returned by protected tool handlers.