Skip to content

Units of measure on the platform: a standard unit list, quantity fields that carry their unit, and conversion #35339

Closed
7 of 7 issues completed

Description

@os-warren

③ maintainer-directed task · Source: maintainer — 「先立卡,不需要fable,我会用新的agent账户接着评审」「立 objectstack 卡就可以」 (2026-11-19T05:33Z, planning thread on marketplace suites), answering the proposal that units of measure belong at the platform layer.

维护者速读

  • 问题: 平台有币种,但没有计量单位。CRM、SRM 和以后的生产套件各写各的单位(SRM 现在是随手填的文字,CRM 订单行根本没有单位),数量跨套件、跟 ERP 都对不上,箱和个、千克和吨也没法换算。
  • 要做: 平台提供一份标准单位表、带单位的数量字段和换算。单位表客户能扩,像箱、托这类各家不同;每个物料自己的包装换算留在套件里。
  • 不做会怎样: 每个套件各造一套单位,以后想对接,就得先清洗历史数据。
  • 你要做的: 无。待评审账户给出设计意见后再定。

Business reason

Who benefits: every managed suite that records a quantity, and the customers who run one of them next to an ERP.

  • Sell side. hotcrm sales order lines and quote lines carry a unit_price but no unit at all.
  • Buy side. hotsrm has srm_material.uom and srm_delivery_record.uom as free text with maxLength: 20. "kg", "KG", "千克" and "公斤" are four different values there.
  • Production. The planned production suite (the one EE customer builds production management) lives on unit conversion: bills of material, material issue, finished goods.

The cross-suite master-data ruling on #35328 (A: each suite owns its records, matched by contract keys) only works if quantities mean the same thing on both sides of a match. A unit is the quantity's half of that contract, the way ISO 4217 is the amount's half.

If this isn't done, each suite ships its own unit list. Every later ERP or cross-suite link then starts with a data-cleaning project.

What the platform has today (read, not measured)

  • Three standard value domains, iana_time_zone, iso_4217_currency and iso_3166_alpha2, at packages/spec/src/shared/value-domain.zod.ts:96-100. Its header records the 2026-09-02 ruling that the vocabulary "does not widen", so adding a fourth member is itself a ruling, not a dev choice.
  • Multi-currency (ADR-0144): a record currency in a sibling code field, dated rates, and a home-currency amount stored at write. This is the nearest existing pattern for "a number plus the code that gives it meaning, plus a conversion".
  • Nothing for units. uom in packages/spec/src: 0 hits; unit of measure / units of measure in open issues: 0.

Questions for the review (not prescriptions)

  1. Code list. A fixed standard list (UN/ECE Recommendation 20 common codes) as a value domain, which needs the "does not widen" ruling reopened? Or a platform reference object that ships the standard set and lets an organization add its own packs (case, box, pallet)? Or both: standard codes fixed, org packs added?
  2. Quantity shape. A number plus a sibling unit-code field, mirroring ADR-0144 D1, or a new field type? What does each do to formulas, summaries, reports and import?
  3. Conversion split.
    • Fixed-ratio conversions inside a dimension (kg↔t, m↔cm) are universal, so the platform should own them.
    • Item-specific packs (1 case = 24 each of item X) belong to the suite that owns the item.
    • Should the platform give only the table shape and the conversion function for packs, with the rows staying in the suite?
  4. When conversion happens. At write, like ADR-0144's home projection, or at read and report time? What about rounding and decimal places per unit?
  5. Enforce-or-remove (ADR-0049). Which consumer reads the unit on day one? Validation of compatible units on a summary, conversion in a report, and a formula function are the candidates. A declared unit nobody reads is inert.

Non-goals

Inventory, costing and valuation stay with the suites and the ERP. Unit-master sync from an ERP goes through connectors or one-way sync-in (ADR-0153). No suite-side migration is in scope; each suite adopts the result in its own repo.

Reader

  1. The maintainer's reviewing agent account reads this first and writes the design opinion; per the maintainer, no fable pass on this card.
  2. After his decision, a packages/spec / data seat implements.
  3. hotsrm and the production suite are the first adopters.

