version: 1
kind: platform-infra-kafka

metadata:
  id: kafka-event-bus
  owner: unidesk
  spec: pikasTech/HWLAB#2449
  relatedIssues:
    - 2243
    - 2449
    - 2462

defaults:
  targetId: NC01
  switch:
    enabled: true
    mode: durable-event-stream
    appIntegrationEnabled: true
    produceEnabled: true
    consumeEnabled: true

operator:
  implementation: strimzi
  version: 1.1.0
  manifestUrl: https://github.com/strimzi/strimzi-kafka-operator/releases/download/1.1.0/strimzi-cluster-operator-1.1.0.yaml
  deploymentName: strimzi-cluster-operator
  serviceAccountName: strimzi-cluster-operator
  resources:
    requests:
      cpu: 200m
      memory: 384Mi
    limits:
      cpu: 1000m
      memory: 384Mi
  crds:
    - kafkas.kafka.strimzi.io
    - kafkanodepools.kafka.strimzi.io
    - kafkatopics.kafka.strimzi.io
    - kafkausers.kafka.strimzi.io

targets:
  - id: NC01
    route: NC01:k3s
    namespace: platform-infra
    role: active
    enabled: true
    createNamespace: true
    storageClassName: local-path
  - id: D518
    route: D518:k3s
    namespace: platform-infra
    role: active
    enabled: true
    createNamespace: true
    storageClassName: local-path

cluster:
  name: platform-infra-kafka
  nodePoolName: dual-role
  kafkaVersion: 4.3.0
  metadataVersion: 4.3-IV0
  replicas: 1
  resources:
    requests:
      cpu: 250m
      memory: 768Mi
    limits:
      cpu: 1000m
      memory: 1280Mi
  jvmOptions:
    xms: 256m
    xmx: 768m
  entityOperator:
    topicOperator:
      resources:
        requests:
          cpu: 100m
          memory: 192Mi
        limits:
          cpu: 500m
          memory: 384Mi
      jvmOptions:
        xms: 64m
        xmx: 128m
    userOperator:
      resources:
        requests:
          cpu: 100m
          memory: 192Mi
        limits:
          cpu: 500m
          memory: 384Mi
      jvmOptions:
        xms: 64m
        xmx: 128m
  storage:
    size: 4Gi
    deleteClaim: false
  listeners:
    plain:
      enabled: true
      port: 9092
    tls:
      enabled: true
      port: 9093
  authorization:
    enabled: false
    mode: deferred-app-integration

topics:
  - name: codex-stdio.raw.v1
    partitions: 1
    replicas: 1
    retentionMs: 604800000
    cleanupPolicy: delete
    description: AgentRun v0.2 codex stdio raw stdin/stdout/stderr frames for Workbench trace debugging.
  - name: agentrun.event.v1
    partitions: 1
    replicas: 1
    retentionMs: 604800000
    cleanupPolicy: delete
    description: AgentRun v0.2 manager run and command events for HWLAB v0.3 projection.
  - name: agentrun.event.debug.v1
    partitions: 1
    replicas: 1
    retentionMs: 86400000
    cleanupPolicy: delete
    description: Explicit stdio-derived partial reconstruction events for isolated AgentRun-to-HWLAB source-direct debugging.
  - name: hwlab.event.v1
    partitions: 1
    replicas: 1
    retentionMs: 604800000
    cleanupPolicy: delete
    description: HWLAB v0.3 Workbench projection events for SSE passthrough.
  - name: hwlab.event.debug.v1
    partitions: 1
    replicas: 1
    retentionMs: 86400000
    cleanupPolicy: delete
    description: Isolated source-direct HWLAB debug events for explicit trace replay through debug SSE and production reducers.
  - name: hwlab.agentrun.command.v1
    partitions: 1
    replicas: 1
    retentionMs: 604800000
    cleanupPolicy: delete
    description: HWLAB v0.3 admitted user commands for AgentRun v0.2.
  - name: agentrun.hwlab.event.v1
    partitions: 1
    replicas: 1
    retentionMs: 604800000
    cleanupPolicy: delete
    description: AgentRun v0.2 run/command events for HWLAB v0.3 ingestion.
  - name: hwlab.agentrun.command.dlq.v1
    partitions: 1
    replicas: 1
    retentionMs: 1209600000
    cleanupPolicy: delete
    description: Dead-letter topic for HWLAB to AgentRun command delivery.
  - name: agentrun.hwlab.event.dlq.v1
    partitions: 1
    replicas: 1
    retentionMs: 1209600000
    cleanupPolicy: delete
    description: Dead-letter topic for AgentRun to HWLAB event delivery.
  - name: platform-infra.kafka.smoke.v1
    partitions: 1
    replicas: 1
    retentionMs: 86400000
    cleanupPolicy: delete
    description: Platform-infra Kafka broker smoke topic.

