Skip to content

No data size or data rate types: add an Information dimension (bit/byte, KB and KiB) and DataRate = DataSize / Time #366

Open

Description

@matt-edmondson

What's missing

Phase 6 of the semantic-domains roadmap proposes data size and data rate types. The roadmap recommends generating them by adding an Information dimension to the quantity metadata. None of it exists yet: Semantics.SourceGenerators/Metadata/dimensions.json has no Information dimension, and units.json has no bit or byte units.

Plan: docs/roadmap-semantic-domains.md L188-L203

  • DataSize (bytes) with binary (KiB/MiB) and decimal (KB/MB) prefixes, DataRate (bit/s), the integral/derivative relationship between them over Time.
  • Generator vs. hand-written: strongly consider adding Information as a dimension in dimensions.json (unit = byte/bit) so DataSize/DataRate fall out of the existing machinery, including the DataRate = DataSize / Time relationship.

Open question 4 (L231-L232) also recommends the generator approach. The roadmap describes itself as a proposal rather than a commitment, so whether this is still wanted is your call. It rates this phase S–M effort, and it depends only on the existing Quantities generator.

Why it matters

Without these types, consumers keep file sizes and bandwidths as bare long or double. Two mix-ups then go unnoticed:

  • bits vs bytes (a factor of 8)
  • kB vs KiB (1000 vs 1024)

For example, a 100 Mbit/s link carrying a 1 GiB file takes about 86 s, but adding a bits-per-second value to a bytes figure compiles without complaint. The roadmap also treats this phase as the cleanest test of whether the generator can take on a new dimension.

Design point to settle first

Information has no SI base exponent. Each dimensionalFormula in dimensions.json is written over the SI base dimensions (plus angle), and the C++ projection (Semantics.Cpp) maps each dimension onto those exponents. An Information dimension therefore needs one of two things before the metadata is edited:

  • a new axis, which would change the C++ dimension prelude and the dimension info the .NET side carries
  • a documented decision to put it on the dimensionless vector and rely on the nominal type layer alone

SEM008 relationship checking and the C++ nominal classes both depend on which way this goes.

Acceptance criteria

  • Units: an Information dimension (or a documented hand-written alternative) with bit and byte units.
  • Prefixes: decimal prefixes (kB, MB, GB) and binary prefixes (KiB, MiB, GiB) both convert exactly. magnitudes.json holds only SI prefixes, so the binary factors need their own entries.
  • Rate: a DataRate dimension (bit/s, byte/s and prefixed forms), and the DataSize / Time -> DataRate relationship in the integrals/derivatives metadata. Operators are generated and SEM008 passes.
  • Generated files: alias props regenerated with scripts/Generate-AliasProps.ps1, and generated sources committed so verify-generated passes.
  • C++: the C++ projection still compiles (Semantics.Cpp.Test).
  • Tests: unit conversions, including KiB vs kB and bit vs byte, plus the rate relationship.

Dependencies

None beyond the existing quantity generator.

Activity

  1. matt-edmondson commented on Oct 5, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    • Category: Feature Request (roadmap Phase 6, Information dimension, DataSize and DataRate)
    • Priority: Low. This is a proposed roadmap item and nothing is broken. It is still a useful test of how far the generator extends.
    • Area: Semantics.SourceGenerators/Metadata (dimensions.json, units.json, magnitudes.json for the binary prefixes), the integrals/derivatives relationships, and the Semantics.Cpp dimension prelude. Suggested owner: @matt-edmondson, quantity generator. Settle the design point first: either a new dimension axis, or putting Information on the dimensionless vector. SEM008 and the C++ projection both depend on that choice.
    • Duplicates / related: no duplicate. A sibling roadmap item to No Money/Currency types: add Semantics.Money (ISO 4217 Currency, Money that refuses cross-currency arithmetic, allocation without lost pennies) #367 (Phase 3, Money).
    • In progress: no open PR covers this

    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions