Repository navigation
refactor(core): avoid redundant payload decoding in session inbox and prompt - #57946
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
No problems found; the refactor keeps the same behaviour. Effect make already validates its input, so dropping the nested Prompt.make/Delivery.make/ID make calls still validates each value once. The type check in publish matches the old fromRow plus compaction rejection, and a malformed payload now fails in projectDelivered with the same defect result. Hoisting decodeAssistantContent is safe.
Checked with the session tests in packages/core (prompt, move, compact, skill, execution, runner, owned: 352 pass, 0 fail) and bun run typecheck, which passed.
Public API unchanged (internal packages/core session code only).
5 tasks
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
Several paths in
packages/core/src/session/redundantly validate or decode values that are already validated at the boundary or decoded in a downstream projector:SessionInbox.publishcallsfromRow(row)to readid,type, anddeliverybefore publishingSessionEvent.InboxDelivered, even though those fields are top-level columns onSessionInboxTableandprojectDeliveredalready decodes the deleted row viafromRow(deleted).SessionInbox.fromRowandSessionInbox.admitCompactionre-wrap already-typedrow.id,row.session_id, andinput.deliveryvalues in.make(...)before passing them to schema constructors that validate them again.SessionPrompt.preparespreadsPrompt.make(...)intoSessionInbox.UserPayload.make(...), validating all prompt fields and base64 attachments twice, and re-wrapsevent.deliverywithSessionInbox.Delivery.make(...).SessionMessageUpdater.updaterebuildsSchema.decodeUnknownSync(Schema.Array(SessionMessage.AssistantContent))insideupdate()on everysession.message.content.updatedevent.Change
Pass already-typed columns and fields directly to the owning schema constructors, avoid decoding inbox payloads prior to
InboxDeliveredprojection, and hoist the assistant content array decoder to module scope.Out of scope
PromptandSessionInboxin@opencode/schema.