Skip to content

Commit 9e0bc61

Browse files
docs(skills): field-types teaches the dynamic roll-up over a stored home amount (#34076)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9JJcYUaBywmN3uCa97Wdw7C)_ Fixes #33714 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:数据技能 `field-types.md` 的「货币」一节补上一段加一个示例:对子对象本位币存储字段(某个 `homeAmount.field` 指向的字段)做 `sum`/`min`/`max`/`avg` 汇总时,汇总字段声明 `currencyConfig: { currencyMode: 'dynamic' }`、不写 `defaultCurrency`,界面就按组织本位币显示;并说明其他 `dynamic` 汇总会被 `defineStack` 拒收、`count` 不能带货币。另加一条评测用例。 - 为什么改:#33710 已让平台接受这种写法,但技能没教;AI 照技能写只会留成裸数字,或者写成 `fixed` 加本位币代码,而 ADR-0144 规定元数据不得写出本位币。 - 风险与回滚:纯技能文档加评测,不动 schema 和运行时;为了腾预算删了两处同文件重复(`currency` 行的键列表改成指向「货币」一节;自动编号的重复示例),被删的内容在同文件别处仍在。token 棘轮行 3208 → 3349,按实测钉死。回滚 = revert 本 PR。 - 先看:`skills/objectstack-data/rules/field-types.md` 的「A roll-up of the home field」段与示例;`scripts/check-skills-token-ratchet.mjs` 该文件那一行及注释;评测文件末尾的第 20 条。 - 两分钟验证:`node scripts/check-skills-token-ratchet.mjs | grep field-types` 应显示 `3349 / 3349`,且命令退出 0。 - 需要你做的:本 PR 碰 `skills/**`,按受治理流程保持 draft,等 GOVERNED_APPROVERS 批准后由席位落地。 ## What changes - **`skills/objectstack-data/rules/field-types.md` § Currency**, right after the `homeAmount` paragraph: one paragraph, "A roll-up of the home field", and a three-line `Field.summary` snippet (`project.actual_cost` = `sum` of `expense.amount_home`, `currencyConfig: { currencyMode: 'dynamic' }`). It teaches: - a `sum` / `min` / `max` / `avg` `summary` over a child's `homeAmount.field` declares `currencyMode: 'dynamic'` with no `defaultCurrency`, and shows in `localization.currency`; undeclared, a bare number; - ADR-0144: metadata never names the home currency, so never `'fixed'` with it; - `defineStack` (`os validate`, the build) refuses `'dynamic'` on any other roll-up, and any `currencyConfig` on a `count`. - **Sources, on main `fb79d47c`:** - `packages/spec/src/stack.zod.ts` `collectRecordCurrencyPathErrors` case (d): "A `summary` (`sum`, `min`, `max`, `avg`) declaring `currencyMode: 'dynamic'` … is admitted only when the child field it rolls up is a stored home amount: a field that some `currencyConfig.homeAmount.field` on the child object names … Any other `dynamic` roll-up is refused". - `packages/spec/src/data/object.zod.ts` `refuseUnadmittedSummaryCurrency` (wired into the object schema, so `defineStack` runs it): "A count is a number of rows, never an amount, so it has no currency: delete `currencyConfig`." The same function admits `dynamic` only "(no `defaultCurrency`)". - `content/docs/data-modeling/currency.mdx` § Totals in the home currency: "declare `currencyMode: 'dynamic'` on it, with no code … the metadata never names which currency that is"; ADR-0144 D8 rule 5: "Metadata never names the home currency". - **Paid down first** under the standing ruling 「A:先削重复,余额按实测提高」 (records 6513306068, 6784270263), two same-file restatement cuts, 115 bytes: - the `currency` table row's `currencyConfig` key list `(currencyMode, defaultCurrency, currencyField, homeAmount)` becomes `(→ Currency)` (-45 B as first cut; the round-1 arrow form is 2 B shorter again). Surviving home: § Currency, whose snippet and prose spell all four keys. - the § Autonumber `{ type: 'autonumber', format: 'CASE-{0000}' }` snippet (-70 B). Surviving home: the `autonumber` row (`format` … e.g. `"CASE-{0000}"`, line 132) and the token table's `CASE-{0000}` row. - Considered and kept: the Lookup snippet (the data skill's only home of the `lookupFilters` shape) and the Formula snippet (only home of the `F` template import). - **Token ratchet row** `skills/objectstack-data/rules/field-types.md` 3208 → 3349, pinned at the measurement (`wc -c` 13395 → ceil(13395 / 4) = 3349, zero headroom), with a dated comment naming both cuts and their homes. - **Eval:** case 20 appended at the tail of `skills/objectstack-data/evals/objects-fields-relationships.json` (no existing case touched; #33432 holds the `writeRequiresMasterRead` case of this file). The prompt tempts "just set the total's currency to USD"; `must_contain` `summary`, `amount_home`, `currencyMode: 'dynamic'`; `must_not_contain` `defaultCurrency: 'USD'` (the code a wrong answer writes; a correct restatement such as "no `defaultCurrency`" or "never `currencyMode: 'fixed'`" does not trip it). The expected output satisfies its own assertions (checked by script). - **Changeset:** `.changeset/33714-home-currency-rollup-skill.md`, `@objectstack/skills` patch. ### Size readings (published `skills/**`) | Reading | Before (`fb79d47c`) | After | |:--|--:|--:| | `field-types.md` lines / bytes | 246 / 12821 | 252 / 13395 | | `field-types.md` tokens / ceiling | 3206 / 3208 | 3349 / 3349 | | `objectstack-data` package, all files, lines / bytes | 4311 / 211790 | 4334 / 213777 | | all `skills/**/SKILL.md`, lines / bytes | 4596 / 237075 | 4596 / 237075 (unchanged) | | ratcheted (authored) tokens / ceilings, at `78cfc281` | 187806 / 194122 | 187950 / 194264 | | eval fixtures tokens | 46787 | 47140 | | bundle total tokens | 246388 | 246885 | ## Tests No code changed, so there is no unit test and no ablation. Forced test edits: none. Gates at head `78cfc281` (base `fb79d47c`), run in this worktree after the last commit: - Build closure first: `turbo run build --concurrency=2 --filter='./packages/**'` under `os-verify-lock.sh`: `VERDICT command-exit 0` (7m22s). - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`: 63 derived commands, every one exit 0. `--ran` reconciles: "63 derived famil(ies) accounted for — 63 run, 0 NOT-MEASURED (a DERIVED zero …)". - Also run: `pnpm --filter @objectstack/spec check:skill-examples` exit 0, `check:skill-docs` exit 0, `check:skill-refs` exit 0; the author ran `check-skills-token-ratchet.mjs --self-test` exit 0 (104 cases), `pnpm check:skill-links` exit 0, `pnpm check:skill-identifier-liveness` exit 0, and a control-character grep on the four files (no hits). - `test:repo`, the type-check lanes and the CI-only families are CI's; read their check-runs on this PR. <details><summary>The 63 derived commands and their exits</summary> ```text node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0 node scripts/check-adr-0087-registration.mjs --self-test :: exit 0 node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-declaration-mirrors.mjs :: exit 0 node scripts/check-declaration-mirrors.mjs --self-test :: exit 0 node scripts/check-doc-route-spelling.mjs --advisory :: exit 0 node scripts/check-doc-route-spelling.mjs --self-test :: exit 0 node scripts/check-dts-emitted.mjs --self-test :: exit 0 node scripts/check-empty-changeset.mjs --base origin/main :: exit 0 node scripts/check-empty-changeset.mjs --self-test :: exit 0 node scripts/check-self-test-wired.mjs :: exit 0 node scripts/check-self-test-wired.mjs --self-test :: exit 0 node scripts/check-self-test-workflow-commands.mjs :: exit 0 node scripts/check-self-test-workflow-commands.mjs --self-test :: exit 0 node scripts/check-skills-token-ratchet.mjs :: exit 0 node scripts/check-skills-token-ratchet.mjs --self-test :: exit 0 node scripts/check-whole-set-label-write.mjs :: exit 0 node scripts/check-whole-set-label-write.mjs --self-test :: exit 0 node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0 node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0 node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0 node scripts/ci/snapshot-next.mjs --self-test :: exit 0 node scripts/pm/bare-root-worklist.mjs --self-test :: exit 0 node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0 node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0 node scripts/release-pending-publish.mjs --self-test :: exit 0 pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0 pnpm check:agent-test-spelling :: exit 0 pnpm check:bash32-floor :: exit 0 pnpm check:changeset-gate-self-tests :: exit 0 pnpm check:ci-filter-parity :: exit 0 pnpm check:cli-command-ids :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:corpus-claim-drift :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:doc-authoring :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:dts-closure :: exit 0 pnpm check:dual-build-cjs-loads :: exit 0 pnpm check:entry-guard :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:lean-entry-closure :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:parse-guard :: exit 0 pnpm check:pm-dispatch-gates :: exit 0 pnpm check:pm-governed-merges :: exit 0 pnpm check:pm-skill-id-lint :: exit 0 pnpm check:pnpm-filter-targets :: exit 0 pnpm check:pnpm-flag-spellings :: exit 0 pnpm check:published-files :: exit 0 pnpm check:ratchet-remedy-authority :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:role-word :: exit 0 pnpm check:scripts-symbol-anchors :: exit 0 pnpm check:skill-compatibility :: exit 0 pnpm check:skill-frame-sync :: exit 0 pnpm check:skill-identifier-liveness :: exit 0 pnpm check:skill-links :: exit 0 pnpm check:sourcemap-no-sources-content :: exit 0 pnpm check:watch-hint-literal :: exit 0 ``` </details> ## Acceptance notes - **Authoring route.** `dispatch-gates --tier` mandates the contract-review tier for `skills/**` (clause ①). This card thread is served below that tier, so the `skills/**` text, the eval case, the changeset and the ratchet row were authored and committed by an isolated `os-dev` subagent pinned to that tier, on this same branch and worktree, as the claim records. The thread verified the facts against main, ran the gates, pushed and opened this PR. - Left out for budget: the running-server half of the refusal (a metadata-API save or publish answers `INVALID_METADATA` / 422 with the same message). `currency.mdx` § Roll-ups and datasets carries it. - The `count` refusal is the object door (`refuseUnadmittedSummaryCurrency`), which `defineStack` runs as part of the object parse; the skill names `defineStack` for both refusals in one sentence. - `skills/objectstack-data/evals/README.md` lists each eval file's topics and does not say "currency" (already true before this PR, since case 18). Left untouched: outside the claimed file surface. - **Review round 1** (at-tier review record 6898808993 at `78cfc281`, PASS with one should-fix), head `7c9814a6`, authored at the contract-review tier like the first commit, after merging `origin/main` (`a640ecf3`, clean): - F1: eval case 20 `must_not_contain` is now `defaultCurrency: 'USD'` alone; the bare `defaultCurrency` and `currencyMode: 'fixed'` entries failed a correct answer that restates the rule. Checked: the restatement "No defaultCurrency here, and never `currencyMode: 'fixed'` with it." passes; `currencyConfig: { currencyMode: 'fixed', defaultCurrency: 'USD' }` is caught. - N1: "without it, as a bare number" → "undeclared, a bare number". - N2: the `currency` row pointer is `(→ Currency)`, the file's arrow form. - N3 (optional `relationshipField` in the snippet): skipped, about +30 B with nothing to pay for it. - Ratchet row re-pinned 3350 → 3349 at the measurement (13395 B); comment numbers updated. - Re-run at `7c9814a6`: `check-skills-token-ratchet.mjs` 0, `--self-test` 0, spec `check:skill-docs` 0, `check:skill-refs` 0, `check:skill-examples` 0 (after a spec rebuild under the lock; the first run answered 3, stale `dist` after the merge), `check:skill-links` 0, `check-nul-bytes` 0, case-20 self-consistency script 0. The 63-command derived set below is the run at `78cfc281`. - Out-of-scope findings: none. ## Verification ```bash node scripts/check-skills-token-ratchet.mjs | grep field-types # 3349 / 3349, exit 0 pnpm --filter @objectstack/spec check:skill-docs pnpm --filter @objectstack/spec check:skill-examples ``` --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmPwzDmc8SYayZfateR)_ <!-- signed: domain:skills#2 · os-steve · session_01ADHkmPwzDmc8SYayZfateR --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9ff49b9 commit 9e0bc61

4 files changed

Lines changed: 53 additions & 9 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): the data skill teaches the `dynamic` roll-up over a stored home amount
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`skills/objectstack-data/rules/field-types.md` § Currency now says how a roll-up of a home-currency amount is drawn as money: a `sum` / `min` / `max` / `avg` `summary` over a child field that a `homeAmount.field` names declares `currencyConfig: { currencyMode: 'dynamic' }` with no `defaultCurrency`, and is then shown in the organization's home currency (`localization.currency`) instead of as a bare number. Metadata never names the home currency (ADR-0144), so the roll-up is never `fixed` with that code; `defineStack` (`os validate`, the build) refuses `dynamic` on any other roll-up, and a `count` carries no `currencyConfig`. One worked example and a matching eval case. To pay for it, two same-file restatements are cut: the `currency` row's list of `currencyConfig` keys (§ Currency spells each) and the Autonumber snippet (the `autonumber` row and the token table carry the same `CASE-{0000}` format). No schema or runtime change.

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,19 @@ export const CEILINGS = new Map([
889889
// parenthetical is cut to a pointer (-168 bytes; home: rules/relationships.md § Delete
890890
// Behaviors, every fact). `wc -c` = 12831 bytes -> ceil(12831 / 4) = 3208 tokens: RE-LOCK
891891
// down at the landed count, zero headroom.
892-
['skills/objectstack-data/rules/field-types.md', 3208],
892+
// 3208 -> 3349 (#33714, 2026-11-15): § Currency teaches the roll-up of a stored home
893+
// amount: a `sum` / `min` / `max` / `avg` `summary` over a child's `homeAmount.field`
894+
// declares `currencyMode: 'dynamic'` with no `defaultCurrency` and shows in
895+
// `localization.currency`; `dynamic` on any other roll-up and a `currencyConfig` on a
896+
// `count` are refused; one `project` / `expense` example. +689 bytes. PAID DOWN FIRST by
897+
// two same-file restatement cuts, 115 bytes (45 + 70): the `currency` row's list of
898+
// `currencyConfig` keys, cut to a pointer (home: § Currency, which spells all four), and
899+
// the Autonumber snippet (home: the `autonumber` row's `format` example and the token
900+
// table, both `CASE-{0000}`). `wc -c` = 13395 bytes -> ceil(13395 / 4) = 3349 tokens,
901+
// zero headroom, ceiling +141, pinned AT the measurement. Standing ruling (2026-10-27,
902+
// tap A, verbatim and untranslated): 「A:先削重复,余额按实测提高」; recognised path per
903+
// ruling record 6513306068; seat widening record 6784270263.
904+
['skills/objectstack-data/rules/field-types.md', 3349],
893905
['skills/objectstack-data/rules/indexing.md', 3241],
894906
// 1590 -> 1909 (#32364, 2026-11-11): § Sealing (`seal`) teaches `lifecycle.seal`
895907
// (+1574 B). PAID DOWN FIRST by three same-file restatements (-296 B): the ❌

‎skills/objectstack-data/evals/objects-fields-relationships.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,22 @@
343343
"label: '负责人'"
344344
]
345345
}
346+
},
347+
{
348+
"id": 20,
349+
"prompt": "Our `expense` rows are entered in many currencies: `amount` is a per-record currency field and the engine already stores its home-currency value in `amount_home`. On `project` I want an `actual_cost` total of all its expenses, shown as money, not as a plain number. We report in dollars, so can I just set the total's currency to USD?",
350+
"expected_output": "Roll up the stored home amount, not `amount`: on `project`, `actual_cost` is a `summary` with `function: 'sum'` over `expense`'s `amount_home`, and it declares `currencyConfig: { currencyMode: 'dynamic' }` with no currency code. Every `amount_home` row is already in the organization's home currency, so the total is drawn in `localization.currency` on the record page and in lists; without that declaration it is a bare number. Do not write USD on it: metadata never names the home currency (ADR-0144), so the total follows the organization setting. `dynamic` is admitted only on a roll-up of a home amount (`defineStack` / `os validate` refuses it over any other child field), and a `count` roll-up carries no currency at all.",
351+
"files": [],
352+
"assertions": {
353+
"must_contain": [
354+
"summary",
355+
"amount_home",
356+
"currencyMode: 'dynamic'"
357+
],
358+
"must_not_contain": [
359+
"defaultCurrency: 'USD'"
360+
]
361+
}
346362
}
347363
]
348364
}

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const fields = {
4949
| Type | When to Use | Config |
5050
|:-----|:------------|:-------|
5151
| `number` | Generic numeric value | `min`, `max`, `precision`, `scale` |
52-
| `currency` | Monetary amounts | `currencyConfig` (currencyMode, defaultCurrency, currencyField, homeAmount) |
52+
| `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

5555
## Date & Time
@@ -176,6 +176,19 @@ home-currency amount in `field` (a `'dynamic'` `currency`) at the `rateDate`
176176
(`date`/`datetime`) rate, and that rate in `rateField` (`number`), both
177177
`readonly: true`. Cross-currency totals sum `field`.
178178

179+
**A roll-up of the home field.** A `sum` / `min` / `max` / `avg` `summary` over a
180+
child's `homeAmount.field` declares `currencyMode: 'dynamic'`, no `defaultCurrency`
181+
(ADR-0144: metadata never names the home currency, so never `'fixed'` with it).
182+
It shows in `localization.currency`; undeclared, a bare number. `defineStack`
183+
(`os validate`, the build) refuses `'dynamic'` on any other roll-up, and any
184+
`currencyConfig` on a `count`.
185+
186+
```typescript
187+
// on project; expense.amount_home is the expense amount's homeAmount.field
188+
actual_cost: Field.summary({ summaryOperations: { object: 'expense', field: 'amount_home', function: 'sum' },
189+
currencyConfig: { currencyMode: 'dynamic' } }),
190+
```
191+
179192
**A line in its parent's currency.** On a `master_detail` child, `currencyField`
180193
may be `'<master_detail field>.<parent code field>'`: one hop (a `lookup` path
181194
is refused) to the parent's `iso_4217_currency` field. The line stores no code:
@@ -221,13 +234,6 @@ const total = {
221234

222235
### Autonumber
223236

224-
```typescript
225-
{
226-
type: 'autonumber',
227-
format: 'CASE-{0000}',
228-
}
229-
```
230-
231237
The `format` is literal text interleaved with `{...}` tokens:
232238

233239
| Token | Renders | Example |

0 commit comments

Comments
 (0)