Skip to content

refactor(managed-agent): Make runtime backends optional Maven modules - #16141

Merged
doudouOUC merged 3 commits into
mainfrom
codex/managed-runtime-backend-modules
Nov 3, 2026
Merged

doudouOUC merged 3 commits into
mainfrom
codex/managed-runtime-backend-modules

Conversation

@doudouOUC

@doudouOUC doudouOUC commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does

Splits Local, SSH, Kubernetes, External and Static Runtime implementations into independent Maven artifacts. Services embedding the ordinary server library explicitly add only the same-version backends they need; all five backend dependencies are optional. The default standalone executable and operator artifacts remain complete, with their existing classifiers and reference packaging.

Selected backends are validated before resources are created. SSH-only assembly no longer initializes Local, and Spring owns shared SSH connection cleanup. Historical operations retain pending state and storage claims while their backend is unavailable, then resume when it returns. Maintenance requests the capability needed by each action while retaining SQL-only branches. Kubernetes workspace paths are validated as remote Pod paths independently of the control-plane operating system. The design and configuration reference are synchronized in English and Chinese.

Why it's needed

The existing adapter bundle combines unrelated backend implementations, and SSH assembly requires a Local provider. An embedding service cannot choose its backend dependencies independently. This change establishes that boundary while preserving recovery, storage ownership and resource cleanup when available backends change.

Reviewer Test Plan

Acceptance remains pending. Local checks cover scripts, workflow contracts, documentation and static boundaries; the complete release-script test file passes all 56 cases after repairing its source-move fixture. The Java verification budget shared with the earlier Local/External work is closed at 599.048/600 seconds; the current Java module graph and runtime regressions require CI evidence.

How to verify

  1. Reference the ordinary server from another Maven application. Confirm no backend implementation is included transitively. Explicitly add a same-version backend and confirm it becomes available; a disabled Broker should need none. Check isolated classpaths for all five single backends, Local+SSH and full, including a missing-provider failure before resource allocation.
  2. Build the normal standalone and operator artifacts. Confirm the fixed exec classifier, application configuration and metadata, five backend JARs and service registrations, Lombok exclusion and maintenance launchers remain compatible. The ordinary library should contain no standalone application YAML.
  3. Exercise SSH-only and Local-only assembly. Unselected providers must not read credentials, initialize state or create clients/processes. Preserve SSH admission restrictions and already-admitted execution, close, recovery and permitted replay. Failed startup and normal shutdown must release SSH controller ownership. A Kubernetes Pod path such as /workspace must be accepted on Linux, macOS and Windows control planes while relative, dot-component and non-normalized paths remain rejected.
  4. Persist unresolved Local uploads and SSH registrations, remove their backend and confirm pending state and storage claims remain intact. Restore the original backend and confirm reconciliation resumes with the original identity. Missing Kubernetes must reject physical CSI actions while retaining SQL-only maintenance; missing Local must reject Local-dependent maintenance before persistent side effects. Complete MySQL, Hosted/fault, real SSH/Kubernetes and cross-platform acceptance.

Evidence (Before & After)

N/A — backend modularization has no UI changes. A separate verification comment records local results, prior CI failures, their corrections and remaining acceptance work.

Tested on

OS Status
🍏 macOS ✅ Script/workflow and static checks; current Java acceptance pending
🪟 Windows ⚠️ Not tested
🐧 Linux ⚠️ Local testing not performed; current CI acceptance pending

Environment (optional)

macOS arm64, Node.js 26.12.1 and npm 11.20.0. Java acceptance requires JDK 21. Based on main 4dce337ea28d6b8718934b40b8a358cd362f1578, preserving its Store constructor injection and configuration metadata support. Root build/typecheck/bundle and the 110 affected script tests passed again after rebasing onto this main revision; the profile-owned specialist test configuration is preserved.

Risk & Scope

  • Main risk or tradeoff: the internal provider SPI, Java package boundaries and assembly lifecycle change. Required runtime and infrastructure acceptance is incomplete; merge readiness depends on current-head CI and remaining real-environment qualification. Selecting backend dependencies does not remove shared database, Harness or messaging dependencies.
  • Not validated / out of scope: current Java unit/H2, Checkstyle, SpotBugs, embedding, packaging, MySQL, Hosted/fault, real SSH/Kubernetes and complete platform acceptance remain pending. Selective standalone builds, variant archives/examples and their CI matrix are deferred; the PR contains no backend build selector. JAR hot-loading, Kubernetes scratch and prewarm removal are also out of scope.
  • Breaking changes / migration notes: rebuild internal SPI providers at the same version and update imports of moved implementation classes. Embedding consumers enabling a backend must explicitly add its optional artifact. Persisted provider kinds, storage identities, SQL schema and wire formats stay unchanged. Drain work before removing its backend, or retain pending operations and storage claims until the original backend is restored.

The complete synchronized design is available in English and Chinese.

Linked Issues

Follow-up to merged PR #15871. No issue is closed by this PR.

中文说明

本 PR 的改动

将 Local、SSH、Kubernetes、External 和 Static Runtime 实现拆为独立 Maven 产物。嵌入普通 server library 的服务只显式添加所需的同版本后端,五个后端依赖均为 optional。默认独立可执行包及运维产物保持完整,沿用既有 classifier 和参考打包方式。

选中后端在创建资源前完成校验。SSH-only 装配不再初始化 Local,共享 SSH 连接由 Spring 负责清理。历史操作在所属后端不可用时保留 pending 状态和存储占用,恢复后端后继续。运维按 action 获取所需能力,同时保留纯 SQL 分支。Kubernetes Workspace 路径按远端 Pod 路径校验,不依赖控制平面操作系统。设计及配置参考同步提供中英文版本。

为什么需要

现有 adapter 包混合了彼此独立的后端实现,SSH 装配还要求 Local provider,嵌入服务无法独立选择后端依赖。本次建立这一边界,同时保留可用后端变化时的恢复、存储所有权和资源清理行为。

Reviewer 测试计划

验收仍待完成。本地检查覆盖脚本、工作流契约、文档和静态边界;修复源码迁移后的夹具路径后,发布脚本测试文件的全部 56 个用例通过。与前期 Local/External 工作共享的 Java 验证预算已在 599.048/600 秒关闭;当前 Java 模块图及 runtime 回归需要 CI 证据。

如何验证

  1. 在另一个 Maven 应用中引用普通 server,确认不传递引入任何后端实现;显式添加同版本后端后确认其可用,Broker 停用时应无需后端。检查五种单后端、Local+SSH 和 full 的隔离 classpath,包括缺包时在资源分配前失败。
  2. 构建正常独立应用及运维产物,确认固定 exec classifier、应用配置及元数据、五个后端 JAR 和服务注册、Lombok 排除及运维启动器保持兼容。普通 library 不应包含独立应用 YAML。
  3. 验证 SSH-only 与 Local-only 装配,未选 provider 不得读取凭据、初始化状态或创建客户端/进程。保留 SSH 准入限制及已接纳任务的执行、关闭、恢复和获准重放。启动失败与正常关闭都必须释放 SSH controller 所有权。Linux、macOS 和 Windows 控制平面都应接受 /workspace 这样的 Kubernetes Pod 路径,同时继续拒绝相对路径、点分量及未规范化路径。
  4. 持久化未决 Local 上传和 SSH 注册,移除所属后端后确认 pending 状态与存储占用完整保留;恢复原后端后按原身份继续对账。缺少 Kubernetes 时须拒绝物理 CSI 操作,同时保留纯 SQL 运维;缺少 Local 时,相关运维须在持久化副作用前拒绝。完成 MySQL、Hosted/fault、真实 SSH/Kubernetes 和跨平台验收。

证据(Before & After)

N/A — 后端模块化没有 UI 改动。独立验证评论记录本地结果、上一版 CI 失败及其修正,以及剩余验收工作。

测试平台

OS 状态
🍏 macOS ✅ 脚本/工作流及静态检查;当前 Java 验收待完成
🪟 Windows ⚠️ 未测试
🐧 Linux ⚠️ 未在本地测试;当前 CI 验收待完成

环境(可选)

macOS arm64、Node.js 26.12.1、npm 11.20.0。Java 验收要求 JDK 21。基于 main 4dce337ea28d6b8718934b40b8a358cd362f1578,保留其中的 Store 构造注入和配置元数据支持。rebase 到此 main 版本后,根目录 build/typecheck/bundle 和 110 项相关脚本测试再次通过;保留专项 profile 负责测试启用的配置。

风险与范围

  • 主要风险或取舍:内部 provider SPI、Java 包边界和装配生命周期变化。必需的 runtime 及基础设施验收尚未完成;是否具备合并条件取决于当前 head 的 CI 和剩余真实环境验收。选择后端依赖不会移除共享的数据库、Harness 或消息依赖。
  • 未验证或不在范围内:当前 Java unit/H2、Checkstyle、SpotBugs、embedding、打包、MySQL、Hosted/fault、真实 SSH/Kubernetes 和完整平台验收仍待完成。选择性独立构建、变体归档/示例及对应 CI 矩阵后置,PR 不含后端构建选择器。JAR 热加载、Kubernetes scratch 和取消预热也不在范围内。
  • 破坏性变化或迁移说明:内部 SPI provider 须按同版本重新构建,直接导入已移动实现类的代码须更新 import。启用后端的嵌入服务须显式添加对应 optional 产物。持久化 provider kind、存储身份、SQL schema 和协议格式不变。应在移除后端前排空其工作,或保留 pending 操作及存储占用直到原后端恢复。

完整且同步的设计提供英文版和中文版。

关联事项

作为已合并 PR #15871 的后续工作。本 PR 不自动关闭任何 issue。

@doudouOUC

Copy link
Copy Markdown
Collaborator Author

本地验证与 E2E 待验收记录

提交:7ae49ce3e9f76a3b7a27822390465dc6c46f88ee;基线:73474ef094ea1c6bb2a95a9a2a33a28b0ec58e9e。整合最新 main 无冲突,保留 Store 构造注入。根目录检查执行于 17209b96f285bb5b691146d9af7087f196295ecc,当前提交只比该状态多两份设计文档的基线/状态说明更新,代码和测试内容相同。

整合 main 后完成的检查

检查 结果 范围
NODE_OPTIONS=--max-old-space-size=6144 npm run build 通过,175.813 秒 根目录各 JS/TS workspace 构建
NODE_OPTIONS=--max-old-space-size=6144 npm run typecheck 通过,62.040 秒 根目录类型检查,包含 integration
npm run bundle 通过,3.470 秒 CLI bundle;未据此执行 native Worker E2E
npx vitest run --config scripts/tests/vitest.config.ts scripts/tests/managed-agent-server-e2e.test.js 54/54 通过 main 更新了该脚本测试读取的 Store 文件,已对整合后版本重跑
提交钩子、双语文档格式、差异检查 通过 未跳过提交钩子;git diff --check 无问题

本地环境为 macOS arm64、Node.js 26.12.1、npm 11.20.0。Windows 和 Linux 本地未测。

保留的前期脚本证据

  • 构建选择器与分发脚本测试:31 通过、1 个 root-only chown 用例跳过、0 失败;使用合成 ZIP 和 fake Java,不代表真实 JVM 或成品验收。
  • 增加 Local+SSH 示例后,归档专项测试 2/2 通过,覆盖精简包与 Local+SSH 包;相关脚本 ESLint 通过。
  • 九份相关 workflow/runner 测试首次执行:703 通过、15 跳过、1 失败。失败来自旧的固定 exec classifier 断言;修正后受影响文件 54/54 通过,本次整合后再次 54/54 通过。其余八份文件保留此前结果;当前唯一用例覆盖合计 704 通过、15 跳过,并非声称又完整运行了一遍九份文件。
  • 所有 15 份 reactor POM 已做静态 XML 解析;包归属、后端间依赖、迁移后的引用、文档链接和最终差异已审查。31 个移动 Java 文件在去除 package/import 后主体完全一致。静态审查不能代替编译、Checkstyle 或 SpotBugs。

