[INFRA-007] Job events and audit logging #169

Closed
opened 2026-02-01 07:24:42 +00:00 by jason.woltje · 0 comments
Owner

Summary

Implement job-events module for immutable audit logging using event sourcing pattern.

Event Types

Job lifecycle:

  • job.created, job.queued, job.started, job.completed, job.failed

Step lifecycle:

  • step.started, step.progress, step.output, step.completed

AI events:

  • ai.tool_called, ai.tokens_used, ai.artifact_created

Gate events:

  • gate.started, gate.passed, gate.failed

Storage Strategy

  • PostgreSQL: Immutable audit log (permanent)
  • Valkey Streams: Recent events (last 1000 per job)
  • Valkey Pub/Sub: Real-time streaming

API Endpoints

  • GET /runner-jobs/:jobId/events - List events for a job
  • GET /runner-jobs/:jobId/events/stream - SSE stream of events

Tasks

  • Create apps/api/src/job-events/job-events.module.ts
  • Create apps/api/src/job-events/job-events.service.ts
  • Create apps/api/src/job-events/job-events.controller.ts
  • Implement event emission (internal service)
  • Implement PostgreSQL persistence
  • Implement Valkey Streams for recent events
  • Implement Pub/Sub for real-time

Files to Create

  • apps/api/src/job-events/job-events.module.ts
  • apps/api/src/job-events/job-events.service.ts
  • apps/api/src/job-events/job-events.controller.ts
  • apps/api/src/job-events/dto/

Acceptance Criteria

  • Events are emitted for all job/step state changes
  • Events are persisted to PostgreSQL
  • Recent events available via Valkey Streams
  • Real-time streaming works via Pub/Sub
## Summary Implement job-events module for immutable audit logging using event sourcing pattern. ## Event Types Job lifecycle: - job.created, job.queued, job.started, job.completed, job.failed Step lifecycle: - step.started, step.progress, step.output, step.completed AI events: - ai.tool_called, ai.tokens_used, ai.artifact_created Gate events: - gate.started, gate.passed, gate.failed ## Storage Strategy - PostgreSQL: Immutable audit log (permanent) - Valkey Streams: Recent events (last 1000 per job) - Valkey Pub/Sub: Real-time streaming ## API Endpoints - GET /runner-jobs/:jobId/events - List events for a job - GET /runner-jobs/:jobId/events/stream - SSE stream of events ## Tasks - [ ] Create apps/api/src/job-events/job-events.module.ts - [ ] Create apps/api/src/job-events/job-events.service.ts - [ ] Create apps/api/src/job-events/job-events.controller.ts - [ ] Implement event emission (internal service) - [ ] Implement PostgreSQL persistence - [ ] Implement Valkey Streams for recent events - [ ] Implement Pub/Sub for real-time ## Files to Create - apps/api/src/job-events/job-events.module.ts - apps/api/src/job-events/job-events.service.ts - apps/api/src/job-events/job-events.controller.ts - apps/api/src/job-events/dto/ ## Acceptance Criteria - Events are emitted for all job/step state changes - Events are persisted to PostgreSQL - Recent events available via Valkey Streams - Real-time streaming works via Pub/Sub ## Related - Epic: #162 - Depends on: #164 (schema), #165 (BullMQ/Valkey)
jason.woltje added this to the M4.2-Infrastructure (0.0.4) milestone 2026-02-01 07:24:42 +00:00
jason.woltje added the phase-2apip0api labels 2026-02-01 07:24:42 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mosaic/stack#169