Repository navigation
Commit 63e47fe
fix(objectql, spec)!: a single-object save refuses a dynamic roll-up over a child field that is not a stored home amount, in defineStack's words (#33855)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XThUCLpnVeG2WSghJgQjdG7)_
domain:spec#4 · os-project-manager · session_01FEkQ5nU2dZbC2HWMg47r4D
Fixes #33713
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.
## 维护者速读
- 改了什么:运行中的服务器上,单对象保存/发布(元数据 API)现在和 `defineStack` 一样,拒绝"声明
`currencyMode: 'dynamic'`、却汇总的不是子对象本位币金额字段"的汇总字段,返回 422
`INVALID_METADATA`,提示原文与 `defineStack`
完全一致(同一份拼写)。扩展(`object_extension`)加进来的汇总或子字段,按服务器实际提供的对象来判;子对象上的
`homeAmount` 只有在其声明本身合法时才算数,扩展无法把普通数字字段"冒充"成本位币字段。
- 为什么改:#33710 放开了"本位币汇总声明 dynamic",但只在 `defineStack` 判子字段;单对象保存那道门只判
`record` 汇总,于是汇总固定 EUR 金额、普通数字或公式的 dynamic 汇总能被存下,页面用本位币符号显示其合计,币种是错的。
- 风险与回滚:收窄的只是 #33710 刚放开、尚未进任何稳定版(最新稳定版 18.4.0 不含)的形状;合法的本位币汇总照常保存。回滚即
revert 本 PR。
- 先看:`packages/objectql/src/record-currency-aggregate-door.ts` 中
`followRefusalsOf` 新增的两段
(d);`packages/spec/src/data/record-currency-path.ts` 末尾的
`storedHomeAmountSourceOf`(N7 的判据)。
- 两分钟验证:`pnpm --filter @objectstack/objectql exec vitest run
src/protocol-batch-object-registration.test.ts`,`[#33713]` 一组 5
项全过(三种错误字段 422、本位币汇总照常保存、扩展加汇总同样 422)。
- 需要你做的:无,席位落地。
## What changes
**S1, the engine door.** `recordCurrencyFollowRefusal`
(`packages/objectql/src/record-currency-aggregate-door.ts`) gains case
(d) beside its `record` case (c). A `summary` with `function` `sum` /
`min` / `max` / `avg` that declares `currencyMode: 'dynamic'`, or a
`currencyConfig` naming no mode, is refused when its child field is not
a stored home amount on the child as this server serves it. It is judged
at both ends, as (c) is: at the parent's save, over a registered child,
and at the child's save, under a registered parent's roll-up (a child
saved so that the roll-up no longer reads a home amount). A child field
the child does not hold is no verdict, as for (c). The refusal is
`RecordCurrencyFollowRefusedError`, the code and status the `record`
refusal already uses: `INVALID_METADATA` / 422. Nothing in the
measurement gave a reason for another code. The pair key is a new kind,
`dynamic`, so a summary moved from a refused `record` declaration to a
refused `dynamic` one is the run's own change (R7).
**One spelling of (d).** The sentence moves from `stack.zod.ts` into
`packages/spec/src/data/record-currency-path.ts`, which already shares
(a) and (c), as `recordCurrencyDynamicRollupNotHomeError`. `defineStack`
and the engine both print it. The file is already exported from
`@objectstack/spec/data`, so the data barrel is untouched. Its two new
exports appear in `api-surface/data.json` and
`export-origins/data.json`.
**N7.** `storedHomeAmountSourceOf` (same file) replaces
`homeAmountSourceOf`, at both doors. A `homeAmount` makes its `field` a
stored home amount only where it is valid as declared, which is the
object door's reading in `refuseDishonestHomeAmount`. It must sit on a
`record`-mode `currency` amount and name another field of the same map.
That field must be a `currency` field in `dynamic` mode (an absent mode
is `dynamic`), `readonly: true`, with no `expression`, and claimed by
that one amount. An authored object already guarantees this, so
`defineStack` answers the same for every stack whose fields are all
authored. A map merged with an extension's fields, or an object as a
server serves it, can no longer launder a plain number, a `fixed`
amount, a writable or computed field, or a doubly claimed column. The
candidate list in the refusal now names only valid home amounts.
**N6.** No registration path was added and `registry.ts` is untouched.
Since #33621 the follow door is asked with the object as served
(`servedFoldWithLayer`). That covers an `extend` layer in its slot, and
a `lookup` that returns the served child with every enabled extension.
It is asked at a single save, in the batch writer and at the end of a
registration run. So the new arm judges a roll-up an extension adds to a
parent, and a child field an extension adds, by that same path.
`defineStack` still skips an end it knows only through an extension,
because it cannot see that object's owner. Its docblock now says the
engine judges such a pair at the end of the run that installs the stack.
**N1.** The `FieldSchema.currencyConfig` `.describe()` now says the
roll-ups it lists are refused "by `defineStack` and by a single-object
save or publish on a running server alike". The reference pages are
regenerated.
**Docs (surface amendment 6893463231).**
`content/docs/data-modeling/currency.mdx` had two sentences from #33710
saying a single-object save "does not judge the child field yet
(#33713)". This fix makes both false, so both now state the 422 at the
metadata API, as the `record` bullet beside them does.
**Liveness.** `field/currencyConfig` gains a dated `NARROWED 2026-11-15
(#33713 …)` line naming the new reader and the shared spelling. The
verdict stays LIVE.
**ADR-0087.** One semantic entry,
`summary-dynamic-currency-rollup-home-amount-judged-as-served`, and the
changeset carries `adr-0087: registered` with it. It is owed for the
measurement below. The gate would also refuse `not-required
(no-migration-prescription)` on any `Metadata-protocol: narrowed`
changeset.
## Tests
- `packages/objectql/src/protocol-batch-object-registration.test.ts`,
new describe `[#33713]` (real kernel, real registry, `saveMetaItem`
published on the `meta-envelope` face):
- A `dynamic` roll-up over a `fixed` EUR amount, a plain number and a
formula is refused 422 `INVALID_METADATA`
(`RecordCurrencyFollowRefusedError`). The message opens with the case
(d) sentence, and nothing is stored or registered.
- CONTROL: the #33659 probe shape, a `dynamic` roll-up of `amount_home`,
saves and is served.
- CONTROL: a `count` roll-up and a roll-up declaring no currency save as
before.
- A `record` roll-up over the fixed amount answers as before, 422 with
(c)'s sentence.
- N6: an `object_extension` item adding the roll-up is refused 422 and
stores nothing.
- `packages/objectql/src/record-currency-guards.test.ts`, new describe
for case (d), at the registry's single-save question:
- The three child fields are refused whichever end registers second.
Each message is EQUAL to `defineStack`'s finding for the same pair, so
the wording is pinned at both doors.
- A `{}` config and `min` / `max` / `avg` are refused the same way.
- A roll-up over the record-mode amount itself stays D6's first
(`RecordCurrencySummaryRefusedError`), pinned and not re-judged.
- CONTROL: the probe shape registers in either order for all four
functions. No-currency and `fixed` roll-ups are not judged.
- A child save that de-homes a registered roll-up's field is refused,
naming the parent's roll-up. A registration run that leaves an old pair
as it found it is not refused (R7), and one that de-homes it is.
- N6: an extension adding the roll-up is refused at a single save. An
extension adding the child field is judged at either end. A post-seal
`registerApp` whose `objectExtensions` add the roll-up is refused at the
end of its run and leaves nothing of the package.
- N7: an extension forging `homeAmount` over a plain number does not
admit the roll-up, and its message equals `defineStack`'s. CONTROL: an
extension with its own valid home field and amount does admit it.
- `packages/spec/src/data/currency-summary-home-rollup.test.ts`, two new
describes:
- N7 at `defineStack`: an `objectExtensions` entry forging `homeAmount`
over a writable amount, a `number` field, a `fixed` amount, a computed
field, or a doubly claimed home field is refused. A valid extension home
amount is admitted. `storedHomeAmountSourceOf` over the parsed probe
child answers `amount` for `amount_home` and nothing for every other
field.
- Wording: `defineStack`'s finding equals
`recordCurrencyDynamicRollupNotHomeError(...)` for four child fields.
- **Ablations** (mutation through `scripts/ablation-replace.mjs`,
restored to the HEAD blob each time, `git diff HEAD` empty):
- Dynamic arm: `declaresDynamicCurrency` forced false in
`record-currency-aggregate-door.ts`. 9 tests red (2 metadata-API, 7
registry). All controls stayed green.
- N7 check: `storedHomeAmountSourceOf` put back to the old
any-`homeAmount` reading. Spec was rebuilt and `ablation-dist-preflight`
found the marker in 2 dist files. 3 spec tests and 2 objectql tests went
red. After the restore, spec was rebuilt and the preflight `--absent`
read clean.
## Acceptance notes
- **The migration measurement.** The latest stable `@objectstack/spec`,
18.4.0 (published 2026-11-13T12:30Z), does not carry #33710: none of its
tarball's files hold the object door's new wording. The `next` snapshot
`0.0.0-next-20261115100430` (dist-tag `next`, published
2026-11-15T10:32Z, `gitHead` bd96ec9) does: 4 dist files hold it. That
is a published version with the widening, so the entry is added. Against
the last stable release, the net change is still a widening (18.4.0
refused every `dynamic` summary).
- **A single save does not apply R7.** A single save judges its layer
against an empty slot (`before: null`), as it already does for (a) and
(c). So once a bad `dynamic` roll-up is stored past this door (stored
before this release and hydrated at boot), re-saving the child unchanged
through `/meta` is refused over it. A registration run compares the pair
and does not refuse it. The test pins the run's half.
- **(d) does not read `rateDate` / `rateField`.** They say nothing about
which currency the home field holds. The object door still judges them
on an authored object.
- **N2 is unchanged.** On the engine, D6's roll-up door answers first
for a roll-up over an amount in each row's own currency. For an amount
that follows the parent through the very `master_detail`, D6 admits the
roll-up and (d) refuses it in `defineStack`'s words, the same order the
stack pass has.
- `packages/objectql/src/registry.ts`'s comment above the single-save
follow question still names only the following amount and the `record`
roll-up. It is outside the surface (`registry.ts` was granted for an N6
call site only, and none was needed). Noted, not edited.
## Verification
All readings on head `c6d372dc` (base `b76df9a6`; `origin/main` is 19
commits ahead, none touching this diff's files).
<details><summary>Package suites, typecheck, dogfood</summary>
- `pnpm --filter @objectstack/spec test`: Test Files 842 passed (842),
Tests 26948 passed, 1 todo.
- `pnpm --filter @objectstack/objectql test`: Test Files 596 passed
(596), Tests 13151 passed.
- `pnpm --filter @objectstack/spec typecheck && pnpm --filter
@objectstack/objectql typecheck`: exit 0.
- Full dogfood battery (owed by the `(narrowing)` arm), `pnpm --filter
@objectstack/dogfood test` under the lock after the closure build:
`VERDICT command-exit 0`, Test Files 467 passed, 3 skipped (470), Tests
3958 passed, 42 skipped (4000).
</details>
<details><summary>Derived gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 121 commands. Each was run with its exit
code captured before any pipe.
- 119 passed on the first pass. `check:dual-build-cjs-loads` and
`check:published-readme-exports` answered exit 3 (PREREQUISITE NOT MET:
six packages outside this diff had no `dist/`). After building them,
both exit 0.
- `--ran`: `121 derived famil(ies) accounted for — 121 run, 0
NOT-MEASURED`.
- `pnpm --filter @objectstack/spec check:generated`: exit 0 after
`gen:api-surface`, `gen:export-origins`, `gen:schema` and `gen:docs`.
- The log is `pm-orders/spec/33713-gates-ran.txt`. CI runs every other
family.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes (CI).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5nU2dZbC2HWMg47r4D)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 5326028 commit 63e47fe
16 files changed
Lines changed: 699 additions & 86 deletions
File tree
- .changeset
- content/docs
- data-modeling
- references
- data
- system
- packages
- objectql/src
- spec
- api-surface
- export-origins
- liveness
- src
- data
- migrations/entries/semantic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
267 | 269 | | |
268 | 270 | | |
269 | 271 | | |
| |||
472 | 474 | | |
473 | 475 | | |
474 | 476 | | |
475 | | - | |
476 | | - | |
477 | | - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
478 | 480 | | |
479 | 481 | | |
480 | 482 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
282 | | - | |
| 282 | + | |
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| |||
656 | 656 | | |
657 | 657 | | |
658 | 658 | | |
659 | | - | |
| 659 | + | |
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
| |||
0 commit comments