Skip to content

Commit b66e07d

Browse files
committed
chore(changeset): record which seed rows landed per organization
Claude-Session: https://claude.ai/code/session_017xRBcTJTE7kSbcMoJQ4Txf Co-authored-by: Claude <noreply@anthropic.com>
1 parent f72ceee commit b66e07d

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/metadata-protocol': minor
3+
'@objectstack/runtime': minor
4+
'@objectstack/platform-objects': minor
5+
---
6+
7+
fix(metadata-protocol,runtime): a seed row a person deleted is no longer inserted again under a new id by the next seed replay
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: semantic
11+
12+
A seed replays long after its first load: on every boot of a single-tenant runtime (`objectstack serve`, `os start`) and per organization whenever a host replays the seed union, for example on a package upgrade. The create-only default (`mode` omitted, which is `ignore`) inserted every declared row it did not find, and `upsert` did the same. A row a person deleted therefore came back under a new id at the next replay.
13+
14+
The seed loads AppPlugin runs now keep a per-organization record of which seed rows landed: the boot seed, the per-organization replay (the `seed-replayer` service) and the dev hot-reload seeder. The record is the new platform object `sys_seed_landed_key` (`SysSeedLandedKey`, registered by `PlatformObjectsPlugin`). It holds one row per landed key: the organization, the object, and the dataset's `externalId` fields with the values the row was matched by. The loader records every keyed row an `upsert` or `ignore` dataset lands, whether it inserted the row, updated it or matched it and left it alone. A row an earlier release seeded therefore counts as landed from the first load after the upgrade. A missing row is inserted only when its key never landed in that organization:
15+
16+
- A deleted seed row stays deleted across reboots and upgrades. A row an upgrade adds to the seed still lands.
17+
- An edited row is left as the person left it. Under `ignore` this includes a renamed key: the old name is not inserted again.
18+
- A reference to a removed row is left as it is, and a row whose own key names a removed row is withdrawn with it. Nothing is reported unresolved for either, so a replay after a person's delete still loads clean.
19+
- One `info` line per load says how many seed rows were not inserted again, and where.
20+
21+
The deliberate re-seed is the `seed-replayer` service called with `{ reseed: true }`. It inserts every missing row, including the ones a person removed, and records them again. A new database starts with an empty record. Deleting an organization deletes its record.
22+
23+
`SeedLoaderService` takes the record through a new constructor option, `landedKeys: 'honour' | 'reseed'`. A caller that does not pass it neither reads nor writes the record, so the package publish, marketplace install, reseed and purge doors behave as before. A load keeps no record when it seeds no organization, and says so at `info`. It also keeps none when the composition does not register `sys_seed_landed_key`, and says so at `warn`. A record write that fails is reported once at `error`. It fails neither the rows nor the load, and the next load records every row that is still present.

0 commit comments

Comments
 (0)