Skip to content

refactor(windows): 新增过渡 crate lithe-legacy-java,把仅 Windows 使用的旧 Java/Maven Core 命令移出 Core (#1495) - #1739

Merged
xiaoyumuxi merged 5 commits into
previewfrom
feat/1495-windows-legacy-java
Nov 6, 2026
Merged

xiaoyumuxi merged 5 commits into
previewfrom
feat/1495-windows-legacy-java

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

做了什么

Issue #1495 要把 Java/Maven 逻辑迁出 Rust Core 和宿主。macOS 侧这半还没动(见文末“范围”),本 PR 先把仅 Windows 使用的部分移出 Core,Windows TypeScript 不变。

  • 新增过渡 crate windows/tauri/crates/lithe-legacy-tooling,对外入口是 try_execute(request) -> Option<String>:请求命中旧命令名时,返回与 Core 原先逐字节一致的响应和错误码;其余请求返回 None,继续交给 Core。
    • 覆盖的命令:maven.scan / launchPlan / dependencyPlan / dependencies / diagnostics / testResults,java.workspacePolicy / jdtCacheRetention / jdtWorkspaceFingerprint / sourceDefinition / runMarkers,spring.index,mybatis.index。
    • 同时提供 Windows 宿主直接调用的函数:超长类路径 jar、启动命令规划、JDK 选择、JDT 工作区键、运行源码枚举、Maven settings 本地仓库改写。
    • 对应的 Core 单测一并移入 crate。crate 文档写明它的过渡性质和删除条件。
  • Core 删除仅 Windows 使用的部分(macOS 没有引用,已 grep 确认):三个 Maven 计划/诊断命令和六个 maven.* 命令的分发分支、execution::classpath_jar、list_run_java_sources、jdt_workspace_key 包装。
  • Core 开放过渡 crate 需要的通用函数:check_cancellation / CancellationScope、execution 的版本与工具链需求函数、is_run_scan_excluded_directory;这些新公开项的 Rustdoc 一并补上。
  • Windows 宿主:core_execute 和 platform_invoke 先调用 try_execute;run / lsp / Maven 用户 settings 的调用点改为过渡 crate;Cargo.toml / Cargo.lock 增加依赖。
  • test-stability-windows.ps1 新增过渡 crate 的计时测试;功能矩阵中 5 个条目的 Windows 证据路径改到 crate。

为什么 crate 叫 lithe-legacy-tooling 而不是 lithe-legacy-java

verify-no-host-language-specifics 是严格棘轮:baseline 只降、allowlist 只减,没有用 --update-baseline 给“搬代码导致的计数上升”开口子的余地。上一版 crate 名叫 lithe-legacy-java 时,Windows 宿主一引用它就把 java 这个词带进 7 个文件(core.rs、platform.rs、run.rs、lsp.rs 等,共 12 处词命中),闸门必然红。宿主需要知道的是“这里要调用处理遗留命令的 crate”,不需要知道是哪门语言,所以 crate 改名为 lithe-legacy-tooling,计数回落到基线以下。

同一版本的 tests/languages.rs 用 maven.scan/maven.dependencies/maven.testResults 三个命令名做分派(三个 match 臂 = +3 nameComparisons),同样过不了闸门。改为用 maven_json 直接调用 Core 仍保留的 project::scan/dependencies/test_results,测试覆盖不变。

保留在 Core 的部分

java.* 命令、spring.index、mybatis.index、java_selection、launch_command、JDT 键推导、settings_with_local_repository,以及 Maven scan / dependencies / test_results 的函数,仍被 macOS 或 Core 内部的 Maven build provider 使用。crate 里这些是复制,不是移动;等 macOS 侧也迁进独立插件后再从 Core 删除。

需要评审注意

  • try_execute 不经过 request_trace、远程工作区作用域和 Git 执行策略作用域。这些旧命令此前也只在本地工作区使用,但评审时请确认可以接受。
  • lsp/jdt_workspace.rs 仍直接调用 Core 的 java.jdt* 命令,留给后续。
  • 以下文档对已删除命令的描述已过时,本 PR 没有改,后续统一处理:shared/contracts/rust-core-api.md、shared/contracts/application-boundary.md、几条相关 Agent Note、.agents/skills/develop-litethe/SKILL.md。

范围(重要)

本 PR 只做 Windows 这半。macOS 侧 14 个 java.* 命令仍在直连 Core,其中宿主当前只有 3 个具备通用插件通道(sourceDefinition → definition provider、codeVision → codeLens provider、jdtCacheRetention → languageServers.stateRetention),其余 11 个(run/navigation marker、prepareLaunch、workspacePolicy、jdtWorkspaceFingerprint、structure、className、serverPort、spring.index、mybatis.index)还没有对应扩展点。在补上这些通用能力或明确接受功能回退之前,不动 macOS 侧,避免删掉 Core 逻辑导致功能直接失效。

验证

在 macOS 本地:

  • cargo test -p lithe-core:全部通过。
  • cargo test --manifest-path windows/tauri/src-tauri/Cargo.toml -p lithe-legacy-tooling:132 个测试通过,crate 无警告。
  • node scripts/architecture/verify-no-host-language-specifics.mjs --base origin/preview:Ratchet verified。
  • ./scripts/rust-core/verify-rust-core-comments.sh:通过。
  • ./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/preview HEAD:通过。
  • cargo check --manifest-path windows/tauri/src-tauri/Cargo.toml --bin lithe-windows:只剩 preview 上本来就有的 2 个 Windows 专用错误(project_window_registry.rs 的 os::windows 和 as_raw_handle,macOS 上无法编译),没有新增错误或警告。

未执行:Windows 实机单测(test-stability-windows.ps1)和 Parallels 冒烟(Maven 工具窗口、长类路径 Java 运行与调试、JDT 缓存清理、Spring / MyBatis 索引),需要在 Windows CI 或实机上确认。

@ghfind-review ghfind-review Bot added the review: high ghfind author score; see https://ghfind.com label Nov 4, 2026
@xiaoyumuxi
xiaoyumuxi marked this pull request as ready for review November 4, 2026 23:12
@lithe-code-review

Copy link
Copy Markdown

Lithe Review

⏳ 正在以标准模式审查代码,完成或失败后会更新本评论。

@lithe-code-review

Copy link
Copy Markdown

Lithe 运行验收

版本:42dcf2909661cc2db0750bfe382d533c534af10b;状态:partial。
本报告独立于代码审查;只报告实际执行的场景,不代表所有问题均已修复。

对照:共同祖先 4dd3165912a7ef4ccfd7240890a33b63751c9b3e → PR head;当前目标分支合并适用性:未运行。

  • 条件不足,未验证:Preserve the request/response contracts of all 13 intercepted commands: six maven commands, java.workspacePolicy, java.jdtCacheRetention, java.jdtWorkspaceFingerprint, java.sourceDefinition, java.runMarkers, spring.index, and mybatis.index. Unknown requests must remain available to Core.
    • Cargo and rustc are inventoried, but a compatible Windows C compiler, native linker, and SDK libraries are not. The native dependencies require them; they cannot be assumed from the opaque compilerEnvironment identifier. No prebuilt native driver is supplied.
  • 条件不足,未验证:Preserve the Windows host's migrated direct helper behavior: classpath-JAR and argfile planning, release-version parsing, JDK selection, JDT workspace keys, Java source enumeration, and Maven settings rewriting.
    • The supplied inventory lacks the compatible Windows C compiler/linker and SDK needed to build an executable calling these production Rust APIs. Java is unnecessary for these API checks, but their results would not establish actual JVM launch behavior.
  • 条件不足,未验证:Confirm that unchanged Windows frontend callers still reach the migrated implementations through both native invoke paths and that run, LSP, settings, and indexing workflows retain their observable behavior.
    • There is no interactive desktop. No runnable product, Java installation, Maven runtime, JDT server, or debug adapter is supplied in the capability inventory. Native dialogs, editor interactions, and tool-window workflows cannot be established with frontend mocks. Responsiveness claims also require a prespecified measurement protocol.

未覆盖:

  • All planned behavioral checks remain unexecuted, including the promised byte-for-byte response compatibility. No success or bug markers can honestly be supplied.
  • Real Tauri dispatch through both entry points, unchanged TypeScript consumers, correlation IDs, cancellation, deadlines, and stale-result handling remain unverified. The acknowledged bypass of request tracing, remote-workspace scope, and Git execution policy also lacks runtime evidence.
  • Actual Maven execution and plugin-produced dependency/test outputs remain uncovered; deterministic file fixtures would establish parsing and planning only.
  • Actual JVM class loading, debug startup, Windows argfile encoding, temporary-file ownership and cleanup, and installed-resource immutability remain uncovered.
  • Native JDK discovery and agreement among Run, Maven, and LSP selections remain uncovered; candidate-selection fixtures cannot prove discovery.
  • JDT startup, cache deletion/retention, editor navigation, and Spring/MyBatis consumer integration remain uncovered by native API checks.
  • Maven settings discovery, confirmation/cancellation, optimistic conflict detection, atomic writes, rereading, and effective repository use remain uncovered by the XML helper checks.
  • Additional filesystem failure cases, source-enumeration traversal budgets, dependency-parser bounds, and adversarial XML/source cases are not exhaustively specified by these representative scenarios.
  • macOS workflows require capability macos and are blocked on this Windows environment. Preservation of retained Core implementations and macOS consumers is not established.
  • Visual responsiveness and intermittent behavior have no prespecified statistical protocol and remain blocked; a single successful attempt would not establish them.
  • Code ownership/deletion requirements, migrated unit-test completeness, timing-harness integration, feature-matrix evidence, deferred documentation corrections, and the conditional feat(architecture): 新增宿主语言特定内容闸门并固定 Java 拆分计划(Refs #1495) #1727 baseline update require separate review or validation.
  • The original Issue [Feature] macOS 存量重构计划:清理废弃实现,将 Maven/Java 领域逻辑完整迁入插件后端 #1495 body was not supplied. Coverage follows this PR's transitional scope and repository context; it does not establish completion of the broader plugin migration.

工作副本与运行状态已清理;可复用编译缓存按 12 GiB / 7 天预算保留。
详细步骤和原始证据保存在服务器受限目录(14 天、总计不超过 1 GiB);当前没有公开下载链接。

…ven Core 命令

Issue #1495 把 Java/Maven 逻辑迁出 Rust Core 和宿主。Windows 前端仍通过旧命令名调用这些能力,
本提交把它们放进 Windows 专属的过渡 crate,对外只有 try_execute:命中旧命令名时返回与 Core 原先逐字节一致的
JSON 响应和错误码,其余命令返回 None,由调用方继续交给 Core。Windows 前端因此无需改动。

覆盖的命令:maven.scan、maven.launchPlan、maven.dependencyPlan、maven.dependencies、maven.diagnostics、
maven.testResults、java.workspacePolicy、java.jdtCacheRetention、java.jdtWorkspaceFingerprint、
java.sourceDefinition、java.runMarkers、spring.index、mybatis.index。

同时提供 Windows 宿主直接调用的函数:超长类路径 jar 规划、启动命令规划、JDK 选择、JDT 工作区键、
Maven settings 本地仓库改写、运行源码枚举。对应的 Core 单元测试一并移入 crate 的 src/tests。

crate 文档说明了它是过渡实现以及删除条件:Windows 的 Java/Maven 能力改由插件提供之后整体删除。
try_execute 仅模拟 Core 的取消作用域,不经过 request_trace、远程工作区作用域和 Git 执行策略作用域。

(cherry picked from commit 20fbe23)
Issue #1495:这些能力已搬入 windows/tauri/crates/lithe-legacy-java,macOS 从未调用,Core 不再保留。

删除(已用 grep 确认 macOS 和 Core 其他模块没有引用):
- maven.launchPlan、maven.dependencyPlan、maven.diagnostics 三个命令,以及 maven.scan、maven.dependencies、
  maven.testResults 在 dispatcher 和 CoreCommand 中的分支;Core 内部仍使用的 scan、dependencies、
  test_results 函数保留,供构建提供者调用
- 仅服务这些命令的 launch_plan、dependency_plan、diagnostics 实现与诊断响应类型
- execution::classpath_jar(超长类路径 jar 规划)
- execution::workspace_scan 中的 list_run_java_sources 及其测试
- lib.rs 里的 jdt_workspace_key 包装;project 对 settings_with_local_repository 的公开导出改为 crate 内可见
  (JDT Maven settings 仍在 Core 内使用)

保留并开放:
- lithe_core::check_cancellation 与 CancellationScope,供 crate 的 try_execute 复用 Core 的取消语义
- execution 下版本比较与工具链需求相关的少量函数改为 pub,并从 execution 重新导出
- is_run_scan_excluded_directory 对外重新导出;launch_command 的内部常量改回私有

tests/languages.rs 中仍覆盖 scan、dependencies、test_results 的测试保留,经测试专用的 execute_json 垫片
直接调用 project 中的函数;已删除命令对应的测试随实现迁到 crate。

(cherry picked from commit 70c2fe0)
…测与功能矩阵

Issue #1495:Windows 前端不变,原先发给 Core 的旧命令在宿主入口先交给 lithe_legacy_java::try_execute。

- core_execute 与 platform_invoke 两个入口都先调用 try_execute,命中旧命令名即返回,否则继续走 Core
- run.rs、run/launch_arguments.rs、lsp.rs、lsp/jdt_workspace.rs、maven/user_settings.rs 中对已迁出函数
  (超长类路径 jar、启动命令规划、JDK 选择、JDT 工作区键、运行源码枚举、本地仓库 settings 改写)的调用
  改为 lithe_legacy_java
- Cargo.toml 增加 lithe-legacy-java 路径依赖;Cargo.lock 同步增加该包及其依赖项
- test-stability-windows.ps1 的 WindowsRust 范围新增 lithe-legacy-java 的计时测试,依赖包测试不会被
  宿主包的 cargo test 带上
- 功能矩阵中 Windows 的证据文件从 Core 已删除或不再被 Windows 使用的路径改为 crate 路径:
  run-java-long-classpath、run-discovery、java-runtime-discovery、java-maven-profiles-dependencies、
  maven-user-settings-editing

(cherry picked from commit 7b2a8fe)
启动计划只需要确认模块属于当前 reactor,因此只收集模块相对路径;
插件继承、坐标校验等仅 Core 运行标记用过的解析一并删除。
parent 的 groupId/version 仍按 Maven 规则补给未声明的子模块。

(cherry picked from commit 42dcf29)
#1739 的四个提交移植到最新 preview 后仍过不了
`verify-no-host-language-specifics`:它让 reviewer 跑 `--update-baseline`,
但闸门是严格棘轮,baseline 只降、allowlist 只减,搬代码引起的计数上升不能
用改基线绕开。两处真正的原因都已修掉:

- 过渡 crate 改名为 `lithe-legacy-tooling`。crate 名叫 `lithe-legacy-java`
  时,宿主引用它就会把 `java` 这个词带进 `windows/tauri/src-tauri/src` 的
  七个文件(core.rs、platform.rs、run.rs、lsp.rs 等共 12 处词命中)。宿主
  说的是“处理遗留命令”,不需要知道是哪门语言,改名后计数回落到基线以下。
- `tests/languages.rs` 不再用 `maven.scan`/`maven.dependencies`/
  `maven.testResults` 三个命令名做分派(那三个 match 臂是 +3
  nameComparisons),改为 `maven_json` 直接调用 Core 仍保留的
  `project::scan`/`dependencies`/`test_results`。测试覆盖不变。

同批补上 #1739 把几个函数改成 `pub` 后缺的 Rustdoc
(`validate_sidecar_version`、`version_satisfies`、`version_parts`、
`cancellation::check`、`ToolchainRequirementsDocument` 的字段)。

验证(macOS 本地):
- `cargo test -p lithe-core`:全绿
- `cargo test -p lithe-legacy-tooling`:132 个通过
- `verify-no-host-language-specifics.mjs --base origin/preview`:Ratchet verified
- `verify-rust-core-comments.sh`:通过
- `cargo check --bin lithe-windows`:只剩 preview 既有的 2 个 Windows 专用错误
- `verify-platform-feature-matrix-change.sh origin/preview HEAD`:通过

未执行:Windows 实机单测与 Parallels 冒烟,需要在 Windows CI 或实机确认。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: high ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant