From c7ad2716f1634c007a711fa3db0e6b50e7bcbb48 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 7 Aug 2026 12:30:53 +0000 Subject: [PATCH] =?UTF-8?q?docs(adr-0122):=20D6=20=E7=82=B9=E6=98=8E?= =?UTF-8?q?=E5=90=8C=E6=9E=84=20pin=20=E7=9A=84=E7=BC=96=E8=AF=91=E6=9C=9F?= =?UTF-8?q?=E8=AF=81=E6=98=8E=E8=90=BD=E5=9C=A8=E5=93=AA=E4=B8=80=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ADR-0122 D6 原文写「tsc proves the exemption on the same run that type-checks the package」。字面不准确:`packages/spec` 的 `typecheck` 是两步 (`tsc --noEmit && pnpm check:test-typecheck`),第一步走 BUILD 配置,而 `tsconfig.json` 排除了 `**/*.test.ts` —— pin 文件 `type-alias-convention.pin.test.ts` 正是 `*.test.ts`,根本不在裸 tsc 的 program 里。 实测(给被钉同构的 `MCPApprovalPolicySchema` 加 `.default('never')`,Iso22): 裸 tsc --noEmit ................ EXIT=0 pnpm check:test-typecheck ...... EXIT=1 src/type-alias-convention.pin.test.ts: 1 type error(s) in a file the ledger does not cover. 基线两步皆 EXIT=0;test-project 的原始报错为 `src/type-alias-convention.pin.test.ts(282,28): error TS2344: Type 'false' does not satisfy the constraint 'true'.`(282 行即 Iso22,点名该 schema)。 结论未变:门咬得住,且咬在 debt ledger 不覆盖的文件上(该 pin 文件无 `test-typecheck-debt.json` 条目,基线即零错误,新增一个即红)。本次只订正 「哪一步证明」这一处措辞,并把零错误基线这半个保证一并写明。 仅改 ADR 文本。不动 `packages/spec` 的脚本、pin 文件、debt ledger 或任何门禁行为。 Fixes #6183 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_014wsZeReNTqiceBfLb5Pyf5 --- ...122-schema-type-alias-naming-convention.md | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/adr/0122-schema-type-alias-naming-convention.md b/docs/adr/0122-schema-type-alias-naming-convention.md index 2bcc105c32..3320e558ba 100644 --- a/docs/adr/0122-schema-type-alias-naming-convention.md +++ b/docs/adr/0122-schema-type-alias-naming-convention.md @@ -133,10 +133,23 @@ Two alternatives were measured and rejected: about types, and isomorphism rots: add a `.default()` three levels down and an alias silently joins the covered set with no signal. So every exempt schema carries a compile-time assertion that `z.input` and `z.infer` really are the same type, in -`packages/spec/src/type-alias-convention.pin.test.ts`. tsc proves the exemption on the -same run that type-checks the package, and the file goes red — naming the alias — the -day one stops being true. An exemption nobody can state falsely is the only kind worth -having; this is the same instinct as `check:durability-log-level`'s empty baseline. +`packages/spec/src/type-alias-convention.pin.test.ts`. tsc proves the exemption on every +`pnpm typecheck` run, and the file goes red — naming the alias — the day one stops being +true. + +Which of that command's two **steps** proves it is worth stating precisely, because it is +not the obvious one. `packages/spec`'s `typecheck` script is +`tsc --noEmit && pnpm check:test-typecheck`, and the bare `tsc` runs the BUILD config, +whose `**/*.test.ts` exclusion keeps this `*.test.ts` pin file out of its program +entirely. The proof therefore lands in the **second** step, which puts the test layer back +in front of tsc over `tsconfig.test.json` (#5286). Measured, by giving a pinned schema a +`.default()`: the bare `tsc --noEmit` stays at exit 0, and `check:test-typecheck` is what +turns red, naming the file — `1 type error(s) in a file the ledger does not cover`. That +last phrase is the other half of the guarantee: the pin file carries no +`test-typecheck-debt.json` entry, so its baseline on that surface is **zero** errors and a +single new one fails the gate. An +exemption nobody can state falsely is the only kind worth having; this is the same instinct +as `check:durability-log-level`'s empty baseline. **D7 — The backflow gate.** `pnpm check:spec-parsed-alias` (`scripts/check-spec-parsed-alias.mjs`, in lint.yml's `lint` job) requires every bare