Repository navigation
Commit b55d6ab
fix(service-settings): the settings manifest list serves a sourced select's options, the table the save judges against (#30568)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgM7Q68LNSRHwuQMpf4XmEdG)_
domain:server#4 · os-bill · session_01Utp6CZMkHvuDeVYgTD73qF
## 维护者速读
- **改了什么:** 设置清单接口(`GET /api/settings`,以及服务内的 `getManifest` /
`listManifests`)现在给「默认语言」这类由运行时来源决定选项的下拉框,返回和单个命名空间页面、和保存校验同一份选项(部署实际支持的语言),不再返回清单里写死的四种;spec
的说明同步写明这个例外。
- **为什么改:** 上一张卡让「默认语言」页面和保存都改读部署语言列表,但设置总览和 SDK
读的清单接口还在说老四种,读清单的人看到的表和保存时真正判定的表不一致。
- **风险与回滚:** 不收窄(`Clause-②: no`):保存接受什么、拒绝什么一点没变,只是清单如实说出来;没有 i18n
服务的组合仍返回原来四种;登记的清单对象本身不被改动。回滚即撤本 PR。
- **先看:** `packages/services/service-settings/src/settings-service.ts` 里
`getManifest` / `listManifests` 改为走 `servedManifest`
的两处;`settings-routes.ts`
清单路由传请求语言的一行;`packages/spec/src/system/settings-manifest.zod.ts` 中
`valueDomain` 说明新加的一段。
- **两分钟验证:** `pnpm --filter @objectstack/service-settings exec vitest
run --maxWorkers=2 src/localization-locale-options.test.ts`,预期 15
条全绿,其中「the manifest list serves the table the namespace read serves and
the save judges against」一条。
- **需要你做的:** 无,席位落地。
Fixes #30455
Clause-②: no — the manifest list now states the table the save already
enforces; nothing a caller sends is refused differently.
Metadata-protocol: none
## What changes
**One resolution for every manifest read (`settings-service.ts`).** PR
#30446 added `servedManifest`, which replaces a sourced key's `options`
with its option source's answer, and only the namespace read
(`getNamespace`, `GET /api/settings/:namespace`) went through it.
`getManifest()` and `listManifests()` returned the registered manifest,
so `GET /api/settings` served `localization.locale`'s declared four
(`en-US`, `zh-CN`, `ja-JP`, `es-ES`) while the save judged the i18n
service's list.
- `getManifest(namespace, display?)` and `listManifests(ctx?, display?)`
now return `servedManifest(reg, namespace, {}, display)`: no values in
effect are passed, so the source answers the options a write is judged
against (no stored-value spelling or "no longer offered" entry, which
belong to a page). A namespace with no source, or a source with no
answer, is returned as the registered object itself, unchanged identity.
- The `display` argument is optional; existing callers
(`localization-currency-lock.ts`, `cloud-connection`
`runtime-config-plugin.ts`, `plugin-security`
`upgrade-impact-report.ts`) compile and behave as before for every
unsourced namespace.
- `GET /api/settings` passes the request's language (`requestLocaleOf`,
the namespace read's helper), one line.
- `SettingsOptionSource`'s docblock (`settings-service.types.ts`) names
the manifest reads among the moments a source is asked.
**Spec (`packages/spec/src/system/settings-manifest.zod.ts`, TSDoc
only).** The `valueDomain` docblock said a select without `valueDomain`
keeps `options` as its exhaustive save boundary. It now names the
runtime option source as the other boundary mover: where a source
answers, its options are what a write is judged against and what every
manifest read serves; the declared `options` are the fallback; it is a
runtime registration, not an authorable key. No `.describe()` string
changed, so no generated artifact moved (`check:generated`: 14 of 14 up
to date after a spec build).
## Tests
`localization-locale-options.test.ts` (real `LiteKernel` boot, real
settings routes), one new case and one adjusted:
- **New:** with the i18n list `['en', 'zh-CN', 'fr-FR', 'vi-VN']` and
`fr-FR` in effect, `GET /api/settings`'s `localization.locale` options
equal the namespace read's served options and `getManifest` / in-process
`listManifests` answer the same; every listed value saves 200, and the
declared `ja-JP` the list leaves out is refused `invalid_option` with
`constraint.allowed` equal to the listed values.
- **Adjusted:** the first case asserted `getManifest` returns the
declared four while a source answers. It now asserts that once the
source has no answer (`[]`), `getManifest` is the declared four again,
which is what proves the registered manifest was never changed.
Ablation through `scripts/ablation-replace.mjs`: `listManifests` made to
return `reg.manifest` ⇒ the new case red, 14 others green; restored,
blob equal to `HEAD`, `git diff HEAD` empty.
## Acceptance notes
- `getManifest` is now a served read like the namespace read. No caller
in the tree needs the declared table from it: the one in-package caller
(`registerLocalizationCurrencyLock`) only probes that the namespace
exists.
- `listManifests` asks each namespace's sources before the permission
filter; only `localization.locale` has one today, and a source is a
synchronous in-memory read.
## Verification
All at head `1b5ca0e2` (the branch with `origin/main` 86ae2ca merged),
after `pnpm install --frozen-lockfile` (exit 0) and a full build (`turbo
run build --filter='!@objectstack/docs'`, 119/119, under the verify
lock):
- `pnpm --filter @objectstack/service-settings test`: 69 files, 1172
passed; `typecheck`: exit 0 (both before the merge; the merged commits
touch neither this package nor its dependencies' sources this diff
reads).
- `pnpm --filter @objectstack/spec build` exit 0, then
`check:generated`: 14 of 14 artifacts up to date.
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 83 families from the change set;
each run with its exit recorded before any pipe: 83 of 83 exit 0.
`--ran`: 83 derived, 83 run, 0 NOT-MEASURED, exit 0.
- `pnpm lint`: exit 0.
- Full dogfood: not run. The title carries no `!` and `Clause-②` carries
no `(narrowing)` arm.
- CI check-runs: not yet reported at opening.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CZMwT3iajiQDWrXgCn)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1756666 commit b55d6ab
6 files changed
Lines changed: 95 additions & 14 deletions
File tree
- .changeset
- packages
- services/service-settings/src
- spec/src/system
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
129 | 166 | | |
130 | 167 | | |
131 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
276 | | - | |
277 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
278 | 279 | | |
279 | 280 | | |
280 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1572 | 1572 | | |
1573 | 1573 | | |
1574 | 1574 | | |
1575 | | - | |
1576 | | - | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
1577 | 1582 | | |
1578 | 1583 | | |
1579 | | - | |
| 1584 | + | |
1580 | 1585 | | |
1581 | 1586 | | |
1582 | 1587 | | |
| |||
1605 | 1610 | | |
1606 | 1611 | | |
1607 | 1612 | | |
1608 | | - | |
1609 | | - | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
1610 | 1619 | | |
1611 | | - | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
1612 | 1623 | | |
1613 | 1624 | | |
1614 | 1625 | | |
| |||
1742 | 1753 | | |
1743 | 1754 | | |
1744 | 1755 | | |
1745 | | - | |
1746 | | - | |
1747 | | - | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
1748 | 1763 | | |
1749 | 1764 | | |
1750 | 1765 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
503 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
504 | 506 | | |
505 | 507 | | |
506 | 508 | | |
| |||
510 | 512 | | |
511 | 513 | | |
512 | 514 | | |
513 | | - | |
| 515 | + | |
| 516 | + | |
514 | 517 | | |
515 | 518 | | |
516 | 519 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
502 | 513 | | |
503 | 514 | | |
504 | 515 | | |
| |||
0 commit comments