Skip to content

fix: derive 2.25 UIDs from RFC 4122 UUIDs, and document the intentional 1.0 changes - #562

Merged
awatson1978 merged 1 commit into
release/1.0-beta-corefrom
core/finding-33-uid-doc
Sep 30, 2026
Merged

awatson1978 merged 1 commit into
release/1.0-beta-corefrom
core/finding-33-uid-doc

Conversation

@awatson1978

Copy link
Copy Markdown
Collaborator

This closes review finding 33: DicomMetaDictionary.uid() now derives its output from a real UUID, and a new docs/INTENTIONAL_CHANGES.md records the behavior changes 1.0 makes on purpose.

The review map listed finding 33 as documentation-only, on the assumption the new generator was already in place. On this branch it wasn't — uid() here was still the 0.x digit-concatenation version — so rather than document a change that hadn't happened, I ported the small v2 generator and wrote the documentation against real code. Failing test first: the issue-61 suite carried the UUID-derivation contract as a skipped KNOWN GAP, and I verified it fails against the old generator before applying the port.

Some background. A UID is the permanent identifier DICOM gives every study, series, and image — once an archive stores one, it's never corrected. The standard (PS3.5 Annex B.2) allows the 2.25 root only when the digits after it are the decimal form of a single 128-bit UUID (RFC 4122). The old generator just concatenated 39 random decimal digits, which overflows the 128-bit ceiling about 73% of the time, and even its in-range outputs never carried the version and variant bits a UUID must have. Every UID it produced was formally invalid.

The ported generator makes a fresh version 4 UUID — from globalThis.crypto.getRandomValues where Web Crypto exists, with a format-preserving Math.random fallback elsewhere — and encodes it as a decimal:

const { DicomMetaDictionary } = dcmjs.data;

DicomMetaDictionary.uid();
// before: "2.25." + 39 random digits — up to 10^39 - 1, not a UUID
//   e.g. "2.25.847292018470137492810473920184739201847"  (> 2^128 - 1: invalid)
// after: the decimal encoding of a version 4, RFC 4122-variant UUID
//   e.g. "2.25.313588121722925986199481636825908231781"  (at most 39 digits, always within 2^128 - 1)

Consumers should note the integer part is now at most 39 digits rather than always 39, and that UIDs 0.x already generated and archived are invalid and can't be corrected after the fact. Per the review map's verdict there is deliberately no opt-out — an option to generate invalid permanent identifiers helps nobody. The issue-61 suite's KNOWN GAP test is unskipped and green, and the catalog entry flips gap → green.

The documentation half: docs/INTENTIONAL_CHANGES.md is a new, clearly-scoped home for the three review-map findings whose verdict was "improvement, keep and document" — this uid() change (finding 33), the private-creator range narrowing that just merged in #559 (finding 26), and the cleanTags list correction (finding 2). The cleanTags entry is written honestly: that change hasn't landed on this branch yet and the entry says so, but it records the contract and the getTagsNameToEmpty() opt-out recipe in advance so the anonymizer port can point here.

🤖 Generated with Claude Code

…al 1.0 changes

DicomMetaDictionary.uid() built the 2.25 integer part from 39 random
decimal digits, which exceeded 2^128 - 1 about 73% of the time and
never carried the RFC 4122 version/variant bits, so every generated
UID was formally invalid under PS3.5 Annex B.2. Ports the v2
generator: a fresh version 4 UUID (Web Crypto when available) encoded
as a decimal, at most 39 digits, unskips the KNOWN GAP test in the
issue-61 suite, and flips the catalog entry to green.

Adds docs/INTENTIONAL_CHANGES.md recording the three review-map
improvements kept on purpose: the uid() format (finding 33), the
private-creator range narrowing (finding 26), and the cleanTags
list correction (finding 2, not yet landed on this branch).

Closes review finding 33 of the PR #512 review map.

Co-Authored-By: Claude Fable 5 <[email protected]>
@awatson1978
awatson1978 merged commit 821cc25 into release/1.0-beta-core Sep 30, 2026
8 checks passed
@awatson1978
awatson1978 deleted the core/finding-33-uid-doc branch September 30, 2026 20:10
awatson1978 added a commit that referenced this pull request Sep 30, 2026
Finding 26 landed as PR #559 and finding 33 as PR #562 (which ported
the v2 uid() rather than documenting only). Master hotfixes are
deferred per today's decision; finding 2's documentation pre-landed
in docs/INTENTIONAL_CHANGES.md ahead of the anonymizer port.

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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