chore: address Copilot review feedback across the field-review PRs - #46
Merged
Merged
Conversation
Substantive: - tokenizer (#26 follow-up): the salvaging guard around the fallback addElement could let structureCount exceed maxElements without ever surfacing limit-exceeded when the fallback was the last element read (EOF / pre-stopAt) — contradicting the resource-bound contract. Removed the guard; run()'s recovery call site now catches a limit-exceeded from recoverToFallback and surfaces it as a partial result, consistent with how every other cap trip is reported. Repro'd: merged code returned ok/no-error with the cap exceeded; fixed reports limit-exceeded with the pre-limit elements retained. - pixelData (#28 follow-up): nativePixelDataView assumed a little-endian host. Now byte-swaps when dataset order differs from the detected host order, so it is correct on a big-endian host too. - errors (#30 follow-up): isDicomError also requires `instanceof Error` (reliable across the dual ESM/CJS build, both extend the one global Error), so a bare branded plain object is rejected. Test updated to a real cross-build Error. Minor: - parse: removed a leftover duplicate JSDoc above NATIVE_TRANSFER_SYNTAXES (#28). - dataSet: floatStrings/intStrings docs say "absent or empty"; added a NaN-contract test for empty/non-numeric components (#32). - valueParsers: isValidUid doc references DicomDataSet.string() concretely (#32). - PLAN: disambiguated field-review W7/W13 from the adversarial-review W-series (#32). - tokenizer.test: D1 title notes the input is conformant (#25). Copilot's `unique symbol` concern on errors.ts is a false positive — it typechecks clean on ts7 + typescript@6 and the annotation is required for the computed-key brand field. Full suite 717 passed; lint/typecheck/format/attw clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015fdQkZCohJHGNBjEMbk8ga
There was a problem hiding this comment.
Pull request overview
Follow-up maintenance PR that incorporates previously raised review feedback across the MedFusion field-review PR series, primarily tightening resource-bound error surfacing, endianness correctness, and cross-build error-guard behavior while updating tests/docs to match the refined contracts.
Changes:
- Tokenizer recovery now correctly surfaces
limit-exceededas a partial-result error even when triggered during sequence fallback recovery (and even when it’s the last element read). - Native pixel-data typed views now byte-swap when dataset byte order differs from the detected host byte order (supporting big-endian hosts).
isDicomErroris hardened to requireinstanceof Errorplus the sharedSymbol.forbrand; tests and docs updated accordingly.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/valueParsers.ts | Clarifies isValidUid doc reference to DicomDataSet.string() semantics. |
| src/tokenizer.ts | Catches limit-exceeded thrown during fallback recovery and returns it as a partial-result error (preserves never-throws contract). |
| src/tokenizer.test.ts | Updates D1 test labeling and adds/adjusts regression coverage for the fallback+maxElements partial-result behavior. |
| src/pixelData.ts | Detects host endianness and swaps 16-bit native pixel samples when dataset order differs from host. |
| src/parse.ts | Removes a duplicate/leftover JSDoc line above native transfer syntax documentation. |
| src/errors.ts | Tightens isDicomError guard to require instanceof Error in addition to the brand symbol. |
| src/errors.test.ts | Updates guard tests to reject branded plain objects and accept cross-build Error + brand. |
| src/dataSet.ts | Updates floatStrings/intStrings docs to match the “absent or empty” accessor contract. |
| src/dataSet.test.ts | Adds coverage for NaN behavior on empty/non-numeric bulk numeric components (positional alignment). |
| PLAN.md | Disambiguates field-review W7/W13 vs adversarial-review W-series references. |
| CHANGELOG.md | Updates release notes to reflect the new “catch at call site” behavior for fallback limit surfacing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Follow-up to the merged field-review PRs (#25–#30, #32) addressing GitHub Copilot's review comments. Each was triaged against source; the substantive ones have repros/tests.
Substantive
salvagingguard around the fallbackaddElementcould letstructureCountexceedmaxElementswithout ever surfacinglimit-exceededwhen the fallback was the last element read (EOF / just beforestopAt). Removed the guard;run()'s recovery call site now catches alimit-exceededfromrecoverToFallbackand surfaces it as a partial result — consistent with how every other cap trip is reported. Verified: the merged code returnedok/no-error with the cap exceeded; the fix reportslimit-exceededwith the pre-limit elements retained.nativePixelDataViewhard-coded the host as little-endian. It now byte-swaps when the dataset's order differs from the detected host order, so 16-bit views are correct on a big-endian host too (LE-host behavior unchanged; the BE≡LE fixture test still passes).isDicomErrornow also requiresinstanceof Error(reliable across the dual ESM/CJS build — both extend the one globalError), so a bare branded plain object is rejected. Test updated to a real cross-buildErrorcarrying the shared brand.Minor
NATIVE_TRANSFER_SYNTAXES(fix(writer): validate transfer syntax against pixel-data payload; BE pixel view (D2, §3) #28).floatStrings/intStringsdocs say "absent or empty"; added a NaN-contract test for empty/non-numeric components (feat(api): isValidUid (W7) and bulk multi-value accessors (W13) #32).isValidUiddoc referencesDicomDataSet.string()concretely (feat(api): isValidUid (W7) and bulk multi-value accessors (W13) #32).Not changed (false positive)
Copilot flagged the
unique symbolannotation onerrors.tsas likely to fail typechecking. It does not — it compiles clean on ts7 + typescript@6, and the annotation is required for the computed-key brand field (a plainsymboltriggers TS1166, as this PR's own test churn confirmed).Verification
Full suite 717 passed / 4 skipped; lint, typecheck, format, attw all clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_015fdQkZCohJHGNBjEMbk8ga