Skip to content

refactor(codemode): avoid merging root definitions twice - #46081

Merged
kitlangton merged 1 commit into
v2from
schema-definitions
Aug 31, 2026
Merged

kitlangton merged 1 commit into
v2from
schema-definitions

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Why

JSON Schema rendering constructs a dictionary from root definitions and $defs, then immediately passes it to renderSchema, which copies and merges those same definitions again.

What Changes

Start the root renderer with an empty inherited-definition context. Its existing schema-local merge remains the single owner of root definitions, preserving $defs precedence, nested shadowing, sibling isolation, and compact/pretty output.

Scope

One production line plus focused tests. Effect schema document definitions in toTypeScript are unchanged; no schema, tool API, or interpreter changes.

Verification

cd packages/codemode
bun run test test/signature.test.ts
bun typecheck
cd ../..
bunx prettier --check packages/codemode/src/tool-schema.ts packages/codemode/test/signature.test.ts
git diff --check HEAD^ HEAD

28 signature tests passed before and after the production change. Package typechecking, formatting, and whitespace checks passed. The new cases exercise legacy definitions, $defs precedence, and nested/sibling scope in both rendering modes.

@kitlangton
kitlangton merged commit d609752 into v2 Aug 31, 2026
14 of 15 checks passed
@kitlangton
kitlangton deleted the schema-definitions branch August 31, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant