Skip to content

Commit fcb86f7

Browse files
committed
docs(spec): name the built-artifact and stored-object-row legs in the rateField scale floor's upgrade entry
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVugtCCwBs98FeR27P
1 parent 997cb02 commit fcb86f7

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎.changeset/30103-home-amount-rate-field-scale-floor.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Skills-docs: none — `skills/objectstack-data/rules/field-types.md` teaches `ra
1414

1515
- **Before.** A rate field declared `Field.number({ readonly: true, scale: 4 })` parsed. The engine stored the rate it used with all twelve decimals anyway (the rate row's own value, never rounded), so the declared `scale` only rounded the rate a reader was shown: `0.1389` for a stored `0.138912345678`, a rate that no longer reproduced the stored home amount.
1616
- **Now.** The parse refuses it at `fields.AMOUNT.currencyConfig.homeAmount.rateField`, naming the field, its `scale` and the floor 12, the rate's scale (ruling 6469382727: twelve digits after the decimal point, total precision 24). A rate field with no `scale` is accepted: on a `number` field an absent `scale` declares no fixed width, so the rate shows every digit it was stored with. `scale: 12` or more is accepted.
17-
- **Unchanged.** What the engine stores and computes, and every stored row.
17+
- **Unchanged.** What the engine stores and computes, and every stored data row (record values).
18+
- **Metadata already on disk.** A built artifact whose object declares such a rate field is refused whole at load (its `ObjectStackDefinitionSchema` parse fails before anything registers): fix the source and rebuild. A stored `sys_metadata` object row is kept as authored and still loads and registers; boot logs `[metadata_spec_invalid]` at `fields.AMOUNT.currencyConfig.homeAmount.rateField`, and its next save is refused `422 INVALID_METADATA` until the rate field's `scale` is raised to 12 or more, or deleted.
1819
- **Docs.** `CURRENCY_FRACTION_DIGITS` and the currency page now say the table is CLDR's fraction digits, and list the sixteen codes where they differ from ISO 4217's minor units: IQD (CLDR 0, ISO 3) and AFN, ALL, COP, HUF, IDR, IRR, KPW, LAK, LBP, MGA, MMK, PKR, SOS, SYP, YER (CLDR 0, ISO 2), measured against SIX's ISO 4217 List One of 2024-06-25.
1920

2021
**FROM → TO.** `amount_rate: Field.number({ readonly: true, scale: 4 })` → `amount_rate: Field.number({ readonly: true, scale: 12 })`, or `Field.number({ readonly: true })` with no `scale`.

‎packages/spec/src/migrations/entries/semantic/18.home-amount-rate-field-scale-floor.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,19 @@ export const entry: SemanticMigration = {
2020
+ 'fields.AMOUNT.currencyConfig.homeAmount.rateField, naming the field, its scale and the floor 12. An undeclared '
2121
+ 'scale is accepted: on a number field it declares no fixed width, so the rate shows its stored digits. NOT '
2222
+ 'mechanically converted: raising the scale or deleting it are both right, and which one is the author\'s '
23-
+ 'display choice. Stored rows are unaffected; the engine already kept every digit.',
23+
+ 'display choice. OLDER BUILT ARTIFACTS: an artifact whose object declares such a rate field fails its '
24+
+ 'ObjectStackDefinitionSchema parse at load, before anything in it registers, so the whole artifact is refused '
25+
+ 'and the metadata plugin\'s start fails with the Zod issue at that path; rebuild the artifact after fixing the '
26+
+ 'source. STORED sys_metadata OBJECT ROWS are kept as authored and nothing converts one: such a row still loads '
27+
+ 'and registers unchanged, boot logs it with a [metadata_spec_invalid] line at '
28+
+ 'fields.AMOUNT.currencyConfig.homeAmount.rateField, and its next save is refused with 422 INVALID_METADATA '
29+
+ 'until the scale is raised to 12 or more or deleted. Stored DATA rows (record values) are unaffected; the '
30+
+ 'engine already kept every digit of the rate.',
2431
acceptanceCriteria:
2532
'objectstack validate (ObjectStackDefinitionSchema.safeParse) reports no issue at '
2633
+ 'fields.AMOUNT.currencyConfig.homeAmount.rateField for any amount declaring homeAmount, and the rate field '
2734
+ 'either declares no scale or declares scale 12 or more; a record written afterwards shows its stored rate with '
28-
+ 'all of its decimals.',
35+
+ 'all of its decimals. Rebuild every built artifact after the fix. For stored sys_metadata object rows, look '
36+
+ 'for the [metadata_spec_invalid] boot line at fields.AMOUNT.currencyConfig.homeAmount.rateField: raise that '
37+
+ 'rate field\'s scale to 12 or more, or delete it, and save the object.',
2938
};

0 commit comments

Comments
 (0)