Skip to content

refactor(runtime)!: 退役 runtime 导出的 HttpServer 委派包装器 (#5122) - #6141

Merged
qq9340100 merged 2 commits into
mainfrom
claude/issue-5122-retire-httpserver-wrapper
Aug 7, 2026
Merged

refactor(runtime)!: 退役 runtime 导出的 HttpServer 委派包装器 (#5122)#6141
qq9340100 merged 2 commits into
mainfrom
claude/issue-5122-retire-httpserver-wrapper

Conversation

@qq9340100

@qq9340100 qq9340100 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Fixes #5122

按 2026-08-06 维护者裁决退役 @objectstack/runtime 导出的 HttpServer 委派包装器(#4939「从未被装配的件退役优于修」先例 + ADR-0049 remove 侧)。⛔ 不做条件转发,⛔ 不做「维持 + 文档标注」。

前提复核(在最新 origin/main 上)

  • packages/runtime/src/http-server.tsclass HttpServer implements IHttpServer 仍是只转发必选成员的形态(get/post/put/delete/patch/use/listen/close),getPort? / getRawApp? / setFallbackHandler? 一个都不转发 —— 与 issue 描述一致。
  • 组合点仍为:new HttpServer( 全仓(含 examples/)零命中。反查对照用同族邻居 new HonoHttpServer( 命中 20+ 处,证明搜索本身有效,不是空搜。
  • 该符号在仓内的全部出现只有两处:类文件自身,和 packages/runtime/src/index.ts:48 的 barrel 导出。没有测试构造过它(packages/runtime/src/ 下无 http-server.test.ts),scripts/adr-anchors.json 未锚定它,也没有任何 baseline/ledger 记名。

改动

  1. 删除 packages/runtime/src/http-server.ts
  2. 从 runtime barrel 移除导出,原地留一条 NOTE:说明为什么退役、以及正确的组合方式是直接注册 IHttpServer 适配器实例http.server(每个真实 host 本来就是这么做的),防止同型包装器被复刻。
  3. 新增 packages/runtime/src/http-server-retirement.test.ts —— 运行期缺席钉子(3 条),带反空转守卫。
  4. changeset:@objectstack/runtime major(public API 移除),正文含迁移表、以及「E7(#5040 执行器):翻转 —— publish 硬拒收窄为「不支持子集 + 命名空间门」,声明式端点随 v17 放行执行 #5111 之后 setFallbackHandler 是声明式 apis: 端点唯一通路」这一事实 —— 这句话存在的目的就是阻止未来有人再造一个丢弃可选成员的同型包装器。fix(runtime): 无 setFallbackHandler 的适配器改以 warn 宣告声明式端点不可达 (#5400) #5409 已落的 warn 宣告继续作为 runtime 侧兜底(它能点名 seam 缺席,但点不出吞掉 seam 的包装器,所以两者不重复)。

为什么钉子是运行期探测而不是类型级

packages/runtime/tsconfig.json 排除了 **/*.test.ts,tsc --noEmit 读的就是这份配置,vitest 又从不做类型检查(#4311)—— 这正是 #4642 记录的陷阱:类型级钉子在这里是空转的。所以用 namespace 探测 + 反空转守卫(barrel 导出数量下限 + Runtime 在场),并额外钉住源文件不存在(防止它以「不导出的私有包装器」形态回来),该断言自己也带路径反空转守卫(邻居 http-dispatcher.ts 必须在)。

barrel 用静态 namespace 导入而非用例内 await import():这个 barrel 冷启动要几秒,放进用例会撞 vitest 5s 默认超时 —— 那是 flake,不是发现(第一版就撞了)。

反向验证(方向在运行前先行预测)

预测:把删掉的类文件与 barrel 导出同时还原,两条移除钉子应转(它们读的是「在场」谓词,不是可以靠「什么都不产出」蒙混过关的计数),而第三条「邻居导出仍在」应保持绿——它是反空转搭档,不是移除钉子。

实测与预测一致:

Tests  2 failed | 1 passed (3)
FAIL … > the barrel exports no `HttpServer`
  AssertionError: @objectstack/runtime must not export HttpServer: expected true to be false
FAIL … > the module file is gone, so it cannot come back as an unexported private wrapper
  AssertionError: packages/runtime/src/http-server.ts is retired (#5122) …: expected true to be false
✓  … > keeps the HTTP exports that were its neighbours — the deletion took nothing with it

随后已还原为移除态。

验证

合入 origin/main(含已合并的 #6122)后重跑:

pnpm --filter @objectstack/runtime test
  Test Files  104 passed (104)
       Tests  1490 passed (1490)

pnpm --filter '@objectstack/runtime^...' build && pnpm --filter @objectstack/runtime typecheck
  > tsc --noEmit          (无输出 = 通过)

npx eslint packages/runtime/src/index.ts packages/runtime/src/http-server-retirement.test.ts --no-inline-config
  exit 0

pnpm check:nul-bytes / check:adr-anchors / check:doc-authoring / check:published-files /
check:type-check-coverage / check:release-notes / check:route-envelope /
check:error-code-casing / check:engine-double-contract / check:empty-changeset
  全部 OK

刻意未做


🤖 Generated with Claude Code

https://claude.ai/code/session_01Wbxm29qPKnLf44AbSxizqW

claude added 2 commits August 7, 2026 03:16
…#5122)

`HttpServer implements IHttpServer` forwarded only the contract's REQUIRED
members, so `getPort` / `getRawApp` / `setFallbackHandler` all read as absent
to the `typeof x === 'function'` probe the contract prescribes — a wrapped
adapter lost every optional capability it actually provided. Since #5111
`setFallbackHandler` is the only entry path for declarative `apis:` endpoints,
so wrapping a capable adapter would 404 every declared endpoint silently.

`new HttpServer(` had zero occurrences repo-wide (examples included), so the
2026-08-06 maintainer ruling retires the class per the #4939 `ApiRegistry`
precedent + ADR-0049's remove side, rather than growing a forwarding surface
nobody composes.

- delete packages/runtime/src/http-server.ts and its barrel export
- pin the absence at runtime (http-server-retirement.test.ts) with
  anti-vacuity guards; a compile-time pin is inert here (tsconfig excludes
  **/*.test.ts, #4311/#4642)
- changeset: @objectstack/runtime major, with the migration note and the
  #5111 fact recorded so the wrapper is not reinvented

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 3:19am

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

This PR changes 1 package(s): @objectstack/runtime.

21 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/api/client-sdk.mdx (via packages/runtime)
  • content/docs/api/index.mdx (via @objectstack/runtime)
  • content/docs/api/wire-format.mdx (via @objectstack/runtime)
  • content/docs/automation/hook-bodies.mdx (via @objectstack/runtime)
  • content/docs/concepts/metadata-lifecycle.mdx (via @objectstack/runtime)
  • content/docs/concepts/north-star.mdx (via packages/runtime)
  • content/docs/data-modeling/drivers.mdx (via @objectstack/runtime)
  • content/docs/deployment/index.mdx (via @objectstack/runtime)
  • content/docs/deployment/production-readiness.mdx (via @objectstack/runtime)
  • content/docs/deployment/single-project-mode.mdx (via @objectstack/runtime)
  • content/docs/deployment/vercel.mdx (via @objectstack/runtime)
  • content/docs/getting-started/your-first-project.mdx (via @objectstack/runtime)
  • content/docs/kernel/cluster.mdx (via @objectstack/runtime)
  • content/docs/permissions/authentication.mdx (via @objectstack/runtime)
  • content/docs/permissions/authorization.mdx (via packages/runtime)
  • content/docs/plugins/packages.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/http-protocol.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/index.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/lifecycle.mdx (via @objectstack/runtime)
  • content/docs/releases/implementation-status.mdx (via @objectstack/runtime)
  • content/docs/releases/v17.mdx (via @objectstack/runtime)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling labels Aug 7, 2026
@qq9340100
qq9340100 marked this pull request as ready for review August 7, 2026 03:34
@qq9340100
qq9340100 added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit 0cd08d5 Aug 7, 2026
25 checks passed
@qq9340100
qq9340100 deleted the claude/issue-5122-retire-httpserver-wrapper branch August 7, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runtime 导出的 HttpServer 包装器静默丢弃 IHttpServer 的全部可选成员(getPort / getRawApp / setFallbackHandler)

2 participants