Repository navigation
Treat an SSE error event as an incomplete replay walk - #8
Merged
Merged
Conversation
An `error` event stopped the walk with `complete` true, so read_activity returned a summary built from a partial replay, with no activity_error, and cached it for terminal runs. cursor_supervise could then list such a row as stale or unfinished_after_end, never as incomplete, and later reads reused the summary without retrying the stream. The walk now stops on `error` with `complete` false, and read_activity reports it as an UPSTREAM activity_error, without a summary or caching. Found by an external audit of 0dc8147. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEZSiBG4UoNrAh3mC9CUmP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
This fixes the one remaining defect from the external audit of
0dc8147.In
stream.py::_walk, an SSEerrorevent stopped the replay walk withcomplete = True.supervision.py::read_activityignoredstream_error, which had three effects:cursor_get_run(activity): returned a summary built from a partial replay, with noactivity_error.cursor_supervise: could list such a row asstaleorunfinished_after_end, and never asincomplete.Fix
_walk: anerrorevent still ends the walk, butcompletestays false. It now breaks immediately, so a live timestamp on the error event cannot mark the walk complete.read_activity: onstream_error, it returnsactivity_error(UPSTREAM: …) with no summary, and caches nothing.cursor_supervisethen counts the row inincompletethrough the existing logic.truncated: truenext tostream_error: truein that case. This is accurate, since the end of the replay was not proven.README.mdanddocs/api-contract.md.Test
test_a_stream_error_is_neither_a_complete_summary_nor_cachedreads the same terminal run twice.errorevent. The call must return noactivity, and itsactivity_errormust start withUPSTREAM.The test fails on
0dc8147and passes with the fix.Validation
ruff check src tests scripts: passes.pytest: 125 tests pass.erroron demand.🤖 Generated with Claude Code
https://claude.ai/code/session_01FEZSiBG4UoNrAh3mC9CUmP
Generated by Claude Code