尚未执行,验收待完成

共享 Java 预算已使用 599.048/600 秒,本次五后端扩展及 PR 整理没有重置预算,也没有追加 Java/javac/Maven 执行。前期 Local/External 版本的聚焦 Java 通过仅是历史记录;embedding-host 和 packaged-classpath 尝试曾超时,这些旧结果不构成本提交验收证据。

以下必须等待对应 CI 或真实环境结果:

  • 修订模块图的 Java 编译、unit/H2 回归、Checkstyle、SpotBugs,以及普通 library 的 embedding-host 验收。
  • 五种单后端、Local+SSH、full 七种真实成品构建;实际嵌套 JAR、SPI 注册、被排除实现类和仅使用成品 classpath 的启动检查。CI 矩阵已加入,每个变体分别归档证据。
  • 已加入但未执行的回归:SSH-only 无 Local 初始化、历史上传/注册保留 pending 和 holder 后恢复、SSH 准入不退化、失败 Spring 启动释放控制锁、Local 运维缺包在持久化前拒绝、SQL-only 维护不加载 Kubernetes。
  • 真实启用的 SSH/Kubernetes、MySQL、Hosted/fault、跨平台和完整 CI。关闭 Broker 的成品启动探针不能证明真实 SSH 主机或 Kubernetes 集群可用。

本 PR 保持 Draft;没有发布、部署或真实基础设施验收声明。预热策略不在本次变更范围内。

@wenshao

wenshao commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

PR 16141 round 1 verification — Verdict: findings — 25/32 scripted assertions passed, 7 failed. Verified head: 7ae49ce3e9f76a3b7a27822390465dc6c46f88ee (base 73474ef094ea1c6bb2a95a9a2a33a28b0ec58e9e).

中文摘要

结论:findings(不具备合并条件)。 25/32 条脚本化断言通过,7 条失败;失败全部归因于本 PR。中心主张本身成立:五个后端确实被拆成可独立选择的产物,七种真实成品都只发现所选 provider 并能启动;普通 server 依赖的 embedding host 不会创建任何托管资源,显式启用后才启动。问题在于工具链和测试/CI 门禁,而不是运行时拆分。

A/B 结论(实测): base 的 exec 包后端载荷只有单一 qwen-managed-agent-adapters(内含全部五个后端);head 的 full 包变成五个独立 runtime-* jar。head 的 external-only 包只包含 runtime-external,manifest 为 Qwen-Runtime-Backends: external。七个变体的 boot 探针 7/7 通过,retirement launcher 7/7 通过;但七变体的配置元数据断言 7/7 失败(同一处路径写错)。base 与 head 的类并集对比 85 个简单类名中 84 个仍在,唯一缺失的 SshConnectionManager$CommandResult 已被 HostCommandRunner.Result 取代,属有意重构。

Findings:

  1. 归档检查把 spring-configuration-metadata.json 找在 BOOT-INF/classes/META-INF/,而 Spring Boot 实际写在归档根 META-INF/;导致七变体 CI 矩阵、参考分发打包器全部失败。base 包同样在根目录,证明是检查路径写错,不是运行时回归。
  2. 三个新后端源文件在闭括号前有空行,Checkstyle 在 runtime-host 直接失败;-fae 还暴露 runtime-external,源码扫描确认 runtime-local 也有,共 3 处。
  3. 新属性 qwen.managed-agent.runtime-broker.provider-options 没有中英文描述,配置参考检查失败;补描述后还要求重新生成两份参考文档。
  4. sdk-java.yml 超出 workflow 体积棘轮 1294 字节(155722 vs 150332+4096),Lint & Static 已红。
  5. EmbeddedRuntimeBrokerTest 仍反射已删除的 localProvisioner 字段,mvn test 报 NoSuchFieldException。
  6. StaticRuntimeProviderFactoryTest 期望不带尾斜杠的 URI,而 BrokerValues.requireOrigin 会归一化为带 /,测试失败。

未覆盖: 完整 Java reactor 在 169 个测试类后停止(改跑 16 个变更类的定向门禁);真实 MySQL/Hosted/fault、真实 SSH/Kubernetes、SpotBugs、跨平台矩阵未跑;WorkspaceCsiNativeActivationGateTest 需要 packages/core/dist(本容器 core 构建被 browser-use dist 阻塞),SessionWorktreeStoreTest 需要 git ≥ 2.40(容器为 2.39.5)。RuntimeProviderMaintenanceTest 与 LocalProcessRuntimeProvisionerTest 的环境缺项(/etc/machine-id、UTF-8 locale)已补齐并复跑通过,不计为 PR 失败。

What the PR claims and what was measured

The PR's central claim is that Local, SSH, Kubernetes, External and Static runtimes become five independently selectable Maven artifacts; a selector builds seven distributions (five single-backend, Local+SSH, full) containing exactly the selected implementations; the ordinary server dependency carries none of them; and existing recovery, storage-ownership and maintenance behavior survives. This round drove the real Maven reactor, the real spring-boot repackaged jars and the real embedding-host projects with JDK 21 and Maven 3.9.11 inside credential-free containers.

The claim holds at the artifact level. The seven variants were built one at a time with node scripts/build-managed-agent-runtime.mjs --backends=<set> --verify; for every variant the archive inspector's provider-discovery probe booted the packaged classpath and reported exactly the selected providers (boot-probe-* 7/7 PASS), and the retirement launcher loaded from the executable jar (7/7 PASS). The ordinary server-only embedding host started with no ManagedAgentService, no DataSource and no ServiceLoader providers (EmbeddingHostTest 1/1 PASS), while the explicitly enabled host started its own H2 pool (EnabledHostTest 2/2 PASS).

Cell Oracle Base (73474ef0) Head (7ae49ce3)
Full exec archive backend payload unzip -Z1 of the real repackaged jar one qwen-managed-agent-adapters jar + runtime-broker five runtime-{external,kubernetes,local,ssh,static} jars + runtime-{http,host,broker}
Full archive manifest META-INF/MANIFEST.MF no backend variant fields Qwen-Runtime-Backends: external,kubernetes,local,ssh,static; Qwen-Runtime-Variant: full
External-only archive nested jars + manifest + boot probe selector does not exist only runtime-external among backends; manifest external; boot probe reports only external; excluded provider classes are absent
Library embedding real Maven consumer project not applicable server-only host creates no managed resources; enabled host starts its own pool
Class preservation simple class names in base adapters vs head runtime union 85 names 84 names; SshConnectionManager$CommandResult replaced by HostCommandRunner.Result (intentional)

The head already shows two red CI jobs at the verified commit: Lint & Static (ubuntu-latest, Node 22.x) and Build and verify reference distribution; the SDK Java (fast) / ubuntu-latest / Java 21 job was still running when this report was assembled. The failures below were reproduced locally from the same commit, not inferred from the PR text.

The three deterministic CI gate failures reproduced at head

A/B of the real archive payloads and the seven-variant matrix

Findings

1. Critical — the archive inspector looks for configuration metadata at a path Spring Boot does not write

scripts/managed-runtime-backends.mjs:83 and ManagedAgentPackagingIT.java:39 both require BOOT-INF/classes/META-INF/spring-configuration-metadata.json. The real repackaged archives contain META-INF/spring-configuration-metadata.json at the archive root instead. This is not new to the PR: the base exec archive (73474ef0) places the file at the same root path, so the expectation is wrong rather than the packaging layout having changed.

Blast radius: every one of the seven variants fails standaloneArtifactsIncludeConfigurationWhileLibraryDoesNot; inspectRuntimeArchive is also used by package-managed-agent-reference.mjs, so the reference distribution cannot be assembled. The failure is deterministic and reproduced on all seven variants.

$ node scripts/build-managed-agent-runtime.mjs --backends=external --verify
[ERROR] ManagedAgentPackagingIT.standaloneArtifactsIncludeConfigurationWhileLibraryDoesNot:39
Expecting actual not to be null
...
Maven exited with 1.

$ node scripts/package-managed-agent-reference.mjs --backends=full \
    --version=0.1.0-alpha.verify --source-revision=$(git rev-parse HEAD) --output=/tmp/ref
Runtime archive is missing BOOT-INF/classes/META-INF/spring-configuration-metadata.json:
  .../qwen-managed-agent-server-0.1.0-alpha-exec.jar
Suggested fix (measured)

Change the resource in both places to the root path:

- 'BOOT-INF/classes/META-INF/spring-configuration-metadata.json',
+ 'META-INF/spring-configuration-metadata.json',
- assertThat(executable.getEntry("BOOT-INF/classes/META-INF/spring-configuration-metadata.json")).isNotNull();
+ assertThat(executable.getEntry("META-INF/spring-configuration-metadata.json")).isNotNull();

Measured in the scratch pack worktree: with the two-line change, node scripts/build-managed-agent-runtime.mjs --backends=external --verify completed with 4/4 tests passing (1 skipped) and BUILD SUCCESS. The change was reverted afterwards; the head tree is clean. This is a tooling/test path defect, not a runtime packaging regression.

2. Critical — Checkstyle rejects three new backend sources

The CI command fails in runtime-host before the reactor reaches the other modules:

$ cd packages/managed-agent-server
$ mvn --batch-mode --no-transfer-progress checkstyle:check checkstyle:check@runtime-broker-checkstyle
[ERROR] src/main/java/com/alibaba/qwen/code/runtimebroker/host/RuntimeStateFiles.java:[45] (regexp) RegexpMultiline: Blank line before closing brace
[INFO] Qwen Managed Agent runtime-host .................... FAILURE

-fae additionally reports ExternalRuntimeProviderFactory.java:[132]; a source scan finds the same pattern in LocalRuntimeProviderFactory.java:[177]. All three files are new or moved into the runtime modules by this PR.

Suggested fix (measured)

Remove the blank line between the last statement's closing brace and the type's closing brace in:

  • packages/managed-agent-server/runtime-host/src/main/java/com/alibaba/qwen/code/runtimebroker/host/RuntimeStateFiles.java
  • packages/managed-agent-server/runtime-external/src/main/java/com/alibaba/qwen/code/runtimebroker/provisioning/external/ExternalRuntimeProviderFactory.java
  • packages/managed-agent-server/runtime-local/src/main/java/com/alibaba/qwen/code/runtimebroker/provisioning/local/LocalRuntimeProviderFactory.java

Measured: with all three removed, mvn checkstyle:check checkstyle:check@runtime-broker-checkstyle returned BUILD SUCCESS. The files were restored afterwards.

3. Critical — the new provider-options property is undocumented and the generated reference is stale

ManagedAgentProperties.java:857 adds private Map<String, String> providerOptions = Map.of();, but packages/managed-agent-server/configuration-descriptions.json has no entry for qwen.managed-agent.runtime-broker.provider-options. The release gate fails before the reference distribution is assembled:

$ node scripts/generate-managed-agent-configuration-reference.mjs --check
qwen.managed-agent.runtime-broker.provider-options has no en description in packages/managed-agent-server/configuration-descriptions.json
qwen.managed-agent.runtime-broker.provider-options has no zh description in packages/managed-agent-server/configuration-descriptions.json
exit=1

After adding the descriptions, the same check still fails because the generated reference documents were not regenerated: docs/users/managed-agent-configuration-reference.md and .zh-CN.md are out of date.

