Skip to content

Accept sticky history suffixes only when they continue the cache (#300) - #301

Merged
rmcdaniel merged 1 commit into
mainfrom
feat/300-sticky-history-suffix
Nov 12, 2026
Merged

rmcdaniel merged 1 commit into
mainfrom
feat/300-sticky-history-suffix

Conversation

@rmcdaniel

Copy link
Copy Markdown
Member

Python half of sticky_history_suffix v1 (server#1017), ported from sdk-php#384 (shipped in PHP SDK 3.14.0). Closes #300.

Change

  • With a sticky cache enabled, registration advertises sticky_history_suffix and capability_manifest.sticky_history_suffix = {supported: true, minimum_protocol_version: "1.18", version: 1}. Support is read from the Server's server_capabilities.sticky_history_suffix (supported: true, version: 1).
  • A poll answer with history_after_sequence = N > 0 goes through _load_suffix_history. Any further suffix pages are fetched first. The suffix is used only on sticky_hit_expected when the cached history ends at exactly N and the events run gap-free from N+1 to history_last_sequence. Anything else drops the entry, counts forced_cold_replay and refetches from MA== (base64("0")) on the current lease. A suffix is never treated as full history.
  • When the Server supports suffixes, the sticky completion claim carries history_last_sequence, the last cached sequence.
  • Answers with history_after_sequence absent or 0, which is every pre-3.5.0 Server, keep the existing path unchanged.

Tests

  • tests/test_sticky_history_suffix.py: the five server#1017 vectors (hit, gap, overlap, non-contiguous, cold), plus a suffix that ends short, a boundary that differs from the cache, empty suffixes, a paged suffix, a suffix outside a sticky hit, a Server without suffix support, boundary 0, and the claim field.
  • TestStickyWorkerRegistration: advertisement and Server-support parsing (version 1 only).
  • Replay corpus: sticky-history-suffix-gap-refetches drives the real worker through a hit (no fetch) and a gap (one MA== refetch).
  • Locally on Python 3.13: full suite 5912 passed, plus ruff, mypy and the corpus validator.

🤖 Generated with Claude Code

Workers with a sticky cache advertise sticky_history_suffix v1
(server#1017). A suffix answer is used only on a sticky hit whose cached
history ends at exactly history_after_sequence and whose events run
gap-free to history_last_sequence; anything else drops the entry and
refetches full history from the start. The completion claim reports the
cached last sequence when the Server supports suffixes.

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

Copy link
Copy Markdown

@rmcdaniel
rmcdaniel merged commit c0b952f into main Nov 12, 2026
21 checks passed
@rmcdaniel
rmcdaniel deleted the feat/300-sticky-history-suffix branch November 12, 2026 00:03
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.

Accept sticky history suffixes (sticky_history_suffix v1, server#1017)

1 participant