Skip to content

Commit 4203db7

Browse files
docs(skills): the objectstack-data skill names the platform's exchange-rate table and teaches unitConfig (#38980)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBG4YD4RMAt72Ga5PdYYZDAQ)_ Part of #38939 Claim for this branch: #38939 comment 7314913435 Clause-②: no Metadata-protocol: none repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ ## 维护者速读 - 用户能看到什么变化:用户无感,界面和运行行为都没变;照着数据建模技能文档做多币种报价或带计量单位的产品的作者和 AI,现在能直接读到平台已经自带汇率表和计量单位规则,不会再自己另建一张汇率表、写一段换算逻辑,或做一个随手填写的单位字段。 - 为什么做:正式发布前的验收评测里,有两道题带着技能也答错;这两条事实以前只写在项目管理技能的平台清单里,只装数据建模技能的人读不到。 - 出错会怎样:只改文字,不改任何运行行为;如果新说法有误,作者会照着写错汇率或单位的声明,撤回本次合并即可复原。 - 要你做什么:这是对外发布的技能包,需要你审阅后亲手合并。 - 本 PR 之后卡片仍开着:卡片第 3 条(评测题 objects 22、24 带技能重跑通过)未测,由评测席重跑后再关卡。 ## What changes Two published files of `skills/objectstack-data`, two rows of the token ratchet, and one changeset. No eval fixture, no file of `skills/objectstack-project`, no schema and no runtime file is touched. | Place | Before | After | |:--|:--|:--| | `rules/field-types.md`, § Currency, the `homeAmount` paragraph | Said the engine stores the home amount at the `rateDate` rate. It did not say where the rates live. | Adds: the rates are the platform's `sys_exchange_rate`, which an administrator keeps in Setup; never an app rate object or a conversion hook; a foreign amount with no rate on or before `rateDate` is refused (`ERR_EXCHANGE_RATE_MISSING`). | | `rules/field-types.md`, new § Unit of measure (under Common Field Configurations, after Currency) | No file of the skill outside `evals/` held `unitConfig`, `unitMode`, `H87`, `KGM` or `sys_unit`. | One type-checked example with the three shapes: `unitMode: 'code'` on a `text` field, and on a `number` field `'fixed'` with `unit: 'KGM'` and `'record'` with `unitField`. One paragraph: a unit is never free text, a picklist or an app unit object; `unitMode` has no default; the stored code is exact uppercase, a standard UN/ECE Rec 20 code (`H87`, `KGM`, `XBX` named) or one the organization adds to `sys_unit` in Setup; the two write refusals; `unitDimension`; the free-text conversion run. | | `rules/field-types.md`, the `text` and `number` rows | Config lists without `unitConfig`. | Each list ends with `unitConfig` and a pointer to the new section, as the `currency` row points at Currency. | | `rules/field-types.md`, `## Choosing a type` and `## Changing a field that has data`, first line of each | Each carried a parenthetical that repeated a fact stated elsewhere. | Both parentheticals are cut (the paydown, below). | | `SKILL.md`, `## Where to go`, the Field Types row | "A field's type and config, a default, changing a field that has data" | The same, plus "exchange rates (`sys_exchange_rate`), units of measure (`unitConfig`)". | | `SKILL.md`, `## Where to go`, the sentence above the table | "Open the file for your task first." | Cut (the paydown, below). The table's "Open first" column header says the same; the platform and ui entries have no such sentence. | | `scripts/check-skills-token-ratchet.mjs` | `SKILL.md` 2224, `rules/field-types.md` 4200 | 2233 and 4566, each pinned at its measurement, each with its accounting comment. | **Why the entry file changes at all.** A request to "create an exchange-rate object and a conversion hook" is routed by the entry to the object and hook files, which do not mention the rate table. Without a word in the routing table, nothing sends that request to § Currency. The row now names both identifiers, so the request meets them before it builds anything. **Every added sentence, and the code it was read from** | Sentence | Source | |:--|:--| | The rates are `sys_exchange_rate` | `packages/objectql/src/home-amount-projection.ts`, `EXCHANGE_RATE_OBJECT`; `packages/platform-objects/src/system/sys-exchange-rate.object.ts` | | An administrator keeps it in Setup | `packages/platform-objects/src/apps/setup-nav.contributions.ts`, `nav_exchange_rates`; the object's "Who writes" note (organization administrators) | | No app rate object or conversion hook | The projection converts at write and is the only writer of the home and rate fields (same file, "Who writes the two fields") | | A foreign amount with no rate on or before `rateDate` is refused, `ERR_EXCHANGE_RATE_MISSING` | Same file: the latest `effective_date` on or before the document date, else refused; an amount in the home currency needs no rate row, hence "foreign" | | `unitConfig` on a `number` field (`'fixed'`, `'record'`) or a `text` field (`'code'`); no default `unitMode` | `packages/spec/src/data/field.zod.ts`, `UnitConfigSchema`, `UNIT_CONFIG_MODES_BY_FIELD_TYPE`, `unitModeMessage` | | The field `unitField` names is a `text` field of the same object with no `unitConfig` or `valueDomain` | `packages/spec/src/data/object.zod.ts`, `refuseDishonestRecordUnitField` | | Exact uppercase; `H87` piece, `KGM` kilogram, `XBX` box; `STANDARD_UNITS` in `@objectstack/spec/data` | `packages/spec/src/data/standard-units.ts` | | An organization's own unit lives in `sys_unit`, added in Setup, and cannot be a `fixed` unit | `sys-unit.object.ts`; `setup-nav.contributions.ts`, `nav_units_of_measure`; `fixedUnitMessage` in `field.zod.ts` | | `ERR_UNIT_CODE_UNKNOWN` (`pcs`, `kg`, `C62`, `EA`), `ERR_UNIT_CODE_REQUIRED` | `packages/objectql/src/validation/unit-code-membership.ts`; `C62` and `EA` are in no standard row and cannot be organization codes | | `unitDimension` on `'record'` and `'code'` only | The three closed shapes in `field.zod.ts` | | `os migrate unit-codes` | `packages/cli/src/commands/migrate/unit-codes.ts` | The same facts are in the generated platform catalog (`skills/objectstack-project/references/platform-catalog.md`, the `sys_exchange_rate` and `sys_unit` rows), which this PR does not touch. ### Size | File | Lines | Bytes | Tokens (`ceil(utf8 bytes / 4)`) | |:--|:--|:--|:--| | `skills/objectstack-data/rules/field-types.md` | 318 to 346 | 16799 to 18262 (+1463) | 4200 to 4566 (+366) | | `skills/objectstack-data/SKILL.md` | 167 to 165 | 8923 to 8958 (+35) | 2224 to 2233 (+9; the 27-byte stamp line is not priced) | | All `SKILL.md` files of the catalog | 2141 to 2139 | 120425 to 120460 | | | `skills/objectstack-data`, authored files outside `evals/` | 3696 to 3722 | 175542 to 177040 | | | Whole shipped tree, the ratchet's own total | | | 287587 to 287962 (+375) | The entry file stays inside its router budget of 9 KB: 8958 bytes. ### The ratchet raise Both rows had zero headroom. Raise path: ruling record 6513306068, letter B. The standing ruling, verbatim and untranslated: 「A:先削重复,余额按实测提高」. - `rules/field-types.md`: +1560 bytes of new text. Paid down first by two restatement cuts in the same file, 97 bytes (45 + 52): the `secret` parenthetical under `## Choosing a type` (its home is the `secret` row of the same file, which says encrypted at rest and names ADR-0100) and the parenthetical under `## Changing a field that has data` that repeated the entry's first trap, which the same line already points at. The row moves by the measured remainder, +366, to 4566. - `SKILL.md`: +71 bytes on the routing row. Paid down first by the sentence above the routing table, 36 bytes. The row moves by the measured remainder, +9, to 2233. ## Tests Read on head `bf4e7c2be3` (the branch with `origin/main` at `d38006b9b3` merged in). - `node scripts/check-skills-token-ratchet.mjs`: exit 0; `skills/objectstack-data/SKILL.md is 2233 tokens (ceiling 2233; headroom 0)`, `skills/objectstack-data/rules/field-types.md is 4566 tokens (ceiling 4566; headroom 0)`. `--self-test`: exit 0, 111 cases pass. - `pnpm --filter @objectstack/spec run check:skill-examples`: exit 0, "342 prose examples type-check across 3 surface(s)". The new block carries the check marker and is one of them: with `unitMode` misspelled in it on disk (a one-time check, restored and hash-compared to the committed blob), the same command exits 1 with `error TS2561` at `skills/objectstack-data/rules/field-types.md:228:41`. - `pnpm --filter @objectstack/spec run check:skill-docs`, `check:skill-served-sections`, `check:skill-refs`: exit 0 each. `pnpm check:skill-links`, `check:skill-identifier-liveness`, `check:skill-compatibility`, `check:skill-frame-sync`, `check:doc-authoring`, `check:nul-bytes`: exit 0 each. - A runtime parse of the example by the built spec (`ObjectSchema.safeParse`): accepted. The same probe confirmed each refusal the paragraph states at the build door: a lowercase `unit`, `C62`, a missing `unitMode`, `'code'` on a `number` field, `'fixed'` on a `text` field, `unitConfig` on a `currency` field, `unitDimension` under `'fixed'`, and a pointed-at field that carries `unitConfig` or `valueDomain`. - The write refusals were not booted. Their codes were read from source, and the two test files that pin them pass on this head: `unit-code-membership.test.ts` and `home-amount-projection.test.ts`, 70 tests. <details> <summary>Derived gate set: 70 commands, 68 run, 2 not measured</summary> `node scripts/pm/dispatch-gates.mjs --ran` on `bf4e7c2be3`: "70 derived famil(ies) accounted for — 68 run, 2 NOT-MEASURED (1 DERIVED from a recorded exit 3, 1 claimed)". All 68 exited 0. - NOT MEASURED: `pnpm check:dual-build-cjs-loads`, exit 3, PREREQUISITE NOT MET. It reads the built output of every dual-build package, and this diff touches no package, so no workspace build is owed locally. CI runs it after its build. - NOT MEASURED: `pnpm check:pm-dispatch-gates`. It did not finish inside the 10-minute foreground limit (stopped at 570 s, exit 124, every check printed until then green). CI runs it. - `pnpm --filter @objectstack/lint run check:doc-formula-expressions` and `pnpm check:lean-entry-closure` first answered exit 3; each exited 0 after the targeted build its refusal names. - The derivation is from `bf4e7c2be3`. `origin/main` has moved three commits since; none touches a path of this PR. </details> <details> <summary>Token read for eval objects #22 and #24</summary> Counts of each assertion token in the lines this PR adds, and in the two files after the change. | Case | Token | Added lines | `SKILL.md` | `rules/field-types.md` | |:--|:--|:--|:--|:--| | 22 must contain | `unitConfig` | 8 | 1 | 7 | | 22 must contain | `unitMode` | 4 | 0 | 4 | | 22 must contain | `H87` | 1 | 0 | 1 | | 22 must contain | `KGM` | 2 | 0 | 2 | | 24 must contain | `sys_exchange_rate` | 2 | 1 | 1 | | 24 must contain | `homeAmount` | 0 | 0 | 4 (already there) | | 24 must contain | `currencyMode: 'record'` | 0 | 0 | 3 (already there) | No forbidden token of either case is in an added line: `uom: Field.select(`, `type: 'select'`, `name: 'exchange_rate'`, `event: 'afterInsert'`, 0 each. The new paragraph says "a picklist" and "an app rate object" for that reason, so an answer that copies it writes no forbidden literal. The with-skill re-run of the two cases is NOT MEASURED here. A model run is the eval seat's round, and this PR ran none. **What remains on #38939, so this PR is `Part of`:** card note 3, the with-skill re-run of eval objects 22 and 24. The card stays open with `pm:dispatched` until the eval seat records that re-run. </details> ## Acceptance notes - **The entry file changes in two places, not one.** The card allows one routing line. The second change, the sentence above the routing table, is the paydown the ratchet's raise path requires in the same file. It is in the same section. If the owning seat reads the fence as excluding it, the alternative is to restore the sentence and carry `SKILL.md` at 2242 tokens with no deletion shown, which the raise path does not allow. - **Two derived gates are not measured locally**, named under Tests. - **Case 22 forbids a literal the bundle writes.** `type: 'select'` is in `skills/objectstack-data/references/examples-objects.md` for other fields, and a right answer that warns against a select by naming it would fail the case. That is an eval assertion, which #38941 holds; noted, not changed here. - **The catalog and the data skill now both state these two facts.** The catalog is generated from `packages/spec/scripts/lib/platform-catalog.ts`; the data skill's text is hand-written. A change to either table's contract needs both. - The unit row of the weekly skills sweep card #35769 asks for the same unit teaching and for `H87` and `KGM` literally; it is carried here. ## Verification Read first, by risk: 1. `skills/objectstack-data/rules/field-types.md`, the new `### Unit of measure` paragraph: every clause is a claim about what the write path refuses. 2. Same file, the sentence added to the `homeAmount` paragraph: "never an app rate object or a conversion hook" is the instruction an agent will follow. 3. `skills/objectstack-data/SKILL.md`, `## Where to go`: the routing row, and the sentence that was cut above the table. Two-minute check: `node scripts/check-skills-token-ratchet.mjs` prints "skills/objectstack-data/rules/field-types.md is 4566 tokens (ceiling 4566; headroom 0)" and "skills/objectstack-data/SKILL.md is 2233 tokens (ceiling 2233; headroom 0)", and `git diff origin/main...HEAD --stat` lists four files. Governed surface (`skills/**`, Tier H): this PR stays draft. No reviewer is requested and nothing is queued or armed by the author. --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzeatqKfTRUzTJVa9jQ)_ <!-- signed: repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1095535 commit 4203db7

