AYAZ AHMED / PORTFOLIO
← ALL PROJECTSSELECTED WORK / 02

RUST / AGENT RUNTIME

TOTEM

A Rust agent runtime built around an async PipelineStage contract, CAPSEM capability evaluation, MCP/A2A tool adapters and a BLAKE3-linked execution log.

TOTEM demonstration
RUST / SENTINEL EXECUTION RUNTIME
01 / THE PROJECT

Typed execution across policy, protocol and audit boundaries.

Totem executes structured AgentTask values through a shared, ordered runtime. Axum HTTP and Tonic gRPC servers share the same RuntimeContext, registry and audit logger. Pipeline stages mutate an ExecutionContext while preserving typed task/action identities. This separates transport, context reduction, permission checks, tool invocation and execution evidence into independently inspectable Rust crates.

9

Pipeline stages

Ordered stages implementing the shared async trait.

8,000

Context-token budget

Default approximate window used by ContextStage.

3 × 100 ms

Scheduler benchmark fixture

Simulated branch-latency comparison, separate from tool dispatch.

02 / THROUGH THE SYSTEM

INPUT → OUTPUT
  1. 01

    Accept

    Axum HTTP and Tonic gRPC share a RuntimeContext and the same execution pipeline.

  2. 02

    Prepare

    Scheduler components model dependencies; the context stage applies a bounded window with salience scoring.

  3. 03

    Check

    CAPSEM evaluates capabilities and explicit revocations before tools are dispatched.

  4. 04

    Dispatch

    MCP filesystem calls and registry-backed tools route through their protocol-specific adapters.

  5. 05

    Record

    Tool outputs, latency and audit events feed the execution result and BLAKE3-linked history.

01 / ENGINEERING

Async stage composition and error propagation

PipelineStage is an async trait bounded by Send + Sync. ExecutionPipeline invokes each stage with an immutable AgentTask and mutable ExecutionContext; errors propagate with ? and terminate the remaining sequence. The composition root wires Scheduler → Context → CAPSEM → MCP → ToolManager → A2A → Audit → Evaluation → Recovery. Both API transports dispatch through this same instance.

02 / ENGINEERING

Policy precedence and context salience

CAPSEM resolves resource/action grants and explicit revocations before dispatch. Denial takes precedence over a wildcard grant; the configured restricted tool exercises that path. The context layer scores messages and tool results by role, recency and content signals, then evicts lower-salience entries to satisfy its approximate token budget. The default window is 8,000 tokens.

03 / ENGINEERING

Protocol dispatch and shared registry state

An Arc-backed DashMap registry holds tool definitions, schemas and transport descriptors. ToolManager dispatches local, HTTP, GraphQL and A2A calls; MCP filesystem actions go through their own JSON-RPC stage. Optional attestations are checked during registration and invocation. The running service exposes registry discovery and an A2A Agent Card. Generic gRPC tool descriptors use an HTTP JSON gateway adapter, distinct from the Tonic server API.

04 / ENGINEERING

Hash-linked audit and scheduler instrumentation

BLAKE3 binds each audit event to the preceding hash; verification recomputes the chain. Tool results retain action IDs, output and latency, while Evaluation writes execution metrics into context metadata. The DAG subsystem implements topological levels, cycle detection and branch pruning. Its timing test compares three 100 ms simulated branches sequentially and concurrently to benchmark scheduler concurrency and branch dispatch latency. Non-MCP ToolManager actions currently execute in sequence.

04 / BUILT WITH

TOOLS & THEIR PLACE
  • 01Tokio / RustAsync execution & ownership
  • 02async-traitPipelineStage interface
  • 03CAPSEMCapability policies
  • 04MCP / JSON-RPCFilesystem tool transport
  • 05Tonic / ProstTyped gRPC service
  • 06DashMap / ArcShared tool registry
  • 07BLAKE3Hash-linked audit
  • 08A2A / GraphQLRemote dispatch adapters
AYAZ AHMED / PORTFOLIOBACK TO COLLECTION ↑