Skip to content

Backfill unit catalog + constants domains from main; fix Fahrenheit and Generic constants#90

Merged
matt-edmondson merged 2 commits into
vectorsfrom
claude/vectors-sync-progress-ofoith
Jun 12, 2026
Merged

Backfill unit catalog + constants domains from main; fix Fahrenheit and Generic constants#90
matt-edmondson merged 2 commits into
vectorsfrom
claude/vectors-sync-progress-ofoith

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Summary

First step of the parity plan: backfills the unit catalog and physical-constant domains that the vectors rework hadn't yet carried over from main, and fixes two real bugs found along the way.

Units (~60 across 30 dimensions)

  • Imperial / US customary: nautical mile, knot, feet-per-second, acre, hectare, square mile/km/cm, cubic foot/inch/cm, imperial gallon, US quart/pint/fluid-ounce, stone, short ton, pound-force, BTU, Rankine, foot-candle
  • CGS: dyne, erg, centipoise, dyne-per-centimeter
  • Traditional radiological: curie, rad, rem, roentgen
  • SI-prefixed conveniences: kPa, kN, kJ, kW, MW, kHz, MHz, mA, kA, kV, kΩ, MΩ, μF/nF/pF, kmol/mmol, ns, mcd, mrad
  • Chemistry: millimolar, micromolar, dalton, enzyme unit, calorie-per-mole, ampere-hour
  • Angle / ratio: gradian, revolution, ppm, ppb, percent-by-weight, standard gravity, torr, watt-hour, kilocalorie, atomic mass unit, g/cm³, g/L

Each unit gets a named conversion factor in conversions.json (exact values where defined), an explicit plural factoryName, and availableUnits wiring — From{Unit} factories and typed In(unit) support come out of the generator.

Constants

New domain constants in domains.json: Acoustics (reference sound pressure/intensity/power, Sabine constant), Optics (luminous efficacy), NuclearPhysics (atomic mass unit, nuclear magneton), FluidMechanics (standard air density, water surface tension).

Bug fixes

  1. Fahrenheit conversion was inverted: the metadata carried the K→F transform (×1.8, −459.67), so Temperature.FromFahrenheit(32) computed −402 K and threw on the V0 non-negativity guard. Now ×5/9 +255.372 (exact). Nothing had tested it.
  2. PhysicalConstants.Generic.*<T>() was entirely unusable: T.CreateChecked(PreciseNumber) throws NotSupportedException (PreciseNumber's TryConvertToChecked is unimplemented). The generator now emits PreciseNumber.To<T>(), the supported materialisation path. Also previously untested.

Deliberately not ported (with rationale)

  • Luminance units (nit, cd/m², foot-lambert) — no Luminance dimension exists yet; belongs to the missing-quantities phase.
  • PerSecond — no RateConstant dimension yet; same phase.
  • MolesPerSecond — mislabelled on main (ReactionRate is volumetric, mol/(m³·s)).
  • Main's Mathematical constant helpers (OneHalf, FourThirds…) — generated code uses literals.
  • Dalton is defined as 1 g/mol on MolarMass rather than main's 1.66×10⁻²⁷ value, which was the per-particle mass, not a molar mass.

Testing

  • 26 new tests in UnitBackfillTests covering factories across all the new unit families, In(unit) round-trips, the Fahrenheit/Rankine fix, and the new constants.
  • Full suite: 664 pass (638 before + 26 new), 0 quantity regressions; the 93 failures are the pre-existing Windows-path tests that don't apply on a Linux runner.
  • Build clean, no SEM001–SEM004 diagnostics.

https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW


Generated by Claude Code

claude added 2 commits June 12, 2026 06:37
T.CreateChecked(PreciseNumber) throws NotSupportedException for every
constant (PreciseNumber's TryConvertToChecked is unimplemented), so the
whole PhysicalConstants.Generic surface was unusable. PreciseNumber's
supported materialisation path is To<T>().

https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW
Restores the units and physical constants that the vectors rework had
not yet carried over from main:

- ~60 units across 30 dimensions: imperial/US customary (acre, US/imperial
  gallons, PSI-family pressure via Torr, pound-force, BTU, knot, stone...),
  CGS (dyne, erg, poise-family, dyn/cm), traditional radiological (curie,
  rad, rem, roentgen), SI-prefixed conveniences (kPa, kW, MW, kHz, MHz, mA,
  kV, kΩ, μF/nF/pF, kmol/mmol...), chemistry (millimolar, micromolar,
  dalton, enzyme unit, cal/mol), and angle/ratio units (gradian,
  revolution, milliradian, ppm, ppb, % w/w).
- Constants for the Acoustics (reference sound pressure/intensity/power,
  Sabine), Optics (luminous efficacy), NuclearPhysics (atomic mass unit,
  nuclear magneton) and FluidMechanics (standard air density, water
  surface tension) domains.
- Fixes the inverted Fahrenheit→Kelvin affine conversion: the metadata
  carried the K→F transform (×1.8, −459.67), so FromFahrenheit(32°F)
  produced −402 K and threw on the non-negativity guard. Now ×5/9,
  +255.372; Rankine added on the same scale.

Deliberately not ported: Luminance units (no Luminance dimension yet),
PerSecond (no RateConstant dimension yet), MolesPerSecond (mislabelled
on main — ReactionRate is volumetric), and main's Mathematical constant
helpers (generated code uses literals). Dalton is defined as 1 g/mol on
MolarMass rather than main's 1.66e-27 (which was the per-particle mass,
not a molar mass).

https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
0.0% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@matt-edmondson matt-edmondson merged commit f08bee5 into vectors Jun 12, 2026
4 of 5 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