Suggested fix (measured)

Add bilingual descriptions to configuration-descriptions.json, then regenerate both documents:

$ node scripts/generate-managed-agent-configuration-reference.mjs
Wrote docs/users/managed-agent-configuration-reference.md
Wrote docs/users/managed-agent-configuration-reference.zh-CN.md
$ node scripts/generate-managed-agent-configuration-reference.mjs --check
exit=0

Measured with a temporary description entry and a temporary regeneration; the check passed. The description and generated files were restored afterwards.

4. Critical — sdk-java.yml exceeds the workflow size ratchet

The verified file is 155,722 bytes; .github/workflows/.size-baseline records 150,332 with a 4,096-byte allowance, so it is 1,294 bytes over. The CI annotation and the local mirror agree:

$ WORKFLOW_SIZE_BASE_SHA=73474ef094ea1c6bb2a95a9a2a33a28b0ec58e9e \
    npx vitest run --config scripts/tests/vitest.config.ts scripts/tests/workflow-size.test.js
FAIL  scripts/tests/workflow-size.test.js > workflow size growth ratchet >
      .github/workflows/sdk-java.yml is within its baseline allowance
Tests  1 failed | 237 passed | 1 skipped (239)
Suggested fix (measured)

Either record the real growth in .size-baseline (155722 sdk-java.yml) and say why, or move the seven-variant loop into a .github/scripts/ helper to keep the workflow below the allowance. Measured: bumping the baseline made the suite 238 passed, 1 skipped, 0 failed. The baseline was restored afterwards; the PR should choose the script extraction if it wants to keep the ratchet honest.

5. High — EmbeddedRuntimeBrokerTest reflects a field the refactor removed

The test helper still asks for the old field name:

$ mvn -f packages/managed-agent-server/pom.xml -pl verification \
    -Dtest=EmbeddedRuntimeBrokerTest test
java.lang.NoSuchFieldException: localProvisioner
  at ...EmbeddedRuntimeBrokerTest.provisionerOf(EmbeddedRuntimeBrokerTest.java:563)
  at ...constructsAnExternalScratchProvisionerForAValidConfiguration(EmbeddedRuntimeBrokerTest.java:459)

EmbeddedRuntimeBroker now stores the selected factory in primaryProvisioner (EmbeddedRuntimeBroker.java:66). The production code compiles; the test suite is red.

Suggested fix (measured)
- .getDeclaredField("localProvisioner");
+ .getDeclaredField("primaryProvisioner");

Measured with this change and the next finding's change: EmbeddedRuntimeBrokerTest + StaticRuntimeProviderFactoryTest ran 41 tests with 0 failures/errors (1 skipped). Both files were restored afterwards.

6. High — StaticRuntimeProviderFactoryTest expects an unnormalized URI

StaticRuntimeProviderFactoryTest.java:32 expects http://127.0.0.1:41270, but every lease endpoint goes through BrokerValues.requireOrigin, which returns value.resolve("/") (BrokerValues.java:121), producing http://127.0.0.1:41270/.

$ mvn -f packages/managed-agent-server/pom.xml -pl verification \
    -Dtest=StaticRuntimeProviderFactoryTest test
expected: http://127.0.0.1:41270
 but was: http://127.0.0.1:41270/
  at ...StaticRuntimeProviderFactoryTest.returnsTheConfiguredLeaseWithoutAccessingOtherProviderPorts(StaticRuntimeProviderFactoryTest.java:32)
Suggested fix (measured)
- assertThat(lease.getEndpoint()).isEqualTo(URI.create("http://127.0.0.1:41270"));
+ assertThat(lease.getEndpoint()).isEqualTo(URI.create("http://127.0.0.1:41270/"));

Measured together with the field rename above: 41/41 tests pass. This is a test expectation, not a behavior change; the trailing slash is the existing requireOrigin contract on base and head.

Not covered

  • The full Java unit reactor was stopped after 169 test classes once the focused gate had found the two test defects. The focused gate covers all 16 changed test classes (232 tests: 228 pass, 2 fail, 2 skipped). The full run's additional reds were environmental: WorkspaceCsiNativeActivationGateTest needs packages/core/dist (the core build is blocked by a missing browser-use/dist in this container), SessionWorktreeStoreTest needs git ≥ 2.40 (container has 2.39.5), and LocalProcessRuntimeProvisionerTest initially hit a non-UTF-8 locale (re-ran green under C.UTF-8). RuntimeProviderMaintenanceTest initially lacked /etc/machine-id and passed after the file was mounted; neither environment result is counted as a PR failure.
  • Real MySQL, Hosted/fault, real SSH and Kubernetes qualification, SpotBugs, the full SDK Java matrix and Windows/macOS were not run. The PR's own test plan lists these as pending.
  • The reference distribution's assembly and boot were not completed because the configuration-reference gate (finding 3) fails before that step; the packager was run far enough to hit finding 1.
  • The seven-variant matrix ran on Linux/JDK 21 with Maven 3.9.11; it did not exercise a real SSH host or a Kubernetes cluster.

Methodology

Round directory: tmp/pr16141-head/tmp/pr16141-verify-20261102-211144/. Head worktree at 7ae49ce3 and base worktree at 73474ef0 were separate git worktrees; packaging, embedding and base builds each used their own worktree and private Maven repository. Every command ran in a credential-free node:22-bookworm container with Temurin JDK 21 and Maven 3.9.11; node scripts/verify-pr-prepare.mjs --require-isolation returned 0 in each container before any PR code ran. Raw logs are under logs/ (01-build.log, 03-unit-tests.log, 07-embedding.log, 09/17 focused runs, 13-checkstyle.log, 14-config-reference.log, 08-workflow-size.log, 18–25 fix trials), and the seven surefire reports are under matrix/. The two captures were produced with scripts/verify-capture.mjs from the same evidence files. All temporary source/test/baseline changes used for fix verification were reverted; git status in both worktrees is clean.

— DeepSeek-V4.1-Flash-1017@fda99a87 via Qwen Code /verify-pr (v0.26.5; skill e02c61466216)

@doudouOUC doudouOUC changed the title refactor(managed-agent): Split runtime backends into optional modules refactor(managed-agent): Make runtime backends optional Maven modules Nov 2, 2026
@doudouOUC

Copy link
Copy Markdown
Collaborator Author

本次将 PR 收敛到 独立 Maven 后端、optional 依赖及必要装配。提交:08d6c1b24b697d0ab245ddcc035962bab1b9aae2,统计基线:73474ef094ea1c6bb2a95a9a2a33a28b0ec58e9e。

保留五个后端独立 JAR、隔离 classpath/嵌入测试、历史操作恢复、SSH 准入与连接生命周期保护。默认完整 exec 和运维产物保持兼容。撤出选择性构建器、变体 manifest/classifier、精简归档、六份部署示例及手动 systemd unit、七种成品 CI 矩阵,并合并重复设计文档。其他服务通过 Maven 显式添加所需后端,无须引入其余实现。

PR 从 170 个文件、+4776/-660(净增4116) 收敛为 154 个文件、+3378/-596(净增2782),净新增减少1334行。本次没有修改生产 Java 逻辑。

本轮验证:

检查 结果与边界
9份相关 workflow/runner 测试 700通过、15跳过、0失败;121.562秒
默认参考归档测试 27通过、1个root-only chown跳过、0失败;使用fake Java,不代表JVM验收
配置参考生成器测试 10/10通过
工作流体积门槛 通过;sdk-java.yml为154074字节,比基线增长3742,小于4096;未改门槛或baseline
ESLint、Prettier、git diff --check 通过;正常提交钩子通过
静态边界与文档 16份POM解析,5个后端optional runtime且互不依赖,124处相对链接检查;两轮静态审查及独立复核未发现进一步问题

静态比对确认:server的build配置和参考打包器恢复为main原实现;CI与main的差异只剩新增模块的缓存路径,既有full Java、MySQL、Hosted/fault等gates未削弱。根目录build/typecheck/bundle复用17209b96f285bb5b691146d9af7087f196295ecc上已通过、输入未变的结果;本轮改变的脚本/工作流另行验证如上。

上一版CI失败已逐项核对:Lint & Static因工作流体积超过增长限制,本次收敛后门槛通过;参考分发因provider-options缺中英文配置描述,本次已补齐并同步两份参考页。配置参考的本地生成/--check使用“能精确重现原参考页的既有metadata,加上源码中新增map字段”的渲染夹具,检查通过;它不是当前编译产物,真实新metadata检查仍待CI。

共享Java预算仍为 599.048/600秒,本轮未运行Java/javac/Maven。当前Java回归、Checkstyle、SpotBugs、普通打包/embedding、真实SSH/Kubernetes、MySQL、Hosted/fault和完整跨平台验收仍待CI或真实环境;PR保持Draft。此前失败及超时仍保留为历史证据。本评论更新了前一验证评论中的交付范围:七种独立分发变体已后置,不再是本PR的待交付项。未发布、未部署,预热策略未变。

@wenshao

wenshao commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Failed to process this request. Please re-mention the bot to retry.

@doudouOUC
doudouOUC marked this pull request as ready for review November 2, 2026 13:49
@doudouOUC
doudouOUC enabled auto-merge (squash) November 2, 2026 13:49
@doudouOUC doudouOUC self-assigned this Nov 2, 2026
@qwen-code-review-bot

qwen-code-review-bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Qwen Triage finished — view run. See the stage comments in this thread for the result.

✅ Qwen Triage 已完成 —— 查看运行。结果见本线程中的各阶段评论。

@wenshao

wenshao commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Failed to process this request. Please re-mention the bot to retry.

yiliang114
yiliang114 previously approved these changes Nov 2, 2026

@yiliang114 yiliang114 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope & Linkage

154 files / +3,378 −596. This refactor splits the five runtime backends (Local, SSH, Kubernetes, External, Static) into independent Maven artifacts behind a new RuntimeProviderFactory SPI. The server POM declares all five backends as optional dependencies; the default standalone and operator assemblies retain the full set. CI workflows (sdk-java.yml, verify-maven-repo.yml) consistently list the seven new modules in every cache and write-back path. No issue is closed by this PR; it follows up on merged #15871.

Key observations

SPI design — clean. RuntimeProviderFactory.kinds() → validate(settings) → create(settings, transport, dependencies) is a well-gated, no-leak lifecycle: validation is configuration-only, resource creation happens only after validation passes, and partial creation is cleaned up on failure. RuntimeProviderRegistry uses ServiceLoader and correctly blocks the reserved kubernetes kind and duplicate registrations.

Validation gates before side effects. Every factory validates before creating resources. LocalRuntimeProviderFactory.validate() checks paths and rejects relative extension cache directories before opening any local state. SshRuntimeProviderFactory.validate() checks node IDs, isolation class, and configuration exclusivity without touching SSH. The Kubernetes factory validates HTTPS origin and file paths. Tests confirm absent directories are never created during validation.

Backend selection is explicit. RuntimeBackendSelection.from(settings) derives the needed backends from configuration alone — no classpath probing, no implicit fallback. SSH nodes with local-process provisioning correctly require both backends. SSH-only provisioning rejects local-only settings.

Spring lifecycle improved. ManagedAgentConfiguration now sets destroyMethod = "close" on the SSH connections bean (was empty string), so Spring properly calls SshConnectionManager.close() on shutdown. The bean is gated behind RuntimeBackendSelection.includes(SSH_PROCESS) and created through RuntimeProviderRegistry.

Preflight updated consistently. ManagedAgentPreflight.brokerChecks() delegates to the SPI's validate() and preflight() methods instead of hard-coding per-provisioner logic. toolPathCheck handles ssh-process specifically.

