Repository navigation
Commit 6ffe37e
docs(spec,cli): seed replace deletes nothing, and the AppPlugin loads skip a landed row a person deleted (#31135)
<!-- claude-projects-attribution: {"github_login":"marchtian"} -->
_Requested by **田騏** · [project
thread](https://claude.ai/code/project/chan_01VmuUhXU9SSUzqJYyXSmYSi?thread=cmsg_01VmuUhXU9SSUzqJYyXSmYSiQSToiq8oWUfF5GruxpTNDG)_
Fixes #31099
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么:** 只改文字。`seed.zod.ts` 里 `replace`
不再写成"先删整表再插入",改为"不删任何东西,只插入,给调用方已清空的缓存表用";`insert`
不再写"重复时失败",改为"每次重放都再插一遍";`mode` 的说明补上已落地行的记录规则和 `{ reseed: true }`
这扇门。`os diff` 对 `replace` 数据集的提示同步改正。
- **为什么改:** 旧文字和加载器实际行为相反:作者或 AI 读到"replace
会清表",会以为重放能刷新数据,实际只会把行再插一遍。上一张卡已经改了技能包和文档,spec 的 `.describe()` 和 CLI
提示还停在旧说法。
- **风险与回滚:** 无行为变化,只动注释、`.describe()`、一条 CLI 提示字符串和它的测试,以及自动生成的 4
个参考页。回滚即 revert。
- **先看:** `packages/spec/src/data/seed.zod.ts`(`SeedMode` 注释、`mode` 的
JSDoc 新段落和 `.describe()`);`packages/cli/src/commands/diff.ts` 第 81 行。
- **两分钟验证:** `pnpm --filter @objectstack/cli exec vitest run --project
unit test/diff-upgrade-plan.test.ts`,预期 7 个测试全过,`replace` 的提示为 "a replay
deletes nothing and inserts these again"。
- **需要你做的:** 无,席位落地。
## What changes
Text only; no behaviour change. Every sentence was worded from the
loader and AppPlugin code on `main` (5f00374), not from the old text.
- `packages/spec/src/data/seed.zod.ts`
- `SeedMode` comments: `insert` no longer says "fail on duplicate" — it
inserts every record with no match, so each replay inserts them again,
and a row the database refuses is that row's error
(`SeedLoaderService.writeRecord` / `decideWriteAction` insert
unconditionally; a refused row is pushed to the load's errors while the
rest land). `replace` no longer says "Delete ALL records in object then
insert": it inserts every record, no match, and deletes nothing (its
`writeRecord` arm is a bare insert; nothing in the loader deletes).
- `mode` docstring: a new paragraph on the landed-keys rule. The loads
AppPlugin runs for an organization (single-tenant boot seed,
per-organization replay through `seed-replayer`, dev hot reload), where
the composition registers `sys_seed_landed_key`, record the key of every
keyed row an `ignore` or `upsert` dataset landed and do not insert again
a recorded row that is now gone; a never-recorded key still lands; a
seed publish and a package install or upgrade keep no record;
`seed-replayer(organizationId, { reseed: true })` inserts every missing
row.
- `mode` `.describe()`: the same facts, compressed; no tracker number.
The `ignore`-is-default text (ruling 6631016988 on #30081) is unchanged.
- The `history` string at L116–117 is left as is (historical, card:
optional).
- `packages/cli/src/commands/diff.ts` `seedModeNote`: `replace` now
reads "a replay deletes nothing and inserts these again, so rows already
in the table stay". `packages/cli/test/diff-upgrade-plan.test.ts` pins
the new string (it pinned the old one).
- `content/docs/references/**`: 4 pages regenerated by `gen:schema &&
gen:docs` from the `.describe()`.
- Changeset: `@objectstack/spec` patch + `@objectstack/cli` patch.
Wording is in step with the already-reviewed
`content/docs/data-modeling/seed-data.mdx` ("A Deleted Seed Row Stays
Deleted") and `skills/objectstack-data/references/seeds.md`.
## Tests
- `pnpm --filter @objectstack/cli exec vitest run --project unit` on
89162ff: Test Files 396 passed, Tests 5576 passed. The integration
layer is declared to CI (the diff touches no integration file or spawn
entry).
- After merging `origin/main` (head 68060aa, closure rebuilt):
`diff-upgrade-plan` and the incoming
`connect-agent-both-halves-wire.pin` (unit layer): 2 files, 9 tests
passed. The incoming `authoring-rule-command-parity` is an
integration-layer file, declared to CI.
- eslint on the three touched source/test files: exit 0.
## Acceptance notes
- Independent Fable review of the whole diff: PASS with should-fix (name
the `sys_seed_landed_key` condition and "keyed row" in the docstring;
sharpen the `insert` comment). Both applied in 89162ff; delta review
PASS. Verdict comment to follow on this PR.
- Left alone, noted: `seedModeNote` says nothing for `insert`, which
also inserts every record again on each replay. Outside this card's item
2 (the `replace` line only).
- `docs/qa/platform-checklist/areas/platform-core.json` quotes the old
`replace` text inside a historical "declared ≠ implemented" clause; out
of the card's file surface, left as is.
## Verification
<details><summary>Derived gates (dispatch-gates --commands) — 108 run on
89162ff, all exit 0</summary>
- `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--ran ran.txt` :: exit 0 — "108 derived famil(ies) accounted for — 108
run, 0 NOT-MEASURED".
- First pass: 12 families exited 3 (PREREQUISITE NOT MET:
`packages/spec/dist` stale after the docstring commit, a shallow clone
for `check-plugin-teardown-shape --self-test`, and unbuilt workspace
dists). After `pnpm --filter @objectstack/spec build` and `git fetch
--unshallow origin main`, all 12 reran with exit 0.
- `pnpm --filter @objectstack/spec run check:generated` :: exit 0 (also
post-merge: "All 14 generated artifacts are up to date").
- `pnpm check:doc-authoring` :: exit 0 (no tracker number in
`.describe()`).
</details>
<details><summary>Merge of origin/main</summary>
Merged once before opening (68060aa). The incoming commits touch no
seed, spec or `diff.ts` file. Re-checked: the CLI closure rebuilt,
`check:generated` exit 0, the CLI test files above, and `dispatch-gates
--ran` still 108/108.
</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 (no names
added).
- [x] 3. No formatter ran; eslint passes on the touched files (`pnpm
lint` repo-wide is CI's).
- [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 (the 维护者速读 block is the
repo's own Chinese reader section).
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_017ihL2dzed5sJnRTmwXHWV7
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent d5fd948 commit 6ffe37e
8 files changed
Lines changed: 37 additions & 10 deletions
File tree
- .changeset
- content/docs/references
- api
- data
- kernel
- packages
- cli
- src/commands
- test
- spec/src/data
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
354 | | - | |
| 354 | + | |
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
180 | 194 | | |
181 | 195 | | |
182 | 196 | | |
| |||
197 | 211 | | |
198 | 212 | | |
199 | 213 | | |
200 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
201 | 219 | | |
202 | 220 | | |
203 | 221 | | |
| |||
0 commit comments