Skip to content

Advertise native timeout cleanup after installed vectors pass - #1336

Merged
rmcdaniel merged 3 commits into
mainfrom
general/server-1201-timeout-cleanup
Nov 25, 2026
Merged

rmcdaniel merged 3 commits into
mainfrom
general/server-1201-timeout-cleanup

Conversation

@rmcdaniel

@rmcdaniel rmcdaniel commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Advertise timeout_cleanup: {supported: true, version: 1} in native discovery. The runtime has shipped dark since 3.14.0 (#1235). The contract vectors 1 to 12 now pass installed against published native, with a worker on the published PHP SDK 3.31.0, the first SDK whose worker advertises the capability and sends the interruption marker (durable-workflow/sdk-php#481). Part of #1201.

What changes

  • Discovery. timeout_cleanup::ADVERTISED is true, so /api/cluster/info capabilities and every worker response's server_capabilities carry timeout_cleanup: {supported: true, version: 1}. Admission is unchanged: an opted-in start is still refused with 422 timeout_cleanup_not_supported unless a live worker on the queue advertises the capability, and there is never a silent fallback to a hard timeout.
  • Describe while cleanup is open. Describe and run detail now report outcome: "running" while the engine's timeout request is open, as the portable contract and embedded Workflow 2.40.0 do. This field was null before. state and the other native fields are unchanged.
  • Contracts.
    • The worker OpenAPI documents the WorkerServerCapabilities.timeout_cleanup member (version 68 to 69).
    • The cluster-capabilities parity fixture lists it as a reviewed native addition.
    • The describe divergence entry and docs/rust-server-port.md are updated.
  • Installed harness. scripts/conformance/timeout-cleanup/run.sh runs the vectors against any published native image, with workers on any published PHP SDK installed from Packagist. Nothing in it builds product source. vectors.php drives raw HTTP, and worker.php is the SDK worker. Every container, the network and the local PHP image are removed on exit.

Installed acceptance (published native 3.29.0, PHP SDK 3.31.0)

Image durableworkflow/server@sha256:a2f588ec34b0b3a5a1eb298ce53c0b823260f86cec7bb5c5cb3577dcc5df0127 on SQLite, with durable-workflow/sdk 3.31.0 from Packagist. The clocks are shorter than the contract table (a 12 s allowance).

110 of 110 checks pass. The Server's own advertisement was null, as expected for 3.29.0.

Vector Scenario (allowance 12 s unless noted) Checks Result
admission No worker on the queue, and a queue with only a non-cooperative PHP worker: 422 timeout_cleanup_not_supported, nothing written. The 0, above 86400 and no-hard-timeout field rules also refuse. 7 pass
1 Cleanup returns. One WorkflowTimeoutCleanupStarted with work = hard - allowance, WorkflowTimedOut completed, no WorkflowCompleted, describe failed/timed_out. Code saw WorkflowTimeoutCleanupRequested with cause: timeout. 10 pass
1 (rethrow) Interruption rethrown after compensation, marker sent: completed. 9 pass
2 Compensation throws: failed with failure_id, failure_category: timeout, message ends "Timeout cleanup failed." 10 pass
3 Cleanup outlives the hard deadline: expired, every open timer settled before WorkflowTimedOut. 8 pass
4 terminate and hard cancel during cleanup: WorkflowTerminated / WorkflowCancelled with preempted, no WorkflowTimedOut. 8 pass
5 Server paused from before the work deadline until 5 s after it (allowance 90 s): detected late, work and cleanup deadlines still from admission, completed. 10 pass
6 The worker SIGKILLs itself when the interruption reaches workflow code on its cleanup turn. A fresh process finishes the run: exactly one entry, completed, and only the replacement ran the cleanup activity (allowance 40 s). 9 pass
7 Execution timeout, continue-as-new: the successor keeps the allowance, execution work deadline and hard cap. 10 pass
8 Run timeout, continue-as-new: the successor's run work deadline is its own run deadline - allowance. 10 pass
9 Execution 90 s, run 30 s: kind run, cleanup deadline = run deadline. 8 pass
10 User request-cancellation (120 s) before the work deadline: capped at the hard deadline, no timeout cleanup entered, code saw an ordinary cancellation, WorkflowTimedOut.cancellation_cleanup preempted. 5 pass
11 No opt-in: WorkflowStarted and WorkflowTimedOut carry no timeout_cleanup, no cleanup is entered, and no interruption is delivered. 4 pass
12 Allowance 10 s with a 10 s execution timeout: refused at admission. 1 pass

The per-check table and every recorded history were kept with the run. To reproduce:

SERVER_IMAGE=durableworkflow/server@sha256:a2f588ec34b0b3a5a1eb298ce53c0b823260f86cec7bb5c5cb3577dcc5df0127 \
PHP_SDK_VERSION=3.31.0 EXPECT_ADVERTISED=false scripts/conformance/timeout-cleanup/run.sh

After a release, run it with that release's image and EXPECT_ADVERTISED=true.

Tests

  • admission_refuses_invalid_allowances_and_queues_without_a_capable_worker now asserts both discovery surfaces advertise version 1.
  • The describe test asserts outcome is null while armed and running while cleanup is open.
  • every_published_capability_is_answered counts 70 capabilities and checks the new entry.
  • Locally on rust:1.99.0, the timeout-cleanup and cluster-info unit tests pass, and so do the 15 timeout-cleanup execution tests on SQLite. CI's lib suite at the previous head had one failure, this capability count, which is now fixed. On this overloaded host, a local PostgreSQL 16 run failed in test setup (pool timeouts while opening the database), not in timeout-cleanup assertions. CI's PostgreSQL 17, MySQL 8.0 and MariaDB 10.11 execution jobs run these tests.

Not in this PR

🤖 Generated with Claude Code

Native has served opt-in deadline-triggered timeout cleanup dark since
3.14.0. The contract vectors 1-12 now pass installed against published
native with the published PHP SDK 3.31.0 worker, so cluster info and
worker responses advertise timeout_cleanup {supported: true, version: 1}.
Admission is unchanged: an opted-in start still needs a live worker on
its queue that advertises the capability.

Describe and run detail report the portable outcome "running" while
cleanup is open, as embedded Workflow 2.40.0 does.

scripts/conformance/timeout-cleanup runs the vectors against any
published native image with workers on a published PHP SDK from
Packagist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rmcdaniel
rmcdaniel marked this pull request as ready for review November 25, 2026 21:17
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rmcdaniel

Copy link
Copy Markdown
Member Author

Independent review: PASS. The reviewer saw only this PR and #1201 and reviewed head ccf00aa113a7cd945b7721c278799fa94c71a63c. The current head 53c4a3735ceac177629d5d3a0d500734039ebc11 only merges main into the branch: git diff origin/main HEAD is byte-identical to the reviewed diff, and none of the merged files overlap with this PR.

No blocking findings:

  • Advertising is safe. ADVERTISED controls only discovery. Admission and child admission never read it, so the runtime is exactly the one the installed vectors ran against on published 3.29.0.
  • Contract coverage. Native meets the acceptance criteria and the contract: admission, one-time entry, root-only cause: timeout, the four outcomes, user-request preemption, the closed marker set validated before writes, and inheritance across continue-as-new, redrive and child retry.
  • Describe. outcome: "running" appears only while cleanup is open. It matches embedded TimeoutCleanup::observe and replaces a nullable null.
  • Contract files. The OpenAPI 69, parity fixture, divergence entry and docs agree with each other, and the count of 70 capabilities is right.
  • Harness. Each of the 110 checks fails when its data is missing. The harness removes only its own resources and runs no prune or global Docker commands.

Non-blocking follow-ups:

  • Native's bounded run observation (used by Waterline) does not yet return timeout_cleanup at the top level, as the contract and embedded RunObservation do, and no divergence is registered for it.
  • In the describe divergence entry, since and the embedded version references are stale.
  • The vector 6 and 11 rows in the body are now worded to what the harness asserts.
  • Claims during cleanup require only cooperative_cancellation. A mixed queue can therefore end expired, never a false completed. Release notes should warn against mixed-version queues.

🤖 Generated with Claude Code

@sonarqubecloud

Copy link
Copy Markdown

@rmcdaniel
rmcdaniel added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 6d03a7d Nov 25, 2026
64 checks passed
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