Repository navigation
Commit 7c8d689
skills(data): seed rows obey the package's own validation rules in load order; docs: seed load order comes from lookups and dependsOn (#35652)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D4n2wzAmmp4Z6W5jsqtM2qx)_
Part of #34986
Fixes #35327
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:用 AI
搭应用的作者照着数据技能写演示数据时,会被告知演示数据同样受应用自己的校验规则约束、要按加载顺序逐条过关,并且不要把汇总值直接写进父记录;文档里「数组按依赖顺序导出」的旧说法改正。
- 为什么做:属于「问数评测」这条线。订单到回款场景的一次搭建里,72 条回款演示数据有 66
条被应用自己的「回款不得超过未结余额」规则拒收,技能里没有一句话提醒作者。
- 出错会怎样:这只是教学文字、一道评测题和两处文档措辞;写错了作者会照错的方式写演示数据,可直接撤回。
- 要你做什么:无。「搭建时把被拒的演示数据报给作者」那一半检查不在本次改动内,另行安排。
## What changes
- `skills/objectstack-data/references/seeds.md` gains one paragraph,
each clause measured on `main` (see Acceptance notes): seed rows obey
the object's validation rules, all but `state_machine`; a refused row
never lands; `os validate` does not run those rules on seed rows and `os
verify` fails on each dropped row; a rule reading a parent roll-up sees
the total earlier rows left, so children must fit in record order; a
roll-up value written on a seed row is stored as written and must not be
seeded (a cap then refuses the payments that total already counts).
- `skills/objectstack-data/evals/hooks-security-seeds-datasources.json`:
one case, id 32.
- `content/docs/data-modeling/seed-data.mdx`: the multi-object layout no
longer says `index.ts` exports the array "in dependency order", and "One
file per object" no longer says the index "orders" the datasets. Both
now agree with the page's own Load Order section and with the skill
after PR #35312: lookups and `dependsOn` order the load, array position
only breaks ties. No other sentence on the page makes the old claim.
- `.changeset/34986-skills-seed-rows-obey-validation-rules.md`:
`@objectstack/skills` patch.
### Token ratchet: paid in full by deletion, the row does not move
Standing ruling 6513306068, 「A:先削重复,余额按实测提高」: restatement is cut in the
same file first, and the row moves only by a measured remainder. Here
the cuts cover the teaching (3 bytes under), so
`scripts/check-skills-token-ratchet.mjs` is not edited.
| `seeds.md` | bytes | tokens, ceil(bytes / 4) | ceiling | lines |
|:---|---:|---:|---:|---:|
| before (`eca20d2219`) | 7036 | 1759 | 1759 | 178 |
| after the cuts alone | 6589 | 1648 | 1759 | |
| after (`f2d0e25610`) | 7033 | 1759 | 1759 | 182 |
Cuts (-447 bytes), each a restatement inside the file: the `'name'`
default row of the key table (the field table states the default); "Pick
a stable natural key" (the field table's "Stable business key"); "(not
its UUID)" and the "natural key of an Account record" comment (the
sentence above both); "at load time" (the same sentence's "order the
load"); the second half of the id-fallback note (it restated the first
half); the second `defineSeed` import (the quick start imports it); "and
breaks build determinism" (the determinism gate line says it); the
`applyOn` comment (the sentence above the block); "(fixtures, reference
rows, bootstrap data)" (the quick start's two comments); and the "never
lands" clause of the malformed-value paragraph, folded into one
sentence. The teaching is +444 bytes. Whole shipped tree at this head,
by the gate's own price tag: 275304 tokens; the only priced file this PR
touches is `seeds.md` (1759 before and after), and the rest of the
movement is the eval case, which is measured and not priced. Lines:
`seeds.md` 178 to 182; every `SKILL.md` in the catalog together 4853 to
4853; the whole `skills/` tree 22229 to 22249 (16 of the 20 are the eval
case, which the ratchet measures and does not price).
## Evals
Case 32: a `payment` rule that refuses a payment above the invoice's
open balance, reading `record.invoice.amount_paid`, a `sum` roll-up;
seed one fully paid and one part-paid invoice. The expected answer seeds
the invoices without a roll-up value and payments that each fit what the
rows before left, and does not say seeds skip validation rules or weaken
the rule. `must_contain`: `defineSeed`, `invoice: 'INV-1'`.
`must_not_contain`: `amount_paid: 4800`, `amount_paid: 2000`, the two
seeded roll-up literals. They are code spellings with the case's own
numbers; the skill text uses a different number, so an answer that
quotes the skill's warning does not trip them. The grader is a literal
substring match (`packages/qa/scenarios/src/skill-evals/grade.ts`). No
model run was made for this case.
## Verification
Gates below ran on `4408d12775`; after the review delta (head
`f2d0e25610`: the roll-up sentence now says a cap refuses the payments
the seeded total already counts, and eval case 32 says the payments on
the fully paid invoice are refused, not every payment) the token ratchet
and its self-test, `check:skill-eval-tokens`, the skill-evals test (36
of 36), `check:nul-bytes` and the overlap check were run again and exit
0.
- Two-minute check: `node scripts/check-skills-token-ratchet.mjs` prints
`skills/objectstack-data/references/seeds.md is 1759 tokens (ceiling
1759; headroom 0)` and exits 0.
- Read first: the new paragraph in `seeds.md` (the riskiest hunk: it
ships verbatim to customer agents), then the cuts in the same file, then
eval case 32.
<details><summary>Local gates and tests</summary>
- `pnpm --filter @objectstack/scenarios exec vitest run --maxWorkers=2
test/skill-evals/skill-evals.test.ts`: `Test Files 1 passed (1)`, `Tests
36 passed (36)`, `VERDICT command-exit 0`.
- `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--commands`: 73 families. `--ran` with recorded exit codes: `73 derived,
72 run, 1 NOT-MEASURED, 0 UNRUN`. 72 exited 0, among them
`check-skills-token-ratchet` and its self-test, `check:skill-examples`
(`346 prose examples type-check across 3 surface(s)`),
`check:skill-served-sections`, `check:skill-links`,
`check:doc-authoring`, `check:nul-bytes`,
`check-closing-keyword-parity`, `check-empty-changeset`.
- NOT MEASURED: `pnpm check:dual-build-cjs-loads`, exit 3, PREREQUISITE
NOT MET (it needs every package built; this diff builds none). CI owns
it.
- `node scripts/pm/overlap-check.mjs --branch=claude/area-a4A-34986`:
`VERDICT clean exit 0` against `origin/main` and PR #35649, which shares
the eval file.
- No ablation: the diff changes no behaviour a test pins.
</details>
## Acceptance notes
**Which half is left.** This PR is the teaching half of the direction on
the card. The other half, a build or publish-time finding that names the
refusing rule and the count, is not in this PR and no check code was
written; the card stays open for it.
**What the two builds did differently (the reading the direction asked
for).** The build records named in the reading on the sibling card (two
directories under a project-files mount of another project) are not
reachable from this session, so the rule text of each build was not
read. What the card's own rows prove, in
`docs/qa/scenarios/order_to_cash.json` on `main`: the 95 seeded invoices
carry their end state (`amount_paid`, `balance`), and exactly 66 of the
72 payments are larger than their invoice's seeded `balance` (all 66
belong to a `paid` invoice whose seeded balance is 0); the other 6
belong to part-paid invoices and fit. So the refusing build judged each
payment against a balance that already counted it. A later rebuild pair
recorded on the sibling card split the same way (one build 619 of 619,
the other 66 refused), so the split is not tied to the skills version. A
roll-up that merely lags its inserts does not produce this number:
measured below, the rule does see earlier rows.
**Measured on `main`** (scratch probe, real engine, sqlite, the real
seed loader; not committed):
- (a) No exemption beyond `state_machine`. The loader writes every row
under `SEED_WRITE_EXECUTION_CONTEXT`
(`packages/metadata-protocol/src/seed-loader.ts`, `SEED_OPTIONS`); the
engine skips only `state_machine` for it (`shouldSkipStateMachine`,
`packages/objectql/src/engine-top-level.ts`; the insert path hands it to
`evaluateValidationRules` in `engine-insert.ts`). Probe: a `script` rule
refused a seeded payment with `Failed to write xt_payment record #0
(name=P1): A payment may not exceed the invoice's open balance.`
- (b) The rule runs before the row is written and the roll-up recompute
runs after it (`recomputeSummaries`, same file), and inside one batch
the rows already admitted are overlaid on the value the rule reads
(`summary-batch-accumulation.ts`, pinned by
`packages/rest/src/import-batch-parent-summary-rule.test.ts`). Probe:
payments of 2000, 2000, 1000 against an invoice of 3000 land the first
and third and refuse the second; with the payments dataset listed first
the lookup still loads the invoice first.
- A seed write is a system write, so a roll-up value on a seeded parent
is stored as written; the same value sent by a user write is reset to 0.
Probe: an invoice seeded with `amount: 3000, amount_paid: 3000` keeps
3000 and its only payment is refused, leaving a paid total with no
payment under it. This is the shape of the 66.
- (c) Reporting today. `os validate` and `os build` judge seed values by
field shape and against declared state-machine states only; neither
evaluates a validation rule against a seed row, so they pass. At boot
the loader returns the refusal in `result.errors` and `AppPlugin` logs a
`[Seeder]` warning with the dropped count and the first 20 messages (the
rule's message, not its name). `os verify` counts every dropped seed
record as a failure and exits 1, printing the count and pointing at the
log; it names no rule. Nothing at build or publish time reports it.
**Noted, not filed.** The scenario card's seed rows carry end-state
roll-up values for the invoices, which is what a build that declares
those columns as roll-ups is then judged against. Carrier: the seat that
owns the scenario cards.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#4 · os-elon-musk ·
session_016WV4d1ZJL93Kin2UHFXbFv -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent d44b5e3 commit 7c8d689
4 files changed
Lines changed: 47 additions & 18 deletions
File tree
- .changeset
- content/docs/data-modeling
- skills/objectstack-data
- evals
- references
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
841 | 841 | | |
842 | 842 | | |
843 | 843 | | |
844 | | - | |
| 844 | + | |
845 | 845 | | |
846 | 846 | | |
847 | 847 | | |
| |||
920 | 920 | | |
921 | 921 | | |
922 | 922 | | |
923 | | - | |
| 923 | + | |
| 924 | + | |
924 | 925 | | |
925 | 926 | | |
926 | 927 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
313 | 329 | | |
314 | 330 | | |
315 | 331 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | | - | |
108 | | - | |
| 106 | + | |
| 107 | + | |
109 | 108 | | |
110 | 109 | | |
111 | 110 | | |
112 | 111 | | |
113 | | - | |
114 | | - | |
115 | | - | |
| 112 | + | |
| 113 | + | |
116 | 114 | | |
117 | 115 | | |
118 | 116 | | |
119 | 117 | | |
120 | 118 | | |
121 | 119 | | |
122 | 120 | | |
123 | | - | |
| 121 | + | |
124 | 122 | | |
125 | 123 | | |
126 | 124 | | |
| |||
130 | 128 | | |
131 | 129 | | |
132 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
133 | 138 | | |
134 | 139 | | |
135 | 140 | | |
136 | 141 | | |
137 | 142 | | |
138 | | - | |
| 143 | + | |
139 | 144 | | |
140 | 145 | | |
141 | | - | |
142 | 146 | | |
143 | 147 | | |
144 | 148 | | |
| |||
165 | 169 | | |
166 | 170 | | |
167 | 171 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
172 | 176 | | |
173 | 177 | | |
174 | 178 | | |
| |||
0 commit comments