Skip to main content

Module context

Module context 

Source
Expand description

Context module - Execution context types

This module provides the context types passed through all execution:

  • TenantContext: Multi-tenant isolation boundary (REQUIRED)
  • RuntimeContext: The execution spine
  • TraceContext: W3C distributed tracing
  • InvocationContext: Agent/tool invocation context

§Key Invariant: TenantContext is Required

Every execution MUST have a TenantContext. This ensures:

  • Multi-tenant isolation
  • Resource limit enforcement
  • Audit compliance
  • Billing attribution

§Usage

use enact_core::context::{TenantContext, RuntimeContext};
use enact_core::kernel::{ExecutionId, ParentLink, TenantId, UserId};

// Create tenant context (REQUIRED)
let tenant = TenantContext::new(TenantId::from("tenant_acme"))
    .with_user(UserId::from("usr_alice"));

// Create runtime context with tenant
let ctx = RuntimeContext::new(
    ExecutionId::new(),
    ParentLink::from_user_message("msg_123"),
    tenant,
);

Structs§

InvocationContext
InvocationContext - Context for invoking an agent or tool
InvocationServices
Services available during invocation
ResourceLimits
Resource limits enforced by the runtime per tenant
RuntimeContext
RuntimeContext - The context passed through all execution
RuntimeContextBuilder
Builder for creating RuntimeContext with fluent API
SessionContext
Session context for user-initiated flows
TenantContext
TenantContext - Required context for every execution
TraceContext
TraceContext - W3C Trace Context for distributed tracing