feat(rest): 请求→环境解析统一到 kernel-resolver 缝 — ADR-0076 D11 步骤④ (#2462)#3487
Merged
Conversation
…er seam — ADR-0076 D11 step ④ (#2462) The REST server ran its own parallel hostname/X-Environment-Id chain (hand-copied inline in resolveRequestEnvironmentId, resolveI18nService and computeExecCtx) while the HTTP dispatcher resolves the same question through the host-injected ADR-0006 kernel-resolver seam — the same unscoped request could be attributed to different environments depending on which HTTP surface served it. - New RestRequestEnvResolver seam; RestApiPlugin adapts the host's `kernel-resolver` service into it (cloud registers that service next to `env-registry` already — zero cloud-side change). - resolveRequestEnvironmentId is now THE single entry point; the two inline copies collapse into it. - Resolver verdicts are final (undefined = deliberately unscoped); only a throw degrades to the legacy chain. Legacy chain unchanged for OSS single-environment boots. Verified: 9 new seam-contract tests, rest 348 tests green, http-conformance 41 cross-adapter assertions green, DTS build of the 11-package dependent closure green. 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): 8 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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 步骤④)
REST 服务器一直维护着自己的 hostname/
X-Environment-Id→ environment 平行解析链,且同一条链在resolveRequestEnvironmentId、resolveI18nService、computeExecCtx里手抄了三份;而 HTTP dispatcher 早已把同一个问题交给 host 注入的 ADR-0006kernel-resolver缝(cloud 的CloudKernelResolver,6 级解析链)。后果:同一个 unscoped 请求打在 dispatcher 面和 REST 面上可能归属不同的 environment(REST 链缺 session 级兜底,也不认 resolver 的 control-plane skip 语义)。改动
RestRequestEnvResolver缝(rest 包本地结构类型,照RestKernelManager模式避免 runtime↔rest 包环)。RestApiPlugin把 host 的kernel-resolver服务适配进该缝:装配context{request}调resolveKernel,回读context.environmentId;defaultKernel绑定 host kernel 服务面(resolver 的 session/default-project 级从它解析 auth/objectql/default-project)。cloud 侧零改动——kernel-resolver与env-registry本就注册在同一 host kernel(objectos-stack.ts)。resolveRequestEnvironmentId成为唯一入口:explicit id → 注入 resolver(正常返回即终局,含undefined=有意 unscoped;仅抛错才降级)→ 旧内建链(hostname → header)→ 单环境 default。三份手抄内联链收敛为一处调用。envRegistry链原样保留:OSS 单环境部署(无 resolver 服务)行为零变化,也是 resolver 异常时的降级路径。行为差异(仅 cloud/多租户部署,需 review 把关)
resolver 在场时 unscoped REST 路由从 3 级链变为与 dispatcher 完全一致的 6 级链:
session.activeEnvironmentId/ org default 解析——dispatcher 面早已如此,REST 面补齐(消除双面归属分歧)。undefined为终局,REST 不再二猜。REST 消费点均为数据面路由(REST 自己的/discovery直用 boot 时控制面 protocol,不做 env 解析),实际不受影响。EnvironmentDriverRegistry自带 TTL 缓存,REST 侧 30s 缓存仅在降级链中仍生效——双缓存的正式退役留给 D11 步骤③。验证
rest-env-resolution.test.ts:9 条缝契约测试(explicit 短路 / resolver 优先 / undefined 终局 / 抛错降级 / 旧链原样 / header+default 兜底 / getOrCreate 路由 / plugin 装配含 facade 透传 / 无 resolver 正常服务)。@objectstack/http-conformance跨适配器 41 断言绿(两适配器 socket 级行为一致);--force重建 rest 及 11 个下游包含 DTS 全绿。Closes 部分 #2462(D11 步骤④)。步骤③(按域拆 dispatcher/rest-server)随后单独 PR。
🤖 Generated with Claude Code