Skip to content

Carry the timeout cleanup outcome in native run lists (workflow#863) - #1379

Merged
rmcdaniel merged 2 commits into
mainfrom
general/server-863-summary-timeout-cleanup
Nov 26, 2026
Merged

rmcdaniel merged 2 commits into
mainfrom
general/server-863-summary-timeout-cleanup

Conversation

@rmcdaniel

@rmcdaniel rmcdaniel commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Native half of durable-workflow/workflow#863 (embedded: durable-workflow/workflow#1313). Run lists now carry the timeout cleanup outcome in the same portable shape as the bounded run observation (server#1344) and embedded describe.

API

GET /api/workflows items and GET /api/workflows/{workflow_id}/runs entries gain timeout_cleanup when the run recorded cleanup:

  • While cleanup is open: {outcome: "running", cause: "timeout", timeout_kind, started_at, work_deadline_at, cleanup_deadline_at}.
  • After close: the terminal event's {outcome, timeout_kind, started_at, cleanup_deadline_at, finished_at, failure_id}, keeping string fields only.
  • The key is omitted for ordinary, armed, not-entered and completed runs. This matches the observation and keeps every recorded parity comparison unchanged, since no corpus run opts in.

No schema change

Native's run lists don't read workflow_run_summaries. list_workflows and list_runs select from workflow_runs, and only join the summary table to order imported Waterline projections. Native does write and read that table elsewhere (terminal_summary.rs, active_summary.rs, operator_metrics.rs), but none of those paths serve these lists. So the value is read at list time, the same way task_attention is, and there is no schema version bump, step file or catalog churn. The embedded PR stores the value in a summary column because its lists (Waterline, RunListItemView) read the summary table. Neither side needs the other's migration first.

Operator dashboard: won't do. The dashboard rows that copy WorkflowRunSummary::toArray() (operator_metrics.rs ~137-160 and 391-393) keep the frozen published PHP Server's shape. That server's pinned Workflow version won't move, so native will not add timeout_cleanup there. Lists, describe and the run observation carry the field. No follow-up is open.

Bounded reads

The opt-in check runs once per page. One query (id IN the page, using the same JSON id-list form as task_attention) joins each run's WorkflowStarted row by unique (workflow_run_id, sequence IN (1,2)) seeks. WorkflowStarted is the first event, or the second after StartAccepted, on every native and embedded start, child, retry, continuation and redrive. It keeps runs whose payload carries a timeout_cleanup object, using per-backend JSON type predicates. Of those, it keeps closed runs (failed, cancelled, terminated) and open runs that hold a cooperative cancellation request or were imported: cleanup entry sets the engine's request, nothing clears it while open, and an embedded import does not copy it. Only these candidates read the observation's event. That is the newest event of the type observation_event(status) chooses, via the shared observed_timeout_cleanup_event helper the run observation also uses. When a closed candidate's terminal event is the wanted type, it is the newest event and the lookup stops at once. An opted-in run that failed without timing out scans its own history once, exactly as its observation does. Ordinary runs (for example a WorkflowFailed run), armed runs and completed runs read nothing beyond the page query. Lists apply the same opt-in gate as the observation.

Tests

tests/execution/timeout_cleanup.rs gains assert_listed. It checks that both lists equal the observation's timeout_cleanup, or that the key is absent where the observation omits it. It runs for a run without the option, armed, running, completed, failed, completed-via-marker, expired (in cleanup and before detection), and preempted by terminate and by cancel. A mixed-page test lists an ordinary failed run and an opted-in run cancelled before its work deadline without the key, next to an opted-in run in cleanup. Locally on SQLite, timeout_cleanup:: (15), visibility, continuation, run_observation and operator_metrics execution tests pass. CI runs the MySQL, MariaDB and PostgreSQL matrices.

The describe-timeout-cleanup-state divergence and docs/rust-server-port.md now say that lists, like the observation, return embedded's shape from the release after 3.30.0. The divergence also says lists omit the key when absent, unlike their always-present task_attention: null, so clients should treat absent and null alike.

🤖 Generated with Claude Code

GET /api/workflows and GET /api/workflows/{workflow_id}/runs now return
the bounded run observation's timeout_cleanup on each listed run that
recorded cleanup, and omit it otherwise, as embedded Workflow's run
summary does (workflow#863): outcome running with the cause, kind,
start and deadlines while cleanup is open, then the outcome recorded on
the terminal event.

Native lists read workflow_runs and history, not the summary table, so
this needs no schema change. The value comes from the same event the
observation reads (newest of the type observation_event chooses), now
one shared helper. Reads stay bounded per page: a closed run's
terminal event is its newest, so its lookup stops at once; an open run
can only be in cleanup while it holds a cooperative request, which one
query checks for the whole page; completed runs read nothing.

The describe divergence notes that, like the observation, the lists
return embedded's shape from the release after 3.30.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the run-list change: every failed, cancelled or terminated run
on a page read its history for the observation's event, and with no
index on event_type an ordinary WorkflowFailed run scanned its whole
history looking for WorkflowTimedOut.

One query per page now selects the candidates. It joins each run's
WorkflowStarted (unique (run, sequence) seeks: it is the first event,
or the second after StartAccepted), keeps runs whose payload carries a
timeout_cleanup object (per-backend JSON type predicates), and of those
the closed runs and the open runs holding a cooperative request or
imported (an embedded import does not copy the request). Only the
candidates read the observation's event. This is the observation's own
opt-in gate, so lists equal it exactly.

A new test lists an ordinary failed run and an opted-in run cancelled
before its work deadline without the key, on the same page as a run in
cleanup. The port document describes the reads as they are, and the
divergence entry says lists omit the key when absent, unlike their
task_attention: null.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@rmcdaniel

Copy link
Copy Markdown
Member Author

Independent review: PASS at ff6714739587888533ecf068712b19136f3dd0b9. The reviewer saw only this PR, durable-workflow/workflow#863 and the embedded counterpart #1313.

  • First pass at 3d7211a1: BLOCKING. Every failed, cancelled or terminated run on a list page did a per-run history lookup filtered by event_type, which no index covers. So an ordinary WorkflowFailed run scanned its whole history, up to 200 per page. A docs sentence about the cost was also wrong.
  • Delta at ff671473: PASS.
    • A once-per-page opt-in gate uses per-backend JSON predicates matching the observation's is_object() check. Only opted-in runs in a candidate state are looked up.
    • Ordinary failed and user-cancelled opted-in runs are listed without the key.
    • The docs are corrected, imported open runs pass the prefilter, and the divergence entry tells clients to treat absent and null alike.
  • Non-blocking:
    • The gate assumes WorkflowStarted is at sequence 1 or 2, which every native writer satisfies.
    • Opted-in runs that never entered cleanup can still scan their history, at the observation's own per-run cost.
    • Tests check values returned, not query counts.
  • Follow-up kept out of this PR: the operator-dashboard rows that copy WorkflowRunSummary::toArray(), gated on the published-PHP pin.

🤖 Generated with Claude Code

@rmcdaniel
rmcdaniel added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit 51581b3 Nov 26, 2026
64 checks passed
@rmcdaniel

Copy link
Copy Markdown
Member Author

The operator-dashboard follow-up mentioned in the body and in the review comment is won't do. The published PHP Server is frozen and its pinned Workflow version won't move, so the dashboard rows keep its summary shape. Lists, describe and the run observation carry timeout_cleanup. Nothing is left open here.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant