Skip to content

chore: address Copilot review feedback across the field-review PRs - #46

Merged
MichaelLeeHobbs merged 1 commit into
masterfrom
chore/copilot-review-followup
Jul 24, 2026
Merged

MichaelLeeHobbs merged 1 commit into
masterfrom
chore/copilot-review-followup

Conversation

@MichaelLeeHobbs

Copy link
Copy Markdown
Owner

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

  • fix(tokenizer): keep parse() never-throwing and bound nested encapsulated scans (§3) #26 — resource-bound contract gap. 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 / just before stopAt). 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. Verified: the merged code returned ok/no-error with the cap exceeded; the fix reports limit-exceeded with the pre-limit elements retained.
  • fix(writer): validate transfer syntax against pixel-data payload; BE pixel view (D2, §3) #28 — big-endian host. nativePixelDataView hard-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).
  • feat(api): flip stopAt default to exclusive; add isDicomError; DX polish (§3) #30 — over-permissive guard. isDicomError now 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 carrying the shared brand.

Minor

Not changed (false positive)

Copilot flagged the unique symbol annotation on errors.ts as 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 plain symbol triggers 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

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
Copilot AI review requested due to automatic review settings July 24, 2026 02:20
@MichaelLeeHobbs
MichaelLeeHobbs merged commit 6f8e9cb into master Jul 24, 2026
7 checks passed
@MichaelLeeHobbs
MichaelLeeHobbs deleted the chore/copilot-review-followup branch July 24, 2026 02:21

Copilot AI 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.

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-exceeded as 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).
  • isDicomError is hardened to require instanceof Error plus the shared Symbol.for brand; 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.

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