Maven modules are uniform. All six new pom.xml files share the same structure: parent reference, managed.module.root property, consistent dependency sets, and identical Checkstyle/SpotBugs/Surefire plugin configurations with failIfNoSpecifiedTests=false.

Design docs are bilingual and synchronized. Both 2026-10-31-managed-runtime-backend-modules.md and its .zh-CN counterpart document the module split, backend selection, recovery behavior, and migration notes. Obsolete source paths in older design docs are updated.

Verdict

No P0/P1 findings. The architecture is sound, the SPI contract is well-defined, and the factory implementations follow a consistent validate-then-create pattern. CI workflow changes are mechanical and complete. The PR author explicitly notes that acceptance testing is pending — this is not a code defect.

APPROVE the current head 08d6c1b.

@qqqys qqqys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at 08d6c1b24b697d0ab245ddcc035962bab1b9aae2 — COMMENT (not approving)

Not approving, because a maintainer verification round concluded this PR was not mergeable and filed four Criticals plus two Highs, and at this head three of them cannot be confirmed either way. I want to separate clearly below what I verified as clean from what is simply unconfirmed, because the two are not the same thing.

Unconfirmed: the findings that depend on a lane that has never run here

The round at 13:39 UTC was written against the first commit 7ae49ce3; the second commit 08d6c1b2 narrowed the PR from 170 files to 154. Mapping each finding onto the CI that would settle it:

  • Checkstyle rejects three new backend sources — enforced by SDK Java (fast) / ubuntu-latest / Java 21, which is pending at this head. Unconfirmed.
  • EmbeddedRuntimeBrokerTest reflects a field the refactor removed — same pending lane. Unconfirmed.
  • StaticRuntimeProviderFactoryTest expects an unnormalized URI — same pending lane, and that test file is present in this PR's changed set, so it is live. Unconfirmed.
  • The archive inspector reads configuration metadata at a path Spring Boot does not write — the author states the variant manifest, trimmed-archive and seven-product matrix work was withdrawn, which would make this moot, but I did not verify the inspector itself is gone. Unconfirmed.

Two do look settled, and I want to say so rather than leave them standing: the provider-options documentation and stale generated reference are covered by Build and verify reference distribution, which passed in 4m20s, and the sdk-java.yml workflow-size ratchet is covered by Lint & Static, which passed in 8m0s. Both green lanes are consistent with the author's item-by-item account of the previous failures.

The gap is that the Java side has no execution evidence at this head whatsoever. The author's own comment states that this round ran no Java, javac or Maven locally, with the shared Java budget at 599.048/600 seconds, and that Java regression, Checkstyle, SpotBugs, packaging and embedding, real SSH and Kubernetes, MySQL, Hosted/fault and cross-platform acceptance all remain pending. I am not treating pending CI as a defect, but I cannot certify findings fixed on a lane that has not run, and the maintainer's verdict was explicitly "not mergeable".

Verified clean: the two things that most often break in a split like this

SPI registration is complete, so no backend can silently vanish from discovery. This is the dominant failure mode when backends become optional modules loaded through ServiceLoader, so I censused it rather than sampling it. There are exactly five RuntimeProviderFactory implementations in the tree — ExternalRuntimeProviderFactory, KubernetesRuntimeProviderFactory, LocalRuntimeProviderFactory, SshRuntimeProviderFactory, StaticRuntimeProviderFactory — one per provider module, and each of those five modules carries a matching META-INF/services/com.alibaba.qwen.code.runtimebroker.spi.RuntimeProviderFactory resource.

The parent pom declares seven new modules, and the two without a registration are correctly without one: runtime-http contains only the moved HttpRuntimeTransport (a pure rename, zero added lines), and runtime-host contains HostCommandRunner, RuntimeStateFiles and two renamed classes. Neither holds a factory implementation, so 5 registrations against 7 modules is the right ratio, not a missing pair. This matches the maintainer's independent measurement of five selectable backends.

No CI gate is narrowed. For a module split, the second thing that breaks silently is a lane that stops building or testing one of the new modules. The sdk-java.yml change (+30/−2) is purely additive: the seven new qwen-managed-agent-runtime-* artifact paths are appended to the resolve lists and to the two find … -prune cache write-back exclusion lists, and they are added consistently in all four places. No module is removed from a reactor invocation, and no timeout, selector or tier condition is altered. That corroborates the author's claim that the only CI delta versus main is cache paths for the new modules. I did not read verify-maven-repo.yml (+7/−0), so I am not making a claim about it.

Scale

154 files, +3378/−596, seven new Maven modules and a new SPI surface across contracts. I could not complete a Critical-only scan of that in the window I have, and the two censuses above are the highest-value part of it rather than all of it. In particular I did not read the new SPI interfaces themselves, the optional dependency wiring in the consuming poms, or the behaviour of a deployment that omits a backend it later asks for — which is where a fail-open path would live if one exists.

One factual discrepancy worth resolving

The author's comment states the PR remains a Draft, but the API reports isDraft: false and the PR is open and mergeable. If it is not intended to be mergeable yet, marking it Draft would prevent it landing ahead of the pending Java lane.

Next step

Let SDK Java (fast) / ubuntu-latest / Java 21 finish at this head. If it is green, findings 2, 5 and 6 are settled by execution and the remaining question is only whether the archive inspector survived the scope cut. If it is red, the failure names will say which. I would re-review against a green Java lane.

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Thanks for the PR — and for cutting round 2 down as aggressively as you did.

Template looks good ✓ — every required section is present, and the design doc is linked in both languages with matching structure (seven headings each, same order).

Problem: real and verifiable against main, not theoretical. Two claims, both of which I confirmed in the code being replaced:

  • EmbeddedRuntimeBroker derives remote = ssh != null && ssh.configured() and then unconditionally wraps a Local base provisioner in a RoutingRuntimeProvisioner next to an SshRuntimeProvisioner. An SSH deployment therefore cannot avoid initializing Local.
  • All five backend implementations ship in one adapters artifact, so a service embedding the server library inherits every backend transitively.

Direction: aligned. This follows merged #15871, the boundary is described in a bilingual design doc, and it moves toward what packages/managed-agent-server/AGENTS.md already asks for — production modules compiling independently, tests confined to verification. No CHANGELOG signal needed; this is internal Java module structure, not a CLI surface.

Size: the core-path globs don't match. Everything sits under packages/managed-agent-server/** — a single package, no cross-package span — plus docs/, .github/ and one scripts/ test. The author also has admin on this repo, so the maintainer exemption would apply regardless. No block and no escalation. The non-blocking large-PR advisory does apply:

files lines
Production Java (src/main) 51 1695
SPI service registrations 5 5
POMs 11 449
CI / scripts / JSON 4 71
Production subtotal 71 2220
Test sources 72 1551
Docs 11 203
Total 154 3974

That clears the 1000-line advisory, so: this is large, and splitting is worth considering if a seam exists. In fairness to the diff, 45 of the 154 files are pure renames, so the genuinely new logic is considerably smaller than the raw count reads.

Approach: the scope feels right now. Round 2 already withdrew the selective builder, variant manifests and classifiers, trimmed archives, six deployment examples, the systemd unit and the seven-variant CI matrix (170 files / +4776−660 → 154 / +3378−596), which is close to the answer I'd have given to "could you cut most of this?". What remains matches what I'd have written independently: one Maven module per backend, the SPI in contracts, ServiceLoader plus META-INF/services discovery, <optional> backend dependencies on server, and the exec artifact left complete so operators see no change. Two questions, neither a blocker:

  • RuntimeProviderRegistry is constructed fresh in at least five places — ManagedAgentProperties.validateRuntimeProvider, the ManagedAgentConfiguration SSH bean, three sites in ManagedAgentPreflight, and EmbeddedRuntimeBroker — each running its own ServiceLoader.load() classpath scan. Would one Spring-managed instance cover all of them?
  • validateForPreflight() now runs validateRuntimeProvider() before validateWorkspaceFiles(), whereas on main the external-runtime checks ran inside validateWorkspaceFiles(). A deployment that is misconfigured both ways will now get a different first error. Almost certainly fine, but it is an operator-visible ordering shift.

Risk: no elevated risk signals — none of the changed paths match the revert-correlated set.

Moving on to code review. 🔍

中文说明

感谢贡献,也感谢第二轮把范围收敛得这么干脆。

模板完整 ✓ —— 各必填章节齐全,设计文档中英双语均已链接且结构一致(各七个标题,顺序相同)。

问题: 真实存在,可以在 main 上直接验证,不是理论性加固。两点主张我都在被替换的代码里核对过:

  • EmbeddedRuntimeBroker 通过 remote = ssh != null && ssh.configured() 判断,随后无条件地把 Local base provisioner 与 SshRuntimeProvisioner 一起包进 RoutingRuntimeProvisioner。因此 SSH 部署无法避免初始化 Local。
  • 五个后端实现都打在同一个 adapters 产物里,引用 server library 的服务会传递引入全部后端。

方向: 对齐。这是已合并 #15871 的后续工作,边界有双语设计文档描述,也符合 packages/managed-agent-server/AGENTS.md 既有要求——生产模块独立编译、测试集中在 verification。不需要 CHANGELOG 信号;这是内部 Java 模块结构,不是 CLI 界面。

