Skip to content

feat: Executions - API - Expose container status history on the details endpoint#288

Open
morgan-wowk wants to merge 1 commit into
masterfrom
expose-status-history-in-details
Open

feat: Executions - API - Expose container status history on the details endpoint#288
morgan-wowk wants to merge 1 commit into
masterfrom
expose-status-history-in-details

Conversation

@morgan-wowk

@morgan-wowk morgan-wowk commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a status_history field to GetExecutionInfoResponse (served by GET /api/executions/{id}/details).

The status-transition instrumentation in orchestrator_sql.py already records, on every container-execution status change (deduped on consecutive identical statuses), an entry {status, first_observed_at} into ExecutionNode.extra_data["container_execution_status_history"]. That data was DB-only — no endpoint exposed it. This surfaces it on the details endpoint (which is keyed on the ExecutionNode, the same entity that owns extra_data, and is available regardless of container launch).

Why

Clients can now compute true time-in-status for a task. The list is ordered and its last entry is the node's current status, so status_history[-1].first_observed_at is exactly when the node entered that status — including pre-launch states like QUEUED/PENDING that have no ContainerExecution row (so /container_state can't help).

Details

  • New StatusHistoryEntry dataclass: {status: str, first_observed_at: datetime}.
  • first_observed_at is parsed from the stored ISO-8601 string to a datetime.
  • Malformed/partial entries (missing either key) are skipped; absence yields null rather than [].
  • Purely additive, optional field — no change to existing fields or callers (kw_only dataclass with a default).

Tests

tests/test_execution_nodes_api_service.py — new TestGetExecutionInfo:

  • returns history parsed and in order; last entry's timestamp is a tz-aware datetime
  • None when no history present
  • skips malformed entries

pytest tests/test_execution_nodes_api_service.py → 7 passed. black clean.

…ls endpoint

Surface ExecutionNode.extra_data status-change history (recorded by the
status-transition instrumentation) as a new status_history field on
GetExecutionInfoResponse (GET /api/executions/{id}/details).

Each entry is {status, first_observed_at}; the list is ordered and the last
entry corresponds to the node's current status, so its first_observed_at is
when the node entered that status. This lets clients compute true
time-in-status (e.g. how long a task has been PENDING/QUEUED) instead of
relying on a browser-session heuristic. Malformed/partial entries are skipped;
absence yields null rather than an empty list.
@morgan-wowk morgan-wowk requested a review from Ark-kun as a code owner June 26, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant