Skip to content

default_kind on Unit (v2.3.0 W3) — infrastructure for currency re-kinding #305

Description

@withtwoemms

Tracking issue for W3 of docs/internal/IMPLEMENTATION_PLAN_v230_packages.md (v2.3.0, Package infrastructure), which the plan flagged as needing one.

History: this issue was originally filed as "the datum #303 needs." That framing was wrong on both counts — see the comments. #303 is closed as not-a-bug, and the arrival rule was never an open question. The body below reflects current understanding; the comments preserve how it got there.

What

default_kind: str | None as a declared field on Unit, so a unit can name the kind a quantity in that unit is by default.

Why — the currency case

ADR 011 (decisions/011-currency-kinds-and-contexts.md, Accepted 2026-09-10) records the motivating defect: convert(100, USD → EUR, kind="usd") yields 92.14 euros still kinded usd. A rate edge genuinely transformed the quantity into different stuff, so carrying the source kind through is wrong.

default_kind is the datum that lets arrival at EUR re-kind the result.

Note the consumer does not exist yet. ucon ships no currency kinds or units — currency, usd, eur all raise KindNotFound — and native currency support is #292, still open. So this is forward-looking infrastructure, not a repair. Prioritize accordingly.

The arrival rule is already ratified

Not an open decision. ADR 011 states it, and W3 restates it including the sub-case:

"conflict between explicit kind and target default_kind on .to() → … target's declared kind wins on arrival (the 011 rule); document."

(An earlier revision of this issue presented a conflict with .archive/docs/internal/ARCHITECTURE_number-kind-v6.md, which says refuse. That document is archived and superseded.)

Scope

  • Foundation — adds default_kind on Unit with auto-attachment at construction #306: the field, the TOML key, auto-attachment at construction, explicit kind= winning. Number.to() untouched. Additive and inert: no shipped unit declares one.
  • Arrival rule — implement per ADR 011: arrival at a unit declaring a default_kind re-kinds the result.
  • Which units declare — the one genuinely open judgement, and it is narrow. Currency units should, once native currency support via kinds and rate contexts #292 lands. gray and sievert should not: re-kinding Gy → Sv would assert dose_equivalent with no w_R supplied, which is exactly the claim the shipped radiation_weighting formula (comprehensive.ucon.toml:5239, H = D · w_R) exists to require. Weighting belongs on the arithmetic path, not the conversion path.

Related

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions