fix(spec): 上一个 PR 里的保护信封检查是空的 —— 它跳过了 25 个类型里的 24 个(#4001) - #4519
Merged
Conversation
…f 25 types (#4001) The invariant test added one change ago asserted two things about every registered metadata type: that it does not REJECT the ADR-0010 envelope its loader stamps (the hard-422 case), and that it does not silently lose it. The reject half worked — it found `hook` and `datasource` on its first run. The other half did not. It probed each schema with one generic body and asked whether `_packageId` survived. A type whose required fields that body did not supply failed for unrelated reasons, and the assertion returned early. TWENTY- FOUR of the twenty-five types took that early return. Only `field` was ever really checked, and the suite reported green. That is this campaign's own subject matter — a success signal covering an omission — reproduced inside the instrument built to detect it, one change after the ledger recorded the identical lesson about the strictness gate's non-recursive directory walk. A check that skips is indistinguishable from a check that passes. The declaration side is now STRUCTURAL: it walks the schema, unwrapping lazy/pipe/optional/default and expanding unions, and asks whether any resolved object shape declares the key. That needs no valid instance, so it cannot skip. Two guards keep it honest: - a type the walker cannot resolve is a hard FAILURE, not a pass. The walker going quiet is exactly when this test would otherwise stop covering something. - the debt list carries a reverse pin that fails when an entry is fixed, so the list cannot outlive the debt it tracks. What it found: 8 registered types do not declare the envelope, not 1 — `action`, `book`, `field`, `job`, `mapping`, `page`, `translation`, `validation`. Each loses protection metadata on every round-trip today and becomes a hard 422 the day its schema closes. `job` and `book` are closed here; 6 remain listed. Three occurrences now of one pattern, in three different instruments: the ledger gate's non-recursive walk, `strictObject(` not matching the site count, and this early return. Every one was a measuring tool reporting coverage it did not have. The ledger now states the rule it keeps re-deriving: before trusting a green check, make it go red on something you know is there. Verified: spec 282 files / 7141 tests, `tsc --noEmit` clean, all 8 generated artifacts current (the only regeneration is the two envelope key tables), all 15 `check:*` gates green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WnqGjQFQMqd5k81LYV8SCY
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 107 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
marked this pull request as ready for review
August 1, 2026 15:31
This was referenced Aug 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
紧接 #4514。那个 PR 加的不变量测试断言了两件事:每个注册元数据类型不拒收加载器盖的 ADR-0010 信封(硬 422 那一类),以及不静默丢失它。
拒收那一半是有效的——它第一次运行就抓到了
hook和datasource。另一半是空的。
它怎么空的
它用一个通用探针 body 去 parse 每个 schema,再看
_packageId有没有活下来。但一个 schema 如果有探针没提供的必填字段,就会因为无关原因解析失败,断言直接 early return:只有
field真的被检查过。整个套件报绿。这就是这场战役的主题——成功信号掩盖遗漏——出现在为了检测它而建的仪器里,而且就在账本刚刚记下闸门非递归扫描那同一课之后一个改动。
修法:结构式遍历,跳不过去
声明侧改成直接走 schema 结构——拆开
lazy/pipe/optional/default,展开 union——问「有没有哪个解析出的 object shape 声明了这个键」。这个问题不需要构造合法实例,所以不存在「因无关原因失败」的早退路径。
两个护栏让它保持诚实:
它接着找到了什么
不是 1 个,是 8 个未声明信封的注册类型:
action、book、field、job、mapping、page、translation、validation探针版本藏了其中 7 个。每一个今天都在往返中丢保护元数据,且在它的 schema 被收紧那天会变成硬 422。
本 PR 修掉
job和book,清单剩 6 个。一个开始重复的模式
这是同一个模式的第三次,出现在三个不同的仪器上:
data/driver/九个站点隐形strictObject(不算站点 → 「解决了」和「删掉了」同数三个都是测量工具报告了自己并不具备的覆盖度。账本里现在写下了这条反复被重新推导出来的规则:
验证
@objectstack/spec:282 文件 / 7141 用例通过,tsc --noEmit干净book/job两张信封键表)check:*闸门全绿参考
docs/audits/2026-07-unknown-key-strictness-ledger.mdfindings log 第 9 条🤖 Generated with Claude Code
https://claude.ai/code/session_01WnqGjQFQMqd5k81LYV8SCY
Generated by Claude Code