Skip to content

Commit a6c2b83

Browse files
fix(cloud-connection): install-local keeps and honours the landed-key record, so a seed row a tenant deleted stays deleted (#34429)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> Fixes #34405 Clause-②: no (the door starts honouring the loader's existing `landedKeys` guard, #31021; no accepted shape or public export widens; the dev confirms) Metadata-protocol: none Ruling-ref: 6929076086 (#34405, A 「A 重启也不补回」: the install-local restart heal honours the landed-key record) ## 维护者速读 - **改了什么**:install-local 的样例数据灌入(安装、升级、重启自愈、新组织回放、非托管副本首灌)现在会记录并遵守「哪些样例行已落地」的台账 `sys_seed_landed_key`;租户删掉的样例行,重装、升级、重启后不再自己冒回来。「重新灌入样例数据」按钮仍会把缺的行全部补回。 - **为什么改**:租户管理员删掉一条演示客户或演示订单,下次重装或升级又出现,像是删除没生效。平台自身的启动灌入早已遵守这个台账,只有 install-local 这个入口没接上。 - **风险与回滚**:重装或升级后,被删的样例行不再回来,只能用「重新灌入」找回(本卡要的行为)。重启自愈也遵守台账(维护者裁决 A「A 重启也不补回」,记录 6929076086):单租户重启不再补回被人删掉的样例行;样例行被人删光、或被「清除样例数据」清掉后再重装,重启都不补回;只有库里连台账一起丢了(新库)才整套补回。这类「全被台账扣下」的重启,启动横幅、/ready 与 os verify 读作正常(settled),不再报「已安装但 0 行」。#30324 的重启用例只改了两次启动之间的准备步骤(同时清掉台账),归属断言一字未改(裁定 6670861426 只管归属)。回滚即撤销本 PR。 - **先看**:`packages/cloud-connection/src/marketplace-install-local-plugin.ts` 的 `runInlineSeed` 及其四个调用点(各入口选的模式);`marketplace-install-local-landed-keys.test.ts`;`packages/cli/test/package-install-local-sample-owner.integration.test.ts` 两次启动之间新增的清台账步骤。 - **两分钟验证**:`pnpm --filter @objectstack/cloud-connection exec vitest run src/marketplace-install-local-landed-keys.test.ts`,预期 15 个用例全绿(原 13 个在 main 上实测全红;新增的「清除、重装、重启后仍为空」用例在 main 上未测)。 - **需要你做的**:无,席位落地。 ## What changes `MarketplaceInstallLocalPlugin.runInlineSeed` built `SeedLoaderService` without the `landedKeys` option, so install-local neither read nor wrote `sys_seed_landed_key` and the loader's guard (#31021) never applied on this door. `runInlineSeed` now takes the mode as a required parameter and hands it to the loader; every caller names one, none is defaulted. What the loader's two modes do (`SeedLoaderServiceOptions.landedKeys`, `packages/metadata-protocol/src/seed-loader.ts`): - `'honour'`: every keyed row an `upsert` or `ignore` dataset lands (inserted, updated, or matched and left alone) is recorded under the organization the load seeds; a recorded key whose row is now gone is not inserted again (a person removed it), and a reference to such a row is left as it is instead of reported unresolved. A key never recorded still lands, so a row an upgrade adds to the seed is inserted. A withheld row is counted in `skipped`. - `'reseed'`: records the same, and inserts every missing row whatever the record says. - Either mode keeps no record on a load that seeds no organization (said once at `info`) or in a composition that does not register `sys_seed_landed_key` (said once at `warn`). Per door: | Door | Mode | |---|---| | Install and upgrade (`applySideEffects`, the caller's active organization under a wall, else the sole organization) | `honour` | | Restart heal of an empty database | `honour` | | Per-organization replayer this door registers | `honour`; `{ reseed: true }` gives `reseed`, as the AppPlugin replayer does | | Unmanaged copy, first load | `honour` | | Sample-data reseed (ledgered package and unmanaged copy) | `reseed` | No answer shape changes: the install's `seeded` summary and the reseed's `{ manifestId, inserted, updated, skipped, errors, withSampleData }` keep their fields. No replay into other existing organizations on upgrade (decision card #34406, not built). Prose that this change made false is corrected in the same PR: the `mode` JSDoc and `.describe()` in `packages/spec/src/data/seed.zod.ts` (and the four generated reference pages), `content/docs/data-modeling/seed-data.mdx`, and the `sys_seed_landed_key` object's JSDoc in `@objectstack/platform-objects` said a package install or upgrade, its heal, its reseed and the marketplace's fallback `seed-replayer` keep no record. They now say a seed publish is the load that keeps none. This restates the card's route (route B on #34336, ruling-ref 6919107678); no contract shape changes. The seat kept this prose in this PR (17:24Z), and the claim's file surface is amended on #34405 to match the diff. ## Tests New `packages/cloud-connection/src/marketplace-install-local-landed-keys.test.ts`: the real `SeedLoaderService` (`@objectstack/runtime`) over a faithful in-memory engine that registers `sys_seed_landed_key`, each case run on a flat bundle and on a composed one (`packages[]`, the datasets in the package bodies): - install writes `sys_seed_landed_key` for every row it lands, in the organization it seeds; - a seed row deleted after the install stays deleted across a reinstall and an upgrade; the row the upgrade adds lands; - under the organization wall (`isolated`), the install and the upgrade keep it in the caller's active organization, and none in another; - the reseed inserts every missing row, answers `{ inserted: 2, skipped: 2 }`, records each key once, and the record still stands for the next removal; - a restart does not heal back seed rows a person deleted, and still heals a new database whole; - the per-organization replayer honours the record per organization, and `{ reseed: true }` brings a removed row back; - an unmanaged copy: a second install load leaves a deleted row out, the reseed brings it back. <details><summary>Red first, then green</summary> - At `d3f1bcdf6a` (main `857941dbe8` plus the test only): `Tests 13 failed (13)`, each on the missing record or a deleted row back (`expected [] to deeply equal [ 'lk_account:Acme', …(3) ]`, `expected [ 'Acme', 'Globex' ] to deeply equal [ 'Acme' ]`, `expected { inserted: 1, … } to match object { inserted: +0, errors: [] }`). - At `1f3516d7e8` (the fix): `Tests 13 passed (13)`. - `pnpm --filter @objectstack/cloud-connection exec vitest run --maxWorkers=2`: `Test Files 85 passed (85)`, `Tests 1251 passed (1251)`; `pnpm --filter @objectstack/cloud-connection typecheck` (both programs; the new test is in `tsconfig.test.json`'s file list) exit 0. </details> ## Acceptance notes - **The restart heal is wired to `honour`, a door the card does not name (ruled A by the maintainer, 6929076086).** The heal runs only when every seeded object is empty and the ledger does not record a purge, and then withholds every key the database records. Pinned in `marketplace-install-local-landed-keys.test.ts` (flat and composed): a restart over a seed a person emptied (no purge) does not heal it back; a purge followed by a reinstall and a restart stays purged (the reinstall clears `sampleDataPurged`, so the heal's `honour` is what holds it; measured by ablation); a new database (no rows, no record) is healed whole. A heal that withholds every row reports a settled seed (real `skipped`, `info`, no `emptyInstall`), so the boot banner, `objectstack:seed-settled`, `GET /ready` and `os verify` read it as settled (fix round 3). #30324's restart case now reaches its heal through that last state: between its boots it also clears `sys_seed_landed_key`, and its ownership assertions are unchanged (ruling 6670861426 decides who owns the healed rows, not whether a restart refills rows a person deleted). - **A purge followed by a reinstall or upgrade no longer brings the sample rows back**; the sample-data reseed does. That is the card's rule applied to a purge (the purge deletes the rows through the engine, so their keys stay recorded). The listing's `withSampleData` reads the rows, not the ledger, so it answers `false` there. - An existing install records nothing until its next install, upgrade, reseed, replay or restart heal, so a row a person deletes before that load, even after the upgrade, comes back on it once, and stays deleted from then on (the record starts empty). - The loader's `info` line for withheld rows now names an installed package's sample-data reseed beside `seed-replayer` with `{ reseed: true }` as the way back (fix round 3, `@objectstack/metadata-protocol` patch). - Boundary: a heal over datasets that are all `mode: 'update'` on an empty database lands nothing and counts every row in `skipped` (update writes matched rows only). It now reads as settled, not as an empty install, because the summary does not tell an update skip from a withheld row. Telling them apart needs a withheld count in the loader's summary (`@objectstack/metadata-protocol`), which is not in this PR. - Observation, not filed: `runInlineSeed` also builds the loader without `getFieldFiles`, so a seed row naming a seed file is refused on this door. Not reproduced here. ## Verification <details><summary>Gates and overlap</summary> - `pnpm --filter @objectstack/spec build`, `gen:docs` (changed the four reference pages only), `check:generated`: `All 14 generated artifacts are up to date`. - The derived gate list (`node scripts/pm/dispatch-gates.mjs --commands`) was run locally; its readings are in the os-dev-report on the card. CI's `Lint & Repo Gates` runs the farm. - `git merge-tree --write-tree` of this head against the two open PRs that touch a file of this diff, #34418 (`c965590cfc`) and #34316 (`6d8f7954b2`), and against `origin/main` (`eb0d480bb8`): no conflict. #34407 (same file, `applySideEffects` translations) had no commit on its branch at the probe. - Dogfood battery: not owed (no `!` in the title, no `(narrowing)` arm). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5pHNFS9mn8hS13iGyL)_ ## Fix round 1 No code change this round; the head stays `2297ac0d`. Test Core (8/8) is red on one case: `#30324 … a restart over emptied tables heals them, owned by the installer the ledger records` (`expected [] to deeply equal [ 'Sample Deal A', …(2) ]`), reproduced locally. That pin and this PR's restart pin (`a restart does not heal back the seed rows a person deleted…`) assert opposite outcomes for the same scenario: the same database, every seeded row deleted by a person (not purged), then a restart. One argument decides between them, measured: with `landedKeys` removed from the restart heal, this PR's pin goes red 2/13 and #30324 green 6/6; at head the reverse. No shape keeps both: there is no deletion record to tell the two apart. The choice is open on the card (report 6924505372): A keep `honour` and move #30324's restart trigger to a database that has also lost its landed-key record (assertions verbatim), or B revert the heal to the pre-PR behaviour. `git merge-tree` against #34316 and #34428: no conflict, and neither touches `runInlineSeed`. ## Fix round 2 Seat route A (17:56Z; ruled A by the maintainer at 20:54Z, 6929076086): the restart heal keeps `honour`; only #30324's setup between its two boots changes, and the missing purge pin is added. Head `6ce35da793`. - `packages/cli/test/package-install-local-sample-owner.integration.test.ts`: after boot 1 deletes every seeded row by id and stops, the setup also deletes the rows of `sys_seed_landed_key` in `HOME/data/objectstack.db` (better-sqlite3, `fileMustExist`; the path is `os start`'s default with no `-d` and no project config, and the setup throws a precondition error if that file records no landed key for the two seeded objects). Boot 2 now sees what the heal exists for: a database that lost the seeded rows and their record, under a kept ledger and kept users. The setup comment cites ruling 6670861426 and #34405. No assertion changed. - `packages/cloud-connection/src/marketplace-install-local-landed-keys.test.ts`: new pin `a purge stays purged across a reinstall and a restart` (flat and composed). The engine double gains a by-id `delete` under `assertEngineDeleteDispatch` for the purge, and `scripts/engine-double-contract.pinned.json` records it (`--write`: 1 row added, 0 lost). - `content/docs/deployment/cli.mdx` (flagged by the Docs Drift Check) was re-read where it names seeding, sample data, reseed or install-local; no sentence says a restart refills sample rows a person deleted, so it is unchanged. <details><summary>Readings</summary> - #30324 file: `Tests 6 passed (6)`. With the one line that clears `sys_seed_landed_key` deleted (ablation-replace, WRAP mode): `Tests 1 failed | 5 passed (6)`, `a restart over emptied tables heals them...`, `expected [] to deeply equal [ 'Sample Deal A', …(2) ]`; restored, blob == HEAD, `git diff HEAD` empty. - Landed-key suite: `Tests 15 passed (15)`. The new pin was green on its first run over the round-1 plugin (`2297ac0d`'s source). What holds it is the heal's `honour`, not the purge flag: the reinstall withholds all 4 rows, counts them as skipped and so clears `sampleDataPurged`, and the restart's heal then runs and withholds the recorded keys. Ablation: heal `honour` replaced by an undefined mode gives `Tests 4 failed | 11 passed (15)` (the new pin and the restart pin, flat and composed, `expected [ 'Acme', 'Globex' ] to deeply equal []`); restored, blob == HEAD. - `@objectstack/cli` integration: the 10 test files whose names mention install-local, seed or sample: `Test Files 10 passed (10)`, `Tests 86 passed (86)`. The two `*.e2e.test.ts` files with seed in the name are in no vitest project of this package and were not run. - `@objectstack/cloud-connection`: `Test Files 85 passed (85)`, `Tests 1253 passed (1253)`. Typecheck of cloud-connection and cli (with `check:test-typecheck`) exit 0. - `pnpm check:engine-double-contract`: exit 1 at `86d86777` (the new `delete` double not in the pinned ledger, which also failed CI `Lint · ESLint`), exit 0 at `6ce35da793`. - `git merge-tree --write-tree` against #34316 (`6d8f7954b2`) and `origin/main` (`fe19c97188`, which includes the merged #34428): no conflict. In the merged tree, all four `runInlineSeed` callers pass a mode. </details> ## Fix round 3 Answers review#1 (contract review FAIL, 6926546702), built under route A (the restart heal keeps `honour`; seat route at the time, ruled A by the maintainer at 20:54Z, 6929076086). Head `df003ebc97`. - **M1** (`packages/cloud-connection/src/marketplace-install-local-plugin.ts`, `maybeHealSampleData`): when the heal lands nothing, `skipped` is above 0 and there is no error, the rows were withheld by the landed-key record. That is the declared outcome, so the heal logs it at `info` and records `{ inserted: 0, updated: 0, skipped: N, rejected: 0, droppedRefs }` with no `emptyInstall` and no `healed`. The boot banner, `objectstack:seed-settled`, `GET /ready` and `os verify` then read the restart as settled. A load that lands nothing and withholds nothing, or that errors, keeps the `warn` and `emptyInstall`. The change is self-contained: one `else if` branch and one JSDoc paragraph, in commit `05bf2a48f2`. - **S1**: the changeset and `content/docs/data-modeling/seed-data.mdx` now say an existing install records nothing until its next install, upgrade, reseed, replay or restart heal. A row deleted before that load, even after the upgrade, comes back on it. - **N1**: the `SeedSchema.mode` JSDoc and `.describe()` name the `seed-replayer` replay as AppPlugin's or the marketplace's fallback one. They also say that a load which names no organization and finds no sole one keeps no record. The four reference pages are regenerated. - **N2**: the heal's JSDoc says a recorded key is withheld and how that is reported. The changeset gains `@objectstack/platform-objects` (patch) for the `sys_seed_landed_key` JSDoc. - **N3**: the loader's withheld-rows `info` line names an installed package's sample-data reseed beside `seed-replayer` `{ reseed: true }`. The changeset gains `@objectstack/metadata-protocol` (patch). <details><summary>Red first, then green</summary> - At `7c46403ce2` (tests only, over 45afc37's plugin): `src/marketplace-install-local-landed-keys.test.ts` + `src/marketplace-install-local-heal.test.ts`: `Tests 4 failed | 20 passed (24)`. The restart pin and the purge pin (flat and composed) failed, the diff showing `+ emptyInstall: true`, `- skipped: 4 / + skipped: 0`. - At `05bf2a48f2` (the fix): `Tests 24 passed (24)`. - Pins: the restart and purge-reinstall-restart pins read the recorded `seed-summary` outcome (`toEqual` the withheld outcome, so `emptyInstall` absent) and the logger (no heal `warn`, one heal `info`). The new-database control reads `healed: true, inserted: 4`, no `emptyInstall`. The heal suite adds the genuinely empty load (`0/0/0`, no error) and the skipped-with-error load: both still record `emptyInstall` and `warn`. - No end-to-end reader assertion: none of the four readers is reachable from the cloud-connection suite; each reads exactly `rejected`, `droppedRefs` and `emptyInstall`, and the pin asserts that whole object. - cloud-connection: `Test Files 87 passed (87)`, `Tests 1271 passed (1271)`; typecheck exit 0. cli integration (8 install-local files including #30324's) `Tests 83 passed (83)`, plus `seed-record-values-load-parity` and `verify-seed-outcome` `Tests 3 passed (3)`. metadata-protocol `seed-loader-landed-ids.test.ts` `Tests 27 passed (27)`. Spec build, `gen:docs` and `check:generated`: `All 14 generated artifacts are up to date`. - `dispatch-gates`: 126 derived, 124 run (exit 0), 2 not measured (`check:skill-examples`, `check:dual-build-cjs-loads`, unbuilt dists outside the diff). </details> ## Fix round 4 Answers review#1's S2 (should-fix, delta record 6928590840, PASS) and L1-a's non-blocking note N1 (6928502915). Wording only. Head `31c96c553b`. - **S2**: `maybeHealSampleData`'s settled branch keys on the loader's `skipped`, and `skipped` also counts an `update`-mode seed row with no matching row. So a heal over empty tables whose only skips are such rows also records settled, and the text called the branch withheld-only. The heal JSDoc, the branch comment and the `info` line (`packages/cloud-connection/src/marketplace-install-local-plugin.ts`) now say the split reads the loader's `skipped`, which also counts an `update` row with no match. The `info` line no longer says the rows were removed by a person. The changeset (`.changeset/install-local-honours-landed-keys.md`) adds the same sentence and now says a heal that "lands nothing and skips nothing, or errors" is still the empty install. - Unchanged: no branch condition, return value, loader summary or test assertion moved. No test pins the `info` string. `content/docs/data-modeling/seed-data.mdx` does not state the split, so it was not changed. No `packages/spec` file was touched. <details><summary>Readings at 31c96c5</summary> - Dependency closure built (`pnpm --filter '@objectstack/cloud-connection^...' build`, exit 0). - `src/marketplace-install-local-heal.test.ts` + `src/marketplace-install-local-landed-keys.test.ts`: `Test Files 2 passed (2)`, `Tests 24 passed (24)`. - cloud-connection `typecheck`: exit 0. - Exit 0 each: `check-changeset-no-major`, `check-empty-changeset` (and `--self-test`), `check:changeset-gate-self-tests`, `check-adr-0087-registration`, `check:nul-bytes`, `check:doc-authoring`, `check:durability-log-level`, `check:issue-citations`. Round 3 ran the rest of the PR's derived families (124 of 126); CI runs the farm. </details> ## Fix round 5 Answers the merge-queue red of run 43958493299 (`Dogfood Regression Gate (3/3)`, job 133619628264): in `packages/qa/dogfood/test/install-local-no-active-organization.dogfood.test.ts` the control case expected the reinstall after a purge in organization B to land the 28 sample rows again; with this PR it lands 0. Test-only change; no product code moved. Head `e738de9f43`. - **Why it is honour, not a defect.** The purge does not touch `sys_seed_landed_key`: `purgeSeedRows` (`packages/cloud-connection/src/marketplace-install-local-purge.ts:359-380`) only calls `engine.delete` on the seeded objects, and the purge handler (`marketplace-install-local-plugin.ts` around 6485-6503) only adds a ledger flag. No code path deletes a `sys_seed_landed_key` row (the loader only reads and inserts it, `packages/metadata-protocol/src/seed-loader.ts:4758`, `:4830`). B's record survives the purge, so the reinstall withholds every recorded key: the card's rule, with ruling 6929076086 on the restart side. - **The change.** The control now expects the reinstall to report `{ mode: 'inline', inserted: 0, skipped: 28, errors: 0 }` with B holding 0 rows. A reseed after the reinstall proves the way back: `200 { inserted: 28, errors: 0, withSampleData: true }`, B holds 28, A still holds 0. The header and test name say so, and a one-line comment cites #34405 and 6929076086. Every other assertion is unchanged. <details><summary>Readings</summary> - At `31c96c553b`: 191 dogfood files run locally: the 160 files of queue shard 1/3 (cancelled in the queue; recomputed with vitest's shard order over the queue tree, 160 of 160 passed) plus every file a grep for install-local, sample data, seed, reseed, purge, reinstall, upgrade or restart finds. `Test Files 1 failed | 190 passed (191)`; the one red is this case. - At `e738de9f43`: the changed file `Tests 7 passed (7)`; `pnpm --filter @objectstack/dogfood typecheck` exit 0. Derived gates for the one path: 53 derived, 53 run, 0 unrun. - Not measured: `test/flow-record-text-org-locale.dogfood.test.ts`, in queue shard 1/3 but only on main after this branch's base. </details> <!-- signed: repo:objectstack#1 · os-project-manager · session_01FEkQ5pHNFS9mn8hS13iGyL --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 631d77f commit a6c2b83

15 files changed

Lines changed: 634 additions & 52 deletions
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
'@objectstack/cloud-connection': patch
3+
'@objectstack/spec': patch
4+
'@objectstack/platform-objects': patch
5+
'@objectstack/metadata-protocol': patch
6+
---
7+
8+
fix(cloud-connection): a sample row a tenant deleted stays deleted when install-local reinstalls, upgrades, heals or replays the package
9+
10+
Clause-②: no (the door starts honouring the loader's existing `landedKeys` guard, #31021; no accepted shape or public export widens; the dev confirms)
11+
Metadata-protocol: none
12+
13+
install-local's seed loads now keep, and honour, the per-organization record of which seed rows landed (`sys_seed_landed_key`, registered by `@objectstack/platform-objects`). Before, the door built its seed loader without the `landedKeys` option, so it neither read nor wrote that record: a seed row a person deleted (a demo account, a demo order) was inserted again by the next reinstall, upgrade, restart heal or per-organization replay.
14+
15+
- The install and the upgrade (in the installing person's organization under an organization wall, otherwise in the install's sole organization), the restart heal of an empty database, the per-organization replay of a new organization and an unmanaged copy's first load honour the record: a seed row whose key landed in that organization before and whose row is now gone is not inserted again. A key that never landed still lands, so a row an upgrade adds to the seed is inserted, and a new database, which holds no record, is healed whole. A row the record keeps out is counted in `skipped`.
16+
- The sample-data reseed (`POST /api/v1/marketplace/install-local/:manifestId/reseed-sample-data`, for a ledgered package and for an unmanaged copy alike) is the deliberate re-seed: it inserts every missing row whatever the record says, and records it again. Its answer is unchanged.
17+
- The `seed-replayer` service this door registers when no app has registered one now takes `{ reseed: true }`, as the AppPlugin replayer does: that call inserts every missing row; any other call honours the record.
18+
19+
Every row a load lands is recorded, whether it inserted, updated or matched the row. An existing install keeps no record until its next install, upgrade, reseed, replay or restart heal, so a row a person deletes before that load, after this release too, comes back once on it, and stays deleted from then on.
20+
21+
A restart heal that withholds every row (a seed a person emptied, or a purge then a reinstall) reports a settled seed: the withheld rows are counted in `skipped` and logged at `info`, not recorded as an empty install, so the boot banner, `objectstack:seed-settled`, `GET /ready` and `os verify` read it as settled. The split reads the loader's `skipped`, which also counts an `update` seed row with no match, so a heal whose only skips are those also reports settled. A heal that lands nothing and skips nothing, or errors, is still the empty install.
22+
23+
`@objectstack/spec`: the `mode` description of a seed dataset no longer says a package install keeps no record: a seed publish is the load that keeps none, and the sample-data reseed is named beside `seed-replayer(organizationId, { reseed: true })` as the deliberate re-seed.
24+
25+
`@objectstack/platform-objects`: the `sys_seed_landed_key` object's description names install-local's loads among the record's writers and readers, and its sample-data reseed beside `seed-replayer` as the deliberate re-seed.
26+
27+
`@objectstack/metadata-protocol`: the seed loader's `info` line for withheld rows names an installed package's sample-data reseed beside `seed-replayer` with `{ reseed: true }` as the way back.

‎content/docs/data-modeling/seed-data.mdx‎

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,22 @@ organization. A row an upgrade adds to the seed has never landed, so it
163163
is still inserted. A reference to the deleted row from another seed row is left
164164
unwritten rather than reported as an error.
165165

166-
The record is kept and honoured only where AppPlugin runs the load for a known
167-
organization: the single-tenant boot seed (`objectstack serve`, `os start`, on
168-
every restart; a multi-tenant boot seeds through the per-organization replay
169-
instead), the per-organization replay (`seed-replayer`), and the dev hot reload.
170-
A seed publish, a package install or upgrade (`os package install`, the
171-
marketplace install, its heal and its sample-data reseed) keep no record, so a
172-
deleted row comes back on those. So do a load with no organization, a
173-
composition that does not register `sys_seed_landed_key`
174-
(`@objectstack/platform-objects`), and the marketplace's fallback
175-
`seed-replayer`, which it registers when no app has seed data.
176-
177-
A row deleted before your runtime had this rule comes back once, on the first
178-
replay after the upgrade, and stays deleted from then on.
166+
The record is kept and honoured where a load seeds a known organization: the
167+
single-tenant boot seed (`objectstack serve`, `os start`, on every restart; a
168+
multi-tenant boot seeds through the per-organization replay instead), the
169+
per-organization replay (`seed-replayer`, the marketplace's fallback one
170+
included, which it registers when no app has seed data), the dev hot reload,
171+
and a package install or upgrade (`os package install`, the marketplace
172+
install, into the installing person's organization) with its restart heal. A
173+
seed publish keeps no record, so a deleted row comes back on that. So do a load
174+
with no organization and a composition that does not register
175+
`sys_seed_landed_key` (`@objectstack/platform-objects`).
176+
177+
A row deleted before any load recorded it comes back once, on the first load
178+
that keeps the record, and stays deleted from then on. For the boot seed that
179+
is the first boot after the upgrade. An installed package records nothing
180+
until its next install, upgrade, reseed, replay or restart heal, so a row
181+
deleted before that load, even after the upgrade, comes back on it.
179182

180183
To bring the deleted rows back on purpose, a host or plugin calls the
181184
`seed-replayer` kernel service with `{ reseed: true }`:
@@ -185,6 +188,10 @@ const replay = ctx.getService('seed-replayer'); // ctx: the plugin's context
185188
await replay(organizationId, { reseed: true }); // inserts every missing seed row
186189
```
187190

191+
For an installed package, the sample-data reseed
192+
(`POST /api/v1/marketplace/install-local/:manifestId/reseed-sample-data`) does
193+
the same in the caller's organization.
194+
188195
---
189196

190197
## Seeds and State Machines

‎content/docs/references/api/package-api.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ Package manifest installed through POST /api/v1/packages (AUTHORING stage; scope
243243
| :--- | :--- | :--- | :--- |
244244
| **object** | `string` | ✅ | Target Object Name |
245245
| **externalId** | `string \| string[]` | optional (default: `"name"`) | Field (or composite list of fields) matched for the uniqueness check |
246-
| **mode** | `Enum<'insert' \| 'update' \| 'upsert' \| 'replace' \| 'ignore'>` | optional (default: `"ignore"`) | What a load does with a record whose `externalId` matches an existing row. `ignore` (default) is create-only: a missing row is inserted and an existing row is left as it is, so a replay (every boot, a package install or upgrade, a publish) never writes a seeded value back over a later edit. `upsert` also writes every declared column back onto the matched row on each replay; declare it for reference data the package keeps current. `update` writes matched rows only, `insert` inserts every record with no match, so each replay inserts them again, and `replace` does the same and deletes nothing: it is for a table the caller cleared. On the loads AppPlugin runs for an organization (the boot seed, the seed-replayer replay, the dev hot reload), an `ignore` or `upsert` row that landed once and was later deleted is not inserted again; a publish or package install keeps no such record, and seed-replayer called with `{ reseed: true }` inserts every missing row. |
246+
| **mode** | `Enum<'insert' \| 'update' \| 'upsert' \| 'replace' \| 'ignore'>` | optional (default: `"ignore"`) | What a load does with a record whose `externalId` matches an existing row. `ignore` (default) is create-only: a missing row is inserted and an existing row is left as it is, so a replay (every boot, a package install or upgrade, a publish) never writes a seeded value back over a later edit. `upsert` also writes every declared column back onto the matched row on each replay; declare it for reference data the package keeps current. `update` writes matched rows only, `insert` inserts every record with no match, so each replay inserts them again, and `replace` does the same and deletes nothing: it is for a table the caller cleared. On the loads that seed an organization (the boot seed, a seed-replayer replay, the dev hot reload, a package install or upgrade), an `ignore` or `upsert` row that landed once and was later deleted is not inserted again; a publish, or a load that names no organization and finds no sole one, keeps no such record, and seed-replayer called with `{ reseed: true }` or the sample-data reseed inserts every missing row. |
247247
| **columns** | `Record<string, { applyOn?: Enum<'create' \| 'always'> }>` | optional | Per-column write policy, keyed by field name: `{ status: { applyOn: 'create' } }` writes `status` only when the seed creates the row. Omitted, every column is written on create and update. |
248248
| **env** | `Enum<'prod' \| 'dev' \| 'test'>[]` | optional (default: `["prod","dev","test"]`) | Applicable environments |
249249
| **locale** | `string[]` | optional | Applicable locales (BCP-47 tags); omitted applies to every locale. The boot seed filters on the app's i18n.defaultLocale; the marketplace install, sample-data reseed, restart heal and per-organization replay filter on the locale resolved for the load (the localization.locale setting when set, then the locale of the installing, reseeding or founding user, then the app's i18n.defaultLocale where the load names one); package apply and draft publish do not filter by locale — they load every dataset and warn |
@@ -352,7 +352,7 @@ Package manifest installed through POST /api/v1/packages (AUTHORING stage; scope
352352
| :--- | :--- | :--- | :--- |
353353
| **object** | `string` | ✅ | Target Object Name |
354354
| **externalId** | `string \| string[]` | optional (default: `"name"`) | Field (or composite list of fields) matched for the uniqueness check |
355-
| **mode** | `Enum<'insert' \| 'update' \| 'upsert' \| 'replace' \| 'ignore'>` | optional (default: `"ignore"`) | What a load does with a record whose `externalId` matches an existing row. `ignore` (default) is create-only: a missing row is inserted and an existing row is left as it is, so a replay (every boot, a package install or upgrade, a publish) never writes a seeded value back over a later edit. `upsert` also writes every declared column back onto the matched row on each replay; declare it for reference data the package keeps current. `update` writes matched rows only, `insert` inserts every record with no match, so each replay inserts them again, and `replace` does the same and deletes nothing: it is for a table the caller cleared. On the loads AppPlugin runs for an organization (the boot seed, the seed-replayer replay, the dev hot reload), an `ignore` or `upsert` row that landed once and was later deleted is not inserted again; a publish or package install keeps no such record, and seed-replayer called with `{ reseed: true }` inserts every missing row. |
355+
| **mode** | `Enum<'insert' \| 'update' \| 'upsert' \| 'replace' \| 'ignore'>` | optional (default: `"ignore"`) | What a load does with a record whose `externalId` matches an existing row. `ignore` (default) is create-only: a missing row is inserted and an existing row is left as it is, so a replay (every boot, a package install or upgrade, a publish) never writes a seeded value back over a later edit. `upsert` also writes every declared column back onto the matched row on each replay; declare it for reference data the package keeps current. `update` writes matched rows only, `insert` inserts every record with no match, so each replay inserts them again, and `replace` does the same and deletes nothing: it is for a table the caller cleared. On the loads that seed an organization (the boot seed, a seed-replayer replay, the dev hot reload, a package install or upgrade), an `ignore` or `upsert` row that landed once and was later deleted is not inserted again; a publish, or a load that names no organization and finds no sole one, keeps no such record, and seed-replayer called with `{ reseed: true }` or the sample-data reseed inserts every missing row. |
356356
| **columns** | `Record<string, { applyOn?: Enum<'create' \| 'always'> }>` | optional | Per-column write policy, keyed by field name: `{ status: { applyOn: 'create' } }` writes `status` only when the seed creates the row. Omitted, every column is written on create and update. |
357357
| **env** | `Enum<'prod' \| 'dev' \| 'test'>[]` | optional (default: `["prod","dev","test"]`) | Applicable environments |
358358
| **locale** | `string[]` | optional | Applicable locales (BCP-47 tags); omitted applies to every locale. The boot seed filters on the app's i18n.defaultLocale; the marketplace install, sample-data reseed, restart heal and per-organization replay filter on the locale resolved for the load (the localization.locale setting when set, then the locale of the installing, reseeding or founding user, then the app's i18n.defaultLocale where the load names one); package apply and draft publish do not filter by locale — they load every dataset and warn |

‎content/docs/references/data/seed-loader.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Seed loader request with datasets and configuration
230230
| :--- | :--- | :--- | :--- |
231231
| **object** | `string` | ✅ | Target Object Name |
232232
| **externalId** | `string \| string[]` | optional (default: `"name"`) | Field (or composite list of fields) matched for the uniqueness check |
233-
| **mode** | `Enum<'insert' \| 'update' \| 'upsert' \| 'replace' \| 'ignore'>` | optional (default: `"ignore"`) | What a load does with a record whose `externalId` matches an existing row. `ignore` (default) is create-only: a missing row is inserted and an existing row is left as it is, so a replay (every boot, a package install or upgrade, a publish) never writes a seeded value back over a later edit. `upsert` also writes every declared column back onto the matched row on each replay; declare it for reference data the package keeps current. `update` writes matched rows only, `insert` inserts every record with no match, so each replay inserts them again, and `replace` does the same and deletes nothing: it is for a table the caller cleared. On the loads AppPlugin runs for an organization (the boot seed, the seed-replayer replay, the dev hot reload), an `ignore` or `upsert` row that landed once and was later deleted is not inserted again; a publish or package install keeps no such record, and seed-replayer called with `{ reseed: true }` inserts every missing row. |
233+
| **mode** | `Enum<'insert' \| 'update' \| 'upsert' \| 'replace' \| 'ignore'>` | optional (default: `"ignore"`) | What a load does with a record whose `externalId` matches an existing row. `ignore` (default) is create-only: a missing row is inserted and an existing row is left as it is, so a replay (every boot, a package install or upgrade, a publish) never writes a seeded value back over a later edit. `upsert` also writes every declared column back onto the matched row on each replay; declare it for reference data the package keeps current. `update` writes matched rows only, `insert` inserts every record with no match, so each replay inserts them again, and `replace` does the same and deletes nothing: it is for a table the caller cleared. On the loads that seed an organization (the boot seed, a seed-replayer replay, the dev hot reload, a package install or upgrade), an `ignore` or `upsert` row that landed once and was later deleted is not inserted again; a publish, or a load that names no organization and finds no sole one, keeps no such record, and seed-replayer called with `{ reseed: true }` or the sample-data reseed inserts every missing row. |
234234
| **columns** | `Record<string, { applyOn?: Enum<'create' \| 'always'> }>` | optional | Per-column write policy, keyed by field name: `{ status: { applyOn: 'create' } }` writes `status` only when the seed creates the row. Omitted, every column is written on create and update. |
235235
| **env** | `Enum<'prod' \| 'dev' \| 'test'>[]` | optional (default: `["prod","dev","test"]`) | Applicable environments |
236236
| **locale** | `string[]` | optional | Applicable locales (BCP-47 tags); omitted applies to every locale. The boot seed filters on the app's i18n.defaultLocale; the marketplace install, sample-data reseed, restart heal and per-organization replay filter on the locale resolved for the load (the localization.locale setting when set, then the locale of the installing, reseeding or founding user, then the app's i18n.defaultLocale where the load names one); package apply and draft publish do not filter by locale — they load every dataset and warn |

‎content/docs/references/data/seed.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const result = SeedSchema.parse(data);
3030
| :--- | :--- | :--- | :--- |
3131
| **object** | `string` | ✅ | Target Object Name |
3232
| **externalId** | `string \| string[]` | optional (default: `"name"`) | Field (or composite list of fields) matched for the uniqueness check |
33-
| **mode** | `Enum<'insert' \| 'update' \| 'upsert' \| 'replace' \| 'ignore'>` | optional (default: `"ignore"`) | What a load does with a record whose `externalId` matches an existing row. `ignore` (default) is create-only: a missing row is inserted and an existing row is left as it is, so a replay (every boot, a package install or upgrade, a publish) never writes a seeded value back over a later edit. `upsert` also writes every declared column back onto the matched row on each replay; declare it for reference data the package keeps current. `update` writes matched rows only, `insert` inserts every record with no match, so each replay inserts them again, and `replace` does the same and deletes nothing: it is for a table the caller cleared. On the loads AppPlugin runs for an organization (the boot seed, the seed-replayer replay, the dev hot reload), an `ignore` or `upsert` row that landed once and was later deleted is not inserted again; a publish or package install keeps no such record, and seed-replayer called with `{ reseed: true }` inserts every missing row. |
33+
| **mode** | `Enum<'insert' \| 'update' \| 'upsert' \| 'replace' \| 'ignore'>` | optional (default: `"ignore"`) | What a load does with a record whose `externalId` matches an existing row. `ignore` (default) is create-only: a missing row is inserted and an existing row is left as it is, so a replay (every boot, a package install or upgrade, a publish) never writes a seeded value back over a later edit. `upsert` also writes every declared column back onto the matched row on each replay; declare it for reference data the package keeps current. `update` writes matched rows only, `insert` inserts every record with no match, so each replay inserts them again, and `replace` does the same and deletes nothing: it is for a table the caller cleared. On the loads that seed an organization (the boot seed, a seed-replayer replay, the dev hot reload, a package install or upgrade), an `ignore` or `upsert` row that landed once and was later deleted is not inserted again; a publish, or a load that names no organization and finds no sole one, keeps no such record, and seed-replayer called with `{ reseed: true }` or the sample-data reseed inserts every missing row. |
3434
| **columns** | `Record<string, { applyOn?: Enum<'create' \| 'always'> }>` | optional | Per-column write policy, keyed by field name: `{ status: { applyOn: 'create' } }` writes `status` only when the seed creates the row. Omitted, every column is written on create and update. |
3535
| **env** | `Enum<'prod' \| 'dev' \| 'test'>[]` | optional (default: `["prod","dev","test"]`) | Applicable environments |
3636
| **locale** | `string[]` | optional | Applicable locales (BCP-47 tags); omitted applies to every locale. The boot seed filters on the app's i18n.defaultLocale; the marketplace install, sample-data reseed, restart heal and per-organization replay filter on the locale resolved for the load (the localization.locale setting when set, then the locale of the installing, reseeding or founding user, then the app's i18n.defaultLocale where the load names one); package apply and draft publish do not filter by locale — they load every dataset and warn |

0 commit comments

Comments
 (0)