clients:
  - id: hwlab-v03-cloud-api
    namespace: hwlab-v03
    serviceAccountName: hwlab-cloud-api
    kafkaUserName: hwlab-v03-cloud-api
    secretName: hwlab-v03-cloud-api
    produceTopics:
      - hwlab.event.v1
      - hwlab.event.debug.v1
      - hwlab.agentrun.command.v1
    consumeTopics:
      - agentrun.event.v1
      - agentrun.event.debug.v1
      - agentrun.hwlab.event.v1
      - hwlab.event.v1
      - hwlab.event.debug.v1
    dlqTopics:
      - agentrun.hwlab.event.dlq.v1
  - id: hwlab-production-cloud-api
    namespace: hwlab-production
    serviceAccountName: hwlab-cloud-api
    kafkaUserName: hwlab-production-cloud-api
    secretName: hwlab-production-cloud-api
    produceTopics:
      - hwlab.event.v1
      - hwlab.event.debug.v1
      - hwlab.agentrun.command.v1
    consumeTopics:
      - agentrun.event.v1
      - agentrun.event.debug.v1
      - agentrun.hwlab.event.v1
      - hwlab.event.v1
      - hwlab.event.debug.v1
    dlqTopics:
      - agentrun.hwlab.event.dlq.v1
  - id: agentrun-v02-manager
    namespace: agentrun-v02
    serviceAccountName: agentrun-nc01-v02-mgr
    kafkaUserName: agentrun-v02-manager
    secretName: agentrun-v02-manager
    produceTopics:
      - agentrun.event.v1
      - agentrun.event.debug.v1
      - agentrun.hwlab.event.v1
    consumeTopics:
      - codex-stdio.raw.v1
      - hwlab.agentrun.command.v1
    dlqTopics:
      - hwlab.agentrun.command.dlq.v1
  - id: agentrun-v02-runner
    namespace: agentrun-v02
    serviceAccountName: agentrun-nc01-v02-runner
    kafkaUserName: agentrun-v02-runner
    secretName: agentrun-v02-runner
    produceTopics:
      - codex-stdio.raw.v1
    consumeTopics: []
    dlqTopics: []

validation:
  timeoutSeconds: 45
  pollSeconds: 3
  smokeTopic: platform-infra.kafka.smoke.v1

management:
  replay:
    defaultLimit: 5000
    maxLimit: 20000
    defaultTimeoutMs: 10000
    maxTimeoutMs: 15000
    commandGraceMs: 35000
  defaultTailLimit: 10
  maxTailLimit: 50
  defaultGroupListLimit: 25
  maxGroupListLimit: 200
  consumerGroupCleanup:
    defaultCandidateLimit: 25
    maxCandidateLimit: 200
    commandTimeoutSeconds: 30
    deleteBatchSize: 50
    automatic:
      enabled: true
      schedule: "*/10 * * * *"
      image: quay.io/strimzi/kafka:1.1.0-kafka-4.3.0
      consumerGroupsCommand: /opt/kafka/bin/kafka-consumer-groups.sh
      configMapName: platform-infra-kafka-group-retention
      cronJobNamePrefix: kafka-group-retention
      candidateLimit: 50
      activeDeadlineSeconds: 300
      startingDeadlineSeconds: 120
      successfulJobsHistoryLimit: 1
      failedJobsHistoryLimit: 3
      resources:
        requests:
          cpu: 50m
          memory: 128Mi
        limits:
          cpu: 200m
          memory: 256Mi
    policies:
      - id: hwlab-cloud-api-sse
        automatic: true
        prefix: hwlab-v03-cloud-api-sse-
        inactiveStates:
          - Empty
        minimumGroupAgeHours: 1
        timestamp:
          source: group-name-regex
          pattern: ^hwlab-v03-cloud-api-sse-([0-9]{13})-[0-9a-f]{8}$
          captureGroup: 1
          unit: unix-ms
  defaultTopic: hwlab.event.v1
  diagnosticProducerId: unidesk-platform-infra-kafka-cli
