Skip to content

Commit dfc6bbf

Browse files
feat(spec, metadata-protocol): Seed.fallback marks the set an organization gets when its locale matches no set of the object (#35065)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ Closes #34940 Ruling: seat 3, route A (claim comment 6963214228 on the card): an explicit optional per-set marker `fallback: true` on a seed set, loaded only when no set of the same object matches the resolved locale; additive and opt-in, with conditions (1) at most one fallback set per object, (2) enforced at boot and at install/reseed/heal/replay with the liveness ledger recording the key live, (3) the seed docs and the skills seed page name it. Seat rulings on this PR's open questions (2026-11-18T01:25Z): - **Q1 = B.** The `skills/objectstack-data/references/seeds.md` hunk is dropped from this PR. A `domain:skills` child card, filed by triage, carries the seeds.md field rows and the eval case. Commit `e020dc236a` restores seeds.md to its `origin/main` bytes; history is not rewritten. - **Q2.** The load-time refusal of two fallback sets for one object is enough: no authoring-time check and no claim amendment. The strict reading that `fallback` needs `locale` stands. Seat ruling on the contract review of `e020dc236a` (FAIL, M1, comment 6966933253): the shared per-organization replay list is appended to on every merge (boot rehydrate, install or upgrade, reseed), so one reseed left two copies of the one fallback set and the whole-load refusal gave every new organization no seed rows. Fix round 2 (`f64d23edfd`): - The loader counts **distinct declarations**, not raw entries. Identical copies of one dataset count once. The fingerprint covers every key except the runtime `_` envelope, with keys sorted. - The refusal is **scoped to the object**. This replaces the whole-load refusal. (The "only that object's fallback-marked sets are skipped" half is amended by fix round 3 below.) - `mergeSeedDatasets` is not changed (outside the claim). Object names are global, so there is no per-package scoping: two packages that mark different fallback sets for one object refuse that object. Seat ruling on the contract review of `09232b7d0c` (FAIL, M2, comment 6968234700): seat 1, comment 6968296038, route (a), quoted verbatim: > When one object has two distinct fallback-marked declarations, refuse only the fallback choice for that object: no marked set is used as the fallback for an unlisted locale, and the load reports the object at `warn`. Every marked set still loads for the locales it lists, exactly as an unmarked set would. Fix round 3 (`e2c865b89a`, `6e660b0fd2`, `00b85b668b`): M2 was an upgrade inside one running process. The shared replay list then holds version 1's and version 2's datasets. If the marked set changed between the versions, those are two distinct marked declarations from one correctly written package. Before this round, every marked set of the object was then removed, so an `en` organization lost the `en` rows it would have had without the marker. Now the marked sets stay in the locale filter as ordinary sets. Only their use as the fallback for a locale none of them lists is withheld. `mergeSeedDatasets` is still unchanged (ruling 6966988997). Clause-②: yes (widening) Metadata-protocol: added Skills-docs: follow-up #35070 ## 维护者速读 - 改了什么:种子数据集新增可选标记 `fallback: true`。按语言拆分的种子(如 zh-CN 与 en 两套标准价格表),标记其中一套后,语言不在任何一套之列的组织(ja-JP、es-ES)也能拿到这一套,而不是一条都没有。 - 为什么改:之前这类组织拿不到任何一套功能性种子(例如报价依赖的标准价格表),工单 #34940。 - 风险与回滚:纯增量;不写 `fallback` 的数据集行为逐字节不变(每条路径都有不带标记的对照用例)。同一对象标记了两套不同的回退集时(例如同一进程内升级改动了回退集),只拒绝「回退」这一选择:各套仍按自己列出的语言加载,与不带标记时完全相同,未列出语言的组织拿不到回退,并以 warn 报出该对象;同一套被重复合并(重新加载、升级、重置示例数据)只算一套。回滚即还原本 PR。 - 先看:`packages/metadata-protocol/src/seed-loader.ts`(`filterByLocale` 的回退分支与 `refusedFallbackObjects` 条件、`findDuplicateFallbackSets` 的提示文案);`packages/spec/src/data/seed.zod.ts`(新键与 `dependentRequired` 规则)。 - 两分钟验证:`pnpm --filter @objectstack/metadata-protocol exec vitest run src/seed-loader-locale-scope.test.ts`,预期 35 个用例全过,其中 `Seed.fallback fills in…` 一组 19 个。 - 需要你做的:无,席位落地。本 PR 已不触及受管面(技能页的两行改由 domain:skills 子卡承载)。 ## What changes - **Spec** (`SeedSchema`): new optional key `fallback: true` (the one value is `true`). `fallback` without `locale` is refused at parse, at the `fallback` key, through `dependentRequired({ fallback: ['locale'] })` from the closed projection list, so the published JSON Schema carries the rule (`dependentRequired: { fallback: ['locale'] }`) and `dropped-refinements.baseline.json` does not grow. `locale` docs now point at the marker. - **Loader** (`SeedLoaderService`, the one funnel every seeding path goes through): `filterByLocale` keeps a marked dataset the resolved locale would drop when no locale-scoped dataset of its object lists that locale, and logs each such fallback at info. When the env-kept datasets of a load mark two **different** sets of one object, only the fallback choice is refused: every marked set still loads for the locales it lists, exactly as an unmarked set would, and none fills in for a locale no set lists. The load reports one error per object (`field: 'fallback'`, `success: false`) and logs it at warn. The message names both causes (more than one marked set across the packages being seeded, or an upgrade in this process that changed a package's marked set) instead of telling the author to drop a marker. Identical copies of one set count once, so a list merged twice seeds normally. A load with no locale is unchanged: every dataset loads and the existing warning names the marked one too. - **Liveness ledger**: `packages/spec/liveness/seed.json` gains a `live` `fallback` row (evidence, producer, pins); `state-counts/seed.md` regenerated (19 → 20). - **Generated**: `authorable-surface/data.json` (+`data/Seed:fallback`), and the reference pages `gen:docs` rewrites (`references/data/seed.mdx`, `seed-loader.mdx`, and the two that embed the seed table: `api/package-api.mdx`, `kernel/manifest.mdx`). - **Docs**: `content/docs/data-modeling/seed-data.mdx` gets an "A Fallback Set" section, a `defineSeed` signature line and a best-practice pointer. The skills seed page is not touched here (Q1 = B above). Decisions taken (the ruling asked for these to be decided and documented): - **`fallback: true` with no `locale` is refused, not read as redundant** (the stricter option). An unscoped dataset already loads for every locale, so the marker could only promise a behaviour the loader does not have, which is the declared-not-enforced shape ADR-0049 forbids. - **A fallback set lists locales: it must.** It loads for its own locales like any set, and also for unmatched ones. - **"Matches" means a locale-scoped dataset of the same object lists the resolved locale.** A dataset with no `locale` is locale-neutral: it loads beside the chosen set and does not block the fallback. Under the literal reading (an unscoped set "matches" every locale), any object carrying shared rows could never fall back. - **Judged after `env`.** A set `env` scoped out neither matches nor falls back. Two marked sets in different environments are not refused. - **The duplicate refusal is judged whatever the locale**, because the declaration is ambiguous on every load. Waiting for an unmatched locale would surface it on the first organization in a new market. - **The duplicate refusal is per object, and identical copies count once** (seat ruling, fix round 2, above). **It withholds only the fallback choice** (seat ruling, fix round 3, above): the refusal never costs an organization rows it would have had without the marker. ## Tests **Fix round 3** (head `00b85b668b`, see the Verification block for the commands and their sha): - Loader (`seed-loader-locale-scope.test.ts`, 35/35): - With two distinct marked sets, `zh-CN`, `en`, `ja-JP` and no locale each get the same `price_book` rows as the unmarked control. `ja-JP` gets none. Every load reports `field: 'fallback'`. - No `fallback set(s) loaded` info line is printed, and the message no longer says "drop it from the others". - **The M2 pin**: a list holding version 1 and version 2 (the marked `en` set gained a row). `en` gets `Partner, Standard`, the same as the unmarked control. `ja-JP` gets no `price_book`. One `warn` names `'price_book'`. - Two packages: `de-DE` still gets the other package's marked set. - Runtime (`app-plugin.seed-locale-producer.test.ts`, 37/37): - **The M2 pin through the real replayer**: one fresh process per organization, version 1 through `AppPlugin.start`, then version 2 through a second start (shared list length 6). For `org_en` and `org_ja`, the rows match the unmarked control, `account` seeds, and exactly one `warn` appears (0 in the control). - Pin (b) now also asserts that `org_en` gets `Standard`. - The inline-install refusal case asserts that `zh-CN` still gets its marked set. - The M1 pins (identical copies collapse, the reseed and unchanged-upgrade legs) are unchanged and green. - **Ablation, one-time, on `6e660b0fd2`, loader suite from source:** `scripts/ablation-replace.mjs` replaced the guard `&& !refusedFallbackObjects.has(dataset.object)` with `&& true /* ablated */`. It checked anchor 1 to 0 and marker 0 to 1 on disk. Result: 5 failed of 35 (the four round-3 loader cases and the two-package case). Restored: the blob equals HEAD `95540e642a`, and `git diff HEAD` is empty. A first attempt used the replacement `) {`, which the anchor itself contains. The tool refused it before running anything, so that attempt was a no-op. **Earlier rounds** (kept as recorded): Final head `09232b7d0c`: the fix `f64d23edfd`, then a merge of `origin/main`. The merge does not touch `seed-loader.ts`, `seed-datasets.ts`, `seed-locale.ts` or the seed schema. - `pnpm --filter @objectstack/spec test` on `09232b7d0c`: Test Files 852 passed (852), Tests 27306 passed, 1 todo. - `pnpm --filter @objectstack/metadata-protocol test`: Test Files 352 passed, 9 skipped (361); Tests 23143 passed, 45 skipped. Run on `f64d23edfd`, and again on `09232b7d0c` with the same counts. - `pnpm --filter @objectstack/runtime test` on `f64d23edfd`: Test Files 618 passed (618), Tests 11474 passed, 23 skipped. **NOT MEASURED on `09232b7d0c`**: the re-run was stopped at the wind-down order before it finished. - On `09232b7d0c`, after the merge and a closure rebuild: `seed-loader-locale-scope.test.ts` 33/33 and `app-plugin.seed-locale-producer.test.ts` 36/36. - Typecheck of spec, metadata-protocol and runtime exited 0 on `f64d23edfd`. - New or changed in fix round 2: - Loader: per-object refusal (the other object seeds, the unmarked set of the object seeds, one warn line), refusal at any locale, identical copies count once (copies made by clone and by key reordering), and two packages marking one object. - Runtime: **pin (a)** a replay after the same package merged twice through a second `AppPlugin.start` (6 entries in the shared list) still gets the fallback set, and the rest seeds. **Pin (b)** a second package marking a different `price_book` fallback set refuses only `price_book`; `account` and the second package's `plan_en` still seed. The install path also gets a per-object refusal case and a list-merged-twice case. <details><summary>Ablations (one-time, not kept), on <code>f64d23edfd</code></summary> Each ablation ran `scripts/ablation-replace.mjs --hold` (anchor count 1 to 0, marker 0 to 1), rebuilt `@objectstack/metadata-protocol`, and confirmed with `ablation-dist-preflight` that the marker was in 2 built files. The restore used `git checkout HEAD -- path`, checked that the blob hash equals HEAD (`9926b3211f`), rebuilt, and ran `--absent` (marker absent from 24 built files, tree clean). - **Copy collapse removed** (`distinct.set(fingerprint + "#ABLATE_NO_COLLAPSE" + distinct.size, …)`). Loader: 1 failed of 33 (identical copies). Runtime: 2 failed of 36, which are pin (a) and the install list-merged-twice case. - **Per-object scope made whole-load** (the kept list emptied whenever any object is refused). Loader: 3 failed of 33 (per-object, any locale, two packages). Runtime: 2 failed of 36, which are pin (b) and the install per-object case. </details> ## Acceptance notes - **Round 3 file surface:** `packages/spec/liveness/seed.json` was outside the claim's listed surface. Its `fallback` row's evidence and note described the round-2 behaviour ("skipped"), which this round makes false, so it was updated in the same commit. That row was added by this PR and has not been released. - **N3/N4 (nits of 6968234700) not taken:** the fingerprint's non-JSON values and its cost are unchanged. A wrong collapse now leaves both sets marked and both used as the fallback; no row is lost. - **Out of scope, routed by the seat:** the append-only shared `seed-datasets` list after an upgrade (ruling 6968296038, last bullet), filed by triage as #35109. This PR does not change it. - **Not governed**: after the seeds.md revert, `check-governed-merges --branch` reads 0 of 14 paths on the register — NOT governed. `check-skills-token-ratchet` stays green against main's seeds.md (1747 / 1747). - **One fallback per object is a loader refusal, not a stack-level schema refinement.** A refinement over `data: SeedSchema[]` would live in `packages/spec/src/stack.zod.ts`, which is outside this claim's file surface, and it would not see stored `seed` items, which reach the loader without a stack. Stack-level authoring-time detection (`os validate`) is a possible follow-up. - Generated reference pages `api/package-api.mdx` and `kernel/manifest.mdx` changed because they embed the seed table. That is `gen:docs` output, which `check:docs` requires. - `#34791` shares `seed-loader.ts`, `seed.zod.ts`, `seed.test.ts` and the seed docs; `overlap-check` reads that it merges cleanly. ## Verification <details><summary>Local gates on <code>09232b7d0c</code>: <code>dispatch-gates.mjs --commands</code> derived 116 families; 94 exit 0, 2 NOT MEASURED, 20 not run</summary> - Each command's exit code was captured before any pipe and recorded as `:: exit N`. - 96 of 116 were recorded (the run resumed once after a container restart): 94 exit 0. - **NOT MEASURED: `check:skill-examples` (exit 3).** PREREQUISITE NOT MET: `packages/client-react/dist` was not built in this worktree. - **NOT MEASURED: `check:dual-build-cjs-loads` (exit 3).** PREREQUISITE NOT MET: 34 published packages are unbuilt. - **Not run (20)**: the families after `check:refd-timer-probe` in the derived list, stopped at the wind-down order. `dispatch-gates --ran` reads: 20 of 116 UNRUN, 2 NOT-MEASURED. - Recorded on `09232b7d0c` with exit 0: `check:generated`, `check:liveness`, `check:docs`, `check:authorable-surface`, `check:api-surface` and `check:nul-bytes`. `check:test-source-alias` is among the 20 not run. - `overlap-check` on `09232b7d0c`: `VERDICT clean exit 0`. `origin/main` merges cleanly, and `#34791` merges cleanly. - CI's check-runs are the authority for every family above. </details> Full CI (`Test Core`, dogfood shards and the rest of the farm) is left to the PR's check-runs. Dogfood battery: not owed (no `!` in the title, `(widening)` arm). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzi6WQ71HhZSLSvHhdF <!-- 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 b1eb500 commit dfc6bbf

14 files changed

Lines changed: 925 additions & 30 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/metadata-protocol': minor
4+
---
5+
6+
feat(spec, metadata-protocol): `Seed.fallback` marks the set an organization gets when its locale matches no set of the object
7+
8+
Clause-②: yes (widening) — one new optional key, `fallback: true`, on a seed dataset (`SeedSchema`); a seed without it parses and loads exactly as before
9+
Metadata-protocol: added
10+
11+
An app that splits a seed by language with `locale` (a `zh-CN` and an `en` set of the standard price book) used to leave an organization on any other locale (`ja-JP`, `es-ES`) with neither set. Mark one set `fallback: true` and it also loads for every resolved locale that no locale-scoped set of the same object lists:
12+
13+
```ts
14+
defineSeed(PriceBook, { locale: ['zh-CN'], records: [{ name: '标准价格表' }] });
15+
defineSeed(PriceBook, { locale: ['en', 'en-US'], fallback: true, records: [{ name: 'Standard' }] });
16+
```
17+
18+
It is honoured wherever a load filters by locale: the boot seed and the dev hot reload (the app's `i18n.defaultLocale`), and the per-organization replay, marketplace install, sample-data reseed and restart heal (the locale `resolveSeedLocaleForLoad` resolves). The loader logs each fallback set it loaded, at info.
19+
20+
- The marker needs `locale`: `fallback: true` on a dataset with no `locale` is refused when the seed is parsed, because an unscoped dataset already loads for every locale. The published JSON Schema carries the rule as `dependentRequired`.
21+
- A dataset with no `locale` does not count as a match: it loads beside whichever set is chosen.
22+
- `env` is applied first; a set it scoped out neither matches nor falls back.
23+
- At most one fallback set per object in a load: with two different marked sets of one object, only the fallback choice is refused. No marked set fills in for a locale no set lists, and the load reports one error per object (`field: 'fallback'`), logged at warn; every marked set still loads for the locales it lists, as an unmarked set would, and every other object still seeds. Identical copies of one set (a package's datasets merged twice) count once; an upgrade that changed a package's marked set leaves two sets on the replay list until the process restarts.
24+
- A load with no locale (package apply, draft publish, an install no rung resolved a locale for) loads every dataset, the fallback set included, and warns as before.

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

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,62 @@ dataset wrote: both sets stay resident and queryable, because the switch is
339339
additive and not a migration. Clearing the market you left behind is the
340340
operator's job — to switch locales cleanly, start from a fresh database.
341341

342+
### A Fallback Set — `fallback: true`
343+
344+
A locale that no dataset of an object names gets **none** of that object's
345+
locale-scoped rows. Where the seed is functional rather than decorative — the
346+
standard price book that quotes fall back to — an organization on `ja-JP` would
347+
end up with no price book at all when you ship only a `zh-CN` and an `en` set.
348+
Mark one set `fallback: true` and it also loads for every locale no other set
349+
of the object names:
350+
351+
```typescript
352+
defineSeed(PriceBook, {
353+
locale: ['zh-CN'],
354+
records: [{ name: '标准价格表' }],
355+
});
356+
357+
defineSeed(PriceBook, {
358+
locale: ['en', 'en-US'],
359+
fallback: true, // also loads for ja-JP, es-ES, … — any locale no PriceBook set names
360+
records: [{ name: 'Standard' }],
361+
});
362+
```
363+
364+
| Resolved locale | `PriceBook` rows loaded |
365+
|:---|:---|
366+
| `zh-CN` | the `zh-CN` set |
367+
| `en`, `en-US` | the `en` set (its own locales) |
368+
| `ja-JP`, `es-ES`, … | the `en` set, as the fallback |
369+
| none (package apply, draft publish, an unresolved install) | both sets, with the usual warning |
370+
371+
The rules:
372+
373+
- **The fallback set lists its own locales.** `fallback: true` on a dataset with
374+
no `locale` is refused when the seed is parsed: an unscoped dataset already
375+
loads for every locale, so it cannot also be the set that loads only when no
376+
other set matches. Write the locales the set is in and keep the marker.
377+
- **A set with no `locale` does not count as a match.** It is locale-neutral: it
378+
loads beside whichever set is chosen, and the fallback still fills in.
379+
- **Matching is per object**, case-insensitive and otherwise exact, as above. A
380+
`ja-JP` set of some *other* object does not stop the price book's fallback.
381+
- **`env` is applied first.** A set `env` scoped out of the load neither matches
382+
nor falls back.
383+
- **At most one fallback set per object in a load.** Two different sets of one
384+
object both marked `fallback: true` leave no single choice, so only the
385+
fallback choice is refused: no marked set fills in for a locale no set lists,
386+
and the load's error (also logged at warn) names the object. Every marked set
387+
still loads for the locales it lists, exactly as an unmarked set would, and
388+
every other object still seeds. Identical copies of one set — the same
389+
package's datasets merged twice — count once. Two versions of one package
390+
whose marked set changed are two sets: an upgrade keeps the earlier
391+
version's datasets on the per-organization replay list until the process
392+
restarts, so until then an organization on an unlisted locale gets no
393+
fallback for that object.
394+
395+
The loader logs, at info, each fallback set it loaded and the locale it filled
396+
in for. Datasets without the marker load exactly as before.
397+
342398
<Callout type="info">
343399
**Where the loading locale comes from.** On the normal boot path your stack
344400
supplies it: the runtime reads your app's `i18n.defaultLocale` and passes it to
@@ -801,7 +857,9 @@ When the same records need different display strings per language, author both
801857
datasets and scope each with `locale`. Selecting between them in application
802858
code instead bakes the choice into your build output, so shipping another
803859
market means another build. Neither approach removes what the market you left
804-
behind already wrote — see [Locale Scoping](#locale-scoping).
860+
behind already wrote — see [Locale Scoping](#locale-scoping). Mark one set
861+
`fallback: true` so a market you did not author still gets functional rows —
862+
see [A Fallback Set](#a-fallback-set--fallback-true).
805863

806864
### Leave `mode` unset for data the customer owns
807865

@@ -842,6 +900,7 @@ function defineSeed<
842900
columns?: { [field: string]: { applyOn?: 'create' | 'always' } }; // per-column write policy; default: 'always'
843901
env?: Array<'prod' | 'dev' | 'test'>; // default: ['prod','dev','test']
844902
locale?: string[]; // BCP-47 tags; omitted = every locale
903+
fallback?: true; // also load for a locale no other set of the object names (needs locale)
845904
dependsOn?: string[]; // objects this dataset loads after (see "Load Order")
846905
records: Array<SeedRecord<TObj['fields']>>; // declared fields + injectable system columns
847906
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ Package manifest installed through POST /api/v1/packages (AUTHORING stage; scope
246246
| **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 |
249-
| **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 |
249+
| **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. A locale no dataset of the object names gets none of its locale-scoped rows, unless one is marked `fallback: true` |
250+
| **fallback** | `true` | optional | Marks this locale-scoped dataset as its object's fallback: it also loads for a resolved locale that no other locale-scoped dataset of the same object lists. Requires `locale`: a dataset with no locale already loads everywhere, and the pair is refused. At most one dataset per object in a load may be marked; with two different marked datasets of one object, none is used as the fallback and the load reports the object, while each still loads for the locales it lists, as an unmarked dataset would (identical copies count once). A load with no locale loads it like every other dataset. Omitted, the dataset loads only for the locales it lists. |
250251
| **dependsOn** | `string[]` | optional | Objects (by name) this dataset loads after, for an order no lookup field gives — e.g. a beforeInsert hook that reads another seeded object. Each name adds an edge to the load's dependency graph. The load is refused, writing nothing, when a name is the dataset's own object, is not seeded by another dataset of the same load, or closes a cycle with the other edges. Omitted, the order comes from lookup fields alone. |
251252
| **records** | `Record<string, any>[]` | ✅ | Data records |
252253
| **files** | `Record<string, { contentType: string; size: integer; sha256: string; data: string }>` | optional | Bytes of the package files the records name with `seedFile(path)`, keyed by path. Written by `os build`, which reads each path relative to the package root; the loader stores each one as a file the written record owns. |
@@ -355,7 +356,8 @@ Package manifest installed through POST /api/v1/packages (AUTHORING stage; scope
355356
| **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. |
356357
| **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. |
357358
| **env** | `Enum<'prod' \| 'dev' \| 'test'>[]` | optional (default: `["prod","dev","test"]`) | Applicable environments |
358-
| **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 |
359+
| **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. A locale no dataset of the object names gets none of its locale-scoped rows, unless one is marked `fallback: true` |
360+
| **fallback** | `true` | optional | Marks this locale-scoped dataset as its object's fallback: it also loads for a resolved locale that no other locale-scoped dataset of the same object lists. Requires `locale`: a dataset with no locale already loads everywhere, and the pair is refused. At most one dataset per object in a load may be marked; with two different marked datasets of one object, none is used as the fallback and the load reports the object, while each still loads for the locales it lists, as an unmarked dataset would (identical copies count once). A load with no locale loads it like every other dataset. Omitted, the dataset loads only for the locales it lists. |
359361
| **dependsOn** | `string[]` | optional | Objects (by name) this dataset loads after, for an order no lookup field gives — e.g. a beforeInsert hook that reads another seeded object. Each name adds an edge to the load's dependency graph. The load is refused, writing nothing, when a name is the dataset's own object, is not seeded by another dataset of the same load, or closes a cycle with the other edges. Omitted, the order comes from lookup fields alone. |
360362
| **records** | `Record<string, any>[]` | ✅ | Data records |
361363
| **files** | `Record<string, { contentType: string; size: integer; sha256: string; data: string }>` | optional | Bytes of the package files the records name with `seedFile(path)`, keyed by path. Written by `os build`, which reads each path relative to the package root; the loader stores each one as a file the written record owns. |

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ Seed loader request with datasets and configuration
233233
| **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 |
236-
| **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 |
236+
| **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. A locale no dataset of the object names gets none of its locale-scoped rows, unless one is marked `fallback: true` |
237+
| **fallback** | `true` | optional | Marks this locale-scoped dataset as its object's fallback: it also loads for a resolved locale that no other locale-scoped dataset of the same object lists. Requires `locale`: a dataset with no locale already loads everywhere, and the pair is refused. At most one dataset per object in a load may be marked; with two different marked datasets of one object, none is used as the fallback and the load reports the object, while each still loads for the locales it lists, as an unmarked dataset would (identical copies count once). A load with no locale loads it like every other dataset. Omitted, the dataset loads only for the locales it lists. |
237238
| **dependsOn** | `string[]` | optional | Objects (by name) this dataset loads after, for an order no lookup field gives — e.g. a beforeInsert hook that reads another seeded object. Each name adds an edge to the load's dependency graph. The load is refused, writing nothing, when a name is the dataset's own object, is not seeded by another dataset of the same load, or closes a cycle with the other edges. Omitted, the order comes from lookup fields alone. |
238239
| **records** | `Record<string, any>[]` | ✅ | Data records |
239240
| **files** | `Record<string, { contentType: string; size: integer; sha256: string; data: string }>` | optional | Bytes of the package files the records name with `seedFile(path)`, keyed by path. Written by `os build`, which reads each path relative to the package root; the loader stores each one as a file the written record owns. |

0 commit comments

Comments
 (0)