Docs/Architecture/Authenticated Workflows

Authenticated Workflows Architecture

Deep dive into MACAW's authenticated workflow architecture including trust hierarchy, tool invocation flow, verification pipeline, and attestation-based workflow dependencies.

 MACAW Authenticated Workflow Architecture

  Component Overview

  ┌─────────────────────────────────────────────────────────────────────────────────┐
  │                              TRUST HIERARCHY                                     │
  ├─────────────────────────────────────────────────────────────────────────────────┤
  │                                                                                  │
  │  ┌─────────────────┐      ┌─────────────────┐      ┌─────────────────┐          │
  │  │    Registry     │      │  Policy Store   │      │   Audit Log     │          │
  │  │   (TCB - Root   │      │  (Hierarchical  │      │  (Tamper-proof  │          │
  │  │    of Trust)    │      │    Policies)    │      │   Hash Chain)   │          │
  │  └────────┬────────┘      └────────┬────────┘      └────────┬────────┘          │
  │           │                        │                        │                   │
  │           ▼                        ▼                        ▼                   │
  │  ┌─────────────────────────────────────────────────────────────────────┐        │
  │  │                         ToolAgent (PEP)                              │        │
  │  │  • Independent keypair (NOT shared with caller)                      │        │
  │  │  • Verifies signatures via Registry lookup                           │        │
  │  │  • Enforces policy BEFORE execution                                  │        │
  │  │  • Signs responses with its own key                                  │        │
  │  └─────────────────────────────────────────────────────────────────────┘        │
  │                                    ▲                                             │
  │                                    │                                             │
  │  ┌─────────────────────────────────────────────────────────────────────┐        │
  │  │                         MACAWAgent (Caller)                          │        │
  │  │  • Has private/public keypair                                        │        │
  │  │  • Signs all invocations                                             │        │
  │  │  • Declares intent_policy (what it needs)                            │        │
  │  └─────────────────────────────────────────────────────────────────────┘        │
  │                                                                                  │
  └─────────────────────────────────────────────────────────────────────────────────┘

  ---
  Swimlane: Tool Invocation Flow

  ┌──────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
  │  MACAWAgent  │  ToolAgent   │  Registry    │PolicyEnforcer│  Audit Log   │
  │   (Caller)   │    (PEP)     │    (TCB)     │              │              │
  ├──────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
  │              │              │              │              │              │
  │ 1. Prepare   │              │              │              │              │
  │    Invocation│              │              │              │              │
  │    ──────────┤              │              │              │              │
  │              │              │              │              │              │
  │ 2. Sign with │              │              │              │              │
  │    private_key              │              │              │              │
  │    ──────────┤              │              │              │              │
  │              │              │              │              │              │
  │ 3. Call ─────┼─────────────►│              │              │              │
  │    verify_   │              │              │              │              │
  │    and_      │              │              │              │              │
  │    execute() │              │              │              │              │
  │              │              │              │              │              │
  │              │ 4. Extract   │              │              │              │
  │              │    principal_id             │              │              │
  │              │    ──────────┤              │              │              │
  │              │              │              │              │              │
  │              │ 5. Lookup ───┼─────────────►│              │              │
  │              │    public_key│              │              │              │
  │              │◄─────────────┼──────────────┤              │              │
  │              │    (NOT from │   Returns    │              │              │
  │              │     context!)│   pub_key    │              │              │
  │              │              │              │              │              │
  │              │ 6. Crypto.   │              │              │              │
  │              │    verify()  │              │              │              │
  │              │    ──────────┤              │              │              │
  │              │              │              │              │              │
  │              │ 7. Run       │              │              │              │
  │              │    Verifica- │              │              │              │
  │              │    tion      │              │              │              │
  │              │    Pipeline  │              │              │              │
  │              │    ──────────┤              │              │              │
  │              │              │              │              │              │
  │              │ 8. enforce_  │              │              │              │
  │              │    access()──┼──────────────┼─────────────►│              │
  │              │              │              │   Check:     │              │
  │              │              │              │   • intent   │              │
  │              │              │              │     _policy  │              │
  │              │              │              │   • resource │              │
  │              │              │              │     _policy  │              │
  │              │              │              │   • RBAC     │              │
  │              │◄─────────────┼──────────────┼──────────────┤              │
  │              │  (allowed,   │              │              │              │
  │              │   reason)    │              │              │              │
  │              │              │              │              │              │
  │              │ 9. IF DENIED:│              │              │              │
  │              │    Return    │              │              │              │
  │              │    error     │              │              │              │
  │              │    ──────────┤              │              │              │
  │              │              │              │              │              │
  │              │ 10.Execute   │              │              │              │
  │              │    tool      │              │              │              │
  │              │    ──────────┤              │              │              │
  │              │              │              │              │              │
  │              │ 11.Auto-     │              │              │              │
  │              │    attest    │              │              │              │
  │              │    (if cfg)  │              │              │              │
  │              │    ──────────┤              │              │              │
  │              │              │              │              │              │
  │              │ 12.Sign      │              │              │              │
  │              │    result    │              │              │              │
  │              │    with      │              │              │              │
  │              │    ToolAgent │              │              │              │
  │              │    key       │              │              │              │
  │              │    ──────────┤              │              │              │
  │              │              │              │              │              │
  │              │ 13.Audit ────┼──────────────┼──────────────┼─────────────►│
  │              │    execution │              │              │   Append     │
  │              │              │              │              │   signed     │
  │              │              │              │              │   record     │
  │              │              │              │              │              │
  │◄─────────────┼──────────────┤              │              │              │
  │   Signed     │              │              │              │              │
  │   Result     │              │              │              │              │
  │              │              │              │              │              │
  └──────────────┴──────────────┴──────────────┴──────────────┴──────────────┘

  ---
  Swimlane: Verification Pipeline Flow

  ┌──────────────────────────────────────────────────────────────────────────────┐
  │                         VERIFICATION PIPELINE                                 │
  ├──────────────────────────────────────────────────────────────────────────────┤
  │                                                                               │
  │  Invocation ──►┌─────────────────────────────────────────────────────────┐   │
  │                │              VerificationPipeline                        │   │
  │                │                                                          │   │
  │                │   ┌──────────────────────────────────────────────────┐  │   │
  │                │   │  For each verifier (sorted by priority):         │  │   │
  │                │   │                                                   │  │   │
  │                │   │   1. Check should_verify(invocation, context)    │  │   │
  │                │   │      ↓                                            │  │   │
  │                │   │   2. If applicable, run verify()                  │  │   │
  │                │   │      ↓                                            │  │   │
  │                │   │   3. Collect VerificationResult                   │  │   │
  │                │   │      ↓                                            │  │   │
  │                │   │   4. If FAIL and stop_on_first_failure:           │  │   │
  │                │   │      STOP pipeline, return failure                │  │   │
  │                │   │                                                   │  │   │
  │                │   └──────────────────────────────────────────────────┘  │   │
  │                │                                                          │   │
  │                └──────────────────────────────────────────────────────────┘   │
  │                                      │                                        │
  │                                      ▼                                        │
  │                          (overall_success, [results])                         │
  │                                                                               │
  │  Available Verifiers:                                                         │
  │  ├── SignatureVerifier      (priority: 10)  - Verify caller's signature      │
  │  ├── ToolAuthorizationVerifier (priority: 20) - Check tool access            │
  │  ├── RateLimitVerifier      (priority: 30)  - Rate limiting                  │
  │  ├── PromptInjectionVerifier(priority: 40)  - Detect injection patterns      │
  │  ├── CommandInjectionVerifier(priority: 50) - Block dangerous commands       │
  │  ├── PIIMaskingVerifier     (priority: 60)  - Mask sensitive data            │
  │  ├── ParameterVerifier      (priority: 70)  - Validate parameters            │
  │  └── WorkflowIntegrityVerifier(priority: 80)- Check workflow attestations    │
  │                                                                               │
  └──────────────────────────────────────────────────────────────────────────────┘

  ---
  Swimlane: Attestation Flow (Workflow Dependencies)

  ┌──────────────┬──────────────┬──────────────┬──────────────┐
  │   Tool A     │ Session      │   Tool B     │  Verifier    │
  │  (Step 1)    │ Context      │  (Step 2)    │              │
  ├──────────────┼──────────────┼──────────────┼──────────────┤
  │              │              │              │              │
  │ 1. Execute   │              │              │              │
  │    operation │              │              │              │
  │    ──────────┤              │              │              │
  │              │              │              │              │
  │ 2. Auto-     │              │              │              │
  │    attest    │              │              │              │
  │    with key  │              │              │              │
  │    "step_a_  │              │              │              │
  │     complete"│              │              │              │
  │    ──────────┼─────────────►│              │              │
  │              │  Store:      │              │              │
  │              │  {           │              │              │
  │              │   key: "step_a_complete"    │              │
  │              │   value: {...}│             │              │
  │              │   set_by: tool_a_agent      │              │
  │              │   signature: <signed>       │              │
  │              │   one_time: true            │              │
  │              │  }           │              │              │
  │              │              │              │              │
  │              │              │ 3. Invocation│              │
  │              │              │    arrives   │              │
  │              │              │    with req: │              │
  │              │              │    attestations:            │
  │              │              │    ["step_a_ │              │
  │              │              │     complete"]              │
  │              │              │    ──────────┤              │
  │              │              │              │              │
  │              │              │ 4. Verify ───┼─────────────►│
  │              │              │    attestation              │
  │              │              │              │ 5. Lookup    │
  │              │              │              │    key from  │
  │              │◄─────────────┼──────────────┼──Registry    │
  │              │ Read attest  │              │              │
  │              │              │              │ 6. Verify    │
  │              │              │              │    signature │
  │              │              │              │    ──────────┤
  │              │              │              │              │
  │              │              │              │ 7. Check     │
  │              │              │              │    one_time, │
  │              │              │              │    TTL,      │
  │              │              │              │    max_uses  │
  │              │              │              │    ──────────┤
  │              │              │              │              │
  │              │              │◄─────────────┼──────────────┤
  │              │              │   Valid!     │              │
  │              │              │              │              │
  │              │              │ 8. IF valid: │              │
  │              │              │    Execute   │              │
  │              │              │    Step B    │              │
  │              │              │              │              │
  │              │◄─────────────┼──────────────┤              │
  │              │ Consume if   │              │              │
  │              │ one_time=true│              │              │
  │              │              │              │              │
  └──────────────┴──────────────┴──────────────┴──────────────┘

  ---
  Key Security Properties

  ┌─────────────────────────────────────────────────────────────────────────────┐
  │                        SECURITY GUARANTEES                                   │
  ├─────────────────────────────────────────────────────────────────────────────┤
  │                                                                              │
  │  1. NO "GRADING OWN HOMEWORK"                                               │
  │     ─────────────────────────                                                │
  │     ToolAgent has INDEPENDENT keypair                                        │
  │     Caller's signature verified via Registry (NOT from context)              │
  │     ↳ Even if caller lies about identity, signature won't verify            │
  │                                                                              │
  │  2. FAIL-CLOSED POLICY ENFORCEMENT                                          │
  │     ─────────────────────────────                                            │
  │     If policy evaluation crashes → DENY access                               │
  │     If verifier throws exception → DENY access                               │
  │     ↳ Errors never result in allowing unauthorized access                    │
  │                                                                              │
  │  3. CRYPTOGRAPHIC AUDIT TRAIL                                               │
  │     ──────────────────────────                                               │
  │     Every execution logged with:                                             │
  │     • Who (principal_id from verified signature)                             │
  │     • What (tool, operation, params)                                         │
  │     • When (timestamp)                                                       │
  │     • Outcome (success/failure, signed by ToolAgent)                         │
  │     Hash-chained → tampering detected                                        │
  │                                                                              │
  │  4. ATTESTATION-BASED WORKFLOWS                                             │
  │     ─────────────────────────────                                            │
  │     Steps create signed proofs of execution                                  │
  │     Dependent steps verify proofs before proceeding                          │
  │     one_time=true prevents replay                                            │
  │     TTL/max_uses provide fine-grained control                                │
  │                                                                              │
  │  5. INTENT + RESOURCE POLICY INTERSECTION                                   │
  │     ───────────────────────────────────────                                  │
  │     Access = intent_policy ∩ resource_policy                                 │
  │     Agent can only access what it declared AND what resource allows          │
  │     ↳ Prevents privilege escalation                                          │
  │                                                                              │
  └─────────────────────────────────────────────────────────────────────────────┘

  ---
  Summary: The Flow in One Picture

                            ┌──────────────────┐
                            │     Registry     │
                            │ (Public Keys TCB)│
                            └────────┬─────────┘
                                     │
          ┌──────────────────────────┼──────────────────────────┐
          │                          │                          │
          ▼                          ▼                          ▼
  ┌───────────────┐          ┌───────────────┐          ┌───────────────┐
  │  MACAWAgent   │─────────►│  ToolAgent    │─────────►│   Tool        │
  │  (Caller)     │ Signed   │  (PEP)        │ Execute  │ (Actual code) │
  │               │ Request  │               │          │               │
  │ • private_key │          │ • OWN keypair │          │               │
  │ • intent_policy          │ • verify sig  │          │               │
  │               │          │ • enforce     │          │               │
  │               │          │   policy      │          │               │
  │               │◄─────────│ • sign result │◄─────────│               │
  │               │ Signed   │ • audit       │ Result   │               │
  │               │ Response │               │          │               │
  └───────────────┘          └───────────────┘          └───────────────┘
                                     │
                                     ▼
                            ┌───────────────┐
                            │  Audit Log    │
                            │ (Hash-chained)│
                            └───────────────┘

  This architecture ensures that even if a malicious agent tries to spoof its identity or bypass policy, the ToolAgent independently verifies everything using the Registry as the trusted source of truth.

Related