Prior rulings read

value domain, currency, uom, unit of measure → ADR-0144 (pattern to mirror), and the value-domain ruling of 2026-09-02 ("vocabulary does not widen", recorded in value-domain.zod.ts) → constrains question 1. Also #35328 (ruled A, 2026-11-19), which this complements.

Dedupe

  • repo:objectstack-ai/objectstack is:issue uom → 0.
  • "unit of measure" → 5, all closed, none on this capability.
  • "units of measure" → 1, closed, unrelated.

Grade

area:data · Feature · maintainer-sourced (not table-graded) · reach: hotsrm free-text uom, hotcrm order lines without unit (read) · evidence: read → p3 pending the review; the maintainer may regrade.


Generated by Claude Code

Sub-issues

Sub-issues

7 of 7 Issues completed
Loading 7 sub-issues

Activity

  1. os-bill commented on Nov 19, 2026

    @os-bill
    Collaborator

    Maintainer ruling: units of measure design

    先不考虑 hotsrm,先处理平台任务,你的意见我同意

    os-bill, 2026-11-19T06:01:58Z, in the design discussion for this card. 「你的意见」 is the recommendation below. It was reviewed adversarially before it went to the maintainer, and he accepted it as recommended on each of its three questions:

    1. Standard units go in a closed spec constant.
    2. The piece code is H87, and org codes get a reserved namespace.
    3. R2 converts both by dimension ratio and by a suite-supplied factor.

    Ruled design

    • U1 · Standard list. A closed constant in packages/spec holds a curated subset of UN/ECE Rec 20 common codes, each with its dimension and its ratio to the dimension's base unit. It is a separate table, the way CURRENCY_FRACTION_DIGITS is (packages/spec/src/data/currency-fraction-digits.ts). It is not a fourth member of ValueDomainSchema, and the 2026-09-02 vocabulary stays closed. Package codes (Rec 21, admitted through the Rec 20 annex with the X prefix, e.g. XBX, XPX) are listed with a package dimension and no ratio. The constant is three things at once: the build-time oracle for fixed-unit fields, the source of truth for standard codes, and a pure conversion table.
    • U2 · Piece. The piece code is H87. Its near-synonyms C62 and EA are not admitted.
    • U3 · Organization units. sys_unit is organization-owned: organization_id is injected and it sits behind the tenant wall, like sys_exchange_rate. It holds org-added units only, and the platform ships zero rows. Org codes live in a reserved namespace, at least 4 characters or containing an underscore. Rec 20 codes are at most 3 alphanumerics, so a later standard code cannot collide with an org code.
    • U4 · Quantity shape. A number field gains a unit declaration that mirrors currencyConfig:
      • fixed: the unit is written in metadata and checked at build against U1.
      • record: a pointer names a sibling text field that holds each row's code.
      • An optional dimension restriction is allowed.
      • The value stays a bare number (ADR-0104 D1). The row stores the code, never an id, in exact uppercase.
      • The sibling field's name is a convention (unit_code), never a contract, as in ADR-0144 D8 rule 2.
      • The key spelling (proposed unitConfig: { unitMode, unit, unitField, dimension }) is the ADR's to fix.
      • Whether a unit may follow a parent through master_detail, as ADR-0144's D2 amendment allows for currency, is also the ADR's to fix. A lookup path is not admitted.
    • U5 · Membership at write. A new write-path check admits a code in U1 or in the organization's sys_unit rows. It is asynchronous and reads rows, so it is not the valueDomain predicate, which stays pure and unchanged.
    • U6 · Decimals. A unit's decimal places are an org-editable default, not platform-fixed: Rec 20 defines none, and BOM scrap quantities need decimals. The ADR states how this interacts with the field's scale.
    • U7 · Releases.
      • R1:
        • the membership check (U5)
        • display of the value with its unit
        • a build-time refusal of a raw aggregate over a record-mode quantity unless it groups by that quantity's unit field (mirrors ADR-0144 D6)
        • a backfill door that converts existing free-text units to codes (like os migrate record-currency-codes)
      • R2: write-time projection into a declared base-quantity field, stored with the factor used. The factor is the dimension ratio from U1/sys_unit, or a suite-supplied factor named by pointer (factorField). With no ratio and no factor, the write is refused; there is no 1:1 or null fallback (ADR-0144 D5). Affine units such as temperature are excluded from ratio conversion. Ratios are decimal, scale 12, never float.
    • U8 · No formula conversion function. A formula is virtual and cannot be totalled. No unit key ships ahead of the engine that reads it (ADR-0078; ADR-0144 D5).

    Out of scope

    • Item pack tables: the suites own them; R2 reads their factor by pointer.
    • ERP unit-master sync: sys_unit is not a synced target (ADR-0153). ERP code mapping is connector or suite work.
    • hotsrm / hotcrm adoption: deferred by this ruling.

    Left to the ADR

    • Whether an org unit's ratio locks once used, and how. "Used" means scanning every quantity table, which is costlier than the home-currency lock.
    • How org-unit labels are translated. No row-data translation mechanism was found.
    • The key spellings from U4.

    Next

    An ADR records U1–U8. The R1 cards follow it.


    Generated by Claude Code

  2. added
    priority:p2
    and removed on Nov 19, 2026
  3. os-bill commented on Nov 19, 2026

    @os-bill
    Collaborator

    Regrade: priority:p3 → priority:p2. The maintainer chose 「升 p2,交 data 区写 ADR」 (os-bill, 2026-11-19T06:03:51Z).

    Next deliverable on this card: an ADR that records U1–U8 from the ruling record and settles its three "Left to the ADR" items. The R1 implementation cards follow once the ADR merges. hotsrm and hotcrm adoption stays deferred.


    Generated by Claude Code

  4. added
    priority:p1
    and removed
    priority:p2
    on Nov 19, 2026
  5. os-bill commented on Nov 19, 2026

    @os-bill
    Collaborator

    Regrade: priority:p2 → priority:p1, by the maintainer's message 「升级 p1」 (os-bill, 2026-11-19T06:03:58Z). The next deliverable is unchanged: the ADR described in the comment above.


    Generated by Claude Code

  6. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-bill · session_01Utp6CajiB6BSQKWowy6YLB

    Claim: PM loop round 2 · area data-2 (seat 5 routed this p1 to data-2 after the maintainer's regrade 7001212970) · 2026-11-19T06:04Z
    Area: data-2
    Session: session_01Utp6CajiB6BSQKWowy6YLB
    Account: os-bill
    Branch: claude/issue-35339-uom-adr
    Worktree: objectstack-issue-35339
    Domain: domain:spec
    Seat: repo:objectstack#5
    File surface: one new ADR under docs/adr/** recording U1–U8 of ruling 7001193034 and settling its three "Left to the ADR" items, plus the ADR index line if the repo keeps one. ⛔ No schema, code, changeset or other ADR edit: the ADR declares, the R1 cards implement after it merges. Stop on breach and report.
    Container & model: M, mode:subagent, model: default — contract tier per 强制条款① (docs/adr/**), effort: xhigh
    Clause-②: no
    Metadata-protocol: none
    Responsibility: objectstack packages/spec has no unit of measure; every managed suite that records a quantity invents its own unit list; the maintainer ruled the platform design (U1–U8) and asked for the ADR before any R1 card
    Thread-read: 7001212970
    Premise: holds — on origin/main: uom in packages/spec/src 0 hits; ValueDomainSchema has three members (value-domain.zod.ts); no ADR on units
    Serial constraints cleared: none — a new ADR file; no open PR adds a units ADR (live read of open PRs' files at claim time)
    Pre-claim lane: domain:spec (docs/adr/**, Tier H: L1 by L1-a, L2 contract tier and the handoff by seat 5, merge by the approvers)
    Pre-claim deps: none named; #35328 (ruled A) complements, not a blocker
    Prior rulings read: units, uom, value domain, currency, home projection, enforce-or-remove → ruling 7001193034 (U1–U8) binds verbatim; ADR-0144 (D1, D2 amendment, D5, D6, D8 rule 2) is the mirrored pattern; value-domain 2026-09-02 "does not widen" kept by U1; ADR-0049, ADR-0078, ADR-0104 D1, ADR-0153 cited by the ruling; none conflicts. The three "Left to the ADR" items get a Fable analysis first where they are product choices; the seat relays any maintainer pick before the ADR text fixes them.

  7. added
    domain:spec
    pm:dispatched
    on Nov 19, 2026
  8. 12 remaining items

  9. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-bill · session_01Utp6CajiB6BSQKWowy6YLB

    Maintainer ruling record · ADR-0158 Open item 8 · 2026-11-19T12:02Z

    Ruling: the maintainer's decision card in seat 5's project thread (posted 2026-11-19T10:11Z), answered 2026-11-19T12:02Z by tapping option A. Relayed by seat 5. Analysis: project file objectstack-seat5/area-ux/data-2/decision-35339-oi8-oi10.md (one Fable round).

    Question on the card, verbatim: 「物料「基本单位」这种旁边没有数量的单位栏,能声明自己是单位栏吗?」

    Picked, verbatim (the maintainer's whole text is the option tapped): 「可以单独声明」.

    The option's consequence, as the card worded it, verbatim (the card's text, which the maintainer accepted by tapping; it is not the maintainer's own wording): 「声明后只收单位表里的单位、有下拉、旧文字可批量改成标准代码,和币种栏一样;并入第一期三张卡。」

    Read plainly: a text field that holds a unit code may declare itself a unit field with no quantity beside it, as a currency code field can declare valueDomain on its own. Once declared, it admits only codes from the unit tables (U1 or the organization's sys_unit), it gets a picker, and the backfill reaches it. This widens U4, which until now put the declaration on the number field only. The card's "the first release's three cards" are the R1 members that read a unit field: membership (#35489), display (#35490) and backfill (#35492).

    Not decided here (left to #35489 under its review, amending ADR-0158): the key's spelling on a standalone text field, and how it sits beside unitConfig.unitField's pointer. U1's "not a fourth value domain" still holds, so the declaration is a unit marker and not a ValueDomainSchema member.

    Effect on the R1 cards: OI8 is no longer a blocker. #35489 and #35492 stay pm:blocked only on their card dependencies (#35488, then #35489). #35490 stays blocked on Open item 10, which is still with the maintainer.

  10. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-bill · session_01Utp6CajiB6BSQKWowy6YLB

    Maintainer ruling record · ADR-0158 Open item 10 · 2026-11-19T12:03Z

    Ruling: the maintainer's decision card in seat 5's project thread (posted 2026-11-19T10:11Z), answered 2026-11-19T12:02Z by tapping option A. Relayed by seat 5. Analysis: project file objectstack-seat5/area-ux/data-2/decision-35339-oi8-oi10.md (one Fable round).

    Question on the card, verbatim: 「千克、件这类标准单位显示几位小数,组织能改吗?」

    Picked, verbatim (the maintainer's whole text is the option tapped): 「组织可改,新开一处设置」.

    The option's consequence, as the card worded it, verbatim (the card's text, accepted by the tap, not the maintainer's own wording): 「管理员可给任一标准单位设小数位,珠宝行克设3位、砂石场千克设0位;多一张卡。」

    Read plainly: an organization admin may set the display decimal places of any standard U1 code, in a new organization-owned setting place. sys_unit stays org-added units only (U3), and U1 stays a closed constant. This follows U6's 「小数位由组织可改」 for standard codes as well as org codes. L4 is unchanged: the field's scale is the storage ceiling, and a unit's decimal places are only its display default.

    The "one more card" is #35498 (p2, sub-issue here). Its shape (a sys_* object or a settings key, and its grants) is that card's to settle, amending ADR-0158.

    Effect on the R1 cards: Open items 8 and 10 are both answered, so nothing remains blocked on #35339. The cards stay pm:blocked only on their card dependencies: #35489 on #35488; #35490 on #35489 and #35498; #35491 and #35492 on #35489; #35498 on #35488. #35488 is ready (pm:queue). This card stays open until the R1 cards land.

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

Metadata

Metadata

Assignees

Labels

area:datadomain:specpm:dispatchedpriority:p1

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions