fix(client): 把 tests/integration/ 纳入 tsc,并把 discovery 断言改到真实存在的表面 (#5544) - #5565
Merged
Merged
Conversation
…ertions at the surface that exists `packages/client/tests/integration/01-discovery.test.ts` was read by neither gate: `tsconfig.test.json`'s `include` stopped at `src/**/*` and no `exclude` anywhere named the file (the #5476 shape — outside every program, not inside an excluded region), while the regular `vitest.config.ts` excludes `tests/integration/**` because the suite needs a live server. Two channels, both blind, and the suite had drifted onto a `client.discovery` property `ObjectStackClient` does not have. - `tsconfig.test.json`: `include` gains `tests/**/*`. The vitest split is untouched — compiling the file does not run it, and the suite still needs the external server its README describes. tsc is the gate that works without one. - `01-discovery.test.ts`, all three errors the inclusion surfaces: - TC-DISC-004 read `client.discovery`, which never existed on the class (TS2339 x2). The payload lives on the private `discoveryInfo` field, read here through the bracket-notation escape hatch exactly as this package's `src/client.hono.test.ts` already reads it. No public API was invented for the suite. The case also now asserts `routes` is populated — the thing "Route Resolution" is named for, and what `getRoute()` steers every later call with — so assertion strength goes up, not down. - TC-DISC-002's `discovery.apiName.length` (TS18048) is reached optionally and asserted, per #5449's convention in this package: a missing value fails `toBeGreaterThan` rather than being waved through by a `!` or a `?? ''`. Which KEY that assertion should name is a producer-side contract question, not a test's to settle — metadata-protocol emits the deprecated `apiName` and no `name`, the runtime dispatcher emits `name` and no `apiName` — so the spelling is left alone and the evidence is recorded on #4828. Reverse verification, both directions predicted before running: restoring the old assertions under the new `include` reports exactly the 3 original errors; restoring the old `include` as well makes them vanish — rolling this change back does not go red, it goes BLIND, which is the defect being fixed. Fixes #5544 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016FNvXhtSdnEGEfLEsMmvxh
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckNo hand-written docs reference the 0 changed package(s). ✅ |
baozhoutao
marked this pull request as ready for review
August 5, 2026 18:35
baozhoutao
enabled auto-merge
August 5, 2026 18:35
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.
Fixes #5544
前提复核(先证后改)
在合入 #5546 之后的
origin/main@229d29ea4上逐条复核,issue 的前提完全成立:packages/client/tsconfig.test.json的include停在["src/**/*"],全仓没有任何exclude指名tests/integration/—— 是packages/metadata-core/test/types.test.ts的@ts-expect-error是幽灵检查:文件在include: ["src/**/*"]之外,没有任何 exclude 指向它 #5476 那种「在所有 program 之外」的形状,不是@ts-expect-error退役 pin 在packages/spec里是幽灵检查:tsconfig 把**/*.test.ts排除出唯一的tsc --noEmit#5286 那种「落在排除区里」。tests/**/*纳入编译,量到的就是 issue 列的那 1 文件 / 3 条:@ts-expect-error(grep为空),PINS_CHECKED / PHANTOM_PIN_DEBT 不受影响。改了什么
1.
tsconfig.test.json的include纳入tests/**/*,并把配置头部那段「tests/integration/不在任何 tsconfig 里,留给 #5544」的注释改写成现在的事实。运行通道一个字没动:
vitest.config.ts仍然排除tests/integration/**,test:integration仍然走vitest.integration.config.ts、仍然需要 README 里那台外部服务器。让 tsc 读它,不等于让 CI 跑它 —— 两条通道里,只有 tsc 这条在没有服务器时也能工作。2. 3 条错误全修,该文件不进 debt 台账。
client.discovery在ObjectStackClient上从来没存在过(git log -S查不到任何时期的公开discoverygetter)。发现结果存在私有的discoveryInfo字段上,本 PR 用同包src/client.hono.test.ts:158/165已经在用的方括号读法读它 —— 那两行今天就在编译且是干净的(该文件在台账里的 2 条是 objectqlregisterObject的参数标成 schema 的 OUTPUT 类型(z.infer),合法的作者态字面量一律 TS2740 —— 这是 spec/client 两份测试层欠账的同一根因 #5543 的z.infer家族,与此无关)。没有为这个死套件新增任何公开 API,遵守裁定。routes已填充 —— 那正是getRoute()用来路由后续每一次调用的东西,也是这个用例名字的含义。@ts-expect-error不止 spec:@objectstack/client也有 1 处落在 tsconfig 排除区内(全仓横扫结果) #5449 定下的约定改成可选链断言 —— 值缺失时由toBeGreaterThan判红,而不是用!或?? ''兜过去。一个刻意没做的改动(附证据)
apiName在 spec 里被标注为 deprecated(protocol.zod.ts:118-127,canonical 是name)。看上去应该顺手把断言改写成name,但两个 discovery 生产者的拼法是相反的:packages/metadata-protocol/src/protocol.ts:2509的getDiscovery()只发apiName,不发name;packages/runtime的getDiscoveryInfo()只发name—— 同仓packages/runtime/src/http-dispatcher.root.test.ts:38的注释原话就是 "getDiscoveryInfo returns 'name' not 'apiName'"。该套件跑在一台外部服务器上,本单无法证伪它背后是哪个生产者;而在消费者侧写
discovery.name ?? discovery.apiName正是契约优先原则禁止的宽松兜底。所以断言的键原样保留,只修类型错误,并把这份证据补到已有的 #4828(它的决策点 4 正是name必填 vs 生产者不产出),没有另开重复单。反向验证(方向先判后跑,两个方向都对上了)
tests/前缀错误数 = 0值得写明:这条改动回滚不会变红,而是变瞎。第二行才是这个 issue 的本体 —— 一个既不被 vitest 跑、也不被 tsc 读的文件,可以对着一个不存在的属性断言好几个月而全绿。
验证
test-typecheck-debt.json未改动(仍是 3 文件 / 6 条 #5543 家族),该集成文件零错误、不入台账。集成套件本身仍能被vitest list --config vitest.integration.config.ts正常收集到 4 个用例;常规vitest list里它依然是 0 命中(排除关系未变)。changeset
无 changeset,请打
skip-changeset标签。 本 PR 只改一个 tsconfig 的include与一个从未被任何通道执行过的测试文件,不发布任何包、不改变任何运行时行为 —— 与同包 #5546(PR 走的正是 skip-changeset 路径)同型。界外发现
packages/client/vitest.integration.config.ts的test.poolOptions在 Vitest 4 已被移除 —— 「集成测试串行跑」这条声明现在不生效(vitest 只打一条 DEPRECATED 警告) #5564(观察类,finding,未认领):packages/client/vitest.integration.config.ts的test.poolOptions在 Vitest 4 已被移除,vitest 只打一条 DEPRECATED 警告 —— 注释声明的「集成测试串行执行以避免竞态」实际没有生效。全仓孤例。因该套件无自动通道执行,今天无人可踩,故未修入本 PR。apiName/name生产者分裂的证据。packages/spec/authorable-surface.base.json在构建依赖时被gen:schema重写(baseRev 推进)—— 已 revert,未混入本 PR;该现象已由check:authorable-surface在--check模式下也会重写authorable-surface.base.json—— 一次纯核验会改工作区,且任何无关 PR 都能因此静默推进删除门的锚点 #5358 / os-regen 驱动指示的gen:schema在 merge 未 commit 时运行,会把 authorable-surface 锚点倒退回旧 merge-base —— 生成器写入、门全绿、静默撤销 main 的锚点推进 #5370 覆盖,不另开单。🤖 Generated with Claude Code
https://claude.ai/code/session_016FNvXhtSdnEGEfLEsMmvxh
Generated by Claude Code