Skip to content

Backfill missing quantities + hand-written log-scale companions (SPL/SIL/SWL/DI/pH)#92

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

Backfill missing quantities + hand-written log-scale companions (SPL/SIL/SWL/DI/pH)#92
matt-edmondson merged 3 commits into
vectorsfrom
claude/vectors-sync-progress-ofoith

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Summary

Steps 3 and 4 of the parity plan: the quantities main had that vectors lacked, plus the log-scale architecture decision and its implementation.

New generated dimensions (10)

Dimension Unit Relationships
Permittivity F/m
ElectricConductivity S/m
ElectricFlux V·m ElectricField × Area => ElectricFlux
ElectricPowerDensity W/m³ × Volume => Power
Sensitivity V/Pa × Pressure => Voltage (mic sensitivity)
ThermalResistance K/W
RateConstant s⁻¹ none — Ratio / Duration is already owned by Frequency; a second result type for the same operands can't compile
Luminance cd/m², nit, fL × Area => LuminousIntensity
Loudness sone
Sharpness acum

New semantic overloads

Impedance on Resistance (mirrors Admittance on Conductance — Ohm's law works through widening), SoundPressure on Pressure, SoundPower on Power, SoundAbsorption/NoiseReductionCoefficient/SoundTransmissionClass on Ratio, and signed ReflectionCoefficient on SignedRatio.

Log-scale decision (now resolved design decision #5 in CLAUDE.md)

Decibel and pH scales don't obey linear arithmetic, so they're hand-written companions (in the style of the audio-engineering types), not generated dimensions:

  • SoundPressureLevel (dB re 20 µPa) ⇄ SoundPressure
  • SoundIntensityLevel (dB re 10⁻¹² W/m²) ⇄ SoundIntensity
  • SoundPowerLevel (dB re 10⁻¹² W) ⇄ SoundPower
  • DirectionalityIndex (dB) ⇄ intensity Ratio
  • PH ⇄ hydrogen-ion Concentration, plus ToPOH() and acidity checks

All reference values come from the PhysicalConstants domains added in #90.

Two latent metadata bugs fixed

  1. Luminance was an overload of Illuminance — lux (light arriving at a surface) and cd/m² (light leaving one) are different quantities with different units. Replaced by the proper Luminance dimension.
  2. SI-base-first violations: the generator emits an identity factory for the first availableUnits entry, but Concentration led with Molar (×1000) and NuclearCrossSection with Barn (×10⁻²⁸), so FromMolars/FromBarns stored non-SI values while In(unit) assumed SI storage. Both dimensions now lead with the true SI base (MolePerCubicMeter, SquareMeter), making factories and In() agree — FromMolars(1) now stores 1000 mol/m³ as documented.

Remaining parity gap

With this PR the quantity-type parity audit is complete: every type main had now exists on vectors (as a generated dimension/overload, a log-scale companion, or a deliberate rename). Next step is release prep (2.0.0, package-validation baseline, migration guide).

Testing

  • 18 new tests (QuantityBackfillTests): factories and operators for every new dimension, overload widening (incl. Ohm's law through Impedance), round-trips for all five log-scale types, pH chemistry.
  • Full suite: 682 pass (664 before + 18 new), zero regressions; 93 failures are the pre-existing Windows-path tests on the Linux runner.
  • Note for reviewers: the bumped Microsoft.CodeAnalysis.CSharp 5.3.0 requires a compiler this container doesn't have, so local verification was done with a temporarily pinned 4.12.0 (not committed). CI's toolchain builds 5.3.0 natively.

https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW


Generated by Claude Code

claude added 3 commits June 12, 2026 09:31
…from main

New generated dimensions: Permittivity (F/m), ElectricConductivity (S/m),
ElectricFlux (V·m, with ElectricField x Area relationship),
ElectricPowerDensity (W/m³, with x Volume => Power), Sensitivity (V/Pa,
with x Pressure => Voltage), ThermalResistance (K/W), RateConstant (s⁻¹),
Luminance (cd/m², Nit, FootLambert, with x Area => LuminousIntensity),
and the psychoacoustic Loudness (sone) and Sharpness (acum).

New semantic overloads: Impedance on Resistance (mirrors Admittance on
Conductance), SoundPressure on Pressure, SoundPower on Power,
SoundAbsorption / NoiseReductionCoefficient / SoundTransmissionClass on
Ratio, and the signed ReflectionCoefficient on SignedRatio.

Also fixes two latent metadata bugs:
- Luminance was modelled as an overload of Illuminance; lux (light
  arriving) and cd/m² (light leaving) are different quantities, so the
  overload is replaced by the proper Luminance dimension.
- The generator emits an identity factory for the first availableUnits
  entry, but Concentration listed Molar (x1000) and NuclearCrossSection
  listed Barn (x1e-28) first, so From{Base} and In(unit) disagreed about
  the storage unit. Both now lead with the true SI base unit
  (MolePerCubicMeter, SquareMeter); FromMolars and FromBarns now scale
  into SI storage as documented.

RateConstant deliberately has no Time integral: Frequency already owns
Ratio / Duration, and a second result type for the same operands cannot
compile.

https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW
Locks in the log-scale decision: decibel and pH scales don't obey linear
arithmetic, so they are self-contained record structs (like the
audio-engineering types) that convert to and from their linear generated
counterparts, not dimensions.json entries.

- SoundPressureLevel (dB re 20 µPa) <-> SoundPressure
- SoundIntensityLevel (dB re 1e-12 W/m²) <-> SoundIntensity
- SoundPowerLevel (dB re 1e-12 W) <-> SoundPower
- DirectionalityIndex (dB) <-> intensity Ratio
- PH <-> hydrogen-ion Concentration (plus pOH and acidity checks)

Documented as resolved design decision #5 in CLAUDE.md.

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

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots
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 33a28d3 into vectors Jun 12, 2026
4 of 5 checks passed
@matt-edmondson matt-edmondson deleted the claude/vectors-sync-progress-ofoith branch June 12, 2026 10:16
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