规模: 未命中核心路径通配。全部改动位于 packages/managed-agent-server/**——单个 package,不跨 package——外加 docs/、.github/ 和一个 scripts/ 测试。作者对本仓库有 admin 权限,维护者豁免本来也适用。因此不拦截、不上报。但大 PR 提示(非阻塞)适用:生产代码合计 2220 行(Java src/main 1695、SPI 注册 5、POM 449、CI/脚本/JSON 71),测试 1551 行,文档 203 行,总计 154 文件 3974 行。

已超过 1000 行提示线,所以:这个 PR 很大,如果存在可切分的接缝,值得考虑拆分。不过要公道地说,154 个文件里有 45 个是纯重命名,真正新增的逻辑比行数看起来小得多。

方案: 现在的范围是合理的。第二轮已经撤掉了选择性构建器、变体 manifest 与 classifier、精简归档、六份部署示例、systemd unit 和七变体 CI 矩阵(170 文件 / +4776−660 → 154 / +3378−596),这基本就是我会给出的"能不能砍掉大部分"的答案。剩下的部分与我独立设想的方案一致:每个后端一个 Maven 模块、SPI 放在 contracts、用 ServiceLoader 加 META-INF/services 发现、server 上后端依赖标 <optional>、exec 产物保持完整以免运维侧感知变化。两个疑问,都不是阻塞项:

  • RuntimeProviderRegistry 至少在五处被重新构造——ManagedAgentProperties.validateRuntimeProvider、ManagedAgentConfiguration 的 SSH bean、ManagedAgentPreflight 三处、以及 EmbeddedRuntimeBroker——每处都各自跑一遍 ServiceLoader.load() 类路径扫描。是否可以用一个 Spring 托管的实例覆盖全部?
  • validateForPreflight() 现在先跑 validateRuntimeProvider() 再跑 validateWorkspaceFiles(),而 main 上 external-runtime 校验是在 validateWorkspaceFiles() 内部执行的。两处都配错的部署,现在看到的第一个报错会不同。大概率没问题,但确实是运维可见的顺序变化。

风险: 无升级风险信号——改动路径均未命中与回滚相关的那组文件。

进入代码审查 🔍

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at 08d6c1b24b697d0ab245ddcc035962bab1b9aae2 · re-run with @qwen-code /triage

@qwen-code-review-bot

qwen-code-review-bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Code review

I read the diff against the current head and re-checked each of round 1's six findings rather than trusting either the report or the reply. Three are genuinely fixed, one no longer applies, and two are still present and will redden the Java job that is currently in flight.

Blockers

1. EmbeddedRuntimeBrokerTest reflects a field this PR renamed — mvn test cannot pass.

EmbeddedRuntimeBroker renames localProvisioner to primaryProvisioner (head line 66), but EmbeddedRuntimeBrokerTest.provisionerOf() still calls EmbeddedRuntimeBroker.class.getDeclaredField("localProvisioner") at line 563, and the active @Test constructsAnExternalScratchProvisionerForAValidConfiguration calls it at line 459. That is a NoSuchFieldException on every run. The head commit 08d6c1b2 touched 33 files and this test is not among them.

The narrow fix is to point the reflection at primaryProvisioner. The better fix is to drop the reflection entirely — the test only wants the resolved provisioner's kind, and the field name has now moved once, which is exactly the fragility reflection into a private field buys you.

This is round-1 finding #5, unchanged.

2. Checkstyle rejects three new production sources.

packages/sdk-java/qwencode/qwen-code-checks.xml:31-34 registers a RegexpMultiline rule with format \n\n\s*\} and message "Blank line before closing brace". Three files this PR adds end with a blank line before the final }:

  • runtime-host/src/main/java/com/alibaba/qwen/code/runtimebroker/host/RuntimeStateFiles.java
  • runtime-external/src/main/java/com/alibaba/qwen/code/runtimebroker/provisioning/external/ExternalRuntimeProviderFactory.java (line 133)
  • runtime-local/src/main/java/com/alibaba/qwen/code/runtimebroker/provisioning/local/LocalRuntimeProviderFactory.java

I scanned the full diff for an added blank line immediately followed by an added column-0 } and these three are the only hits, so the list should be complete. All six new module POMs bind maven-checkstyle-plugin (I checked each), and sdk-java.yml runs mvn checkstyle:check checkstyle:check@runtime-broker-checkstyle from packages/managed-agent-server on ubuntu-latest / Java 21 — the job currently in progress. Round-1 finding #2, unchanged.

Unresolved — I could not settle this one

3. ManagedAgentPackagingIT configuration-metadata path.

ManagedAgentPackagingIT:35 asserts BOOT-INF/classes/META-INF/spring-configuration-metadata.json. That assertion is new — it does not exist on main. Round 1 measured the real repackaged archive placing the file at archive-root META-INF/ on both base and head, and reported the IT failing on all seven variants through the build selector.

I am not repeating that as a finding, because I could not verify it and the two accounts disagree: standard Spring Boot repackage layout puts annotation-processor output under BOOT-INF/classes/, which would make the assertion correct. This review is static — I do not build or run PR code — so I have no measurement of my own here. What I can say is that the lane which runs it (the surefire artifact-packaging execution at verification/pom.xml:147-163, which needs packaged artifacts in server/target) is not exercised by this run's fast tier, so CI will not settle it either. Please confirm against a real exec jar before the full lanes run.

Not verified: the archive layout, for the reason above. Not verified: MySQL, Hosted/fault, real SSH and Kubernetes behaviour — those lanes are skipped on this run and the PR body already lists them as pending.

Round-1 findings that are now closed

What I checked and think is right

  • The validation move is faithful. validateExternalRuntime() was deleted from ManagedAgentProperties and reappears in ExternalRuntimeProviderFactory.validate() line for line — every check preserved, including the shipped-placeholder-token refusal and the comment explaining why the format rule alone is not enough. All three former call sites are re-wired: ManagedAgentConfiguration's constructor now calls validateRuntimeProvider(), validateForPreflight() calls it, and ManagedAgentPreflight uses the registry directly. This was the change most likely to silently drop a guard, and it did not.
  • Failure paths now release what they own. EmbeddedRuntimeBroker closes local and a partially-constructed remoteProvisioner if routing assembly throws, and closes provisioner if RuntimeBrokerService construction fails. RuntimeProviderRegistry.create() closes a provider whose reported kind disagrees with the configured one. All three are new and all three are the right ownership behaviour.
  • The reserved-kind refusal is not a new breaking change. require("kubernetes") throwing looks alarming next to a runtime-kubernetes module, but main already refuses the bare kubernetes provisioner kind (EmbeddedRuntimeBroker:515-516). kubernetes-workspace still resolves normally through kubernetes().
  • HostCommandRunner is a faithful extraction. Same RECORD_LIMIT = 64 * 1024, same 60s COMMAND_TIMEOUT, same output-discard / virtual-thread-writer / timeout shape as the deleted SshConnectionManager.runCommand. Two small heads-ups, neither blocking: Result now clones stdout in the compact constructor and on every accessor call where CommandResult did neither, so each stdout() allocates; and unavailable() still reports ssh_runtime_unavailable from what is now a shared runtime-host class — accurate while SSH is the only consumer, misleading the day another backend uses it.
  • SSH-only assembly really does skip Local. The SSH connections bean returns null early unless the selection includes ssh-process, and remote is now derived from RuntimeBackendSelection instead of ssh.configured(). That is the coupling the PR set out to remove, and it is gone.
  • The gates were not weakened to make this pass. All six new modules bind Checkstyle and SpotBugs, and verification stays test-only.
  • Design docs are synchronized. English and Chinese both carry the same seven headings in the same order.

Assembly path after the split

sequenceDiagram
    participant P1 as ManagedAgentConfiguration
    participant P2 as ManagedAgentProperties
    participant P3 as RuntimeProviderRegistry
    participant P4 as ServiceLoader
    participant P5 as RuntimeProviderFactory
    participant P6 as EmbeddedRuntimeBroker
    P1->>P2: validateRuntimeProvider()
    P2->>P3: validateSelected(settings)
    P3->>P4: load RuntimeProviderFactory
    P4-->>P3: installed factories, keyed by kind
    P3->>P5: validate(settings) for each selected kind
    P6->>P3: create(settings, transport, dependencies)
    P3->>P5: validate then create
    P5-->>P3: RuntimeProvisioner, caller owns close
    P3-->>P6: provisioner, kind re-checked against config
Loading
Files changed (24 of 154 shown)
File What changed
contracts/.../spi/RuntimeProviderFactory.java New SPI: kinds, config-only validate, create with caller-owned close, preflight, maintenance hook.
contracts/.../spi/RuntimeBackendSelection.java New: derives selected kinds from settings, independent of what the classpath happens to carry.
contracts/.../spi/RuntimeProviderDependencies.java New: four named ports so a backend asks only for what it needs.
contracts/.../spi/{KubernetesRuntimeSupport,OperatorRuntimeRecovery,SshRuntimeAccess,SshRuntimeSupport,WorkspaceCsiRuntimeSpec}.java New capability interfaces the maintenance and SSH paths downcast to.
server/.../config/runtime/RuntimeProviderRegistry.java New: ServiceLoader discovery, duplicate and reserved-kind refusal, validate-then-create.
server/.../config/runtime/EmbeddedRuntimeBroker.java Largest behavioural change (+91/−138): selection-driven assembly, new failure-path cleanup.
server/.../config/ManagedAgentProperties.java +14/−86: external-runtime validation moved out to the factory; new validateRuntimeProvider.
server/.../config/ManagedAgentConfiguration.java Validates on construction; SSH connections bean returns null when SSH is not selected.
server/.../preflight/ManagedAgentPreflight.java +31/−63: asks the registry for per-action capability instead of branching per backend.
runtime-{local,ssh,kubernetes,external,static}/.../*RuntimeProviderFactory.java New per-backend factories; each carries the validation that used to live in the server.
runtime-host/.../HostCommandRunner.java New: process runner extracted verbatim from SshConnectionManager.
runtime-host/.../RuntimeStateFiles.java New — one of the three Checkstyle blockers.
runtime-ssh/.../SshConnectionManager.java +9/−52: delegates process execution to HostCommandRunner; drops the nested CommandResult.
runtime-local/.../LocalRuntimeStore.java +5/−36: state handling thinned now that the factory owns validation.
control-plane/.../SshWorkspaceService.java +16/−10: no longer takes a Local provisioner.
persistence/.../WorkspaceFileUploadStore.java +6: keeps pending uploads and their storage claims when the backend is absent.
managed-agent-server/pom.xml +42: seven new modules and their dependencyManagement entries.
{runtime-host,runtime-http,runtime-local,runtime-ssh,runtime-kubernetes,runtime-external,runtime-static,server,adapters,verification}/pom.xml New and updated module POMs; backends are optional on server.
META-INF/services/...RuntimeProviderFactory ×5 One service registration per backend.
.github/workflows/sdk-java.yml +30/−2 across both commits: cache paths for the new modules, then trimmed back under the size ratchet.
.github/workflows/verify-maven-repo.yml +7: the new artifacts in the repo verification set.
configuration-descriptions.json +7/−2: provider-options descriptions, fixing round-1 finding #3.
docs/design/2026-10-31-managed-runtime-backend-modules{,.zh-CN}.md New bilingual design doc, 70 lines each, matching headings.
verification/src/test/... …and 72 test files: 45 pure renames tracking the moved packages, plus new registry, selection, plugin, SSH-wiring and maintenance tests.

Test evidence

This is an unattended CI run, so I did not build or execute anything from this PR. The evidence below is the PR's own check-runs on the reviewed commit, read through the API.

Final CI results for 08d6c1b (auto-updated by the triage finalize job after CI completed):

Check Conclusion
Managed Agent fast tier ❌ failure
SDK Java (fast) / ubuntu-latest / Java 21 ❌ failure
Test (ubuntu-latest, Node 22.x) ❌ failure
Build and verify reference distribution ✅ success
Check TUI impact ✅ success
Classify PR ✅ success
Integration Tests (no-AK, No Sandbox) ✅ success
Lint & Static (ubuntu-latest, Node 22.x) ✅ success
SDK Java (fast) / Flyway migration version uniqueness ✅ success
SDK Java (fast) / Real daemon E2E / Java 11 ✅ success
Select the Managed Agent tier ✅ success
TUI parity snapshots (ink vs opentui) ✅ success
web-shell E2E Smoke (ubuntu-latest, Node 22.x) ✅ success

One row per check name (latest run); skipped checks omitted; failures sort first. / 每个检查名一行(取最新一次运行),省略 skipped,失败项排在最前。

Nothing is red yet, and nothing has gone green that settles the two blockers either. Lint & Static and Build and verify reference distribution both succeed at this head where both were red at 7ae49ce3, which independently corroborates the author's account of the workflow-size and provider-options fixes. SDK Java (fast) / Flyway migration version uniqueness and SDK Java (fast) / Real daemon E2E / Java 11 are green.

The job that matters — SDK Java (fast) / ubuntu-latest / Java 21, which carries both Run Runtime Broker state tests (mvn clean test, the whole reactor including verification) and Run Managed Agent Server Checkstyle — was still in progress when I read it. That single job is where findings 1 and 2 will surface. I am not polling it; the table above is a snapshot and the finalize job will rewrite it once CI settles.

The skipped set is worth naming explicitly, because it is exactly the acceptance the PR body says is outstanding: Runtime Broker and Managed Agent MySQL, Hosted failover E2E, Hosted process fault gates, and both EventTransport RocketMQ lanes are all skipped on this run, since Select the Managed Agent tier resolved to fast. So the SQL, recovery, fault-injection and real-infrastructure behaviour has no CI coverage here at all — not failing coverage, absent coverage. Test (macos-latest) and Test (windows-latest) are skipped too, so the author's macOS-only local run is the only platform evidence in the thread.

Sandboxed verification would settle the two things neither this diff nor this CI run can: @qwen-code /verify — specifically, whether the real exec archive puts spring-configuration-metadata.json under BOOT-INF/classes/META-INF/ (finding 3, where my reading and round 1's measurement disagree and the fast tier never runs the IT that would decide it), and whether an unselected backend genuinely reads no credentials and initializes no state, which is a claim about code not running and so is invisible in a green suite.

中文说明

代码审查

我按当前 head 通读了 diff,并逐条复核了第一轮的六个 finding,既不采信报告本身,也不采信回复。三条确实已修,一条已不再适用,两条仍然存在,并且会把当前正在跑的 Java job 染红。

阻塞项

1. EmbeddedRuntimeBrokerTest 反射的字段已被本 PR 重命名——mvn test 不可能通过。

EmbeddedRuntimeBroker 把 localProvisioner 改名为 primaryProvisioner(head 第 66 行),但 EmbeddedRuntimeBrokerTest.provisionerOf() 第 563 行仍在调用 getDeclaredField("localProvisioner"),而生效中的 @Test constructsAnExternalScratchProvisionerForAValidConfiguration 在第 459 行调用它。每次运行都会抛 NoSuchFieldException。head commit 08d6c1b2 改了 33 个文件,这个测试不在其中。

最小修法是把反射指向 primaryProvisioner。更好的修法是彻底去掉反射——这个测试只想知道解析出的 provisioner 的 kind,而字段名已经变动过一次,这正是反射私有字段换来的脆弱性。

对应第一轮 finding #5,未修。

2. Checkstyle 拒绝三个新增生产源文件。

qwen-code-checks.xml:31-34 注册了 RegexpMultiline 规则,format 为 \n\n\s*\},消息是 "Blank line before closing brace"。本 PR 新增的三个文件在最后的 } 前留了空行:runtime-host 的 RuntimeStateFiles.java、runtime-external 的 ExternalRuntimeProviderFactory.java(第 133 行)、runtime-local 的 LocalRuntimeProviderFactory.java。

我扫描了整个 diff,查找"新增空行紧跟新增的行首 }",只命中这三处,所以清单应当是完整的。六个新模块的 POM 都绑定了 maven-checkstyle-plugin(逐个核对过),而 sdk-java.yml 会在 ubuntu-latest / Java 21 上从 packages/managed-agent-server 执行 mvn checkstyle:check checkstyle:check@runtime-broker-checkstyle——正是当前在跑的那个 job。对应第一轮 finding #2,未修。

未定论——这一条我无法判定

3. ManagedAgentPackagingIT 的配置元数据路径。

第 35 行断言 BOOT-INF/classes/META-INF/spring-configuration-metadata.json。这个断言是新增的,main 上没有。第一轮实测真实重打包归档(base 与 head 都是)把该文件放在归档根 META-INF/,并报告七个变体全部失败。

我不把它作为 finding 重复提出,因为我无法验证,而且两种说法互相矛盾:Spring Boot repackage 的标准布局会把注解处理器产物放在 BOOT-INF/classes/ 下,那样这个断言就是对的。本次审查是静态的——我不构建也不运行 PR 代码——所以我这里没有自己的实测。能确定的是:跑这个 IT 的 lane(verification/pom.xml:147-163 的 surefire artifact-packaging execution,需要 server/target 里已打包的产物)在本次 fast tier 中不会被执行,所以 CI 也无法判定。请在完整 lane 跑起来之前,用真实的 exec jar 确认一次。

未验证:归档布局,原因如上。未验证:MySQL、Hosted/fault、真实 SSH 与 Kubernetes 行为——本次运行这些 lane 被跳过,PR 正文也已列为待验收。

第一轮已关闭的 finding

我核对过并认为正确的部分

  • 校验搬迁是忠实的。 validateExternalRuntime() 从 ManagedAgentProperties 删除,逐行重现于 ExternalRuntimeProviderFactory.validate()——每项检查都保留,包括模板占位 token 的拒绝,以及解释"为何仅有格式规则不够"的注释。原来三个调用点都重新接上了:ManagedAgentConfiguration 构造函数调用 validateRuntimeProvider(),validateForPreflight() 调用它,ManagedAgentPreflight 直接用 registry。这是最可能悄悄丢掉一道防护的改动,而它没有丢。
  • 失败路径现在会释放自己持有的资源。 EmbeddedRuntimeBroker 在路由装配抛错时关闭 local 和构造到一半的 remoteProvisioner,在 RuntimeBrokerService 构造失败时关闭 provisioner;RuntimeProviderRegistry.create() 在 provider 上报的 kind 与配置不一致时关闭它。三处都是新增,且都是正确的所有权行为。
  • 保留 kind 的拒绝不是新的破坏性变更。 在存在 runtime-kubernetes 模块的旁边让 require("kubernetes") 抛错看起来吓人,但 main 本来就拒绝裸 kubernetes provisioner kind(EmbeddedRuntimeBroker:515-516)。kubernetes-workspace 仍通过 kubernetes() 正常解析。
  • HostCommandRunner 是忠实抽取。 RECORD_LIMIT = 64 * 1024、60 秒 COMMAND_TIMEOUT、输出丢弃 / 虚拟线程写入 / 超时形态都与被删除的 SshConnectionManager.runCommand 一致。两点小提醒,均不阻塞:Result 现在在紧凑构造器和每次访问器调用时都克隆 stdout,而 CommandResult 两者都不做,因此每次 stdout() 都会分配;unavailable() 仍在一个现在属于共享 runtime-host 的类里返回 ssh_runtime_unavailable——在 SSH 是唯一使用者时准确,将来别的后端用它时就会误导。
  • SSH-only 装配确实跳过了 Local。 SSH 连接 bean 在选择未包含 ssh-process 时提前返回 null,remote 现在由 RuntimeBackendSelection 推导而非 ssh.configured()。这正是本 PR 要拆掉的耦合,它已经没了。
  • 门禁没有为了让 PR 通过而被削弱。 六个新模块都绑定了 Checkstyle 和 SpotBugs,verification 仍然只放测试。
  • 设计文档已同步。 中英文各七个标题,顺序一致。

测试证据

这是无人值守的 CI 运行,所以我没有构建或执行本 PR 的任何代码。下面的证据是通过 API 读取的、本 PR 自己在被审 commit 上的 check-run 结果。

目前没有任何一项为红,但也没有任何一项变绿到能判定上述两个阻塞项。Lint & Static 与 Build and verify reference distribution 在本 head 上均成功,而两者在 7ae49ce3 上都是红的——这独立佐证了作者关于工作流体积和 provider-options 两处修复的说法。SDK Java (fast) / Flyway migration version uniqueness 和 SDK Java (fast) / Real daemon E2E / Java 11 为绿。

关键的那个 job——SDK Java (fast) / ubuntu-latest / Java 21,同时承载 Run Runtime Broker state tests(mvn clean test,覆盖含 verification 的整个 reactor)和 Run Managed Agent Server Checkstyle——在我读取时仍在进行中。finding 1 和 2 都会在这一个 job 里暴露。我不会去轮询它;上表是快照,CI 落定后 finalize job 会就地重写它。

被跳过的部分值得点名,因为它恰好就是 PR 正文所说尚未完成的验收:Runtime Broker and Managed Agent MySQL、Hosted failover E2E、Hosted process fault gates 以及两条 EventTransport RocketMQ lane 本次全部跳过,因为 Select the Managed Agent tier 解析为 fast。所以 SQL、恢复、故障注入和真实基础设施行为在本次运行中完全没有 CI 覆盖——不是失败的覆盖,而是缺失的覆盖。Test (macos-latest) 和 Test (windows-latest) 同样被跳过,因此线程里唯一的平台证据就是作者仅在 macOS 上的本地运行。

沙箱验证可以判定这个 diff 和本次 CI 都无法判定的两件事:@qwen-code /verify —— 具体是,真实 exec 归档究竟把 spring-configuration-metadata.json 放在 BOOT-INF/classes/META-INF/ 下还是归档根(finding 3,我的阅读与第一轮的实测不一致,而 fast tier 从不运行那个能裁决的 IT),以及未选中的后端是否真的不读取凭据、不初始化状态——这是一个关于代码不执行的主张,因此在一套绿色测试里是看不见的。

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at 08d6c1b24b697d0ab245ddcc035962bab1b9aae2 · re-run with @qwen-code /triage

@qwen-code-review-bot

qwen-code-review-bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Confidence: 2/5 — the architecture is sound and the risky part of it was done carefully, but two gates cannot pass at this head and both were already reported once.

Stepping back: my independent proposal before reading the diff was one Maven module per backend, the SPI in contracts, ServiceLoader discovery, <optional> backend dependencies on server, and the exec artifact left complete. That is what this PR does. I did not find a simpler path it missed, and I do not have a scope objection left to make — round 2 already withdrew the build selector, the variant manifests and classifiers, the trimmed archives, six deployment examples, the systemd unit and the seven-variant CI matrix, which is the cut I would have asked for.

The part I expected to be weakest turned out to be the strongest. Deleting validateExternalRuntime() from ManagedAgentProperties and re-homing it in a plugin factory is exactly where a guard silently disappears, and it did not: the checks moved line for line, the placeholder-token refusal and its explanatory comment came along, and all three former call sites are re-wired. The new failure-path cleanup — closing a partially-built remote provisioner, closing the provisioner when service construction throws, closing a provider whose reported kind disagrees with configuration — is more careful about ownership than the code it replaces. If I were maintaining this in six months I would thank the author for that, not curse them.

What stops me is narrower than the architecture and, unfortunately, mechanical. EmbeddedRuntimeBrokerTest reflects a private field this PR renamed, so an active @Test throws NoSuchFieldException on every run; and three new production sources end with a blank line before the closing brace, which the repo's Checkstyle configuration explicitly forbids. Neither is a judgement call, neither is a nit, and both sit in the one Java job that was still running when I looked. They were both named in round 1, and the head commit touched 33 files without reaching either — which is the part I would want the author to look at, because it suggests the round-2 convergence was verified against the script, workflow and documentation checks that did get re-run, and not against the Java reactor at all. The author says so plainly: the shared Java budget closed at 599.048/600 seconds and no javac or Maven ran this round. That is an honest account and I believe it; it just means nothing in the thread has executed this code since the rename.

So I am requesting changes rather than deferring. The fixes are two-line-each, and the module split itself deserves to land — but it should land on a head where mvn test and checkstyle:check pass, and where the packaging-metadata assertion in finding 3 has been checked against a real exec jar rather than left for a lane that this run skips.

One thing I want to be explicit about, since it cuts against my verdict: I could not verify finding 3 and I have not presented it as a defect. Round 1 measured the metadata file at the archive root; the standard Spring Boot layout says it belongs under BOOT-INF/classes/. Those cannot both be right, and I have no measurement of my own because this review is static. If the author's reading is the correct one, that is three findings down to two, and the two are trivial.

@doudouOUC — the two blockers are in the Java reactor, which nothing in this round ran. Re-running mvn clean test checkstyle:check from packages/managed-agent-server should surface both immediately.

⚠️ The formal CHANGES_REQUESTED review could not be submitted on this run. GitHub permits one pending review per user per PR, and the concurrent review-pr job holds a pending review under this same bot identity — both the GraphQL and REST attempts returned 422 User can only have one pending review per pull request. I did not submit or dismiss that job's review, because it is not mine to close. The verdict above is unchanged: please read this PR as changes requested, not as a pass, and expect no red review badge until that job finishes or a maintainer records the request.

中文说明

Confidence: 2/5 —— 架构是站得住的,其中最有风险的部分做得很仔细,但当前 head 上有两道门禁不可能通过,而这两条都已经被报过一次。

退一步看:我在读 diff 之前独立设想的方案是每个后端一个 Maven 模块、SPI 放在 contracts、用 ServiceLoader 发现、server 上后端依赖标 <optional>、exec 产物保持完整。这个 PR 做的正是这些。我没有找到它漏掉的更简路径,也不再有任何范围上的异议——第二轮已经撤掉了构建选择器、变体 manifest 与 classifier、精简归档、六份部署示例、systemd unit 和七变体 CI 矩阵,这正是我会要求的那一刀。

我原以为最薄弱的地方反而是最强的。把 validateExternalRuntime() 从 ManagedAgentProperties 删掉、搬进插件工厂,正是一道防护最容易无声消失的位置,而它没有消失:检查逐行搬迁,占位 token 的拒绝及其解释性注释一并带过去了,原来三个调用点也都重新接上。新增的失败路径清理——关闭构造到一半的 remote provisioner、在服务构造抛错时关闭 provisioner、在 provider 上报 kind 与配置不一致时关闭它——在所有权处理上比被替换的代码更严谨。如果六个月后由我来维护,我会因此感谢作者,而不是骂他。

让我停下来的东西比架构狭窄得多,而且很不巧是机械性的。EmbeddedRuntimeBrokerTest 反射了本 PR 重命名的私有字段,于是一个生效中的 @Test 每次运行都抛 NoSuchFieldException;三个新增生产源文件在收尾大括号前留了空行,而仓库的 Checkstyle 配置明确禁止这一点。两者都不是判断题,也都不是吹毛求疵,而且都落在我查看时仍在运行的那一个 Java job 里。它们在第一轮就都被点名过,而 head commit 改了 33 个文件,两处都没碰到——这才是我希望作者正视的地方,因为它说明第二轮的收敛是拿确实重跑过的脚本、工作流和文档检查验证的,完全没有对着 Java reactor 验证。作者自己说得很清楚:共享 Java 预算在 599.048/600 秒关闭,本轮没有跑过 javac 或 Maven。这是诚实的交代,我信;但它意味着自从那次改名之后,线程里没有任何东西真正执行过这份代码。

所以我选择 request changes 而不是 defer。修法各自只有两行,模块拆分本身值得合入——但它应该合在一个 mvn test 和 checkstyle:check 都能通过的 head 上,并且 finding 3 里的打包元数据断言应当拿真实的 exec jar 核对过,而不是留给本次运行会跳过的那条 lane。

有一点我要讲明白,因为它与我的结论相反:finding 3 我无法验证,我也没有把它当作缺陷提出。第一轮实测元数据文件在归档根;Spring Boot 的标准布局说它应该在 BOOT-INF/classes/ 下。两者不可能都对,而我因为做的是静态审查,没有自己的实测。如果作者的读法才是对的,那就是三个 finding 变两个,而剩下的两个都很琐碎。

@doudouOUC —— 两个阻塞项都在 Java reactor 里,而本轮没有任何东西跑过它。从 packages/managed-agent-server 重跑 mvn clean test checkstyle:check 应该能立刻把两处都暴露出来。

⚠️ 本轮无法提交正式的 CHANGES_REQUESTED review。 GitHub 每个用户在一个 PR 上只允许一个 pending review,而并发的 review-pr job 正以同一个 bot 身份持有 pending review——GraphQL 与 REST 两种尝试都返回 422 User can only have one pending review per pull request。我没有提交或丢弃那个 job 的 review,因为它不归我关闭。上面的结论不变:请把本 PR 当作已要求修改而非通过来看,并且在那个 job 结束或维护者记录该请求之前,不会显示红色的 review 标记。

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at 08d6c1b24b697d0ab245ddcc035962bab1b9aae2 · re-run with @qwen-code /triage

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Managed Agent gate failed

Run 41455245494 · commit 08d6c1b24b69

Failing tests

  • com.alibaba.qwen.code.runtimebroker.provisioning.staticruntime.StaticRuntimeProviderFactoryTest.returnsTheConfiguredLeaseWithoutAccessingOtherProviderPorts
  • com.alibaba.qwen.code.managedagent.EmbeddedRuntimeBrokerTest.constructsAnExternalScratchProvisionerForAValidConfiguration

@wenshao

wenshao commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Failed to process this request. Please re-mention the bot to retry.

@doudouOUC

doudouOUC commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

已在 dbe853da862ec033f234ea0009441593f6d60e84 修复本轮确认的 CI 和打包检查问题,共 8 个文件,+43/-12。

问题 处理 验证边界
三处类结尾空行阻断 Checkstyle 删除相同违规空行 原 CI 日志和规则已核对;静态检查无该模式,完整 Checkstyle 待新 CI
Broker 测试反射旧字段 对齐当前 primaryProvisioner 字段 保留 External kind 断言,Java 回归待 CI
Static endpoint 断言遗漏末尾 / 对齐现有 RuntimeLease 的 origin 规范化结果 未改变 endpoint 行为,Java 回归待 CI
Windows 将 Pod 的 /workspace 按本机路径解析 改为与宿主系统无关的 POSIX 路径校验,原样保留合法路径;补 3 个合法、12 个非法输入用例 保留已有 resident close 回归及拒绝非规范路径的行为,跨平台执行待 CI
发布脚本夹具读取已移动源码 从 runtime-external 读取,仍写入 0.26.5 原发布目录 完整发布测试 56/56 通过,零跳过、零重试;历史 patch、固定源 SHA/hash 及拒绝条件不变
默认打包测试读取错误的 metadata 路径 将断言改为 META-INF/spring-configuration-metadata.json 已只读核对当前旧 head 的真实 CI 成品,打包 IT 执行仍待新 CI

失败依据:fast Java、Windows Java、Hosted/Checkstyle、Node 发布夹具。这些是代码或测试问题,已修复后推送,未用重跑掩盖。取消的 label 任务已输出 no-change,不做重试。

关于 round 1 的 metadata finding:这次下载并核对了 reference CI 41455245763 的 artifact 13147140989。它关联 head 08d6c1b24b697d0ab245ddcc035962bab1b9aae2,产物 manifest 的实际 PR merge revision 是 e4471749134021bd142a3c5f3070844d42af4dad。主可执行包与 operator-recovery 包均只有根目录的 META-INF/spring-configuration-metadata.json,没有 BOOT-INF/classes/META-INF/ 下的对应条目;archive SHA-256 为 ab4a7775d0c785649343f0fbe27140c2b2f78878da81792b47acc2e036fe2c56,与随包校验文件一致。这是旧 head 的真实打包证据,不是本次修复后的 Java 测试结果。

本地发布测试、ESLint、Prettier、差异检查和正常提交钩子通过;两次完整增量自审及独立静态复核已完成。共享 Java 预算保持 599.048/600 秒,本轮没有运行 Java/javac/Maven。新提交的 Java 编译、unit/H2、Checkstyle、SpotBugs、打包/embedding、MySQL、RocketMQ、Hosted/fault、真实 SSH/Kubernetes 和跨平台验收仍待对应 CI/环境证据。rebase 后重新执行根目录 build(151.506 秒)、typecheck(57.590 秒)和 bundle(3.066 秒),均通过;这些是 JS/TS 检查,不扩充或替代 Java 验证预算。

PR 当前为 Ready,已更正正文中旧的 Draft 描述,没有改变 PR 状态。人工 approval 后的普通建议处理继续暂停,本轮只修复已确认的 CI/gate 问题;独立 Maven 后端与必要装配的既定范围保持不变。当前 inline review threads 为 0 个(0 unresolved),本轮无须 resolve;此总结不代表完整验收通过。

已机械 rebase 到最新 main 4dce337ea28d6b8718934b40b8a358cd362f1578,保留三个原提交,没有压缩提交。唯一冲突是 main 新扩展的发布夹具:保留它的两个历史补丁、verification POM、所有拒绝和 profile 保护断言,再接入新 External 源码路径。main 的 profile-owned Failsafe 修正及全部 17 个专项 profiles 保持一致。range-diff 确认前两个提交内容相同,本轮其他 Java 修复字节未变。rebase 后发布测试 56/56、Managed Agent E2E runner 脚本测试 54/54 均通过(零跳过、零重试);这里的 runner 脚本测试不是 Java/真实 Worker E2E。

@wenshao

wenshao commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Failed to process this request. Please re-mention the bot to retry.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Managed Agent gate failed

Run 41458230494 · commit 08d6c1b24b69

Failing tests

  • com.alibaba.qwen.code.runtimebroker.provisioning.staticruntime.StaticRuntimeProviderFactoryTest.returnsTheConfiguredLeaseWithoutAccessingOtherProviderPorts
  • com.alibaba.qwen.code.runtimebroker.provisioning.kubernetes.ResidentWorkspaceProvisionerTest.logicalCloseIsAvailableOnlyForTheConfiguredResidentBinding

@wenshao

wenshao commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Failed to process this request. Please re-mention the bot to retry.

doudouOUC and others added 3 commits November 2, 2026 23:43
Extract five backend implementations behind the shared provider SPI and support selected-backend executable distributions. Preserve SQL ownership, defer unavailable historical work, and make Spring own SSH connection cleanup.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Keep optional backend dependencies and safe assembly while deferring selective standalone distributions. Restore default packaging and document the provider configuration.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Validate Kubernetes Pod paths independently of the control-plane OS and align regression fixtures with the split backend packages and packaged metadata. Remove the three Checkstyle violations without changing runtime behavior.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@doudouOUC
doudouOUC force-pushed the codex/managed-runtime-backend-modules branch from a3ac63c to dbe853d Compare November 2, 2026 15:47
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration.

中文

请勿对活跃的 PR 执行 rebase 或 force-push,因为这会使已有的评审评论失效。另外,供日后参考:作为集成流程的一部分,机器人始终会自动将所有改动压缩(squash)为单个提交。

@wenshao

wenshao commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Failed to process this request. Please re-mention the bot to retry.

@qqqys qqqys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at dbe853da862ec033f234ea0009441593f6d60e84 — COMMENT (not approving)

The head moved since my previous round at 08d6c1b2 (rebased onto main 4dce337e, plus fix(managed-agent): Repair runtime backend CI gates). I re-verified every historical blocking finding against the current head. All of them are fixed or moot, with concrete code evidence below. I am still not approving, for two reasons stated at the end — neither is a new defect claim.

Historical blockers: all confirmed fixed at this head

1. Checkstyle rejected three new backend sources (blank line before the class closing brace) — FIXED.
ExternalRuntimeProviderFactory.java, RuntimeStateFiles.java and LocalRuntimeProviderFactory.java each drop exactly one trailing blank line. I censused rather than sampled: across every src/main/java/**/*.java file in all seven new modules (runtime-local, runtime-ssh, runtime-kubernetes, runtime-external, runtime-static, runtime-host, runtime-http) there are zero remaining instances of a blank line immediately preceding a top-level }. Caveat on this one: I inferred the violated rule from the three files the CI log named; I did not read the Checkstyle configuration to confirm the rule ID. So the census is complete against the pattern that actually failed, not against the full ruleset.

