You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit dc8479e
Browse filesBrowse the repository at this point in the historyBrowse files
fix(service-settings): a map setting refuses every key when its key source answers an empty list (#31539)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X1nhftM2hZHHvqk2GLFyVTN)_
domain:server#3 · os-project-manager · session_01FEkQ5nBSzc6ktJyjdFcDb3
Fixes#31422
Clause-②: no (narrowing) (a `map` key whose key source answered an empty
list was accepted at both doors and is refused now; on such a host no
key could name what the setting reads)
Metadata-protocol: none
## 维护者速读
- 改了什么:`map` 类设置(`lifecycle.quotas` / `retention_overrides`
等)的键,按该键注册的选项来源判定。来源答了「空列表」时(例如没有任何声明 lifecycle
的对象),以前跳过键校验、任何键都存进去,`OS_*` 也照样生效;现在两道门都拒绝(保存门 `invalid_option`,环境变量门记一条
error 且不生效)。另补两个缺失的形状 pin(数组值、多列 map 里的标量条目),并把 `lifecycle-service.ts`
里仍把这些键叫 `json` 的注释改正。
- 为什么改:#31386 复审的三处非阻塞项。空列表时放行任何键,与「列表里没有的键就拒绝」不一致。
- 风险与回滚:收窄(Clause-② narrowing):只影响「来源答了空列表」的主机上非空的这些 map
值;这时没有任何键能指向清扫会读的对象。空 map 仍可保存;来源没注册或答不出时,仍按声明的选项判定,未声明选项则放行(有对照
pin)。service-settings 全量测试全绿。回滚即还原本 PR。
- 先看:`packages/services/service-settings/src/settings-service.ts` 的
`mapShapeVerdict` 与 `optionTableOf`(新增
`sourced`),`settings-map-shape-30208.test.ts` 末尾两个 `[#31422]` describe。
- 两分钟验证:`pnpm --filter @objectstack/service-settings exec vitest run
src/settings-map-shape-30208.test.ts`,预期 22 条全绿;其中 2 条在 main 上是红的。
- 需要你做的:无,席位落地(收窄,落地前席位做契约复审)。
## What changes
- **`SettingsService.optionTableOf`** (`service-settings`): the option
table now says which table it is, `sourced: true` when a registered
source answered (even with no options), `false` for the declared
fallback. Its other two callers (the option-bearing save branch and the
env override for non-map keys) ignore the new member and are unchanged.
- **`SettingsService.mapShapeVerdict`**: the key column's domain applies
whenever a source answered (`sourced || allowed.length > 0`). The
`allowed.length > 0` gate is kept only for the declared-table fallback:
a key with no source, or whose source could not answer, still admits
every key when it declares none. Both doors call this one verdict, so
the save door (`invalid_option`, "'k' is not a key this setting
admits.") and the env door (one `error` line, the override not in force)
move together. The docblock states the rule.
- **`LifecycleService`** (`objectql`): comment only. The docblock at
~l.1162 now says these keys are `map` specifiers (#30208), `json` before
it.
## Tests
`packages/services/service-settings/src/settings-map-shape-30208.test.ts`,
6 new rows (16 → 22):
- `[#31422] a key source that answered an empty list admits no key`,
over `lifecycleObjectKeySource` on a registry with no lifecycle-declared
object: the save door refuses `{ quotas: { sys_audit_log: 1000 } }` with
one `invalid_option` naming the entry, nothing stored; the env door does
not put `OS_LIFECYCLE_QUOTAS` in force (one error line). Controls: an
empty map still saves; a source that could not answer (no registry)
leaves the declared table, which declares no key, so any key passes.
- `[#31422] the two shape misses #30208 left unpinned`: an array value
is `invalid_type` (`not_a_map`, "…not an array…"); a scalar entry in the
several-column `retention_overrides` is `invalid_shape` (`not_an_entry`,
naming the entry and `maxAge, expireAfter`). Both are coverage pins and
green on main.
## Acceptance notes
- **Responsibility.** The three non-blocking nits of PR #31386's
contract review (6717755004), recorded on #30208 (6717781477).
- **Narrowing, stated.** On a host whose lifecycle key source answers no
objects, a non-empty `quotas` / `retention_overrides` value, saved or in
`OS_LIFECYCLE_*`, was accepted and is refused now. With no
lifecycle-declared object, no key could name an object the sweep reads,
so nothing that worked stops working. `quota_defaults`' source
(`lifecycleClassKeySource`) never answers empty.
- **Noted, not changed (out of the claim's surface).** The
option-bearing save branch and the env override for non-map keys keep
their own `allowed.length > 0` gate, so a select key whose registered
source answers an empty list still admits any value. Same shape as item
1, on a different family; not filed.
- **Worktree.** The claim names `objectstack-issue-31422`; this ran in
the chain's existing worktree `objectstack-issue-31317` on the same
claimed branch, cut from fresh `origin/main` after #31480 merged.
## Verification
Head `66137fbc` (base `f4b1f9ee`, fresh `origin/main`, which holds
#31480's merge `ec297534`).
<details><summary>Red first, fix, suites</summary>
- The new pins on main's source: Tests 2 failed | 20 passed (22), the
save row (`expected 200 to be 400`) and the env row (`expected 'env' not
to be 'env'`); the controls and the two coverage pins green. With the
fix: 22 passed.
- `@objectstack/service-settings` vitest: Test Files 73 passed (73),
Tests 1407 passed (1407).
- `typecheck` for `@objectstack/service-settings` and
`@objectstack/objectql`: exit 0. `eslint --no-inline-config
packages/services/service-settings packages/objectql/src/lifecycle`:
exit 0.
</details>
<details><summary>Ablation (ablation-replace, restored to
HEAD)</summary>
- `settings-service.ts`: `const admitsKey = sourced || allowed.length >
0 ?` made to ignore `sourced` (`(sourced && String("ABL31422").length <
0) || …`). Mutation landed (anchor 1 to 0, blob 07699b2 to
e0d112878a7f). Pin: Tests 2 failed | 20 passed (22), the same two rows.
Restored: blob == HEAD (07699b2), `git diff HEAD` empty. The suite
reads its own `src/`, so no dist leg.
</details>
<details><summary>Derived gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at `7d88feba`: 70 commands, each run with
`timeout 1500` and stdin from `/dev/null`, exit codes captured before
any pipe, after a `@objectstack/runtime` closure and
`@objectstack/service-settings` build. First pass: 69 exit 0;
`check-adr-0087-registration --base origin/main` exit 1, the narrowing
changeset had no ADR-0087 disposition. Fixed in `66137fbc` (`adr-0087:
not-required (no-migration-prescription)`), then the ten changeset,
citation and closing-keyword gates re-run at `66137fbc`: all exit 0.
`dispatch-gates --ran`: 70 derived, 70 run, 0 NOT-MEASURED, 0 UNRUN. Not
run locally (CI): `test:repo`, dogfood shards, type-check lanes.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5nBSzc6ktJyjdFcDb3)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(service-settings): a `map` setting refuses every key when its key source answers an empty list
6
+
7
+
Clause-②: no (narrowing)
8
+
Metadata-protocol: none
9
+
10
+
<!-- adr-0087: not-required (no-migration-prescription) no key of any schema is added, removed or re-shaped and no stored row is read differently: the narrowing is one runtime refusal at the settings save door and the OS_* env door, for a map key on a host whose key source answers no keys, and its remedy is to clear the value, so there is nothing for `objectstack migrate meta` to rewrite. A value already stored is not re-judged. -->
11
+
12
+
A `map` specifier's keys are judged against the key's option source (`registerOptionSource`), the list the running system answers, such as the lifecycle-declared objects for `lifecycle.quotas` and `lifecycle.retention_overrides`. When that source answered an empty list, the key check was skipped and any key was saved and put in force from `OS_*`. It now refuses each key with `invalid_option` at the save door and logs the override as not in force at the env door, as for any key the list does not hold. This narrows what is accepted: on a host with no lifecycle-declared object, a non-empty value for those keys, saved or set in `OS_LIFECYCLE_*`, was accepted before and is refused now; no such key could name an object the sweep reads. An empty map still saves. A key whose source could not answer, or which has no source, is still judged against its declared options and admits any key when it declares none.
0 commit comments