Skip to content

feat(runtime): dispatcher 薄域注册表接缝 — ADR-0076 D11 步骤③ PR-1 (#2462) - #3491

Merged
os-zhuang merged 1 commit into
mainfrom
feat/d11-step3-domain-handler-registry
Jul 25, 2026
Merged

feat(runtime): dispatcher 薄域注册表接缝 — ADR-0076 D11 步骤③ PR-1 (#2462)#3491
os-zhuang merged 1 commit into
mainfrom
feat/d11-step3-domain-handler-registry

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

动机(#2462 D11 步骤③,系列第一刀)

dispatch() 把所有域塞在一条手写 startsWith if 链里、所有 handler 挂在 dispatcher 类上(4.7k 行且 30 天 34 次提交还在长)——正是 ADR-0076 D11 点名的"干净 port + 上帝实现"。本 PR 落下拆解接缝,刀口刻意切小。

改动

  • DomainHandlerRegistry:first-match {prefix, match, methods, handler} 表。无通配/无参数/无中间件——只回答"这个路径归哪个域"。匹配语义保真复刻旧 if 链,毛边照留(裸 startsWith 会匹配 /i18nxx 的行为原样保留,修毛边不是接缝的职责)。
  • dispatch() 在旧链之前查表;四个种子前缀与其余分支前缀互斥,前置查表与原链位置顺序等价
  • 种子四个内建域,示范三种 handler 形状:/health + /ready(无服务依赖探针)、/analytics(服务桥——fallback vs replace 语义留在服务层,见 D10/D12,故其注册权暂留 dispatcher)、/i18n(可选服务、handler 内 501 自兜)。
  • registerDomainHandler() 公共缝:后续每域一个 PR 把 handler 体 + 注册权移交所属服务包(缺席语义 501→404 在那时逐域决定,配合 D12 honest capabilities 的 discovery 联动)。

迁移纪律(注册表先行、代码后搬、归属最后)

本 PR handler 体不动(仍是 dispatcher 方法,注册项只是包装)——diff 最小、行为零变化最可证。后续 PR 逐域搬体移权,全部迁完后 createHonoApp catch-all 退役(解锁 D11 步骤①)。

验证

  • 新增 11 条接缝测试(注册序 / exact vs prefix / 方法过滤 / 四域行为回归含 /ready 503 分支与 /i18n 501 / 公共缝注册命中)。
  • runtime 全量 610 测试绿;@objectstack/http-conformance 跨适配器 41 断言绿;--force 重建 runtime 及 25 个下游包含 DTS 全绿。

关联 #2462(D11 步骤③ PR-1)。与 #3487(D11 步骤④)相互独立、可并行评审。

🤖 Generated with Claude Code

…er — ADR-0076 D11 step ③ PR-1 (#2462)
dispatch() routed every domain through one hand-written startsWith
if-chain and every handler lived on the dispatcher class — the "god
implementation on a clean port" shape D11 calls out. This is the
decomposition seam, cut deliberately small:
- DomainHandlerRegistry: first-match {prefix, match, methods, handler}
table, no wildcards/params/middleware — only "which domain owns this
path". Matching is FAITHFUL to the legacy chain, rough edges included
(bare startsWith also matching '/i18nxx' is preserved, not fixed).
- dispatch() consults the registry before the legacy chain; the four
seeded prefixes are disjoint from every remaining branch, so
registry-first is order-equivalent.
- Seeded four builtin domains demonstrating the three handler shapes:
/health + /ready (no service dependency), /analytics (service bridge;
fallback-vs-replace semantics stay in the service layer per D10/D12),
/i18n (optional service, in-handler 501).
- registerDomainHandler() is the public seam follow-up domain PRs use to
move handler bodies + registration ownership into owning service
packages (service-absence semantics decided per-domain there, with
D12 discovery honesty).
Verified: 11 new seam tests; runtime 610 tests green; http-conformance
41 cross-adapter assertions green; 25-package dependent closure builds
with DTS.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercelBot commented Jul 25, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
specReadyReadyPreview, CommentJul 25, 2026 3:38am

Request Review

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation tests tooling size/m labels Jul 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

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

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

  • 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/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/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)

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.

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

Labels

documentationImprovements or additions to documentationsize/mteststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@os-zhuang