{
  "version": "0.2",
  "identity_profiles": [
    {
      "id": "aws-credentials",
      "provider": "env-bearer",
      "subject": {
        "kind": "service",
        "principal": "agent://ops/aws",
        "display_name": "AWS Operations Agent",
        "delegation_mode": "none"
      },
      "auth": {
        "mode": "service",
        "required": false,
        "provider_config": {
          "token_env": "AWS_SESSION_TOKEN"
        }
      },
      "trust": {
        "level": "supervised",
        "constraints": {
          "max_autonomy": "supervised",
          "escalation": "fail"
        }
      },
      "presentation": {
        "bindings": [
          {
            "source": "credentials.access_token.value",
            "target": { "kind": "env", "name": "AWS_SESSION_TOKEN" },
            "required": false,
            "redact": true
          }
        ],
        "handoff": "none",
        "cleanup": "always"
      }
    },
    {
      "id": "aws-readonly",
      "provider": "none",
      "subject": {
        "kind": "service",
        "principal": "agent://ops/aws-readonly",
        "display_name": "AWS Read-Only Agent"
      },
      "trust": {
        "level": "restricted",
        "constraints": {
          "max_autonomy": "restricted",
          "escalation": "fail"
        }
      }
    }
  ],
  "evidence_profiles": [
    {
      "id": "ssh-evidence",
      "provider": "ssh",
      "payload": {
        "bind": ["execution_id", "declared_identity", "command", "result"],
        "format": "canonical-json"
      },
      "verify": { "required": false }
    }
  ],
  "workflows": [
    {
      "id": "aws-ops",
      "name": "AWS Operations",
      "contract": {
        "sandbox": "permissive",
        "network": "unrestricted",
        "audit": "always"
      },
      "tasks": [
        {
          "id": "check-identity",
          "name": "Check AWS Caller Identity",
          "shell": {
            "program": "aws",
            "args": ["sts", "get-caller-identity", "--output", "json"]
          },
          "target": { "session_target": "shell" },
          "identity": { "ref": "aws-readonly" },
          "evidence": { "ref": "ssh-evidence" },
          "output": { "format": "json" },
          "schedule": { "cron": "0 8 * * *" }
        },
        {
          "id": "list-s3-buckets",
          "name": "List S3 Buckets",
          "shell": {
            "program": "aws",
            "args": ["s3api", "list-buckets", "--output", "json"]
          },
          "target": { "session_target": "shell" },
          "identity": { "ref": "aws-readonly" },
          "evidence": { "ref": "ssh-evidence" },
          "output": {
            "format": "json",
            "preview_bytes": 4000,
            "offload": "auto"
          },
          "schedule": { "cron": "0 */6 * * *" }
        },
        {
          "id": "list-ec2-instances",
          "name": "List EC2 Instances",
          "shell": {
            "program": "aws",
            "args": ["ec2", "describe-instances", "--query", "Reservations[].Instances[].{Id:InstanceId,Type:InstanceType,State:State.Name,Name:Tags[?Key=='Name']|[0].Value}", "--output", "json"]
          },
          "target": { "session_target": "shell" },
          "identity": { "ref": "aws-readonly" },
          "evidence": { "ref": "ssh-evidence" },
          "output": {
            "format": "json",
            "preview_bytes": 8000
          },
          "schedule": { "cron": "0 */4 * * *" }
        },
        {
          "id": "check-cloudwatch-alarms",
          "name": "Check CloudWatch Alarms",
          "shell": {
            "program": "aws",
            "args": ["cloudwatch", "describe-alarms", "--state-value", "ALARM", "--output", "json"]
          },
          "target": { "session_target": "shell" },
          "identity": { "ref": "aws-readonly" },
          "output": {
            "format": "json",
            "preview_bytes": 4000
          },
          "schedule": { "cron": "*/10 * * * *" },
          "on_failure": {
            "id": "triage-alarm-check",
            "name": "Triage Alarm Check Failure",
            "prompt": "The CloudWatch alarm check failed. Determine whether this is an authentication issue, permissions problem, or API error, and recommend the next step.",
            "target": { "session_target": "isolated", "agent_id": "main" },
            "intent": { "mode": "plan", "read_only": true },
            "context": { "retrieval": "recent", "limit": 3 },
            "delivery": { "mode": "announce", "to": "@owner_dm" }
          }
        },
        {
          "id": "check-cost",
          "name": "Check Monthly Cost Estimate",
          "shell": {
            "program": "aws",
            "args": ["ce", "get-cost-and-usage", "--time-period", "Start=2026-03-01,End=2026-03-28", "--granularity", "MONTHLY", "--metrics", "UnblendedCost", "--output", "json"]
          },
          "target": { "session_target": "shell" },
          "identity": { "ref": "aws-readonly" },
          "evidence": { "ref": "ssh-evidence" },
          "output": { "format": "json" },
          "contract": {
            "required_trust_level": "restricted",
            "trust_enforcement": "strict"
          },
          "schedule": { "cron": "0 9 * * 1" }
        }
      ]
    }
  ]
}
