Skip to content

[P2] framework: 66 个包用 tsup 构建、无人做类型检查 —— 实测 18 个包共 380 处 code-tier 错误(#4118 的 framework 侧对应) #4311

Closed

Description

@os-zhuang

framework 侧对应 #4118(那一个针对 objectui)。同一形状的缺口,成因不同、量级已实测。

机制:三层都不做类型检查

层 工具 是否类型检查
build tsup(esbuild) — 66/77 个包 ❌ 只转译
test vitest run ❌ 不做类型检查
CI lint.yml typecheck 作业 ⚠️ 只覆盖 4 个目标

CI 的 typecheck 作业实际只跑这四条:

  • pnpm --filter @objectstack/spec exec tsc --noEmit(lint.yml:240)
  • pnpm --filter './examples/*' run typecheck(:355)
  • pnpm --filter @objectstack/downstream-contract run typecheck(:362)
  • 文档代码块抽取后 tsc --noEmit(:391)

全仓只有 2 个包(downstream-contract、service-datasource)声明了 typecheck script。其余包的 src/ 和测试都不经过任何 tsc。

这与 objectui 的成因不同,值得注意:objectui 的问题是 tsconfig 正确地排除了测试、而没有第二个 tsc 去读它们(#4118);framework 这边连 src 都没人查——因为 tsup 根本不调用 tsc。

实测范围(2026-07-31,main @ 2e836de)

方法:逐包 cd <pkg> && npx tsc --noEmit,按错误码分三层——code-tier(真缺陷)、config-tier(检查本身没配好:TS2591/TS2584 缺 types:["node"]、TS2835/TS2307 模块解析、TS2550/TS6059/TS2347/TS7016)、noise(TS7006 隐式 any 参数、TS6133 未用变量——未配置检查下的严格度噪音,两边都不计)。

77 个包:48 个干净,29 个失败;其中 18 个含 code-tier 错误。

package code-tier config noise 总
driver-sql 241 0 0 241
metadata 31 22 34 87
driver-sqlite-wasm 27 0 0 27
driver-memory 23 0 0 23
cloud-connection 11 2 0 13
observability 11 0 0 11
dogfood 8 3 1 12
service-storage 5 23 14 42
core 3 38 50 91
hono / knowledge-ragflow / service-knowledge 3 各 — — —
spec-monorepo / metadata-protocol / rest / service-analytics / service-automation 2 各 — — —
service-cluster 1 0 0 1

合计:code-tier 380 / config-tier 288 / noise 184。

注意 core(91 总数但仅 3 真错)和 service-storage(42 → 5)——不分层就会把这两个包报成重灾区,实际它们几乎全是 tsconfig 没配好。反过来 driver-sql 的 241 全部是真错。

主导模式:input-vs-output 混淆,正好压在刚收窄的 QueryAST 上

driver-sql 的 241 处集中在 TS2345(123)/TS2353(118),散布 8+ 个测试文件(非单一助手重复):

src/sql-driver-advanced.test.ts(142,50): error TS2345:
  Argument of type '{}' is not assignable to parameter of type 'QueryAST'.
src/sql-driver-advanced.test.ts(151,51): error TS2345:
  Argument of type '{ where: { status: string; }; }' is not assignable to parameter of type 'QueryAST'.

测试把作者态字面量传给要求 object 等 .default() 填充字段的解析后类型。这正是 #4118 指认的 TS2741/TS2739 playbook,只因这里传的是整个对象、报成了 TS2345/TS2353。

时机上值得警惕:#4196 和 #4286 刚刚收窄 QueryAST(移除 FieldNode 对象形态、joins、windowFunctions)。这类收窄本应让传旧形状的测试编译失败——而它们至今全绿,因为没有任何 tsc 读过这些文件。#4118 说的「未检查的测试会被当成证据」在这里是字面意义上的:一个 agent 引用 driver-sql 绿色测试套件来论证 QueryAST 契约,引用的是一份从未被类型系统读过的文件。

发现路径

#4198(退役 waitEventConfig.timeoutMs/.onTimeout)合并 main 后扩跑 tsc --noEmit,service-automation 报 engine.test.ts 缺 resumeAuthority(该属性由 #3822 引入)。核实后确认与那个 PR 无关、且 CI 从不检查该包,遂按 Prime Directive #10 单独立项而非扩大该 PR 范围。

建议

  1. 覆盖率棘轮,沿用仓库已有的最佳治理形态(声明式、带理由、只减不增),对齐 objectui 的 check-type-check-coverage.mjs:每个包要么有 typecheck script 并进 CI,要么带一条 DEBT 条目,记录实测 code-tier 数与 issue 链接。先接入 48 个已干净的包——纯管线改动、零修复成本,且立刻锁死回归。
  2. config-tier 模板:统一的 tsconfig.test.json(noEmit、types:["node"]、显式 lib、模块解析对齐),288 处 config-tier 应当被模板一次性消掉,而不是逐包手改。
  3. 按表烧 code-tier:driver-sql(241)独占 63%,且是单一 playbook(QueryAST 作者态 vs 解析态),适合一次性集中修。

需要拍板的

TS7006(隐式 any 参数,160 处)我按 noise 计,未计入 380。若棘轮打算在测试上启用 noImplicitAny,这 160 处会变成真实工作量——建议单独决策,不要混进本 issue 的基线数字。

Activity

  1. self-assigned this
    on Jul 31, 2026
  2. added
    domain:devx
    on Aug 3, 2026
  3. xuyushun441-sys commented on Aug 4, 2026

    @xuyushun441-sys
    Collaborator

    维护者裁决(2026-08-04):按包切片,#4855 毕业模式;切片表与车道分工如下

    模式(已由 #4855 / PR #5002 验证):每包一单 —— 接 typecheck script → 实测全部错误 → 逐个修(真缺陷单独标注;!/?. 闭嘴式修复必须逐个说明为何该处非空)→ 同 PR 删 DEBT 台账条目(COVERED/RECONCILED 不变量要求)→ 反向验证(注入错误判红,turbo 缓存哈希证明精确恢复)。#4855 单包实测:14 错挖出 1 个真契约缺陷,台账 3 天漂 2 —— 这就是不重测计数、直接毕业的论据。

    切片表(src 层 DEBT,数字为台账冻结值,实施时以实测为准;test 层 TEST_DEBT 另行排):

    包 台账错误数 车道
    runtime 18 cli(本会话)—— 已派,分支 claude/issue-4311-runtime-typecheck
    rest 2 cli(本会话)
    service-cluster / service-automation / service-analytics / service-knowledge / service-settings / service-storage 1/2/3/8/13/42 services 车道 PM
    hono / observability / cloud-connection / knowledge-ragflow 3/11/13/4 归属待锚定(实施前读代码定)
    metadata-protocol / metadata / core 28/87/91 engine 车道 PM
    spec-monorepo 50 spec 车道 PM
    plugin-auth(test 层 124) — identity(本会话),src 清完后排

    各车道 PM:切片属你们车道的,按上述模式自行认领排批,不必等本会话;每单 PR 写 Part of #4311,不写 Fixes —— 本单留到全部片清完、台账 DEBT 归零时关闭。已在 #4604 留通告。


    Generated by Claude Code

  4. 7 remaining items

  5. os-zhuang commented on Aug 6, 2026

    @os-zhuang
    ContributorAuthor

    台账实测记录一笔(发现于 #5561 第一步 / PR #5725,不改冻结值):

    @objectstack/service-automation 的 DEBT 条目冻结值是 errors: 2,实测 raw 总数为 5(tsc --noEmit -p packages/services/service-automation/tsconfig.json,该包 tsconfig 的 include: ["src"] 覆盖同目录测试):

    该门不重跑 tsc(冻结值按设计是测量快照),所以这个差不红。我没有动那个数字 —— 抬高冻结值等于把别人的债洗成基线,该由本条目的 onboarding/重测环节决定。

    同时 PR #5725 更正了同条目的归因(不动计数):resumeAuthority 改 .optional() 之后,那两处 TS2741 没有消失而是转移 —— 同两行字面量也漏 handlerContract,TS 一次只报一个,现在报的是 handlerContract。注记原文「engine.test.ts misses resumeAuthority」是被那个 PR 改坏的,所以在同一个 PR 里改。


    Generated by Claude Code

  6. added
    tracking
    on Aug 6, 2026
  7. os-zhuang commented on Aug 6, 2026

    @os-zhuang
    ContributorAuthor

    存量裁决轮(维护者 2026-08-06 委托,session_01LeEfA7CFwbJb7JJmXm2KM3):补落 tracking 标签——维护者 2026-08-04 已裁按包切片、各车道 PM 认领的毕业模式(#4855 模式),切片推进中(runtime 片 PR #5045 已合并),本单按裁决保留到 DEBT 台账归零才关闭。多车道协调卡,打标使其退出分诊扫描范围。


    Generated by Claude Code

  8. os-help commented on Aug 10, 2026

    @os-help
    Collaborator

    Still live, with a fresh datapoint from #7145 / PR #7207 (@objectstack/service-storage, origin/main @ aeadbd61c).

    Running the package's own tsconfig — npx tsc --noEmit -p tsconfig.json inside packages/services/service-storage — reports ~20 pre-existing diagnostics across test files untouched by that PR, in two families:

    • TS2835 — relative imports missing the explicit .js extension under moduleResolution: node16/nodenext (error-envelope.conformance.test.ts, local-storage-adapter.test.ts, storage-adapter-list-contract.test.ts, storage-route-ledger.conformance.test.ts, …).
    • TS2550 / TS2339 — Array.prototype.at unavailable at the configured lib target, plus a few fixture-shape mismatches (storage-adapter-list.conformance.test.ts, file-reference-lifecycle.test.ts).

    The package has no typecheck script, so turbo run typecheck skips it and CI's TypeScript Type Check job stays green — exactly the gap this card describes. The tsup DTS build does gate src, which is why only test files show up here.

    Recorded as a datapoint only; not claiming this card.

    Filed from a dev seat while implementing #7145 (out-of-scope observation, not fixed there).


    Generated by Claude Code

  9. added a commit that references this issue on Aug 12, 2026
  10. objectstack-fleet commented on Sep 30, 2026

    @objectstack-fleet
    Contributor

    Closed by the maintainer's ruling: #4311 is done. Its three proposals landed; the last three packages go to #20800

    Triage seat (objectstack-wide, seat post #6015) · session_01AavokzJ5DndAwitDXvKy4U · 2026-09-30T07:16Z. ⛔ Not a claim, ⛔ not a dispatch.

    Provenance. The maintainer answered 「4311 关」 in the live PM chat with the triage seat, to triage's proposal to close this card as superseded by what landed. os-zhuang was unassigned by that ruling. This card had not been updated since 2026-08-10T02:56Z.

    Measured on main (41dcf11884) before closing:

    • Proposal 1, the coverage ratchet, landed. lint.yml runs pnpm check:type-check-coverage (every package declares typecheck or carries a measured DEBT/EXEMPT entry, reconciled both ways) and re-measures each ledger number. turbo run typecheck runs over packages/*, packages/*/* and apps/* in the typecheck-workspace lane. 70 of 74 workspace packages under packages/ now declare typecheck; in July it was 2.
    • Proposal 2, the test-layer template, landed as per-package tsconfig.test.json files named by the typecheck script. 20 packages hold a per-file test-typecheck-debt.json.
    • Proposal 3, the burn-down. driver-sql (241 of the 380) now declares typecheck, as do metadata, driver-sqlite-wasm, driver-memory, core and service-storage.
    • The open question (TS7006 under noImplicitAny on tests) was never ruled and is not carried: nobody enabled it, and the ratchet baselines don't count it.

    What is left is four uncovered packages:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ci/cddomain:devxpriority:p2tracking

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions