Repository navigation
Commit 9e0bc61
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
- .changeset
- scripts
- skills/objectstack-data
- evals
- rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
889 | 889 | | |
890 | 890 | | |
891 | 891 | | |
892 | | - | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
893 | 905 | | |
894 | 906 | | |
895 | 907 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
346 | 362 | | |
347 | 363 | | |
348 | 364 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
179 | 192 | | |
180 | 193 | | |
181 | 194 | | |
| |||
221 | 234 | | |
222 | 235 | | |
223 | 236 | | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | 237 | | |
232 | 238 | | |
233 | 239 | | |
| |||
0 commit comments