version: 1

system:
  id: agent-runtime-builtin
  name: "agent-runtime Built-in Agents"
  default_workflow_order:
    - implement-llm-feature
    - audit-implementation

agents: { $ref: "./agents/" }
tasks: { $ref: "./tasks.yaml" }
handoff_types: { $ref: "./handoff-types.yaml" }

guardrails:
  output-schema-conformance:
    description: >-
      Ensure all agent outputs conform to their respective handoff
      schemas. Validation is performed at runtime via Zod.
    scope:
      agents:
        - llm-feature-implementer
        - implementation-auditor
      tasks:
        - implement-llm-feature
        - audit-dsl
        - audit-runtime
        - audit-cli-contract
        - audit-architecture
        - audit-merge
    rationale: >-
      Structured output conformance is critical for CLI parsing
      and downstream tooling integration.

  no-direct-api-call:
    description: >-
      The implementer agent must not generate code that calls LLM APIs
      directly. All LLM invocations must go through agent-contracts-runtime
      runWorkflow().
    scope:
      agents:
        - llm-feature-implementer
    rationale: >-
      Preserves SDK adapter abstraction, enabling adapter swap,
      plugin hooks, and guardrail enforcement.

  audit-read-only:
    description: >-
      The auditor agent must not create, modify, or delete any files.
      It operates in read-only mode and produces findings only.
    scope:
      agents:
        - implementation-auditor
    rationale: >-
      Audit results must be reviewed by the developer before changes
      are applied. The auditor observes; the developer decides.

guardrail_policies:
  implement-safety-policy:
    description: Guardrail policy for the LLM feature implementation agent
    rules:
      - guardrail: output-schema-conformance
        severity: critical
        action: block
      - guardrail: no-direct-api-call
        severity: critical
        action: block

  audit-safety-policy:
    description: Guardrail policy for the implementation auditor agent
    rules:
      - guardrail: output-schema-conformance
        severity: critical
        action: block
      - guardrail: audit-read-only
        severity: critical
        action: block

workflow:
  implement-llm-feature:
    description: "Implement LLM-powered commands in a CLI tool"
    trigger: cli-command
    entry_conditions:
      - "Target project is a TypeScript / Node.js project"
      - "cli-contract.yaml exists or is being created"
    steps:
      - type: delegate
        task: implement-llm-feature
        from_agent: llm-feature-implementer

  audit-implementation:
    description: "Audit an LLM command integration for pattern conformance"
    trigger: cli-command
    entry_conditions:
      - "Target project has LLM command integration to audit"
    steps:
      - type: delegate
        task: audit-dsl
        from_agent: implementation-auditor
        depends_on: []
      - type: delegate
        task: audit-runtime
        from_agent: implementation-auditor
        depends_on: []
      - type: delegate
        task: audit-cli-contract
        from_agent: implementation-auditor
        depends_on: []
      - type: delegate
        task: audit-architecture
        from_agent: implementation-auditor
        depends_on: []
      - type: delegate
        task: audit-merge
        from_agent: implementation-auditor
        depends_on:
          - audit-dsl
          - audit-runtime
          - audit-cli-contract
          - audit-architecture
