Skip to content

Metadata-generate the logarithmic scales; fold Percent/Gain into the linear metadata#95

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

Metadata-generate the logarithmic scales; fold Percent/Gain into the linear metadata#95
matt-edmondson merged 3 commits into
vectorsfrom
claude/vectors-sync-progress-ofoith

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Summary

Converges the remaining hand-written quantity surface onto metadata, per the "metadata is the source of truth" direction.

1. Percent and Gain fold into the linear metadata

  • Percent was a standalone struct; it's now a unit of the Dimensionless dimension (PercentToRatio = 0.01): Ratio<double>.FromPercent(50) → 0.5, ratio.In(Units.Percent) → 50. The struct is deleted.
  • Gain was a standalone struct; it's now a generated semantic overload of Ratio in dimensions.json — non-negative V0, widens implicitly to Ratio. Unity, Silence, the Decibels conversions, and cascading * live in a hand-written partial.

2. LogarithmicScalesGenerator — log scales from logarithmic.json

A new generator + metadata file gives the logarithmic family a single source of truth. Each entry generates a readonly partial record struct around scale = multiplier · log_base(linear / reference): scalar factory, From{Linear}/To{Linear} conversions (name-overridable, with PhysicalConstants- or literal-backed references), optional log-space +/, comparisons, and invariant ToString. SEM005 validates the schema.

Scale Status
SoundPressureLevel, SoundIntensityLevel, SoundPowerLevel fully generated — hand-written files deleted
Decibels, Cents, Semitones, DirectionalityIndex, PH core generated; bespoke members (Unity, Unison, Octave, Omnidirectional, Neutral/ToPOH/acidity checks, raw-T conveniences, CentsSemitones) remain in small partials

To support the partial-companion pattern, QuantitiesGenerator now emits partial records throughout.

Scorecard

Before this PR the audio/log family was ~10 hand-written types (~1100 lines). After: 2 genuinely bespoke types (NormalizedParameter, QFactor — not quantities, no metadata shape) plus 5 thin partials; everything else comes from dimensions.json/logarithmic.json. Resolved decision #5 in CLAUDE.md is amended accordingly, physics-generator.md gains an "adding a logarithmic scale" walk-through, and the migration guide covers the Percent/Gain changes.

Behavioral notes

  • Gain is now a record class (like all generated quantities) and non-negative via the guarded From{Unit} factories — polarity inversion was never representable in its dB interop anyway.
  • All generated log-scale APIs are signature-compatible with the previous hand-written ones; Decibels additionally gains FromPowerRatio(Ratio<T>).

Testing

  • 3 new tests (Gain widening + guard, cascading *, FromPowerRatio); RatioPercent_RoundTrip rewired to the unit-based API.
  • Full suite: 686 pass (683 before + 3 new), zero regressions; the 93 failures are the pre-existing Windows-path tests on the Linux runner.
  • Local verification used a temporarily pinned Roslyn 4.12.0 (not committed); CI builds the repo's 5.3.0 natively.

https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW


Generated by Claude Code

claude added 3 commits June 13, 2026 01:18
…hmic.json

Logarithmic quantities (decibel levels, pitch intervals, pH) now have a
metadata source of truth. Each logarithmic.json entry generates a
standalone readonly partial record struct built around
scale = multiplier · log_base(linear / reference): the raw-scalar
factory, From{Linear}/To{Linear} conversions against the linear
generated counterpart (with optional name overrides and a
PhysicalConstants- or literal-backed reference), optional log-space
+/- arithmetic, comparisons, and culture-invariant ToString.

Bespoke members that don't fit the schema (named constants,
cross-scale conversions, raw-T conveniences) live in hand-written
partials — QuantitiesGenerator now emits partial records throughout so
generated quantities can carry such companions too.

SEM005 flags missing/duplicate scale names and conversions with no
linear type.

https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW
- SoundPressureLevel, SoundIntensityLevel, SoundPowerLevel: fully
  generated from logarithmic.json; hand-written files deleted.
- Decibels, Cents, Semitones, DirectionalityIndex, PH: cores generated;
  the hand-written files shrink to bespoke partials (Unity, Unison,
  Octave, Omnidirectional, Neutral/ToPOH/IsAcidic/IsBasic, raw-T
  FromAmplitude/FromPower, Cents<->Semitones).
- Percent: was a standalone struct; now a unit of the Dimensionless
  dimension — Ratio.FromPercent(50) == 0.5, ratio.In(Units.Percent).
- Gain: was a standalone struct; now a generated semantic overload of
  Ratio (non-negative V0, widens implicitly), with Unity/Silence, the
  Decibels conversions, and cascading * kept in a partial.
- Decibels gains FromPowerRatio(Ratio<T>) alongside the raw-T
  conveniences; FromGain/ToAmplitude/ToPower are now generated.

Generated snapshots refreshed (all quantity records are now partial).

https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW
Updates resolved decision #5 in CLAUDE.md (logarithmic.json + partials,
SEM005), adds the 'adding a logarithmic scale' walk-through to
physics-generator.md, and refreshes the migration guide rows for
Percent (now a Dimensionless unit) and Gain (now a Ratio overload).

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

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
4 Security Hotspots
0.0% Coverage on New Code (required ≥ 80%)
C Security Rating on New Code (required ≥ A)
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 b3aeb41 into vectors Jun 13, 2026
4 of 5 checks passed
@matt-edmondson matt-edmondson deleted the claude/vectors-sync-progress-ofoith branch June 13, 2026 02:32
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