These docs are a work in progress and may not be fully up to date. Some pages may contain internal notes for our team.
Skip to Content

Data model — Process

Generic header record for any long-running background job. The frontend polls GET /processes/{id} or streams GET /processes/{id}/stream (SSE) to drive the job tray UI. Each process has an append-only ProcessEvent log that captures per-step progress.

Table: processes

ColumnTypeNullableDescription
idbigintnoPrimary key
workspace_idbigintyesOwning workspace
user_idbigintyesUser who triggered the job
typestringyesJob type identifier (see below)
statusstringnoState machine status (see below)
progress_percentintyes0–100 completion estimate
current_stepstringyesHuman-readable label for the running step
summaryjsonyesStructured result data populated on completion
error_messagestringyesException message if status is failed
queuestringyesLaravel queue name the job was dispatched to
attemptsintyesNumber of job dispatch attempts
related_typestringyesPolymorphic model class (e.g. App\Models\AiLocationImportBatch)
related_idbigintyesPolymorphic ID pointing to the originating batch record
input_payloadjsonyesSnapshot of the job’s input parameters
started_attimestampyesWhen the job began processing
finished_attimestampyesWhen the job reached a terminal state
created_attimestamp
updated_attimestamp

Status state machine

StatusTerminalDescription
pendingnoCreated, not yet picked up by a worker
runningnoWorker is actively processing
waiting_reviewnoCompleted a step, paused awaiting user action
completedyesSuccessfully finished
failedyesUnrecoverable error; error_message populated
cancelledyesUser or system cancelled before completion

POST /processes/{id}/retry transitions failedpending. POST /processes/{id}/cancel transitions any non-terminal status → cancelled.

Job types

🔴 [NEEDS CLARIFICATION: Confirm the full type enum from the job or process service layer. Known types based on codebase context: ai_location_import, ai_location_improvement, csv_import.]

ProcessEvent log

Every significant step within a job appends a ProcessEvent row. Events are immutable once written — this is an audit trail, not mutable state.

Table: process_events

ColumnTypeNullableDescription
idbigintnoPrimary key
process_idbigintnoParent process
typestringyesEvent category (e.g. step, error, progress)
statusstringyesStatus snapshot at event time
progress_percentintyesProgress snapshot at event time
stepstringyesStep label
messagestringyesHuman-readable event message
payloadjsonyesStructured event data
created_attimestamp
updated_attimestamp

Relations

  • belongsTo Workspace
  • belongsTo User
  • hasMany ProcessEvent — ordered ascending by id (insertion order)
  • related_type / related_id — polymorphic pointer to the originating batch model (AiLocationImportBatch, AiLocationImprovementBatch, etc.)

SSE streaming

GET /processes/{id}/stream opens a Server-Sent Events connection. The backend emits each new ProcessEvent as it is written, then closes the stream when the process reaches a terminal status or after 25 seconds (whichever comes first). The frontend reconnects automatically if the stream closes before the process is done.