Work Record Object
A Work Record tracks one run of a Station. Each time a station runs, a new work record captures the run's state and output.
Object Structure
{
"id": "wr_abc123def",
"station": "st_def456",
"status": "completed",
"output": { "done_count": 2, "failed_count": 1 },
"config_snapshot": {},
"config_overrides": null,
"started_at": "2024-01-15T10:30:00Z",
"completed_at": "2024-01-15T10:30:45Z",
"performed_by": "api_key_name",
"error": null,
"created_at": "2024-01-15T10:30:00Z"
}
Fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Auto | 12-character unique identifier |
station | string | Yes | ID of the station being executed |
status | string | Auto | Execution status |
output | object | Auto | What the station's handler returned |
config_snapshot | object | Auto | The station's config with the run's overrides, frozen when the run was queued |
config_overrides | object | No | Per-run overrides sent to Run Station |
started_at | string | Auto | When execution started |
completed_at | string | Auto | When execution finished |
performed_by | string | Auto | Who triggered the execution |
error | string | Auto | What went wrong, if failed |
created_at | string | Auto | ISO 8601 timestamp |
Status Values
| Status | Description |
|---|---|
pending | Work record created; queued, waiting for a factory session at the line's location to claim it |
running | Claimed by a factory session |
completed | The handler returned; its result is in output |
failed | The handler failed and wasn't retried, or failed after its retries (see error) |
cancelled | Cancelled by a person or through the API |
timed_out | Running for more than 4 hours, or pending for more than 30 minutes |
Status Transitions
pending → running → completed
│ ├─→ failed
│ └─→ timed_out / cancelled
└─→ timed_out / cancelled
A handler that throws is reported with POST /api/factory/failed. A retryable failure queues the run again, up to 3 retries; after the last, the work record is failed. A retry runs the handler again from the start, so a station must be safe to rerun. A workpiece that fails inside a run doesn't fail the run: the handler completes and reports each workpiece's outcome.
How a run is queued
The work record is the run's queue entry; there is no separate queue. When a run starts, the
Orchestrator freezes the station's config (with the run's config_overrides) as
config_snapshot and the line's location on the work record, and queues it. Editing the
station or the line doesn't change a run already queued.
A factory session at that location claims the oldest queued run with
GET /api/factory/poll, runs the station's handler, and
reports the handler's result, which is stored as output. A retried run stays running,
goes back in the queue and keeps its place there.
The queue fields (location, queued_at, claimed_at, retry_count, factory_session)
live on the work record but aren't returned by the API.
Error Structure
When a work record fails, error holds the message the factory session reported:
{
"status": "failed",
"error": "HTTP request failed with status 500"
}
Triggering Execution
Run a station to create a work record and queue it:
curl -X POST "https://orchestrator.assemblyline.sh/api/v1/stations/st_def456/run" \
-H "api-key: al_xxxxxxxxxxxx" \
-H "api-secret: xxxxxxxxxxxxxxxx"
The orchestrator will:
- Create the work record with status
pending - Freeze the config and location on it and queue it
- Hand it to a factory session at the line's location, which runs the station's handler
- Update status to
completedorfailed
Create Work Record records a run without queuing it.
Polling for Completion
After creating a work record, poll to check completion:
curl -X GET "https://orchestrator.assemblyline.sh/api/v1/work-records/wr_abc123" \
-H "api-key: al_xxxxxxxxxxxx" \
-H "api-secret: xxxxxxxxxxxxxxxx"
Check the status field until it's completed or failed.