Skip to content

Implement PHP Server's sticky execution contract on native (#1017 part 1) - #1140

Merged
rmcdaniel merged 1 commit into
mainfrom
feat/server-1017-sticky-parity
Nov 11, 2026
Merged

rmcdaniel merged 1 commit into
mainfrom
feat/server-1017-sticky-parity

Conversation

@rmcdaniel

Copy link
Copy Markdown
Member

Part 1 of #1017 (PHP parity). Part 2, the history suffix that actually cuts transfer, follows behind the sticky_history_suffix capability (wire shape on #1017; sdk-php owns the SDK half).

Change

Native now follows published PHP Server 2.11.8 / Core 2.15.12 sticky execution:

  • Completion: sticky_cache needs protocol ≥ 1.18, a registration that lists and supports sticky_execution, and the exact worker/run/workflow/build (build falls back to the registration's SDK version). Otherwise 409 portable_worker_affinity_protocol_floor_unavailable, worker_capability_not_supported or sticky_cache_identity_mismatch, as PHP answers. An accepted claim sets workflow_runs.sticky_worker_id/sticky_until (TTL from the claim; cleared when the run closes) and stores the worker's cache metrics.
  • Claim: each workflow claim records and returns sticky_worker_id, sticky_until and sticky_replay_mode (sticky_hit_expected / forced_cold_replay / cold_replay) by Core's rule. Routing and full-history delivery are unchanged, exactly as PHP. The mode is derived from the run's affinity in the existing lease UPDATE, so claims gain no statement.
  • Re-registration of a worker process clears its runs' affinity.
  • Capability: server_capabilities.sticky_execution is Core's StickyExecution::describe() (was false). Operator metrics report real active/ready/leased counts and last-minute hit/forced/cold counts.
  • No schema change: the frozen PHP schema already has the columns.

Behavior change to note

A completion carrying sticky_cache from a worker whose registration doesn't support sticky_execution is now refused (409), as PHP does; native used to ignore the field. sdk-python and sdk-php register the capability before sending claims. sdk-python refused to enable its sticky cache against native because native advertised no support; it now can.

Checks

  • New tests/execution/sticky_execution.rs: cold first claim, identity-mismatch 409, sticky_hit_expected for the sticky worker with full history still delivered, forced_cold_replay for another worker and after TTL expiry, metrics counts, affinity cleared on re-registration.
  • continuations test updated to register the capability it claims.
  • SQLite: cargo test --lib 481 passed (plus a unit test for the claim rule); full --test execution passes. CI runs MySQL/MariaDB/PostgreSQL.

🤖 Generated with Claude Code

Native advertised sticky_execution unsupported, ignored every completion's
sticky_cache claim and told each claim to expect a cold replay (#1017, part
1). It now follows published PHP Server 2.11.8 and Core 2.15.12:

- A completion's sticky_cache needs protocol 1.18, a registration listing
  and supporting sticky_execution, and the exact worker, run, workflow and
  build; otherwise 409 as PHP answers. An accepted claim records the run's
  sticky worker until the claim's TTL, cleared when the run closes, and keeps
  the worker's reported cache metrics.
- Each workflow claim records and returns sticky_worker_id, sticky_until
  and sticky_replay_mode (sticky_hit_expected, forced_cold_replay or
  cold_replay). Routing and full history delivery are unchanged, as in PHP.
- Re-registering a worker process clears its runs' affinity.
- The server capability is Core's StickyExecution::describe(), and
  operator metrics report real affinity and last-minute replay counts.

No schema change: the frozen PHP schema already has these columns.

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

Copy link
Copy Markdown

@rmcdaniel
rmcdaniel added this pull request to the merge queue Nov 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 11, 2026
@rmcdaniel
rmcdaniel added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit d75c654 Nov 11, 2026
63 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