refactor(core): fold single-consumer request modules into model-request - #43958
Merged
Conversation
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.
What
Folds four session request-shaping modules into
model-request.ts, their only remaining consumer. Zero behavior change — every moved function is byte-identical logic under a private name.These modules existed to be shared across the four hand-rolled request sites (runner, generate, title, compaction). After the envelope unification (#42680, #43555) routed all requests through
SessionModelRequest.prepare, that boundary became their sole importer — four files of indirection for ~30 lines each. This makes the code's shape match the architecture that already landed:prepareis the one place requests are shaped, and now it reads top to bottom in one file.model-headers.ts(SessionModelHeaders.make)sessionHeadersprompt-cache-key.ts(SessionPromptCacheKey.make)promptCacheKeymodel-hook.ts(SessionModelHook.apply)applyModelHooksmodel-http.ts(SessionModelHttp.middleware)httpMiddlewareHow
packages/core/src/session/model-request.ts— the four functions land beside the file's other helpers, sharing oneHookScopetype for the identity plugin hooks see. Call sites renamed in place; nothing else touched.prepare).No changeset: internal refactor with no observable change.
Scope
Mechanical fold-in only. No signature, wire, or behavior changes;
model-transport.tskeeps its own module (it has service/layer structure, not just a function).Testing
bun typecheck(packages/core): cleanbun run test(packages/core): 1,935 tests, 0 fail