Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .changeset/33713-dynamic-rollup-engine-door.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
'@objectstack/objectql': minor
'@objectstack/spec': minor
---

fix(objectql, spec)!: a single-object save on a running server refuses a `dynamic` roll-up over a child field that is not a stored home amount, in `defineStack`'s words

Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — `skills/**` teaches no `dynamic` roll-up yet (its home roll-up paragraph is owed by follow-up #33714), so no page states which door refuses the wrong one.

<!-- adr-0087: registered summary-dynamic-currency-rollup-home-amount-judged-as-served -->

**BREAKING** for a hand-written object body saved on a running server. A `summary` with `function` `sum` / `min` / `max` / `avg` that declares `currencyMode: 'dynamic'` (or a `currencyConfig` naming no mode) is admitted only when it rolls up a stored home amount: a child field that the `homeAmount.field` of a record-mode amount on the child names. `defineStack` already refused every other one; the engine registry, which a single-object save meets, judged only `record` roll-ups, so a `dynamic` roll-up over a `fixed` EUR amount, a plain number or a formula was stored there and its total drawn with the home currency's symbol.

What moves (each line FROM → TO):

- a published save or publish of an object through the `/meta` doors (`PUT /meta/object/:name`, the runtime `/meta` dispatcher, `POST /meta/object/:name/publish`, a datasource table import) whose `dynamic` roll-up reads a child field that is not a stored home amount, with the child registered: FROM stored, 200 TO refused 422 `INVALID_METADATA`, nothing stored, with the sentence `defineStack` prints (`recordCurrencyDynamicRollupNotHomeError`, `@objectstack/spec/data`). The same holds in the other order: a child saved so that a registered parent's `dynamic` roll-up no longer reads a home amount is refused, naming the parent's roll-up.
- the same roll-up added by an `objectExtensions` entry or an `object_extension` item, or reading a child field an extension adds: judged against the parent and the child as the server serves them, at the end of an install, upgrade or reload run, on a published single save of the item, and in the batch writers (a package publish, a duplicate, an import): FROM installed or stored TO refused 422.
- a `homeAmount` makes a field a stored home amount only where it is valid as declared: on a `record`-mode `currency` amount, naming another field of the same object that is a `currency` field in `dynamic` mode, `readonly: true`, with no `expression`, and claimed by that one amount (`storedHomeAmountSourceOf`, `@objectstack/spec/data`). The object door already guaranteed this for an authored object; a field map merged with an extension's was taken at its word. At `defineStack` and at the engine registry alike, a `dynamic` roll-up over a field an extension's `homeAmount` names without that reading: FROM admitted TO refused.

The fix: roll up the child's stored home amount (the refusal lists them), declare `currencyMode: 'fixed'` with the code when every amount the roll-up reads is in that one currency, or delete `currencyConfig` on the summary. An extension declaring a home amount gives it a `readonly` `dynamic` currency field of its own.

Unchanged: the `dynamic` roll-up of a stored home amount (the shape `currencyMode: 'dynamic'` was admitted for) saves and is served; a summary with no `currencyConfig`, or `fixed`, is not judged by this arm; a `count` roll-up and every `record` case answer exactly as before; a roll-up over a child amount in each row's own currency is still refused by D6's roll-up door first, whatever it declares. Roll-ups stored before this release keep loading at every boot, which is not asked, and a run that leaves such a pair as it found it is not refused over it. `FieldSchema.currencyConfig`'s description now says that every door refuses the roll-ups it names. The latest stable `@objectstack/spec` (18.4.0) never admitted a `dynamic` summary at all; only the `next` snapshot of 2026-11-15 did, before this door judged it.
20 changes: 11 additions & 9 deletions content/docs/data-modeling/currency.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,14 @@ that column. A `count` column never carries `currencyField`. See the
`currencyMode`) is admitted only for a `sum`, `avg`, `min` or `max` of a stored home
amount, a child field that a `homeAmount.field` on the child object names (see
[Totals in the home currency](#totals-in-the-home-currency)), and naming no currency
code. `defineStack` (`os validate` and the build) refuses one over any other
child field, naming the child's home amounts. A single-object save or publish through the
metadata API on a running server does not judge the child field yet: it parses the one
object, so it refuses only what that object shows (#33713). The object itself refuses
one that names no child field, one that names a currency code, and a `count` in
every mode, at every door.
code. One over any other child field is refused, naming the child's home amounts:
`defineStack` (`os validate` and the build) refuses it, and on a running server a save or
publish through the metadata API refuses it with **`INVALID_METADATA` / 422** and the
same message, whichever object is saved second, judging each object as the server serves
it, extensions included. A `homeAmount` makes a field a home amount only where it is
valid as declared, so an extension cannot make a plain number one by naming it. The
object itself refuses one that names no child field, one that names a currency code, and
a `count` in every mode, at every door.
- **A dataset measure that declares `currency` over a record-mode amount** is refused at
compile with **`DATASET_INVALID` / 400**, and so is a `currency` on a derived measure that
sums record-mode amounts. One code cannot label amounts in several currencies: delete
Expand Down Expand Up @@ -472,9 +474,9 @@ actual_cost: {
The Console then draws the total in `localization.currency` on the record page and in the
list cell (`$250.00` under a USD home currency, `CN¥1,800.00` under CNY), the same currency
a dashboard metric over `amount_home` shows. Without the declaration the roll-up stays a
bare number. `defineStack` (`os validate` and the build) refuses `dynamic` on any other
roll-up, because the amounts it reads are not known to be in the home currency; a
single-object save on a running server does not check that yet (#33713, see
bare number. `dynamic` on any other roll-up is refused, because the amounts it reads are
not known to be in the home currency: by `defineStack` (`os validate` and the build), and
by a save or publish through the metadata API on a running server (see
[Roll-ups and datasets](#roll-ups-and-datasets)).

## See also
Expand Down
2 changes: 1 addition & 1 deletion content/docs/references/data/field.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const result = CurrencyConfigSchema.parse(data);
| **summaryOperations** | `{ object: string; field?: string; function: Enum<'count' \| 'sum' \| 'min' \| 'max' \| 'avg'>; relationshipField?: string; … }` | optional | Roll-up summary definition. The engine recomputes the value when child records are inserted/updated/deleted. |
| **language** | `string` | optional | Programming language for syntax highlighting (e.g., javascript, python, sql) |
| **step** | `number` | optional | Step increment for slider (default: 1) |
| **currencyConfig** | `{ currencyMode?: Enum<'dynamic' \| 'fixed' \| 'record'>; defaultCurrency?: string; currencyField?: string; homeAmount?: object }` | optional | Which currency an amount is in: for a currency field, for a formula field whose returnType is currency, and for a summary that rolls up, through a master_detail, child amounts that follow this record's currency (`currencyMode: 'record'` naming this object's own code field). A summary that rolls up a stored home amount (a child field some `homeAmount.field` names) declares `currencyMode: 'dynamic'`, with no `defaultCurrency`, and shows in the organization's home currency. A summary may otherwise declare only `currencyMode: 'fixed'`, when every amount it reads is in that one currency; a `count` summary, any other `dynamic` summary and any other `record` roll-up are refused. Absent: dynamic mode, and no currency on a summary. |
| **currencyConfig** | `{ currencyMode?: Enum<'dynamic' \| 'fixed' \| 'record'>; defaultCurrency?: string; currencyField?: string; homeAmount?: object }` | optional | Which currency an amount is in: for a currency field, for a formula field whose returnType is currency, and for a summary that rolls up, through a master_detail, child amounts that follow this record's currency (`currencyMode: 'record'` naming this object's own code field). A summary that rolls up a stored home amount (a child field some `homeAmount.field` names) declares `currencyMode: 'dynamic'`, with no `defaultCurrency`, and shows in the organization's home currency. A summary may otherwise declare only `currencyMode: 'fixed'`, when every amount it reads is in that one currency; a `count` summary, any other `dynamic` summary and any other `record` roll-up are refused, by `defineStack` and by a single-object save or publish on a running server alike. Absent: dynamic mode, and no currency on a summary. |
| **dimensions** | `integer` | optional | Vector dimensionality (e.g., 1536 for OpenAI embeddings) |
| **trackHistory** | `boolean` | optional | Render this field's value changes as human-readable entries on the record activity timeline (ADR-0052 §5b). Opt-in per field. |
| **group** | `string` | optional | Field group name for organizing fields in forms and layouts (e.g., "contact_info", "billing", "system") |
Expand Down
4 changes: 2 additions & 2 deletions content/docs/references/data/object.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ const result = ApiMethod.parse(data);
| **summaryOperations** | `{ object: string; field?: string; function: Enum<'count' \| 'sum' \| 'min' \| 'max' \| 'avg'>; relationshipField?: string; … }` | optional | Roll-up summary definition. The engine recomputes the value when child records are inserted/updated/deleted. |
| **language** | `string` | optional | Programming language for syntax highlighting (e.g., javascript, python, sql) |
| **step** | `number` | optional | Step increment for slider (default: 1) |
| **currencyConfig** | `{ currencyMode?: Enum<'dynamic' \| 'fixed' \| 'record'>; defaultCurrency?: string; currencyField?: string; homeAmount?: object }` | optional | Which currency an amount is in: for a currency field, for a formula field whose returnType is currency, and for a summary that rolls up, through a master_detail, child amounts that follow this record's currency (`currencyMode: 'record'` naming this object's own code field). A summary that rolls up a stored home amount (a child field some `homeAmount.field` names) declares `currencyMode: 'dynamic'`, with no `defaultCurrency`, and shows in the organization's home currency. A summary may otherwise declare only `currencyMode: 'fixed'`, when every amount it reads is in that one currency; a `count` summary, any other `dynamic` summary and any other `record` roll-up are refused. Absent: dynamic mode, and no currency on a summary. |
| **currencyConfig** | `{ currencyMode?: Enum<'dynamic' \| 'fixed' \| 'record'>; defaultCurrency?: string; currencyField?: string; homeAmount?: object }` | optional | Which currency an amount is in: for a currency field, for a formula field whose returnType is currency, and for a summary that rolls up, through a master_detail, child amounts that follow this record's currency (`currencyMode: 'record'` naming this object's own code field). A summary that rolls up a stored home amount (a child field some `homeAmount.field` names) declares `currencyMode: 'dynamic'`, with no `defaultCurrency`, and shows in the organization's home currency. A summary may otherwise declare only `currencyMode: 'fixed'`, when every amount it reads is in that one currency; a `count` summary, any other `dynamic` summary and any other `record` roll-up are refused, by `defineStack` and by a single-object save or publish on a running server alike. Absent: dynamic mode, and no currency on a summary. |
| **dimensions** | `integer` | optional | Vector dimensionality (e.g., 1536 for OpenAI embeddings) |
| **trackHistory** | `boolean` | optional | Render this field's value changes as human-readable entries on the record activity timeline (ADR-0052 §5b). Opt-in per field. |
| **group** | `string` | optional | Field group name for organizing fields in forms and layouts (e.g., "contact_info", "billing", "system") |
Expand Down Expand Up @@ -656,7 +656,7 @@ const result = ApiMethod.parse(data);
| **summaryOperations** | `{ object: string; field?: string; function: Enum<'count' \| 'sum' \| 'min' \| 'max' \| 'avg'>; relationshipField?: string; … }` | optional | Roll-up summary definition. The engine recomputes the value when child records are inserted/updated/deleted. |
| **language** | `string` | optional | Programming language for syntax highlighting (e.g., javascript, python, sql) |
| **step** | `number` | optional | Step increment for slider (default: 1) |
| **currencyConfig** | `{ currencyMode?: Enum<'dynamic' \| 'fixed' \| 'record'>; defaultCurrency?: string; currencyField?: string; homeAmount?: object }` | optional | Which currency an amount is in: for a currency field, for a formula field whose returnType is currency, and for a summary that rolls up, through a master_detail, child amounts that follow this record's currency (`currencyMode: 'record'` naming this object's own code field). A summary that rolls up a stored home amount (a child field some `homeAmount.field` names) declares `currencyMode: 'dynamic'`, with no `defaultCurrency`, and shows in the organization's home currency. A summary may otherwise declare only `currencyMode: 'fixed'`, when every amount it reads is in that one currency; a `count` summary, any other `dynamic` summary and any other `record` roll-up are refused. Absent: dynamic mode, and no currency on a summary. |
| **currencyConfig** | `{ currencyMode?: Enum<'dynamic' \| 'fixed' \| 'record'>; defaultCurrency?: string; currencyField?: string; homeAmount?: object }` | optional | Which currency an amount is in: for a currency field, for a formula field whose returnType is currency, and for a summary that rolls up, through a master_detail, child amounts that follow this record's currency (`currencyMode: 'record'` naming this object's own code field). A summary that rolls up a stored home amount (a child field some `homeAmount.field` names) declares `currencyMode: 'dynamic'`, with no `defaultCurrency`, and shows in the organization's home currency. A summary may otherwise declare only `currencyMode: 'fixed'`, when every amount it reads is in that one currency; a `count` summary, any other `dynamic` summary and any other `record` roll-up are refused, by `defineStack` and by a single-object save or publish on a running server alike. Absent: dynamic mode, and no currency on a summary. |
| **dimensions** | `integer` | optional | Vector dimensionality (e.g., 1536 for OpenAI embeddings) |
| **trackHistory** | `boolean` | optional | Render this field's value changes as human-readable entries on the record activity timeline (ADR-0052 §5b). Opt-in per field. |
| **group** | `string` | optional | Field group name for organizing fields in forms and layouts (e.g., "contact_info", "billing", "system") |
Expand Down
Loading
Loading