Full Specification

πŸ“Ž View on Notion β†’


Overview

Purpose: Track concurrent job execution state without MQ overhead.

Context: MIND Universe Job Pool concurrency model.

Problem: Need to track job state (running, lost, finished) without constant MQ polling.


Architecture

Event-Driven Model

The Job Pool maintains all active jobs and communicates with them through the Event Bus. Three event types flow from jobs back to the pool: Heartbeat indicates the job is alive, Finished signals successful completion, and Internal is reserved for system services like the Job Collector. This event-driven approach eliminates the need for constant polling while maintaining full visibility into job state.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Job Pool     │◀───────▢│    Event Bus    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β–Ό                   β–Ό                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Heartbeat     β”‚ β”‚   Finished      β”‚ β”‚   Internal      β”‚
β”‚   Event         β”‚ β”‚   Event         β”‚ β”‚   Event         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Job Lifecycle

Jobs transition through four states from Queued to Running to Finished. The Lost state is reached when no Heartbeat is received within the configurable timeout threshold. This lifecycle allows the Job Collector to identify and unregister stalled jobs without blocking the execution of healthy ones.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Queued   │────▢│  Running  │────▢│  Finished β”‚     β”‚   Lost    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”˜
                        β”‚                                   β”‚
                        └───────── Heartbeat β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          (Timeout β†’ Lost)

Event Types

Event Type Description Frequency
Heartbeat Job alive indicator Every N seconds
Finished Job completed successfully Once per job
Internal System events (JC, Checkpointer) As needed

Components

Job Collector (JC)

Metric Value
Timeout Threshold Configurable (default: 5 min)
Check Interval Every 30 seconds
Action Unregister lost jobs from pool

Checkpointer

Metric Value
Checkpoint Interval Configurable (default: 1 min)
Persistence Local disk snapshot
Recovery Restore queued jobs after restart

Trade-offs

Trade-off Impact
Event bus overhead Minimal (in-process)
Heartbeat frequency Network traffic vs. detection speed
Checkpoint frequency Disk I/O vs. recovery point


← Back to Specifications