Skip to content

refactor(downgrader): drop the unreachable isRecord check on anyOf targets - #95

Merged
dinwwwh merged 1 commit into
mainfrom
claude/project-thread-zdzdtj
Oct 24, 2026
Merged

dinwwwh merged 1 commit into
mainfrom
claude/project-thread-zdzdtj

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Oct 24, 2026

Copy link
Copy Markdown
Member

Requested by dinwwwh · project thread

Problem

Since #92, branch coverage is 99.78%. In convertSchemaRef (3.1 to 3.0), if (isRecord(holder)) is only false for a kept $ref whose part before /anyOf/ doesn't resolve, which no test hits.

Fix

anyOfTargets becomes a Set<unknown> and the resolved value is added as is. The set is only queried with input schema objects in downgradeV30, so an unresolved value in it changes nothing. +2/−5.

Checks

  • pnpm run check passes
  • 262 tests pass
  • Coverage is 100% for statements, branches, functions and lines
  • Output is byte-identical on 66 real documents

Generated by Claude Code

…rgets

`convertSchemaRef` only skipped adding a holder that isn't an object, which
happens just for a kept `$ref` whose part before `/anyOf/` doesn't resolve.
`anyOfTargets` is only queried with input schema objects, so adding the
unresolved value is harmless, and branch coverage is back to 100%.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YNzPR6fb2NHVQPYKsD2eta
@dinwwwh dinwwwh self-assigned this Oct 24, 2026
@codecov

codecov Bot commented Oct 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — the entire PR (1 file, 1 commit, +2/−5).

  • anyOfTargets widened to Set<unknown> — packages/downgrader/src/v3.1-to-v3.0.ts:134.
  • Dropped the isRecord(holder) guard in convertSchemaRef — resolvePointer(...) is now added to the set unconditionally (packages/downgrader/src/v3.1-to-v3.0.ts:283).

I verified the safety argument independently. anyOfTargets is read only by anyOfTargets.has(input) in downgradeV30 (:801), where input is the schema half of a twoBranchAnyOfs tuple pushed in finishSchema (:671). finishSchema runs only from convertObject after the isRecord(value) early return (shared.ts:125), so input is always a non-null, non-array record. resolvePointer returns the raw input reference, so an object holder was already added under the old guard; adding undefined, null, or an array instead can never equal input, and isRecord is still used elsewhere in the file so the import stays live. Behavior is unchanged, and the local run confirms 258 downgrader tests pass with oxlint/oxfmt/tsc clean on the touched file.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@codspeed

codspeed Bot commented Oct 24, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 21 untouched benchmarks


Comparing claude/project-thread-zdzdtj (cc00d7e) with main (ee6d272)

Open in CodSpeed

@dinwwwh
dinwwwh merged commit 6a906e9 into main Oct 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants