asyncapi: 3.0.0
info:
  title: DAIMON Audit & Lifecycle Events
  version: 0.1.0
  description: |
    Outbound event streams a DAIMON instance can publish for operator tooling,
    SIEM ingestion, and federation peers. Default transport is gRPC server-stream;
    AsyncAPI documents the logical schema only.
  license:
    name: BUSL-1.1

defaultContentType: application/json

channels:
  audit/events:
    address: audit/events
    description: Append-only audit event stream.
    messages:
      AuditEvent:
        $ref: '#/components/messages/AuditEvent'

  lifecycle/module:
    address: lifecycle/module
    description: Module load/unload/rollback notifications.
    messages:
      ModuleLifecycle:
        $ref: '#/components/messages/ModuleLifecycle'

  health:
    address: health
    description: Periodic kernel heartbeat.
    messages:
      Heartbeat:
        $ref: '#/components/messages/Heartbeat'

operations:
  publishAudit:
    action: send
    channel:
      $ref: '#/channels/audit~1events'

  publishLifecycle:
    action: send
    channel:
      $ref: '#/channels/lifecycle~1module'

  publishHeartbeat:
    action: send
    channel:
      $ref: '#/channels/health'

components:
  messages:
    AuditEvent:
      name: AuditEvent
      title: Audit Event
      summary: A single audit-log row, as published.
      contentType: application/json
      payload:
        $ref: 'https://uape.dev/schemas/audit-event-1.0.json'

    ModuleLifecycle:
      name: ModuleLifecycle
      contentType: application/json
      payload:
        type: object
        required: [module_id, event, version, ts]
        properties:
          module_id: { type: string, format: uuid }
          event:     { type: string, enum: [loaded, unloaded, rollback, migration_applied, failed] }
          version:   { type: string }
          ts:        { type: integer }

    Heartbeat:
      name: Heartbeat
      contentType: application/json
      payload:
        type: object
        required: [ts, modules_loaded, audit_seq_head]
        properties:
          ts:               { type: integer }
          modules_loaded:   { type: integer, minimum: 0 }
          audit_seq_head:   { type: integer, minimum: 0 }
          kernel_version:   { type: string }
