Skip to content

Architecture V2

SHAURYASANYAL3 edited this page Jul 24, 2026 · 1 revision

Architecture V2: The Invariant Lattice

In AgentWatch V2, we have fundamentally redesigned the core engine to prioritize deterministic speed over theoretical reasoning. The new architecture is built around the Invariant Lattice and the Shadow Simulator.

The Invariant Lattice

The Lattice is a multi-stage, short-circuiting execution interceptor. Every action proposed by an agent must pass through the lattice before it is executed. If any stage blocks the action, the pipeline halts immediately (returning LatticeVerdict.BLOCKED), ensuring zero wasted compute.

Our latency budget for the entire lattice evaluation is ~0.1ms.

Stage 1: CapabilityLattice (Static)

This is a purely static, role-based access control (RBAC) layer.

  • Evaluates if the agent holds the cryptographic or configuration-based capability to execute a specific tool or command.
  • Examples: TransitiveCapabilityResolver, CapabilityChecker.
  • Speed: Microseconds.

Stage 2: StateLattice (Dynamic / Simulative)

This stage evaluates the proposed action against the current state of the system using our Shadow Simulators.

  • Before an action touches the real environment, it is executed against a sandbox simulation (e.g., ShadowFilesystem, ShadowDatabase, ShadowNetwork).
  • If the simulation violates a StateInvariant rule (e.g., "do not overwrite system files"), it is blocked.
  • Speed: Sub-millisecond.

Stage 3: CognitiveLattice (Behavioral)

This stage monitors the agent's behavior patterns over a session to detect loops, drift, or hallucinations.

  • Detectors: GoalDriftDetector, LoopEntropyDetector, MiscalibrationDetector, AttentionScatterDetector.
  • It analyzes the metadata of the execution history without invoking an external LLM.

The EventBus

All lattice evaluations, agent telemetry, and system metrics are fanned out through the EventBus.

  • The EventBus is completely asynchronous and thread-safe.
  • Background threads process telemetry without blocking the agent's critical execution path.
  • Event structure uses strict, lightweight Pydantic models.

The InvariantEvolver

Because rigid rules can sometimes cause false positives, the InvariantEvolver tracks near-misses and blocked actions over time. Based on statistical patterns, it exposes APIs to dynamically suggest tightening or relaxing specific thresholds (suggest_relaxation, suggest_tightening).

Clone this wiki locally