T0007 — @callis/ucum package
Part of the roadmap. Phase 1 · wave 3 · size L.
Goal
Full UCUM unit conversion as an opt-in package with no runtime dependencies. The UnitSystem interface it implements, and the split between core and this package, are described in T0006 design notes.
Scope
packages/ucum(@callis/ucum), exporting aUnitSystemimplementation nameducum.- The unchanged UCUM essence file,
ucum-essence.xmlfrom a pinned commit of ucum-org/ucum, with its checksum. A script (packages/ucum/scripts/) embeds the file byte for byte as a string module; the package reads it when it is first imported and resolves prefixes, base units and units to exact magnitudes and dimension vectors in memory (data decision). - A UCUM expression parser covering prefixes, atoms, exponents,
.and/,{annotations}(ignored for conversion),10*nand10^n. - Conversion and dimension analysis, canonical
multiply/divide, and the special unitsCeland[degF]. Other special units are reported as not convertible. @callis/coreexportsDecimal,MAX_DECIMAL_DIGITS, theUnitSystemtypes andminimalUnitSystem, which the package needs to implement and extend the unit system. Calendar keywords keep the rules of the minimal unit system.- License check (owner condition, ADR-0007): confirm that redistributing the UCUM data under the UCUM license next to MIT code is allowed. Document the result in the package README and include the required notice.
Design notes
UCUM data and license
The UCUM license (Version 1.1) allows reproducing and distributing the Work, but not modifying it or creating derivative works (section 3a), and asks for a copyright notice, a reference to the license and its disclaimer when the Work is distributed whole (section 3b). Neither the license nor the upstream issues about it (ucum-org/ucum#253, #260) grant permission for tables generated from the file, so the planned generator was dropped before any generated data was committed.
Owner decision (2026-11-05): ship the full ucum-essence.xml unchanged and parse it at startup. In the package:
data/ucum-essence.xmlandUCUM-LICENSE.mdare byte for byte the upstream files;data/source.jsonpins the commit and their SHA-256 checksums.src/essence/ucum-essence-xml.tsholds the same text as one string, generated byscripts/embed-essence.tsunder the UCUM notice, so the package needs no file system, DOM or network access. The bundle keeps it as a separate file,dist/essence/ucum-essence-xml.js.- The MIT-licensed code reads that string once, on first import, and keeps the resolved tables in memory only. No generated subset, converted table or altered definition is stored or distributed.
LICENSE.md(MIT for the code, the UCUM notice for the data),SOURCE.mdandUCUM-LICENSE.mdship in the package. Tests check the checksums and the byte identity of the embedded string;check:packagechecks the packed tarball, including the bundled string.
The cost, measured on Node.js 24.18 on an Apple M2 (pnpm --filter @callis/ucum measure, 30 runs; see the package README): 16.7 kB minified and gzipped (4.9 kB code, 11.8 kB UCUM text), 22.7 kB gzipped as built (budget 24 kB), and a median of 9.7 ms to import the package in a fresh process, after @callis/core (9.3–10.0 ms across runs).
Interpretations
The unit algebra, arbitrary and special units, calendar keywords against other UCUM time units, and UCUM's §9 exponents are recorded in spec notes.
Acceptance criteria
-
1 'kg' = 1000 'g',1 'cm' < 1 'm',12 'cm2' / 3 'cm' = 4.0 'cm',1 'mg/dL'converts to'g/L', and100 'Cel' > 50 '[degF]'. - Unknown or invalid units return
undefinedinstead of throwing. - No runtime dependency; the gzip size is reported in the PR.
- The conformance groups
testQuantityandtestQuantityUnitComparisonpass once T0010 is merged. - The license check is documented and the UCUM notice is included.
@callis/ucumis not published (T0025) until this is done.