Skip to content

Carry the timeout cleanup outcome in the run summary (#863) - #1313

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

rmcdaniel merged 4 commits into
mainfrom
general/workflow-863-summary-timeout-cleanup

Conversation

@rmcdaniel

@rmcdaniel rmcdaniel commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Part of #863: run lists carry the timeout cleanup outcome, matching describe (run.timeout_cleanup), run detail and the bounded run observation.

Shape

  • New nullable JSON column workflow_run_summaries.timeout_cleanup (TimeoutCleanup::SUMMARY_COLUMN). It holds exactly what TimeoutCleanup::observe() returns: {outcome: "running", cause: "timeout", timeout_kind, started_at, work_deadline_at, cleanup_deadline_at} while cleanup is open, then the terminal event's recorded {outcome, timeout_kind, started_at, cleanup_deadline_at, finished_at, failure_id}. It is null for ordinary, armed, not-entered and completed runs.
  • WorkflowRunSummary casts it, so Waterline's serialized summaries include it. RunListItemView returns timeout_cleanup in its declared field list, null when absent. This follows the task_attention precedent: list items have a fixed key set, while describe and observation omit the key.
  • No scalar timeout_cleanup_outcome column. Nothing filters on it yet, and the JSON column keeps one source of truth. A scalar column with an index can be added if list filtering is needed later.

When it is written

The column is written by the full RunSummaryProjector::project() path. Cleanup entry (watchdog and executor) and every close (WorkflowTimedOut completed/failed/expired, and terminate/cancel preempted) project the whole run. The bounded projections (claim, activity/child groups, fresh-run fast path) leave the column as it is. Ordinary runs cost nothing: observe() returns early when there is no work deadline and no opt-in. The full path already loads WorkflowStarted and the relevant events.

Migration / backfill

2026_11_26_000100_add_timeout_cleanup_to_workflow_run_summaries follows the lost-lease migration. It runs outside the migrator transaction, under the schema lock budget, is repeatable, and has no backfill. Existing rows stay null. A summary gains the value the next time its run is projected. An opted-in run that closed before the upgrade (workflow_runs.timeout_cleanup_work_deadline_at IS NOT NULL) keeps null until workflow:v2:rebuild-projections --run-id=... rebuilds it. Describe, detail and observation read history and are unaffected. I did not bump RunSummaryProjector::SCHEMA_VERSION, because that would mark every summary in every fleet as needing a rebuild for a field only opted-in runs use.

The schema-rollback guard used for task_attention now covers both additive summary columns. The cached column check is shared (WorkflowTaskLeaseLoss::summaryHasColumn), and a write that hits a dropped column retries without the additive columns.

Native Server: durable-workflow/server#1379. It needs no schema change, because its lists read workflow_runs and history.

Tests

  • V2TimeoutCleanupTest::assertVisibleTimeoutCleanup now also checks the projected summary, its serialized form and the list item against describe/observation. That covers armed (null), running, completed, failed, expired, preempted (terminate and cancel), and a run without the option (null). Removing the projector line fails these assertions.
  • Replay corpus evidence timeout-cleanup-summary-listed with a dedicated corpus test, required because the guarded src/V2/Support/*.php changed. The list item is null while armed, running right after the watchdog enters cleanup, and the recorded completed outcome after the cleanup turn closes the run.
  • After merging main (Prove embedded timeout cleanup at signal/selection waits, under worker loss, and on the deadline turn #1312, State that a completed cleanup outcome does not prove cleanup code ran #1314), assertTimedOutAfterCleanup also checks the summary and list item, together with describe, observation and detail. That covers executor entry, same-turn completion, the signal and selection waits, the late activity result and worker loss.
  • testABoundedProjectionAfterACleanupActivityKeepsTheListedValue: after a cleanup compensation activity, the bounded open-workflow-task projection is the summary's last writer, and the listed value is still running.
  • New rollback test: dropping the column keeps projection working, the list item reports null, and describe is unchanged.
  • V2TimeoutCleanupSummaryMigrationTest: runs outside the transaction, has no backfill, adds the nullable column to a populated table, and can run again. Its weights are added to .github/feature-test-timings.json; verify-feature-shards.php passes.

Run locally on SQLite: V2TimeoutCleanupTest, V2TimeoutCleanupSummaryMigrationTest, V2LostLeaseTrackingMigrationTest, V2WorkflowTaskLostLeaseTest, RunListItemViewTest, MigrationsTest, V2RebuildProjectionsCommandTest, ECS on the changed files, and PHPStan (src tests, no errors). CI runs the MySQL/PostgreSQL matrix.

🤖 Generated with Claude Code

Run lists now show what describe returns under run.timeout_cleanup
(#863). The run summary gains a nullable timeout_cleanup JSON column,
written from TimeoutCleanup::observe() whenever the whole run is
projected. Cleanup entry and every close project the whole run, so the
summary holds outcome running while cleanup is open and the recorded
completed, failed, expired or preempted outcome after close; it is null
for ordinary, armed, not-entered and completed runs. Bounded
projections leave the column as it is.

The model casts the column, so Waterline's serialized summaries carry
it, and RunListItemView returns timeout_cleanup (null when absent) in
its declared field list.

The migration follows the task_attention column: outside the migrator
transaction, under the schema lock budget, repeatable, no backfill. The
additive-column rollback guard now covers both summary columns: the
cached column check is shared, and a write that hits a dropped column
retries without either one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rmcdaniel rmcdaniel added the agent:general Work owned by General label Nov 26, 2026
The summary projector and RunListItemView sit under the replay corpus
guard, so the change carries a regression fixture. The corpus test
starts an opted-in run, checks the list item is null while armed,
outcome running after the watchdog enters cleanup, and the recorded
completed outcome after the cleanup turn closes the run.

The summary migration iterates tables that have or lack the column
through one helper instead of repeating the lost-lease migration's
loops.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rmcdaniel and others added 2 commits November 26, 2026 18:11
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review notes on the run-summary change:

- assertTimedOutAfterCleanup, shared by the executor-entry, same-turn,
  signal, selection, late activity result and worker-loss tests, now
  also checks describe, observation, detail, the projected summary and
  the list item against the recorded outcome.
- A cleanup turn that runs a compensation activity: after the activity
  outcome, the bounded open-workflow-task projection is the summary's
  last writer, and the listed value is still outcome running.
- The summary column and list field have their own constant,
  TimeoutCleanup::SUMMARY_COLUMN, instead of reusing STARTED_KEY.

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 c5a91d8ad5c47751d23099380bf1d75d0180c217. The reviewer saw only this PR and #863.

  • First pass at 1344d9e9: code PASS, but the branch conflicted with main after Prove embedded timeout cleanup at signal/selection waits, under worker loss, and on the deadline turn #1312 merged.
    • The column always equals TimeoutCleanup::observe(): at cleanup entry (watchdog and executor), on close (completed, failed, expired, preempted), and for continue-as-new, redrive and import. Bounded projections never clobber it.
    • The migration is additive, nullable and re-runnable under the schema-lock budget. The missing-column guard is correct, and list items and Waterline serialization expose the field.
    • Neither open question blocks the decision: no automatic backfill (the rebuild path is documented), and null versus an omitted key follows the list items' fixed key set.
  • Delta at c5a91d8a: PASS.
    • The merge with main is exactly the union of both sides.
    • The only production change is the SUMMARY_COLUMN constant, with no behaviour change.
    • The shared timed-out helper now checks the summary and list item on the executor-entry, same-turn, signal, selection and process-loss paths, and a bounded-projection assertion was added.
  • Non-blocking: the bounded test could use a sentinel value to prove preservation rather than a correct rewrite.

🤖 Generated with Claude Code

@rmcdaniel
rmcdaniel merged commit 1f4a84c into main Nov 26, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:general Work owned by General

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant