Skip to content

fix: preserve uncertainty across append retries - #137

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1790188213-append-retry-uncertainty
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1790188213-append-retry-uncertainty

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Python analog of s2-streamstore/s2#767.

When an append attempt fails indefinitely (e.g. unavailable) and a retry then fails definitively (e.g. rate_limited), the SDK raised only the final error, which reads as "no side effect" — even though the earlier attempt may have become durable.

Unary appends (Retrier(track_append_uncertainty=True)) and append sessions (per _InflightInput.prior_uncertainty) now remember that a retried attempt may have taken effect and, when the final error would otherwise look definite, raise

class AppendIndefiniteFailureError(S2Error):
    final_attempt_error: Exception  # also set as __cause__

Already indefinite final errors and successful retries are unchanged; acknowledged inputs drop their uncertainty when they leave inflight_inputs.

Link to Devin session: https://app.devin.ai/sessions/cbd9b244893a445ea0a9a49dc0cd0fe9
Open in Devin Desktop: https://app.devin.ai/desktop/session/cbd9b244893a445ea0a9a49dc0cd0fe9?variant=devin
Requested by: @sgbalogh

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@sgbalogh
sgbalogh marked this pull request as ready for review September 23, 2026 19:18
@sgbalogh
sgbalogh requested a review from a team as a code owner September 23, 2026 19:18
@greptile-apps

greptile-apps Bot commented Sep 23, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge with no outstanding findings.

Findings

  1. P1 Unsent entries inherit uncertainty
Fix with agent prompt
### Issue 1
src/s2_sdk/_s2s/_append_session.py:154-156
This marks every inflight entry uncertain when any request frame was flushed. An entry is added to `inflight_inputs` before its own frame is yielded and flushed, so batch B can be marked merely because batch A was sent. If a retry acknowledges and removes A, then ends with a definite failure before B is sent, B's stale flag causes `AppendIndefiniteFailureError` even though all possibly durable data was acknowledged and B never left the process. Track uncertainty only for entries actually written on the failed session, as the coupled Go implementation does with per-entry [`sentOnSessions`](https://github.com/s2-streamstore/s2-sdk-go/blob/HEAD/s2/append_session.go).

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR preserves append uncertainty across retries so a definitive final error cannot incorrectly imply that earlier attempts had no side effects.

  • Adds and publicly exports AppendIndefiniteFailureError, retaining the final attempt error as both an attribute and cause.
  • Tracks uncertainty in unary append retries and append sessions.
  • Adds coverage for definitive and indefinite retry outcomes.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Begin append attempt] --> B{Attempt result}
    B -->|Success| C[Return success]
    B -->|Indefinite failure and retryable| D[Record prior uncertainty]
    B -->|Definite failure and retryable| E[Retry without adding uncertainty]
    D --> F[Retry append]
    E --> F
    F --> B
    B -->|Terminal indefinite failure| G[Raise original indefinite error]
    B -->|Terminal definite failure| H{Prior uncertainty?}
    H -->|No| I[Raise final error]
    H -->|Yes| J[Raise AppendIndefiniteFailureError]
Loading

Reviews (2) · Last reviewed commit: "fix: preserve uncertainty across append ..."

Comment thread src/s2_sdk/_s2s/_append_session.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant