Skip to content

feat(sse): define sequenced event contract#902

Closed
luoye520ww wants to merge 1 commit into
KunAgent:developfrom
luoye520ww:codex/sse-sequence-contract
Closed

feat(sse): define sequenced event contract#902
luoye520ww wants to merge 1 commit into
KunAgent:developfrom
luoye520ww:codex/sse-sequence-contract

Conversation

@luoye520ww

Copy link
Copy Markdown
Collaborator

Problem

Renderer SSE handling currently receives unversioned event arrays. There is no shared metadata contract for detecting duplicate, stale, or missing stream events before projection.

Root cause

The existing SseEventPayload carries opaque events and a stream ID, but it does not freeze a per-event stream sequence, event identity, or occurrence timestamp.

Scope

This PR defines the sequenced event metadata contract only. It does not change the SSE transport, reducer, reconnect, replay, or cursor behavior.

Changes

  • Add SequencedRuntimeEventSchema and its inferred TypeScript type.
  • Bound stream/event IDs and require a safe non-negative sequence number.
  • Require an offset-aware occurrence timestamp.
  • Add tests for valid envelopes, sequence zero, unsafe values, invalid timestamps, and unknown fields.

Safety

  • Strict schema rejects unrecognized payload fields at this metadata boundary.
  • Sequence values are safe integers and cannot silently lose precision.
  • No renderer state or network behavior changes in this PR.

Typecheck

npm.cmd run typecheck

Result: passed.

Tests

npm.cmd exec vitest run src/shared/sse-sequence.test.ts

Result: 1 file, 3 tests passed.

Actual validation

npm.cmd run lint and npm.cmd run build passed.

Review performed

  • Functional correctness
  • Protocol compatibility
  • Sequence precision and timestamp validation
  • Cross-process safety
  • Test quality and PR scope

PR size

Production files: 1
Test files: 1
Production LOC: 11
Total diff: 57 lines

Follow-ups

Gap detection, bounded replay, persistent resume cursors, and reducer integration remain separate PRs.

@luoye520ww

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated IPC/SSE reliability PR #945, which passed Typecheck, Linux, macOS, and Windows packaged checks. Closing this duplicate to keep the review surface focused.

@luoye520ww luoye520ww closed this Jul 14, 2026
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