4 files changed

Lines changed: 82 additions & 11 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): the objectstack-data skill names the platform's exchange-rate table and teaches `unitConfig`
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The data skill never said that the platform ships the rate table and the unit vocabulary, so an app built from it alone declared its own exchange-rate object with a conversion hook, and a free-text or picklist unit field. The engine's conversion at write and its unit-code check then never ran for that app. Both facts were only in `objectstack-project`'s platform catalog, which a reader of the data skill does not load.
11+
12+
`skills/objectstack-data/rules/field-types.md`, § Currency: the rates `currencyConfig.homeAmount` converts with are the platform's `sys_exchange_rate`, which an administrator keeps in Setup. An app declares no rate object and no conversion hook. A foreign amount with no rate on or before its `rateDate` is refused with `ERR_EXCHANGE_RATE_MISSING`.
13+
14+
The same file gains § Unit of measure, with one type-checked example of the three shapes of `unitConfig`: `{ unitMode: 'code' }` on a `text` field that holds a unit code with no quantity pointing at it, and on a `number` field `{ unitMode: 'fixed', unit: 'KGM' }` or `{ unitMode: 'record', unitField: 'unit_code' }`, where `unit_code` is a `text` field of the same object with no `unitConfig` or `valueDomain` of its own. `unitMode` has no default. A record stores the unit as a code in exact uppercase: a standard UN/ECE Recommendation 20 code (`H87` for a piece, `KGM`, `XBX` for a box; the table is `STANDARD_UNITS` in `@objectstack/spec/data`), or one the organization adds to the platform's `sys_unit` in Setup, which a `fixed` unit cannot name. The write refuses any other value with `ERR_UNIT_CODE_UNKNOWN` (`pcs`, `kg`, and `C62` or `EA` for a piece), and a quantity beside a blank code with `ERR_UNIT_CODE_REQUIRED`. `unitDimension` limits a `record` or `code` field to the units of one dimension. Free text stored before the declaration is converted with `os migrate unit-codes`. The `text` and `number` rows of the type tables point at the section.
15+
16+
`skills/objectstack-data/SKILL.md`: in the "Where to go" table, the Field Types row now names exchange rates (`sys_exchange_rate`) and units of measure (`unitConfig`). The sentence above the table is gone: the table's "Open first" column header says the same.
17+
18+
Two token ceilings move, each after restating text in the same file was deleted first, by the measured remainder: `rules/field-types.md` from 4200 to 4566 (two parentheticals that repeated the `secret` row and the entry's first trap are cut), and `SKILL.md` from 2224 to 2233 (the sentence above the routing table is cut). The entry file is 8958 bytes.

‎scripts/check-skills-token-ratchet.mjs‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,18 @@ export const CEILINGS = new Map([
10541054
// `readonly: true` binds, which that section now carries. 8983 -> 8923 bytes (8956 ->
10551055
// 8896 priced), -60, -> 2224 tokens, pinned AT the measurement.
10561056
// ceil(($(wc -c < skills/objectstack-data/SKILL.md) - 27) / 4) == ceil(8896 / 4)
1057-
['skills/objectstack-data/SKILL.md', 2224],
1057+
// 2224 -> 2233 (#38939): the routing table's Field Types row names what the platform ships
1058+
// for money and units, exchange rates (`sys_exchange_rate`) and units of measure
1059+
// (`unitConfig`), so a request to build a rate object or a free-text unit field is sent to
1060+
// `rules/field-types.md`, where both are taught (+71 bytes). PAID DOWN FIRST, in the same
1061+
// section: the table's lead sentence ("Open the file for your task first."), which the
1062+
// table's own `Open first` column header restates (-36 bytes). 8923 -> 8958 bytes (8896 ->
1063+
// 8931 priced), +35, -> 2233 tokens, zero headroom, the row moves +9, the measured
1064+
// remainder, pinned AT the measurement; the entry stays inside the 9 KB budget its row above
1065+
// pinned. Raise path: ruling record 6513306068, letter B; the standing ruling (2026-10-27,
1066+
// verbatim and untranslated): 「A:先削重复,余额按实测提高」.
1067+
// ceil(($(wc -c < skills/objectstack-data/SKILL.md) - 27) / 4) == ceil(8931 / 4)
1068+
['skills/objectstack-data/SKILL.md', 2233],
10581069
// 5997 -> 6008 (the formula skills follow-ups of PRs #34443 and #34447): the
10591070
// `label(record.f)` row teaches a multi-select (`multiple: true`) reading each
10601071
// selected label in stored order, joined with `, `, and the built-ins line
@@ -1655,7 +1666,23 @@ export const CEILINGS = new Map([
16551666
// while the change was open (its row 3541 -> 3540); the same two sections arrive on top of it,
16561667
// 2639 bytes as before. 14160 -> 16799 bytes -> 4200 tokens, pinned AT the measurement.
16571668
// ceil($(wc -c < skills/objectstack-data/rules/field-types.md) / 4) == ceil(16799 / 4)
1658-
['skills/objectstack-data/rules/field-types.md', 4200],
1669+
// 4200 -> 4566 (#38939): § Currency names the platform's rate table (`sys_exchange_rate`,
1670+
// kept in Setup; never an app rate object or a conversion hook) and the refusal of a foreign
1671+
// amount with no rate (`ERR_EXCHANGE_RATE_MISSING`); a new § Unit of measure teaches
1672+
// `unitConfig` in its three shapes (`'code'` on a `text` field; `'fixed'` with `unit` and
1673+
// `'record'` with `unitField` on a `number` field) in one checked example, the stored code
1674+
// (exact uppercase; standard UN/ECE Rec 20 codes, `H87` and `KGM` named; an organization's
1675+
// own in `sys_unit`), the two write refusals, `unitDimension` and the free-text conversion
1676+
// run; the `text` and `number` rows point at it. +1560 bytes. PAID DOWN FIRST by two
1677+
// same-file restatement cuts, 97 bytes (45 + 52): the `secret` parenthetical under `##
1678+
// Choosing a type` (home: the `secret` row, which says encrypted at rest and names ADR-0100)
1679+
// and the parenthetical under `## Changing a field that has data` that repeated the entry's
1680+
// trap 1, which the same line already points at. `wc -c` = 18262 bytes (+1463) ->
1681+
// ceil(18262 / 4) = 4566 tokens, zero headroom, ceiling +366, the measured remainder, pinned
1682+
// AT the measurement. Raise path: ruling record 6513306068, letter B; the standing ruling
1683+
// (2026-10-27, verbatim and untranslated): 「A:先削重复,余额按实测提高」.
1684+
// ceil($(wc -c < skills/objectstack-data/rules/field-types.md) / 4) == ceil(18262 / 4)
1685+
['skills/objectstack-data/rules/field-types.md', 4566],
16591686
['skills/objectstack-data/rules/indexing.md', 2495], // -746 to the measurement (was 3241)
16601687
// 1590 -> 1909 (#32364, 2026-11-11): § Sealing (`seal`) teaches `lifecycle.seal`
16611688
// (+1574 B). PAID DOWN FIRST by three same-file restatements (-296 B): the ❌

‎skills/objectstack-data/SKILL.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ definition as code.
5959

6060
## Where to go
6161

62-
Open the file for your task first.
63-
6462
| Authoring | Open first |
6563
|:--|:--|
6664
| An object's other keys, a starter object, field groups, `protection`, an extension | [examples-objects.md](./references/examples-objects.md) |
67-
| A field's type and config, a default, changing a field that has data | [Field Types](./rules/field-types.md) |
65+
| A field's type and config, a default, exchange rates (`sys_exchange_rate`), units of measure (`unitConfig`), changing a field that has data | [Field Types](./rules/field-types.md) |
6866
| Names; labels in the request's language | [Naming](./rules/naming.md) |
6967
| `lookup` or `master_detail`, junctions, delete behaviour, roll-ups, line items | [Relationships](./rules/relationships.md) |
7068
| Validation rules, state machines, uniqueness, conditional field rules | [Validation](./rules/validation.md) |

‎skills/objectstack-data/rules/field-types.md‎

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const fields = {
3333

3434
| Type | When to Use | Config |
3535
|:-----|:------------|:-------|
36-
| `text` | Single-line strings (names, codes, titles) | `maxLength`, `minLength`, `defaultValue` |
36+
| `text` | Single-line strings (names, codes, titles) | `maxLength`, `minLength`, `defaultValue`, `unitConfig` (→ Unit of measure) |
3737
| `textarea` | Multi-line plain text (notes, descriptions) | `maxLength`, `minLength` |
3838
| `email` | Email addresses — format validated | `required`, `unique` |
3939
| `url` | Web URLs — format validated | `required` |
@@ -48,7 +48,7 @@ const fields = {
4848

4949
| Type | When to Use | Config |
5050
|:-----|:------------|:-------|
51-
| `number` | Numeric value | `min`, `max`, `precision`, `scale` |
51+
| `number` | Numeric value | `min`, `max`, `precision`, `scale`, `unitConfig` (→ Unit of measure) |
5252
| `currency` | Monetary amounts | `currencyConfig` (→ Currency) |
5353
| `percent` | Percentage; stored as a fraction (0-1) unless the field declares `max` above 1 (`max: 100`), then whole points; seeds, defaults, API values use that scale | `min`, `max`, `precision`, `percentDisplay` — the read-only face: unset or `'bar'` draws a progress bar, `'plain'` the number alone, for a rate or a probability |
5454

@@ -182,7 +182,10 @@ a run with neither.
182182
`homeAmount` (`'record'` only, all three required): the engine stores the
183183
home-currency amount in `field` (a `'dynamic'` `currency`) at the `rateDate`
184184
(`date`/`datetime`) rate, and that rate in `rateField` (`number`), both
185-
`readonly: true`. Cross-currency totals sum `field`.
185+
`readonly: true`. Cross-currency totals sum `field`. The rates are the
186+
platform's `sys_exchange_rate`, which an administrator keeps in Setup: never
187+
an app rate object or a conversion hook. A foreign amount with no rate on or
188+
before `rateDate` is refused (`ERR_EXCHANGE_RATE_MISSING`).
186189

187190
**A roll-up of the home field.** A `sum` / `min` / `max` / `avg` `summary` over a
188191
child's `homeAmount.field` declares `currencyMode: 'dynamic'`, no `defaultCurrency`
@@ -215,6 +218,32 @@ Once a line follows it, the invoice's `currency_code` cannot change
215218
(`VALIDATION_FAILED`; a first code over a blank one passes) until none does:
216219
delete the lines and purge the recycle bin, or move them to another invoice.
217220

221+
### Unit of measure
222+
223+
<!-- os:check -->
224+
```typescript
225+
import { Field } from '@objectstack/spec/data';
226+
227+
const fields = {
228+
uom: Field.text({ unitConfig: { unitMode: 'code' } }), // a unit code, no quantity
229+
weight: Field.number({ unitConfig: { unitMode: 'fixed', unit: 'KGM' } }),
230+
quantity: Field.number({ unitConfig: { unitMode: 'record', unitField: 'unit_code' } }),
231+
unit_code: Field.text(), // no `unitConfig` or `valueDomain` of its own
232+
};
233+
```
234+
235+
A unit is never free text, a picklist or an app unit object: it is
236+
`unitConfig`, on a `number` field (a quantity) or on a `text` field no quantity
237+
points at, and `unitMode` has no default. A record stores the code in exact
238+
uppercase: a standard UN/ECE Rec 20 code (`H87` piece, `KGM` kilogram, `XBX`
239+
box; `STANDARD_UNITS` in `@objectstack/spec/data`), or one the organization
240+
adds to the platform's `sys_unit` in Setup (not under `'fixed'`). The write
241+
refuses any other value (`ERR_UNIT_CODE_UNKNOWN`: `pcs`, `kg`, `C62`, `EA`) and
242+
a quantity beside a blank code (`ERR_UNIT_CODE_REQUIRED`). `unitDimension`
243+
(`'mass'`, `'count'`, …; `'record'` and `'code'`) limits the codes to one
244+
dimension. The quantity stays a bare number. Convert free text stored earlier
245+
with `os migrate unit-codes`.
246+
218247
### Lookup (One-to-Many)
219248

220249
```typescript
@@ -274,8 +303,7 @@ The `format` is literal text interleaved with `{...}` tokens:
274303

275304
## Choosing a type
276305

277-
Beyond `SKILL.md` § Field Type Selection (`secret` is encrypted at rest per
278-
ADR-0100):
306+
Beyond `SKILL.md` § Field Type Selection:
279307

280308
- A yes/no flag, `{ type: 'boolean', defaultValue: false }`, is any `is_*`,
281309
`has_*`, "done?" or "active?". An unchecked box is
@@ -291,7 +319,7 @@ ADR-0100):
291319

292320
## Changing a field that has data
293321

294-
Beyond `SKILL.md` trap 1 (the sync only adds; the column wins at write time):
322+
Beyond `SKILL.md` trap 1:
295323

296324
| Change | Existing DB on restart |
297325
|--|--|

0 commit comments

Comments
 (0)