2. EmbeddedRuntimeBrokerTest reflected a field the refactor removed — FIXED.
provisionerOf(...) now reflects primaryProvisioner, and EmbeddedRuntimeBroker.java:67 declares private final RuntimeProvisioner primaryProvisioner; (assigned at :258, consumed at :340). The reflected name and the (RuntimeProvisioner) cast both match the declared field.

3. StaticRuntimeProviderFactoryTest expected an unnormalized URI — FIXED, and the fix is on the test, correctly.
RuntimeLease.java is not modified by this PR (git diff 4dce337e..dbe853da -- '*RuntimeLease.java' is empty). Its constructor routes the endpoint through BrokerValues.requireOrigin, which validates the origin and then returns value.resolve("/"). The test configures setStaticEndpoint("http://127.0.0.1:41270"), so http://127.0.0.1:41270/ is the only correct expectation. The old assertion was wrong; production behavior did not change.

4. Archive inspector reading configuration metadata at a path Spring Boot does not write — MOOT.
git grep "BOOT-INF/classes/META-INF" dbe853da returns nothing anywhere in the tree. The only remaining reader is ManagedAgentPackagingIT, now asserting the root-level META-INF/spring-configuration-metadata.json, which matches the artifact you downloaded from reference CI run 41455245763.

5. provider-options documentation and stale generated reference — still settled.
Build and verify reference distribution is green at this head (4m34s).

