Skip to content

test(client): discovery 替身改成真实 /discovery 形状,并本地钉死两处退役拼法 - #6112

Merged
qq9340100 merged 1 commit into
mainfrom
claude/issue-5787-client-discovery-double
Aug 7, 2026
Merged

test(client): discovery 替身改成真实 /discovery 形状,并本地钉死两处退役拼法#6112
qq9340100 merged 1 commit into
mainfrom
claude/issue-5787-client-discovery-double

Conversation

@qq9340100

Copy link
Copy Markdown
Collaborator

Fixes #5787

问题

packages/client/src/client.test.tsconnect() 的 discovery 替身拼了两个任何 producer 都没发过的形状:

capabilities: ['metadata', 'data', 'ui'],
endpoints: {}

两处都是惰性的 —— 该用例只断言 expect(fetchMock).toHaveBeenCalled(),不读 body 的任何键 —— 这正是它们连着躲过两轮退役的原因。这是 #5674 在另一个包里的同族兄弟,按「规则的消费半径」而不是按被改的包复查时发现的。

改法

1. 替身按实测的 producer 输出重塑(client.test.ts)

capability map 用 WELL_KNOWN_CAPABILITY_KEYS 构造而不是手写键表 —— 该常量的 schema 注释明确说了它存在的意义就是防止「手列键」这种漂移,手写一份在词汇增长的当天就会悄悄落后。

2. 新增本地 pin packages/client/src/discovery-double-retired-key.test.ts

对齐 packages/rest/src/discovery-double-retired-key.test.ts(#5674)的形状,保持按包,没有提成跨包 repo 级 gate —— issue 正文明确要求不要默认扩大,而且两个包写替身的方式本来就不同:rest mock 的是协议对象(getDiscovery: vi.fn().mockResolvedValue(…)),client mock 的是线(fetchjson())。单一跨包扫描器无论如何都得同时带两种捕获形态,失败信息还会指向读者当下并不在的那个包。两条本地 pin,各读各包真实使用的形态,是更小也更好读的安排。要不要合并成 repo 级 gate 是维护者的决定,不该作为本次修复的副作用发生。

pin 的诚实边界(写进了 docblock):

验证

pnpm --filter @objectstack/client test —— 20 个测试文件 / 240 个用例全绿(pin 新增 3 条)。
pnpm --filter @objectstack/client typecheck —— tsc --noEmitcheck:test-typecheck 均通过;新 pin 与 client.test.ts不在 test-typecheck-debt.json 里,按该 ledger 的规矩必须零错误,实测零错误(ledger 仍是原来的 3 文件 / 6 错误,未动)。

反向验证(方向为事先预测的「红」,即常规方向): 把退役拼法原样放回 client.test.ts 的替身,pin 的两条否定断言双双转红并点名 client.test.ts,而反空转那条保持绿(证明扫描器仍然匹配到了整个替身population,红不是因为扫了空集):

✓ finds the doubles it claims to police (anti-vacuity)
× no double carries `endpoints` (retired in #4828)
  → expected [ 'client.test.ts' ] to deeply equal []
× no double binds `capabilities` to an array
  → expected [ 'client.test.ts' ] to deeply equal []

随后已还原修复,重跑全绿。

范围

Tests-only,无 changeset(需要 skip-changeset 标签)。没有碰 packages/restpackages/spec 或任何生产代码;apiName 保持原样 —— 它不是缺陷,是 GetDiscoveryResponse已声明的弃用别名,真实 producer 至今与 name 同值双发(protocol 18 移除)。同文件里 meta 面的 mock 未动(#5895 / #5946 刚刚有意重塑过)。

🤖 Generated with Claude Code

https://claude.ai/code/session_01Wbxm29qPKnLf44AbSxizqW


Generated by Claude Code

…y, pin both retired spellings

`packages/client/src/client.test.ts`'s `connect()` double spelled two shapes no
discovery producer has ever emitted:

    capabilities: ['metadata', 'data', 'ui'],
    endpoints: {}

`endpoints` was the dispatcher-only verbatim copy of `routes`, retired by #4828
under ADR-0049; the real producer emits `routes` (`ApiRoutesSchema`, required by
`DiscoverySchema`). `capabilities` is a closed object over the one vocabulary,
one `CapabilityDescriptor` per key (#5672 ruling A) — never a string array, and
the three names it listed are `routes` keys, not capability keys.

Both were inert (the test asserts only that the fetch happened), which is why
they survived two retirements. This is the sibling of #5674 one package over,
found by re-reading the rule's consumption radius rather than the edited package.

The double is now shaped on the measured producer output, with the capability
map BUILT from `WELL_KNOWN_CAPABILITY_KEYS` rather than hand-listed, so it
cannot fall behind the vocabulary.

Adds `packages/client/src/discovery-double-retired-key.test.ts`, a LOCAL pin
mirroring `packages/rest/src/discovery-double-retired-key.test.ts` (#5674) —
per-package, not promoted to a repo-level gate, because the two packages write
their doubles in different forms. It reads both forms `packages/client` actually
uses (a fetch mock's `json` body and a direct `discoveryInfo` assignment), finds
5 discovery doubles across 2 files, and asserts the two negatives.

Tests-only; no changeset.

Fixes #5787

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wbxm29qPKnLf44AbSxizqW
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Aug 7, 2026 2:12am

Request Review

@github-actions github-actions Bot added the size/m label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

No hand-written docs reference the 0 changed package(s). ✅

@github-actions github-actions Bot added the tests label Aug 7, 2026
@qq9340100 qq9340100 added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Aug 7, 2026 — with Claude
@qq9340100
qq9340100 marked this pull request as ready for review August 7, 2026 02:22
@qq9340100
qq9340100 added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit a65ff1c Aug 7, 2026
29 of 30 checks passed
@qq9340100
qq9340100 deleted the claude/issue-5787-client-discovery-double branch August 7, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m skip-changeset PR has no user-facing published change; bypasses the changeset gate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

packages/client 的 discovery 测试替身也拼 endpoints(#4828 退役键)、且 capabilities 拼成数组

2 participants