Skip to content

Treat an SSE error event as an incomplete replay walk - #8

Merged
yoch merged 1 commit into
mainfrom
ccr-e9d4cfba-t6i5xz
Oct 6, 2026
Merged

yoch merged 1 commit into
mainfrom
ccr-e9d4cfba-t6i5xz

Conversation

@yoch

@yoch yoch commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Problem

This fixes the one remaining defect from the external audit of 0dc8147.

In stream.py::_walk, an SSE error event stopped the replay walk with complete = True. supervision.py::read_activity ignored stream_error, which had three effects:

  • cursor_get_run(activity): returned a summary built from a partial replay, with no activity_error.
  • cursor_supervise: could list such a row as stale or unfinished_after_end, and never as incomplete.
  • Terminal runs: the wrong summary was cached, so later reads reused it without reading the stream again.

Fix

  • _walk: an error event still ends the walk, but complete stays false. It now breaks immediately, so a live timestamp on the error event cannot mark the walk complete.
  • read_activity: on stream_error, it returns activity_error (UPSTREAM: …) with no summary, and caches nothing. cursor_supervise then counts the row in incomplete through the existing logic.
  • Tail mode: now reports truncated: true next to stream_error: true in that case. This is accurate, since the end of the replay was not proven.
  • Docs: one sentence each in README.md and docs/api-contract.md.

Test

test_a_stream_error_is_neither_a_complete_summary_nor_cached reads the same terminal run twice.

  • First read: the stream sends an error event. The call must return no activity, and its activity_error must start with UPSTREAM.
  • Second read: the stream is valid. The stream must be read again (2 reads), and the summary must be complete.

The test fails on 0dc8147 and passes with the fix.

Validation

  • ruff check src tests scripts: passes.
  • pytest: 125 tests pass.
  • No paid smoke: a real run cannot trigger an SSE error on demand.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FEZSiBG4UoNrAh3mC9CUmP


Generated by Claude Code

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
@yoch
yoch marked this pull request as ready for review October 6, 2026 13:50
@yoch
yoch merged commit b36cf17 into main Oct 6, 2026
2 checks passed
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.

2 participants