Skip to content

feat(runtime): 首批四域 handler 体抽到 domains/ 模块 — ADR-0076 D11 步骤③ PR-2 (#2462) - #3507

Merged
os-zhuang merged 1 commit into
mainfrom
feat/d11-step3-extract-domain-bodies
Jul 27, 2026
Merged

feat(runtime): 首批四域 handler 体抽到 domains/ 模块 — ADR-0076 D11 步骤③ PR-2 (#2462)#3507
os-zhuang merged 1 commit into
mainfrom
feat/d11-step3-extract-domain-bodies

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

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

PR-1(#3491)落了注册表接缝;本 PR 开始搬体:/analytics/i18n/notifications/security 四个 handler 体从 HttpDispatcher 上帝类抽到 packages/runtime/src/domains/ 独立模块。http-dispatcher.ts 净瘦 235 行,每个域一个文件——"agent 改一个域只读一个域"开始兑现。

关键决策:注册权留 dispatcher(修正原计划)

原 issue 清单写"按域抽取 handler 到所属服务包",实施调查推翻了它对多数域的适用性:服务槽是多方提供的——i18n 由 I18nServicePlugin AppPlugin 内存 fallback(app-plugin.ts 对声明了 translations 的 stack 自动注册)提供;analytics 由 service-analytics ObjectQLPlugin fallback 提供。路由是槽的桥,不是某个提供方包的私产——注册权移进任一提供方,另一提供方的部署就 404(正是 A2 调研警告过的回归形状)。独占槽的外部包仍可经 registerDomainHandler() 自注册。

改动

  • domains/analytics.ts / i18n.ts / notifications.ts / security.ts:体逐字搬迁,运行在显式 DomainHandlerDeps 契约上(resolveService / getService / success / error——域可触碰的全部 dispatcher 面,从此可见可审)。
  • dispatcher 保留薄 handleXxx 委托(测试等直调方零改动)。
  • /notifications + /security 撤出 if 链进注册表;registry 新增 match: 'segment'(精确复刻 === p || startsWith(p+'/') 分支形状,/securityfoo 不误吞)。
  • 清除 dispatcher 不再使用的 resolveLocale import。

验证

  • 接缝套件 18 测试(新增 segment 语义 + notifications 401/列表 + security 503/匿名拒绝/segment 边界)。
  • runtime 全量 617 绿;http-conformance 跨适配器 41 断言绿;25 包下游 --force 含 DTS 全绿。

关联 #2462(D11 步骤③ PR-2)。后续 PR 逐域复制该模式(keys/storage/ui/share-links/packages/…),全部迁完后 catch-all 退役解锁步骤①。

🤖 Generated with Claude Code

…ns/ modules — ADR-0076 D11 step ③ PR-2 (#2462)

Moves the /analytics, /i18n, /notifications and /security handler bodies
out of the HttpDispatcher god class into per-domain modules under
src/domains/, each running against the explicit DomainHandlerDeps
contract (resolveService/getService/success/error — the whole dispatcher
surface a domain may touch, made visible). Thin handleXxx delegates stay
for direct callers; /notifications + /security leave the legacy if-chain
for the registry, with new match:'segment' preserving their
`=== p || startsWith(p+'/')` branch shape exactly.

Key call: registration stays dispatcher-owned. The original plan said
"move handlers to their owning service package", but most slots are
multi-provider — i18n is served by I18nServicePlugin OR AppPlugin's
in-memory fallback (app-plugin.ts auto-registers it for stacks declaring
translation bundles); analytics by service-analytics OR the ObjectQLPlugin
fallback. A route is the bridge to a SLOT, not the property of one
provider — registration moving into one provider would 404 the others.
Packages that DO own a slot exclusively can still self-register via
registerDomainHandler().

Verified: seam suite 18 tests; runtime 617 green; http-conformance 41
cross-adapter assertions green; 25-package dependent closure builds with
DTS (--force).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 27, 2026 1:33am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling labels Jul 27, 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.

}

const m = method.toUpperCase();
const subPath = path.replace(/^\/+/, '').replace(/\/+$/, '');
@os-zhuang
os-zhuang merged commit 8f124a7 into main Jul 27, 2026
15 of 16 checks passed
@os-zhuang
os-zhuang deleted the feat/d11-step3-extract-domain-bodies branch July 27, 2026 02:00
os-zhuang added a commit that referenced this pull request Jul 27, 2026
…ions domain (CodeQL high from #3507) (#3510)

The extraction PR moved the legacy `.replace(/\/+$/, '')` verbatim into
domains/notifications.ts, which made it "changed code" and surfaced a
js/polynomial-redos CodeQL alert that the line had latently carried since
ADR-0030. Fix is the same split+filter treatment the security domain
already uses for the identical pattern (its comment even cites the rule).
Side effect: redundant slashes collapse ('//read//' → 'read'), consistent
with the security domain; locked by a new test.

Verified: seam suite 19 tests, runtime 624 green, DTS build green.

Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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/l tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants