Repository navigation
Commit dfc6bbf
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
- .changeset
- content/docs
- data-modeling
- references
- api
- data
- kernel
- packages
- metadata-protocol/src
- runtime/src
- spec
- authorable-surface
- liveness
- state-counts
- src/data
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
342 | 398 | | |
343 | 399 | | |
344 | 400 | | |
| |||
801 | 857 | | |
802 | 858 | | |
803 | 859 | | |
804 | | - | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
805 | 863 | | |
806 | 864 | | |
807 | 865 | | |
| |||
842 | 900 | | |
843 | 901 | | |
844 | 902 | | |
| 903 | + | |
845 | 904 | | |
846 | 905 | | |
847 | 906 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
| 249 | + | |
| 250 | + | |
250 | 251 | | |
251 | 252 | | |
252 | 253 | | |
| |||
355 | 356 | | |
356 | 357 | | |
357 | 358 | | |
358 | | - | |
| 359 | + | |
| 360 | + | |
359 | 361 | | |
360 | 362 | | |
361 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
| 236 | + | |
| 237 | + | |
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
| |||
0 commit comments