feat(runtime): 首批四域 handler 体抽到 domains/ 模块 — ADR-0076 D11 步骤③ PR-2 (#2462) - #3507
Merged
Conversation
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 17 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
| } | ||
|
|
||
| const m = method.toUpperCase(); | ||
| const subPath = path.replace(/^\/+/, '').replace(/\/+$/, ''); |
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>
This was referenced Jul 27, 2026
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.
动机(#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 面,从此可见可审)。handleXxx委托(测试等直调方零改动)。/notifications+/security撤出 if 链进注册表;registry 新增match: 'segment'(精确复刻=== p || startsWith(p+'/')分支形状,/securityfoo不误吞)。resolveLocaleimport。验证
--force含 DTS 全绿。关联 #2462(D11 步骤③ PR-2)。后续 PR 逐域复制该模式(keys/storage/ui/share-links/packages/…),全部迁完后 catch-all 退役解锁步骤①。
🤖 Generated with Claude Code