AIAD Agent

platform

AIAD Agent

Definition

An AIAD (AI-Assisted Development) agent is an autonomous operational unit within the Prismatic Platform, defined by a structured profile document that declares its identity, capabilities, constraints, authority level, and doctrine compliance. Unlike simple scripts or functions, AIAD agents operate within a hierarchical authority structure (L0-L4), can coordinate with other agents through orchestration patterns, and are subject to the NO MERCY, NO DOUBTS doctrine's quality and completeness requirements.

The Prismatic Platform hosts 530+ AIAD agents across 16 domains, ranging from L0 informational observers to L4 supreme coordinators, all registered in the AIAD Agent Registry and discoverable through the platform's auto-indexing system.

Technical Deep Dive

Agent Anatomy

Every AIAD agent consists of three layers:

LayerContentLocation
ProfileIdentity, capabilities, constraints, authority.aiad/agents/*.agent.md
RuntimeOTP process, message handling, stateapps/prismatic_agents/
CommandsUser-facing invocations mapped to agent.aiad/commands/*.cmd.md

Authority Level Distribution (530+ agents)

LevelCountRoleExamples
L4 Supreme~5Platform-wide authorityarcher-supreme, supreme-coordinator
L3 Strategic~30Domain orchestratorsosint-coordinator, red-commander
L2 Tactical~100Task specialistsred-epistemic-attacker, blue-drift-detector
L1 Operational~200Single-operation workerscode-reviewer, test-runner
L0 Informational~195Read-only observerslog-monitor, metric-collector

Domain Distribution

DomainAgentsKey Agents
Security60+Color team agents (Red, Blue, Purple, White, Black, Gray)
Quality40+Quality guardian, credo enforcer, dialyzer agent
OSINT30+OSINT coordinator, tool-specific adapters
Development50+Code reviewer, refactorer, test generator
Infrastructure25+Deploy agent, health monitor, performance profiler
Academy15+Topic curator, quiz generator, progress tracker

Architecture and Implementation

Agent Runtime

defmodule PrismaticAgents.AgentRuntime do
  @moduledoc """
  OTP-based runtime for AIAD agents. Each agent runs as a supervised
  GenServer process with its profile loaded as initial state.
  Authority checks are enforced before every operation dispatch.
  """

  use GenServer

  alias Prismatic.AIAD.AuthorityGuard

  @type state :: %{
          profile: map(),
          status: :idle | :executing | :suspended,
          execution_count: non_neg_integer(),
          last_execution: DateTime.t() | nil
        }

  @spec start_link(map()) :: GenServer.on_start()
  def start_link(profile) do
    GenServer.start_link(__MODULE__, profile,
      name: {:via, Registry, {PrismaticAgents.Registry, profile.name}})
  end

  @impl GenServer
  def init(profile) do
    state = %{
      profile: profile,
      status: :idle,
      execution_count: 0,
      last_execution: nil
    }

    :telemetry.execute(
      [:prismatic, :agent, :started],
      %{count: 1},
      %{name: profile.name, level: profile.level}
    )

    {:ok, state}
  end

  @impl GenServer
  def handle_call({:execute, operation, params}, _from, state) do
    required_level = operation_authority_level(operation)

    case AuthorityGuard.authorize_operation(state.profile.level, required_level) do
      :ok ->
        result = execute_operation(state.profile, operation, params)
        new_state = %{state |
          status: :idle,
          execution_count: state.execution_count + 1,
          last_execution: DateTime.utc_now()
        }
        {:reply, {:ok, result}, new_state}

      {:error, :insufficient_authority} ->
        {:reply, {:error, :insufficient_authority}, state}
    end
  end

  @spec execute_operation(map(), atom(), map()) :: term()
  defp execute_operation(profile, operation, params) do
    :telemetry.execute(
      [:prismatic, :agent, :operation],
      %{count: 1},
      %{agent: profile.name, operation: operation}
    )

    apply(operation_module(operation), :execute, [profile, params])
  end
end

Usage in Prismatic Platform

AIAD agents are the operational backbone of the platform:

  • Development Workflow: Agents handle code review, testing, refactoring, and quality gate enforcement
  • OSINT Intelligence: Specialized agents coordinate the 127 OSINT tool adapters
  • Security Operations: 20 Color Team agents across 6 teams perform adversarial simulation and defense
  • Quality Assurance: Agents enforce zero-warning compilation, Credo strictness, and coverage requirements
  • Platform Evolution: Auto-evolution agents continuously improve the codebase across sessions
  • Academy: Topic agents curate learning content and track student progress

Code Examples

Agent Invocation via Command

defmodule PrismaticAgents.CommandDispatcher do
  @moduledoc """
  Dispatches user commands to the appropriate AIAD agent.
  Maps command slugs to agent names via the command registry.
  """

  @spec dispatch(String.t(), map()) :: {:ok, term()} | {:error, term()}
  def dispatch(command_slug, params) do
    with {:ok, agent_name} <- lookup_agent(command_slug),
         {:ok, pid} <- find_agent_process(agent_name),
         {:ok, result} <- GenServer.call(pid, {:execute, :handle_command, params}) do
      {:ok, result}
    end
  end

  @spec lookup_agent(String.t()) :: {:ok, String.t()} | {:error, :unknown_command}
  defp lookup_agent(command_slug) do
    case PrismaticAgents.CommandRegistry.get_command(command_slug) do
      {:ok, %{agent: agent_name}} -> {:ok, agent_name}
      {:error, :not_found} -> {:error, :unknown_command}
    end
  end

  @spec find_agent_process(String.t()) :: {:ok, pid()} | {:error, :agent_not_running}
  defp find_agent_process(agent_name) do
    case Registry.lookup(PrismaticAgents.Registry, agent_name) do
      [{pid, _}] -> {:ok, pid}
      [] -> {:error, :agent_not_running}
    end
  end
end

Best Practices

  1. Follow the authority principle: Never assign a higher authority level than necessary. Most agents should be L1-L2.

  2. Declare constraints explicitly: Capabilities without constraints are dangerous. Every agent must declare what it cannot do.

  3. Mandate doctrine compliance: Every AIAD agent must include the NO MERCY, NO DOUBTS enforcement block in its profile.

  4. Use the AIAD indexer: Run ./.aiad/bin/aiad index after creating or modifying agent profiles.

  5. Test agent behavior: Every agent operation must have corresponding tests verifying both success and authority rejection paths.

  6. Monitor agent health: Use telemetry events to track agent execution counts, latency, and error rates.

  • Agent Profile -- the declarative identity document for each agent
  • Command Registry -- maps user commands to agents
  • Auto-Discovery -- automatic agent detection and registration
  • Collaboration -- multi-agent coordination patterns
  • Access Control -- authority enforcement on agent operations

See Also


Connect & Contribute

Created by Tomas Korcak (korczis) | Open Source under GHL