6. sdk-java.yml workflow-size ratchet — still settled.
Lint & Static (ubuntu-latest, Node 22.x) is green at this head (15m58s).

7. The second failing test the gate report named, which my previous round did not cover — FIXED, same root cause as #4 in your list.
ResidentWorkspaceProvisionerTest.logicalCloseIsAvailableOnlyForTheConfiguredResidentBinding sets provisioner("kubernetes-workspace") and workspaceCwd("/workspace"), then builds a broker through EmbeddedBrokerFixture. The old resolveWorkspaceCwd used Path.of(cwd).isAbsolute(), which is false for /workspace on Windows — hence the failure appearing only on the windows-latest / Java 21 lane. The replacement is host-independent string validation, and I traced the call chain to confirm the tests actually reach it: workspaceId(broker) → resolveWorkspaceId(broker, resolveWorkspaceCwd(broker)) (EmbeddedRuntimeBroker.java:509).

I also checked the new validator's own logic against its 15 parameterized cases rather than trusting the count. Precedence is A || B || C || (D && E), so the !configured.equals("/") guard correctly short-circuits the segment scan for the root path — without it "/" would self-reject, because "".split("/", -1) yields one empty part. /workspace/project with spaces is accepted; //workspace, /workspace/, /workspace//project, /workspace/., /workspace/../project, C:\workspace, \\server\workspace, the NUL case, null and empty are all rejected. Consistent with the assertions.

