fix(runtime,spec): 让 @objectstack/runtime 的 src 真正被 tsc 读 —— 修 25 条并接进 turbo typecheck (#4311) - #5045
Merged
Merged
Conversation
…进 turbo typecheck (#4311) Part of #4311 (第一片:@objectstack/runtime 的 src 层)。 - packages/runtime: 新增 `typecheck: tsc --noEmit`,清掉实测的 25 条错误 (18 条 TS6133 未用形参/导入,7 条 TS2339 真契约缺陷)。 - packages/spec: `EngineSchemaRegistryView` 补齐六个 package-lifecycle 成员 —— SchemaRegistry 一直实现、三个包一直在调,#4404 落契约时漏declare, 因为 runtime 没有 typecheck 所以没人发现。 - scripts/check-type-check-coverage.mjs: 删 runtime 的 DEBT 条目(毕业要求, 否则 RECONCILED 不变式失败),并订正 TEST_DEBT 里已失真的一句注释。 覆盖率 61/77 → 62/77,DEBT 16 → 15 个包。TEST_DEBT 未被激活(tsconfig 仍 exclude 测试文件,220 条留给后续切片)。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018iARDqtrhQgz6fVHDeDkbQ
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 113 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
xuyushun441-sys
marked this pull request as ready for review
August 4, 2026 00:48
xuyushun441-sys
enabled auto-merge
August 4, 2026 00:48
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.
Part of #4311 — 第一片:
@objectstack/runtime的 src 层(维护者已裁决按包切片)。照 #4855 / PR #5002 的毕业模式:修完 → 接线 → 同 PR 删台账条目。问题
scripts/check-type-check-coverage.mjs的 DEBT 台账把@objectstack/runtime记作:COVERED不变式接受「声明了typecheckscript」或「有一条带实测数的 DEBT 条目」,runtime 走的是后一条 —— 闸门诚实地记录了这个包没被检查,但记录不等于执行。runtime 是 dispatcher / domain handlers / action 执行的所在地,是本仓最重的运行时包之一,它的src/至今没有任何tsc读过。实测:18 → 25,而且「noise only」是错的
台账冻结于
b07d829(2026-07-31);我在最新 main 上实测 25 条。漂移方向与 #4855(12 → 14)一致,再次印证「用记录顶替执行,记录就会漂」。但比数字更重要的是分类被记错了:
7 条 TS2339 全部落在
src/domains/packages.ts,是一处真实的契约缺陷,不是噪音。真缺陷:
EngineSchemaRegistryView少声明了六个成员#4404 (#4251 B3) 把
objectql槽的契约落地为IObjectQLEngine/EngineSchemaRegistryView,文档写的是「the eight members reached through theobjectqlslot from outside the engine package」。这句话在写下时就不成立:SchemaRegistry(packages/objectql/src/registry.ts:1576-1712)一直实现着这六个成员;runtime的/packagesdomain handler(整个/packagesREST 家族的 owner)、metadata-protocol的installPackage/updatePackageManifest原语(protocol.ts:9706,9754)、service-package的 hydration(index.ts:213,243)。为什么没人发现:这三个包当时(和现在)都没有
typecheck—— runtime 与 metadata-protocol 都在 DEBT 台账里。契约的收窄之所以能编译通过,只是因为没有任何 tsc 读过调用方。这正是 #4311 议题正文里那句话的字面重演:「这类收窄本应让传旧形状的调用编译失败 —— 而它们至今全绿,因为没有任何 tsc 读过这些文件」。修在生产者,不在消费者
按契约优先(Prime Directive #12),修法是给 spec 的契约补齐声明,而不是在 runtime 侧写
(registry as any).installPackage:参数/返回类型沿用该文件既有政策(engine-local 类型
InstalledPackage/ObjectStackManifest一律写unknown,spec 不依赖 engine 包),成员写成 required 而非 optional —— 与该文件已写明的立场一致:「this contract describes THAT engine — the slot's actual occupant — not a hypothetical minimal one」。ObjectQL implements IObjectQLEngine的implements校验仍然通过(见下方 objectql 的 typecheck 绿)。零运行时改动:没有任何实现、调用点或响应形状移动;只是让声明追上了一直存在的实现。
另外 18 条 TS6133 —— 逐条说明,没有一条是「加
!闭嘴」本片一个
!也没有加,一个?.也没有加(bang_justifications_count = 0)。TS18048 possibly-undefined 那一类全部在 test 层(TEST_DEBT 的 220 条),本片不碰。src 层的 18 条全是未用符号,三种处理:action-execution.ts13 个导出纯函数的首参deps_depsreconcileActionRegistrations(:1172)本来就写着_deps—— 这是文件内既有先例,不是我发明的写法。删参会改导出函数签名,而调用它们的测试是按位置传参且不受类型检查,静默错位风险远大于收益。domains/auth.ts的path/method/body_path/_method/_body+ 补注释/auth不再按子路径分流,而是把context.request整个交给 auth service(authService.handleRequest(context.request)),由它自己路由 —— 三个参数是那次删除的残留。保留形参是为了与其它 domain handler 的位置签名对齐(createAuthDomain就是按位置传的)。domains/meta.ts的import * as actionExecgrep仅命中 import 行本身)。action-execution.ts顶层无副作用(只有函数声明和一个模块级Set),删除不改变任何加载行为。domains/mcp.ts的toMcpWebRequest(deps, …)_deps接进强制执行
外加删掉
check-type-check-coverage.mjs里 runtime 的 DEBT 条目(毕业动作;不删则RECONCILED不变式失败)。覆盖率 61/77 → 62/77,DEBT 16 → 15 个包。
turbo.json与lint.yml未改动(RUNNABLE不变式已在管它们)。TEST_DEBT 未被本片激活 —— 已确认
runtime 的
tsconfig.json仍然exclude: ["node_modules","dist","**/*.spec.ts","**/*.test.ts"],本 PR 没有动它。所以接上tsc --noEmit只让src/**/*进入检查,66 个测试文件的 220 条错误仍然被TEST_DEBT条目冻结着,TESTS_COVERED不变式照常成立(上面的实跑输出里 test 层仍是 21 个包 / 652 文件 / 2243 条,与 main 逐字相同)。这正是台账机制既有约定所要求的:DEBT 是「src 不检查」,TEST_DEBT 是「src 检查、测试被藏」,两者独立,src 毕业不牵动 test 层。只订正了 TEST_DEBT 条目里一句因本 PR 而失真的注释(「Also in DEBT: its src does not check either.」→ 记明 src 已在 #4311 毕业),实测数字
tests: 66, errors: 220原封未动 —— 台账的诚实性要求删掉已经变假的话,而不是让它留在那里烂掉。反向验证
在
src/domains/packages.ts里给registry.enablePackage(id)塞一个多余实参,走真实 CI 入口:值得注意的是:判红靠的正是本 PR 新加的那条声明 —— 说明补进契约的六个成员是承重的,不是装饰(与 #5002 里
: Flow优于as const的论证同形)。revert 后:
decc78ab0624d82d与注入前那次绿跑的 turbo hash 逐字相同 —— 状态被精确还原,绿不是陈旧缓存蒙对的(照搬 #5002 的证法)。测试与门禁
零行为改动:所有修改要么是类型声明补齐,要么是未用符号改名/删除。1131 个测试逐个通过,数量与 main 一致。
改动范围
scripts/check-type-check-coverage.mjs—— 根目录共享文件,只删 runtime 的 4 行 DEBT 条目 + 改 TEST_DEBT 的一句注释。闸门语义零改动。packages/spec/src/contracts/objectql-engine.ts—— 超出「只动 runtime」的落点,但按 Prime Directive Add comprehensive test suite for Zod schema validation #12 这条缺陷的生产者就在 spec;在消费者侧as any会把一个真实的契约漏声明永久藏进 runtime。.changeset/runtime-typecheck-wired.md——@objectstack/specpatch(导出接口有新增成员,.d.ts对消费者可见);runtime 侧纯类型标注 + dev script,不发版。留给后续切片的
tsconfig的 exclude。/packages的 enable/disable/get/uninstall 四条路由直接写 in-memory registry,而 install/update 已经优先走 protocol service(持久化到sys_packages)、只在服务缺席时回落 registry。四条路由的持久化对称性看着像缺口,但修它要改运行时行为,超出「类型修复不得改变测试行为」的边界,本 PR 不碰。Generated by Claude Code