Skip to content

Guarded Execution Pipeline

William Smith edited this page Jul 13, 2026 · 1 revision

Guarded Execution Pipeline

Relevant source files

The following files were used as context for generating this wiki page:

The Guarded Execution Pipeline is the core orchestration layer of AXIS (Layer 4: Execution Plane). It manages the transition from a user's natural language intent or raw command into a safely executed task on the optimal cluster node. This pipeline ensures that every execution is preceded by resource reservation, safety evaluation, and environment preparation, while providing real-time observability and post-execution learning.

The primary entry point for this logic is the RunGuarded function in internal/execution/guarded.go [internal/execution/guarded.go:215-215].

Execution Flow Overview

The pipeline follows a strict sequence to maintain the "Truth Rule" and cluster stability.

1. Intent Resolution and Requirement Inference

The pipeline first resolves the user's Description into an Intent [internal/execution/guarded.go:134-139]. This involves:

2. Placement and Safety Gating

Once requirements are known, the pipeline selects a target node:

3. Resource Reservation

Before the command is dispatched, a commitment is made in the reservation.Ledger [internal/execution/guarded.go:343-356].

  • RAM/VRAM Locking: Memory is reserved on the target node to prevent overcommitment during the task's lifecycle.
  • Heartbeat Mechanism: A background task periodically updates the ledger to signify the execution is still alive [internal/execution/guarded.go:53-58].

4. Environment Injection and Execution

The pipeline prepares the execution environment:

5. Observation and Learning

After completion, the pipeline records the outcome:

Technical Architecture Diagrams

Intent to Code Entity Mapping

This diagram maps the conceptual "Natural Language Intent" to the specific Go types and logic used during the resolution phase.

Conceptual Step Code Entity / Symbol File Reference
User Input GuardedExecutionRequest internal/execution/guarded.go
Template Match scripts.Script internal/scripts/registry.go
Past Success skills.LearnedSkill internal/skills/skills.go
Hardware Needs models.TaskRequirements internal/models/tasks.go
Execution State PreparedExecution internal/execution/guarded.go
graph TD
    subgraph "Natural Language Space"
        Input["User Description: 'run llama3'"]
    end

    subgraph "Code Entity Space"
        REQ["GuardedExecutionRequest"]
        INT["Intent (struct)"]
        REG["scripts.Registry"]
        SKL["skills.Store"]
        INF["InferRequirements()"]
        PREP["PreparedExecution"]
    end

    Input --> REQ
    REQ --> REG
    REQ --> SKL
    REG -- "Match" --> INT
    SKL -- "Match" --> INT
    INT -- "None Found" --> INF
    
    INT --> PREP
    INF --> PREP
Loading

Sources: internal/execution/guarded.go:72-132, internal/scripts/registry.go:26-52, internal/skills/skills.go:15-34

The Guarded Lifecycle

This diagram illustrates the sequence of operations within RunGuarded, highlighting the interaction between the safety system, the ledger, and the transport layer.

sequenceDiagram
    participant CLI as axis binary
    participant GE as execution.RunGuarded
    participant SE as safety.Evaluator
    participant RL as reservation.Ledger
    participant TX as transport.SSHExecutor
    participant SK as skills.Store

    CLI->>GE: Call RunGuarded(req)
    GE->>SE: Check(command)
    Note over SE: Applies RuleSet
    SE-->>GE: SafetyVerdict (Allow/Deny)
    
    GE->>RL: Reserve(node, ram_mb)
    RL-->>GE: LedgerExecID
    
    loop Heartbeat
        GE->>RL: Heartbeat(LedgerExecID)
    end
    
    alt isLocal
        GE->>GE: RunLocalShell()
    else isRemote
        GE->>TX: Stream(ctx, command, stdout, stderr)
    end
    
    GE->>RL: Release(LedgerExecID)
    GE->>SK: RecordSuccess(desc, cmd, node)
    GE-->>CLI: GuardedExecutionResult (NDJSON)
Loading

Sources: internal/execution/guarded.go:215-410, internal/execution/guarded.go:53-58, internal/skills/skills.go:79-88

Key Data Structures

GuardedExecutionRequest

The input configuration for the pipeline.

PreparedExecution

An internal transient state containing all context needed to launch the process.

Observability and Output

The pipeline produces streaming output. When invoked via the API or CLI, it typically emits NDJSON (Newline Delimited JSON) representing the GuardedExecutionResult [internal/execution/guarded.go:90-114]. This allows clients to track:

  1. Placement Reasoning: Why a specific node was chosen [internal/execution/guarded.go:102-102].
  2. Safety Status: If the command was blocked or requires confirmation [internal/execution/guarded.go:103-104].
  3. Resource Usage: Real-time telemetry from the process once it finishes [internal/execution/guarded.go:111-113].

Sources: internal/execution/guarded.go:1-410, internal/scripts/registry.go:1-137, internal/skills/skills.go:1-177, internal/execution/nix.go:1-157


Clone this wiki locally