Optional-dependency wiring is as designed. All five backend artifacts are <scope>runtime</scope> + <optional>true</optional> in server/pom.xml, so an embedding consumer inherits none of them transitively.

Why this is a COMMENT and not an APPROVE

a) No Java execution evidence exists at this head, and every one of the seven findings above was originally revealed by execution, not by reading. The decisive lane SDK Java (fast) / ubuntu-latest / Java 21 is pending; Runtime Broker and Managed Agent MySQL, Hosted process fault gates, Hosted failover E2E, and both EventTransport gates are skipping, so the lanes that previously produced the Managed Agent gate failure list have not run against dbe853da at all. I am not treating pending CI as a defect and did not wait for it. But my confirmations above are static, and one of them (#1) rests on an inferred rule. Where a finding was proven by a failing test, a green run of that test is the matching evidence, and it does not exist yet.

b) The Critical-only scan of the current code is incomplete. 155 files, +3416/−603, seven new Maven modules and a new SPI surface. Within this round's budget I verified the fix commit end to end and re-checked the two censuses from last round (SPI registration completeness, no CI gate narrowed), but I have still not read: the RuntimeProviderFactory / RuntimeProviderRegistry interfaces themselves, the fail-open question of a deployment that omits a backend it later requests, the pending-state and storage-claim recovery path when a backend disappears mid-operation, and the SSH connection cleanup lifecycle now that Spring owns destroyMethod = "close". Those are exactly the places a module split would hide a correctness or data-loss defect. I am not reporting a finding in any of them — I am reporting that I did not look, which is not the same as clean.

Next step

Let SDK Java (fast) / ubuntu-latest / Java 21 finish at dbe853da. If it is green, findings 1–4 and 7 are settled by execution and item (a) above disappears; the remaining gap is only the unread SPI/recovery surface in (b), which I would close in a follow-up round rather than have you change anything. If it is red, the failure names will say which. Nothing in this round asks for a code change.

One non-blocking note: the pr-force-push-reminder fired on this push. The rebase preserved the three original commits and range-diff confirmed the first two are content-identical, so nothing was lost here — just be aware the bots squash on integration anyway.

@yiliang114 yiliang114 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope & Linkage

30 files / +451 −40. This narrowed PR establishes the RuntimeProviderFactory SPI and RuntimeBackendSelection contract, adds the new module cache paths to CI workflows, and gates existing integration points behind backend selection — without shipping the backend module implementations themselves. A clean contract-first landing. Follow-up to merged #15871. No issue is closed.

Key observations

SPI design — clean. RuntimeProviderFactory.kinds() → validate(settings) → create(settings, transport, dependencies) is a well-gated lifecycle. RuntimeProviderDependencies uses default IllegalStateException throws so providers only borrow the ports they need. RuntimeBackendSelection.from(settings) correctly derives the needed backend set from configuration alone: SSH-only with nodes → {ssh-process}, Local with nodes → {local-process, ssh-process}, nodes on non-Local/non-SSH primary → rejected, no nodes → {primary}.

Integration gating is correctly placed. SshWorkspaceService implements SshRuntimeAccess and gates SSH catalog population, list/admit/schedule/acceptance operations behind RuntimeBackendSelection.includes(SSH_PROCESS). ManagedRuntimeCoordinator blocks SSH-only Hosted Workspace execution and delegates context-change/capability checks. WorkspaceRuntimeResolver blocks local mount operations when the backend is not local. WorkspaceFileUploadStore derives the required backend from the target and blocks when unavailable. Every gate rejects before side effects.

No resource cleanup regression. SshWorkspaceService.close() removes the manual connections.close() call, which is now redundant — the managedSshConnections bean in ManagedAgentConfiguration carries destroyMethod = "close" and is gated behind RuntimeBackendSelection.includes(SSH_PROCESS).

CI workflow changes are mechanical and forward-looking. sdk-java.yml and verify-maven-repo.yml consistently add the seven new qwen-managed-agent-runtime-* artifact paths to cache resolve, write-back exclusion, and artifact verification lists. The paths are harmless when the corresponding modules don't exist yet — find -prune and cache restore both skip non-existent paths silently.

Documentation is bilingual and synchronized. Both 2026-10-31-managed-runtime-backend-modules.md and its .zh-CN counterpart document the module split, backend selection, recovery behavior, and migration notes. Older design docs have their source paths updated.

Previous reviews at superseded heads

My APPROVE at head 08d6c1b was push-dismissed; qqqys's COMMENT at that head flagged four findings pending the Java compile lane — all of which depended on backend module sources that were removed from scope in this narrowing.

Verdict

No P0/P1 findings. The SPI contract is well-defined, the selection logic is correct, and the integration gates reject before side effects. The Flyway migration uniqueness lane passed at this head, confirming compilation; the main SDK Java lane is still running but this does not block approval.

APPROVE the current head dbe853da.

@qqqys qqqys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at dbe853da862ec033f234ea0009441593f6d60e84 — APPROVE

This is a corrected verdict on an unchanged head. My previous round here was a COMMENT for two stated reasons: no Java execution evidence at this head, and an unfinished scan of the new SPI surface. Both are now resolved, and I said in that round that I would re-review against a green Java lane. It is green, and so is everything above it.

Reason (a) resolved: the whole Java tier executed at this head

SDK Java (fast) / ubuntu-latest / Java 21 passed in 26m53s — the lane that was pending when I filed the COMMENT, and the one that settles the findings originally revealed by execution. Beyond it, all twelve SDK Java (full) lanes passed, which is stronger evidence than I asked for:

  • windows-latest / Java 21 (8m32s) — settles ResidentWorkspaceProvisionerTest.logicalCloseIsAvailableOnlyForTheConfiguredResidentBinding, the failure that only reproduced on Windows because the old Path.of("/workspace").isAbsolute() is false there. The host-independent POSIX validation now passes on the platform that broke.
  • Runtime Broker and Managed Agent MySQL / Java 21 (1h14m3s) and Hosted process fault gates / MySQL 8.4 / Java 21 (1h56m7s) — exercise the recovery, pending-state and storage-claim behaviour that a backend split could silently break, against real MySQL rather than H2.
  • Hosted failover E2E (33m26s), both EventTransport gates, macos-latest, ubuntu Java 11/17/21, Real daemon E2E / Java 11, Flyway migration version uniqueness, Managed Agent fast tier and Managed Agent gate.

Also green: Test (ubuntu-latest, Node 22.x) 36m44s, web-shell E2E Smoke 44m27s, Lint & Static, Integration Tests (no-AK), Build and verify reference distribution, TUI parity snapshots. No lane is failing or pending at this head. The seven findings I confirmed statically last round are now confirmed by execution too, including the Checkstyle census whose rule I had only inferred.

Reason (b) resolved: the fail-open question has a fail-closed answer

The item I most wanted to read was whether a deployment that omits a backend it later requests degrades silently. It does not. In RuntimeProviderRegistry:

  • require(kind) throws IllegalStateException("Runtime provider is not installed: …; add its provider JAR (installed: …)") when the kind is absent from the discovered set, and separately refuses the reserved kubernetes kind. Both are hard refusals that name what is installed — diagnosable, not silent.
  • The constructor rejects a duplicate or reserved kind outright, so a second JAR claiming an existing kind cannot shadow it.
  • create(...) closes the provider and throws when provider.kind() disagrees with the configured kind, so a mis-registered factory leaks no resource.
  • validateSelected(settings) walks RuntimeBackendSelection.from(settings).kinds() sorted and calls require(kind).validate(settings) — deterministic order, and require throws before validate can run, so a missing backend fails during validation rather than during resource creation.

That ordering holds at every call site, which I censused rather than sampled: ManagedAgentConfiguration:107, ManagedAgentProperties:481, EmbeddedRuntimeBroker:180, and ManagedAgentPreflight:1077 and :1172. On the SSH path specifically, ManagedAgentConfiguration:100-109 validates and only then calls registry.ssh().createConnections(...), and the bean is @Bean(destroyMethod = "close") so Spring owns SshConnections cleanup on shutdown. The bean returns null when RuntimeBackendSelection does not include SSH_PROCESS, which is what keeps an SSH-only assembly from initializing Local and a Local-only assembly from touching SSH credentials.

Carried forward from last round and still verified: five RuntimeProviderFactory implementations against five matching META-INF/services resources, with runtime-http and runtime-host correctly holding none; all five backend artifacts <scope>runtime</scope> + <optional>true</optional> in server/pom.xml, so an embedding consumer inherits none transitively; and sdk-java.yml purely additive across all four cache paths, with no module dropped from a reactor invocation and no timeout, selector or tier condition altered.

Scope of this approval

I read the SPI registry and its call sites, the SSH bean lifecycle, the whole CI-gate fix commit, the POSIX workspace-path validator and its call chain, and the two censuses above. I did not read all 155 files line by line — the moved-class renames, the design documentation and the bulk of the relocated test bodies I assessed by diff shape and by the green tier rather than by close reading. Nothing I did read is provably defective, and the lanes that would catch a defect in the parts I skimmed all ran and passed. Approving on that basis.

@doudouOUC
doudouOUC merged commit 90eb13e into main Nov 3, 2026
122 of 123 checks passed
@doudouOUC
doudouOUC deleted the codex/managed-runtime-backend-modules branch November 3, 2026 02:05
@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Released in v0.26.7.

@wenshao

wenshao commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Failed to process this request. Please re-mention the bot to retry.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants