Repository navigation
Commit f796089
fix(spec,metadata-protocol)!: retire the seed modes insert and replace, which inserted every record again on each replay (#34791)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBFyg5B2muWbKZjA9phXVWse)_
Fixes #34613
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #34798
## 维护者速读
- 改了什么:seed 的 `mode` 去掉 `insert` 和 `replace`,只剩 `update` / `upsert` /
`ignore`(默认 `ignore` 不变)。写这两个值的数据集在 `defineSeed` / `defineStack` / `os
validate` /
保存与发布门被拒,报错直接写出改法;已经存下来的旧数据集在启动、组织重放、热重载、安装时单独拒收,其余数据集照常加载。场景跑分器的种子改用默认
`ignore`;它把被某一轮删掉的种子行放回去时改走该数据包的 sample-data
reseed(安装门会按落地记录扣下被删的种子行),放不回的行点名报出,不再记成已放回。
- 为什么改:按裁定 6942780880(选 B)。seed
每次启动、安装、发布都会重放,这两种模式不匹配已有行,所以每次重放都再插一遍:实测三次启动 1→2→3 行,人员引用只在最新那行补上。
- 风险与回滚:收窄,不是 Tier H:check-governed-merges 判定不在受治理面(0/86 路径,+1473 / −532
共 2005 行);裁决 6942780880 第 4 步是 seat-2
的执行文字,不是维护者原话,维护者对本卡的原话是「接受未知,评审完就合」(6949639011)。源头侧存量为零(本仓、hotcrm、cloud
main 9cce314 都没有;托管 AI 构建器只写 `upsert`,读数见 #34479 评论
6943182271);托管环境里已存的包体读不到,是未知面,见 Acceptance notes。回滚即还原本 PR。
- 先看:`packages/spec/src/data/seed.zod.ts` 的
`SeedMode`(`enumWithRetiredValues`
带处方);`packages/metadata-protocol/src/seed-loader.ts` 新增的 `loadStored` 和
`loadDataset`
开头的模式拒收;`packages/metadata/src/artifact-retired-seed-modes.ts`(已编译制品里的旧数据集先摘出再严格解析、解析后放回,整机照常启动)。
- 两分钟验证:`pnpm --filter @objectstack/metadata-protocol exec vitest run
src/seed-loader-retired-mode-34613.test.ts`,预期 8 例全绿;制品启动:`pnpm --filter
@objectstack/runtime exec vitest run
src/standalone-stack-artifact-retired-seed-mode-34613.test.ts`,预期 3 例全绿。
- 需要你做的:无。维护者已接受托管存量未知(6949639011「接受未知,评审完就合」);区域在 L1、席位契约评审和终 head 的
dogfood 电池通过后落地。
## What changes
Per the maintainer's ruling on this card (comment 6942780880, option
**B**): retire the seed modes `insert` and `replace`.
- **`SeedMode` (`@objectstack/spec/data`)** narrows from `insert |
update | upsert | replace | ignore` to `update | upsert | ignore`,
default `ignore` unchanged. The two values are kept as retired enum
values (`enumWithRetiredValues`, ADR-0049), so `mode: 'insert'` / `mode:
'replace'` fail parse with a prescription that names the fix: keep the
default `mode: 'ignore'` (or `'upsert'`) and set `externalId` to the
field that names a row, to a list of fields when no single field does,
or to `'id'` when the records carry their own ids. `defineSeed`,
`defineStack`, `os validate` / `os build` and the metadata save and
publish doors all refuse through that one parse.
- **Stored datasets are refused alone, loudly.** A package built before
this change, or a seed already stored, can still carry a retired mode.
`SeedLoaderService.loadStored` (`@objectstack/metadata-protocol`) is the
funnel the replaying loads now go through: the single-tenant boot seed,
the per-organization replay, the dev hot reload
(`packages/runtime/src/app-plugin.ts`) and the marketplace local install
(`packages/cloud-connection/src/marketplace-install-local-plugin.ts`). A
retired-mode dataset writes nothing; the load result carries one error
for it with the schema's prescription and `success: false`; every other
dataset loads. A dataset that is malformed for any other reason still
fails the whole parse, as before. The publish doors keep their
whole-request refusal (422), unchanged.
- **Compiled artifacts still boot.** The artifact door
(`MetadataPlugin._parseAndRegisterArtifact`, `@objectstack/metadata`)
strict-parses the whole definition, so a stale `objectstack.json`
carrying one retired-mode dataset would otherwise abort the boot. The
door now takes such a dataset out of every seed collection the artifact
can hold (top-level `data`, `manifest.data`, each assembled package
body's `data` and `manifest.data`) before the parse, hands it back to
the same collection afterwards, and logs one warning naming it and the
fix; the seed load then refuses it alone. Seeds are never registered as
metadata items, so nothing else reads the handed-back dataset. A
never-valid mode is still the door's parse refusal. (L2 review M1.)
- **The loader refuses the mode itself.** `loadDataset` refuses a mode
outside the live `SeedMode` set before any write, so `load()` and
`validate()` handed an unparsed request answer what a real load does:
nothing written, every record errored, the prescription as the error,
logged at `error`. The `insert` / `replace` arms are removed from
`writeRecord` and `decideWriteAction`. A request with no mode at all
keeps its old path. (L2 review S1.)
- **`RETIRED_SEED_MODE_VALUES`** (`@objectstack/spec/data`, new export):
the retired values, membership only, read by the artifact door and the
loader so neither restates the list.
- **Hints repointed.** The save door's and the loader's hint for a key
no record carries used to say "or use mode 'insert' for rows with no
natural key", steering into the one mode that duplicates. It now names a
list of fields or `'id'`.
- **Scenario runner restore (contract review 6969536704, M3).** The
runner's seed datasets carry no `mode` (default `ignore`). The install
door keeps the organization's record of landed seed rows
(`sys_seed_landed_key`, no package in the key) and installs under
`honour`, which withholds a recorded row that is gone (`skipped`, no
error), so a restore sent as a second data-only package put nothing
back, booked the row as reinserted, and after three rounds left the
later operations of template mode's iterate-run half `notMeasured`.
`loadSeedRows` (`packages/qa/scenarios/src/runner/orchestrate.ts`) now
reads the door's `skipped`: the restore goes on through that package's
sample-data reseed (`POST
/api/v1/marketplace/install-local/:manifestId/reseed-sample-data`, the
deliberate re-seed; `AppHarness.reseedManaged`, optional), and whenever
the door skipped a row the objects are read back and each row still not
there is refused by name with the reason, never counted as written or
reinserted. A dataset refused whole (`field: 'mode'`) refuses each of
its rows (N23). The install door's behaviour is unchanged (`honour`
stays). The test double's door keeps the landed-row record and answers a
retired mode with one dataset entry, as the real door does (N22).
- **Lint.** The advisory rule `seed-insert-mode-duplicates-on-replay`
(`validateSeedReplaySafety`) is removed; the schema refusal does its job
for both modes. Author-time rule count 71 → 70 at the merged head (main
is at 71 after #34822 and a later rule; this PR retires one; the four
docs transcripts follow).
- **`os diff`** on a dataset declaring either mode says the mode is
retired, that a replay refuses the dataset, and what to declare.
- **Conversion route (same PR, per the seat's 08:47Z order).**
`content/docs/data-modeling/seed-data.mdx` › *Moving off `insert` and
`replace`* gives the three conversions (a field, a composite list,
`'id'`), a before/after, the rebuild/reinstall step. Step 2 says a
reference the first load leaves empty still belongs in a composite key:
since main's #34854 each later load finds that row by the key as
authored, and the load that can resolve the reference fills it in.
ADR-0087 D3 entry `seed-mode-insert-replace-retired` (no D2 conversion:
which field names a row is the author's to declare).
- Changeset `.changeset/34613-seed-mode-insert-replace-retired.md`;
reference docs regenerated.
## Verification
-
`packages/metadata-protocol/src/seed-loader-retired-mode-34613.test.ts`
(new, 8): through `loadStored`, insert / replace each refused alone
while two other datasets land; an all-refused load answers failed with
nothing written; `load()` handed an unparsed retired dataset refuses it
(nothing written, every record errored, one `error` log) while the other
dataset lands; `validate()` answers the same refusal; controls: no
retired dataset → `load()`'s answer unchanged; a never-valid mode
(`merge`) still fails the whole parse.
-
`packages/runtime/src/standalone-stack-artifact-retired-seed-mode-34613.test.ts`
(new, 3): a real `createStandaloneStack` boot over a compiled artifact
carrying an `insert` (and a `replace`) dataset completes, the dataset's
object registers, the keyed dataset lands, the stale one writes nothing;
control: a `merge` mode still fails the door's parse.
- `packages/metadata/src/artifact-retired-seed-modes.test.ts` (new, 3):
every seed collection path, the input not mutated, the hand-back to the
same collection, and the control that a never-valid mode is left to the
parse.
- `packages/spec/src/data/seed.test.ts`: the two values refused with the
prescription at path `['mode']`; the live modes parse.
- `protocol.seed-external-id-refusal` tests: insert / replace now
refused at the save door with the prescription, nothing stored.
-
`packages/cloud-connection/src/marketplace-install-local-landed-keys.test.ts`
(new top-level describe, 2): through the real door and
`SeedLoaderService`, a data-only package keyed on `id` seeds `ct1`,
`ct2`; `ct2` is deleted; a second package carrying `ct2` answers
`inserted: 0, skipped: 1, errors: 0, errorList: []` and the row stays
gone; that package's reseed answers `inserted: 1` and the row is back;
control: an unrecorded row lands from a second package. This confirms M3
at the door.
- `packages/qa/scenarios/test/runner/orchestrate.test.ts`: the double's
control (an install withholds a recorded row that is gone, the reseed
brings it back, a held row is skipped, an unrecorded row lands, an
unknown package's reseed is 404); a restore puts back a withheld row
through exactly one reseed of the restore package; a harness with no
reseed door refuses the row by name (`sys_seed_landed_key`, `no reseed
door`) and books nothing as reinserted. Before the runner fix, with the
honest double, 7 of 150 tests were red, among them the crm card's
`runCard` (template iterate-run operations `notMeasured: 3`) and every
restore pin (`demotravel_expense_claim: 1 missing (c001)`,
`democrm_account: 1 missing (ac1)`); after it 153 of 153 pass. Ablation
at `1f74fbc7` through `scripts/ablation-replace.mjs` (`{ reseedWithheld:
true }` removed from the restore's call, anchor 1 → 0, blob `902855e2` →
`446674cf`): 8 red, restored to the HEAD blob with `git diff HEAD`
empty.
- Real boot, three boots over one SQLite file with `OrganizationsPlugin`
(scratch probe through `@objectstack/verify` `bootStack`, not
committed), a task dataset plus a keyed tag dataset, a person signing up
before boot 3:
| task dataset | boot 1 | boot 2 | boot 3 |
|---|---|---|---|
| `mode: 'insert'` | refused, 0 rows (tag: 1) | refused, 0 (tag: 1) |
refused, 0 (tag: 1) |
| `mode: 'replace'` | refused, 0 (tag: 1) | refused, 0 (tag: 1) |
refused, 0 (tag: 1) |
| converted: `externalId: 'name'` | 1 row | same id | same id, now names
the person |
| `externalId: ['name', 'assignee']` (person not yet signed up) | 1 | 2
| 3 |
Each refusal logs `✗ Seed dataset for 'seedowner_task' was not loaded:
<prescription>`. The last row was measured at `ef48f915`, before main's
#34854 (card #34800) fixed it: such a row is now found again by its
authored key on every later load and filled once the person resolves.
The docs caveat and the "list only fields every load can fill" advice
built on that row were removed at `f596517c` (seat S2, finding
6957342048).
- `defineStack` with `mode: 'insert'` → `✗ data.0.mode: seed.mode:
'insert' was removed …`.
- Suites green: spec, metadata (2635), metadata-protocol (23064), lint
(9112), objectql (`engine-seed-required-deferral`), runtime,
cloud-connection (1308), plugin-security
(`predicate-related-read-tenant-scope`), dogfood
(`grant-table-write-contract`; the full battery on `f596517c` failed
exactly 1 of 4140 tests, the #28952 control in
`seed-external-id-refusal.dogfood.test.ts` that saved an `insert` seed
and expected 200, a forced edit fixed at `4932db39` to expect the 422
mode refusal that never reaches the key judgment, amendment 6959256004;
the full battery on `4932db39` then passed, 479 files and 4072 tests, 3
and 68 skipped, VERDICT 0, recorded on #34613; `ebf3a6ae` merges
origin/main `fb5c42d1` cleanly over it, with the regen chain clean and
the net diff unchanged; after the second merge-queue removal, `da7dd9ec`
hand-merges origin/main `1282a464` and resolves the four `os validate`
transcripts to 70 author-time rules (measured), `b398503c` regenerates
protocol.mdx, api-surface and export-origins over the merge (restoring
main's generated rows from #34719, #34976 and #34799 that the hand merge
had dropped; this PR's own rows were never lost), `b5e8fd0f` corrects
the changeset count line to 71 to 70; the full battery on `b5e8fd0f`
passed, 479 files and 4072 tests, 3 and 68 skipped, VERDICT 0, comment
6967579608; `863908f4` drops the scenario runner's retired `mode:
'insert'` (seat delta-4 M2, amendment 6967843392), and the full battery
on `863908f4` passed, 479 files and 4072 tests, 3 and 68 skipped,
VERDICT 0, os-dev-report 6969229130; `3f014443` merges origin/main
`526282e1` through os-regen-merge.sh with no conflicts, and `d56fedc2`
regenerates protocol.mdx to restore main's view.timesheet rows that the
driver dropped; the net diff is unchanged (84 files, identical changed
lines), and the full battery on `d56fedc2` passed: 479 files and 4072
tests, 3 and 68 skipped, VERDICT 0, os-dev-report 6969269115;
`2215056c`, `1f74fbc7`, `0dd0e0af` and `fdaf6213` answer contract review
6969536704 M3 (the restore's reseed route and its pins) and move the
release wording to 18.7.0, and the full battery on `fdaf6213` passed,
479 files and 4072 tests, 3 and 68 skipped, VERDICT 0; `5af3e083` merges
origin/main `958ee035` (the 18.6.0 version cut) through
os-regen-merge.sh with no conflicts and nothing to regenerate
(`check:generated`: all 14 artifacts up to date), the net diff is 86
files, +1473 / -532, and `git diff origin/main...HEAD | grep -n
'18\.6\.0'` is empty; the full battery on `5af3e083` passed: 479 files
and 4072 tests, 3 and 68 skipped, VERDICT 0), cli (the 220 test files
that name seeds, authoring rules or `os diff`: 3058 passed, 9 skipped).
- Gates: `check:generated` (references regenerated;
`check:test-typecheck` OK), `gen:migration-registry` current,
`check-docs-transcript-drift` (70 at the merged head),
`check:adr-0087-registration`, `check:changeset-fixed`,
`check-changeset-no-major`, `check-empty-changeset`, `tsc --noEmit` for
metadata-protocol / runtime / cloud-connection / lint / cli, eslint on
touched files (0 errors), `check:test-source-alias`,
`check:where-matcher`, `check:engine-double-contract`,
`check:skill-identifier-liveness` (the `seed-modes` binding reads
`SEED_MODE_VALUES`, the array `SeedMode` wraps, since the gate cannot
read an `enumWithRetiredValues` call).
## Acceptance notes
- **FROM, measured on `origin/main` e533651** (premise reading):
`insert` keyed by name 1 → 2 → 3 rows over three boots, only the newest
row naming the person; keyless `insert` and `replace` the same; with a
`unique` field the replay insert was refused and the one row stayed
empty; `ignore` control one row, same id. TO: both values refused; a
converted dataset holds one row.
- **Stock reading and its source.** Source-side stock is zero from
`863908f4` on, which drops the scenario runner's `mode: 'insert'`
(`loadSeedRows`, brought in by main's #34985; seat delta-4 M2, amendment
6967843392): no non-test `mode: 'insert'` / `'replace'` in this repo,
hotcrm, or cloud `main` 9cce314, and the hosted AI builder writes only
`upsert` (cloud seat reading, #34479 comment 6943182271). **Unknown
surface:** stored seed metadata and installed package bodies in hosted
environments could not be read (no production credentials). A stored
dataset there carrying either mode is refused alone at its next replay
with the fix in the message, and the rest of its package loads; a
compiled artifact carrying one still boots (pinned above). The
maintainer accepted the unknown (6949639011, 「接受未知,评审完就合」), so landing
does not wait on a count.
- Rows earlier replays duplicated are data and are left as they are.
- L2 nits not changed here: N1 (the boot banner's Seeds row counts no
rejection when a refused dataset loads beside others; the refusal is
still logged), N2 (the prescriptions and the docs name 18.7.0: the
18.6.0 cut, Version PR #33849, merged at 2026-11-18T05:13Z without this
PR; this PR's `@objectstack/spec` changeset is `minor` over 18.6.0,
`@objectstack/spec` is in the changeset `fixed` group, and no pending
changeset on `main` or here bumps a package of that group `major`, so
the first release carrying the refusal is 18.7.0), N4 (an admitted
dataset whose `dependsOn` names the refused dataset's object is refused
by the dependency check with its own message), N5 (`loadStored` is not
on `ISeedLoaderService`; adding it is a contract change of its own), N6
(the refusal rides the existing error shape with `recordIndex: 0`).
- **Follow-ups filed.** #34798 (blocked by this card):
`skills/objectstack-data/references/seeds.md` and
`skills/objectstack-platform/SKILL.md` still teach the retired modes.
#34800 (a composite `externalId` over a reference the first load leaves
empty) was fixed on main by #34854 while this PR was open; this branch
carries that fix through the main merge. #34963: the local artifact
checksum is computed before withheld datasets are restored (seat N10).
#34975 (p2, area takes it right after this merge): the
platform-checklist items `platform-core.seed-mode-matrix` and
`access-security.agent-ceiling-set-assignment-refusal` still exercise
the retired modes (the daily checklist watchdog is expected to go red on
`main` until it lands), FOLLOW-UPS K6, and three stale comments (seat
N14, N16, N18).
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX)_
<!-- signed: repo:objectstack#1 · os-warren ·
session_01JQwxbaX2qDxUq9sF93EqqL -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 6cc1b3e commit f796089
86 files changed
Lines changed: 1473 additions & 532 deletions
File tree
- .changeset
- content/docs
- data-modeling
- deployment
- getting-started
- references
- api
- data
- kernel
- ui
- packages
- cli
- src/commands
- test
- cloud-connection/src
- lint/src
- metadata-core/src
- metadata-protocol/src
- metadata/src
- objectql/src
- qa
- dogfood/test
- scenarios
- src/runner
- test/runner
- runtime/src
- spec
- api-surface
- export-origins
- src
- data
- migrations/entries/semantic
- verify/src
- scripts
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 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 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | 76 | | |
78 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
129 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
130 | 165 | | |
131 | 166 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 167 | + | |
| 168 | + | |
138 | 169 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
| 170 | + | |
144 | 171 | | |
145 | | - | |
146 | 172 | | |
147 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
148 | 179 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 180 | + | |
| 181 | + | |
155 | 182 | | |
156 | 183 | | |
157 | 184 | | |
| |||
243 | 270 | | |
244 | 271 | | |
245 | 272 | | |
246 | | - | |
247 | | - | |
| 273 | + | |
| 274 | + | |
248 | 275 | | |
249 | 276 | | |
250 | 277 | | |
| |||
597 | 624 | | |
598 | 625 | | |
599 | 626 | | |
600 | | - | |
601 | | - | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
602 | 630 | | |
603 | 631 | | |
604 | 632 | | |
| |||
865 | 893 | | |
866 | 894 | | |
867 | 895 | | |
868 | | - | |
869 | | - | |
| 896 | + | |
| 897 | + | |
870 | 898 | | |
871 | 899 | | |
872 | 900 | | |
| |||
896 | 924 | | |
897 | 925 | | |
898 | 926 | | |
899 | | - | |
| 927 | + | |
900 | 928 | | |
901 | 929 | | |
902 | 930 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
887 | 887 | | |
888 | 888 | | |
889 | 889 | | |
890 | | - | |
| 890 | + | |
891 | 891 | | |
892 | 892 | | |
893 | 893 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
866 | 866 | | |
867 | 867 | | |
868 | 868 | | |
869 | | - | |
| 869 | + | |
870 | 870 | | |
871 | 871 | | |
872 | 872 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
314 | | - | |
| 314 | + | |
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| |||
0 commit comments