Skip to main content

execute_with_telemetry

Function execute_with_telemetry 

Source
pub fn execute_with_telemetry(
    capability: &dyn Capability,
    args: &Value,
    dry_run: bool,
    wal_path: &Path,
) -> Result<ExecutionResult>
Expand description

Execute a capability with full telemetry, resource guarding, and WAL logging.

§Execution Flow

  1. Capture hardware telemetry and process snapshot (before)
  2. Check resource limits via LlmoSafeGuard (circuit breaker at 80%)
  3. Check zombie count (reject if > 10)
  4. Check args size (reject if > 1MB)
  5. Log JobStarted event to WAL
  6. Validate arguments against capability schema
  7. Execute the capability
  8. Capture hardware telemetry and process snapshot (after)
  9. Identify spawned PIDs
  10. Log JobCompleted or JobFailed event to WAL

§Arguments

  • capability — The capability to execute (any type implementing Capability)
  • args — JSON arguments for the capability
  • dry_run — If true, the capability may skip side effects
  • wal_path — Path to the WAL file (appended to)

§Returns

An ExecutionResult with before/after snapshots and the capability output. Even on validation or execution failure, returns Ok with success: false so the caller can inspect telemetry deltas.

§Errors

Returns Error::ResourceLimitExceeded if the LlmoSafeGuard circuit breaker trips, zombie count exceeds 10, or args exceed 1MB. WAL write failures also propagate as errors.

§Timeout Limitation

The timeout_secs parameter is currently not enforced. Rust’s std::thread cannot be interrupted once started. A true timeout requires either subprocess isolation or tokio::spawn_blocking with cancellation. This is tracked for v0.2.0 (see FINDING #17 in module docs).