refactor(codemode): name the data boundary and prepare tools once - #48021
Open
rekram1-node wants to merge 1 commit into
Open
refactor(codemode): name the data boundary and prepare tools once#48021rekram1-node wants to merge 1 commit into
rekram1-node wants to merge 1 commit into
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.
Summary
Second cleanup pass, following #48009. Behavior-preserving; the existing
copyOutparity tests (toStrictEqual) now pin the new functions.One data boundary module
copyIn(value, label, preserveCodeModeValues)+copyOut(value, mode)did three different jobs behind a boolean and a two-pass pipeline. They're replaced by a new dependency-freedata.tswith one walker and three named directions:toProgram(value, label)Values.*, wraps host Date/Map/…)boundedData/copyIn(…, true)fromData(value, label)copyIn(…, false)on tool output andJSON.parsetoData(value, label, undefinedAs?)copyOut(copyIn(…), "json" | "nullify")Tool arguments and the execution result now traverse once instead of twice.
SafeObject,isBlockedMember, andToolRuntimeErrormove todata.tstoo, so the stdlib andopenapi/spec.tsno longer import the tool runtime (Effect Schema, search, hooks) for a three-line blocked-name check.JSON.stringifyis restructured so each branch does exactly one copy instead of a discarded validation pass plus a real one.Tools prepared once
ToolRuntime.prepare(tools)now returns{ root, catalog, searchIndex }andToolRuntime.makeconsumes it. Previously the trie was rebuilt on every execution (and twice per one-shotCodeMode.execute). Removed:searchIndex(),DiscoveryPlan, the deadToolRuntime.rootfield.codemode.tsOptionsis the base type;ExecuteOptions = Options & { code }(was inverted viaOmit).OptionsextendsToolCallHooksinstead of redeclaring both hooks.execute = make(options).execute(options.code).executeProgram(code, prepared, limits, hooks)is generic inRand no longer takes the public options bag, removing the reversecodemode.ts → execute.tstype coupling.Net −44 lines.
Test plan
bun typecheck(withnoUnusedLocals)bun test— 1141 passpackages/corehas no references to removed exports