Repository navigation
feat(core): deterministic session log replay with synced watermark - #35040
Merged
Merged
Conversation
This was referenced Jul 19, 2026
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
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.
Summary
Replay durable Session logs through a fixed pre-captured watermark and emit
log.syncedexactly once, replacing the oldlog.caught_upmoving-boundary marker. This makes reconnect-safe log replay deterministic while preserving live tail delivery for events committed during replay.Changes
packages/schema: renameEventLog.CaughtUp/log.caught_uptoEventLog.Synced/log.synced, update marker docs, and cover optionalseqencoding.packages/core: add boundedreadAfter { through, limit },LayerOptions.logReadPageSizedefaulting to 512, pull-driven paged replay, once-only synced marker, andisCaughtUp->isSynced.packages/protocol: update the Session log SSE union and route description to thelog.syncedcontract.packages/clientandpackages/sdk-next: update marker-related tests without regenerating generated client trees.specs/v2: document the marker rename, deterministic watermark replay, and generated-client integration timing.Decisions
aggregateIDonlog.syncedfor consistency with envelopes, hints, and core aggregate APIs.seqwhen the captured watermark is empty (-1).LayerOptions.logReadPageSize, default512.session.getwatermark and generalized aggregate log API.Closes #35015
Part of #35021
Test Plan
packages/schema:bun typecheckpassed.packages/core:bun typecheckpassed.packages/core:bun run test -- test/event.test.ts test/session-log.test.ts test/session-create.test.ts test/session-prompt.test.tspassed.packages/protocol:bun typecheckpassed.packages/client:bun typecheckpassed.packages/client:bun run test -- test/effect.test.ts test/promise.test.tspassed.packages/sdk-next:bun typecheckpassed.packages/sdk-next:bun run test -- test/embedded.test.tspassed.bunx prettier --check packages/client/test/effect.test.ts packages/client/test/promise.test.ts packages/core/src/event.ts packages/core/src/session.ts packages/core/test/event.test.ts packages/core/test/session-create.test.ts packages/core/test/session-log.test.ts packages/core/test/session-prompt.test.ts packages/protocol/src/groups/session.ts packages/schema/src/event-log.ts packages/schema/src/event.ts packages/schema/test/event.test.ts packages/sdk-next/test/embedded.test.ts specs/v2/schema-changelog.md specs/v2/session.mdpassed.bun turbo typecheckpassed.Generated client regeneration intentionally happens at integration time per the audit merge protocol; generated trees are untouched on this branch.