diff --git a/.agents/notes/implemented/architecture/2026-09-13-language-tooling-and-lsp-runtime-ownership.md b/.agents/notes/implemented/architecture/2026-09-13-language-tooling-and-lsp-runtime-ownership.md index 721df59164..fa6d1c660c 100644 --- a/.agents/notes/implemented/architecture/2026-09-13-language-tooling-and-lsp-runtime-ownership.md +++ b/.agents/notes/implemented/architecture/2026-09-13-language-tooling-and-lsp-runtime-ownership.md @@ -194,6 +194,17 @@ capability → Rust 以 LSP request ID 关联 deadline,用不透明 operation ID 投影 terminal result。停止 session 时先 `shutdown` 后 `exit`,服务器 无响应则由超时路径强制停止,不直接用 `terminate()` 代替。 +进程创建后启动失败(initialize 出错、索引被替换或取消)时,进程必须在有界期限内 +确认退出才算清理完成,不能只发信号就丢弃会话。普通 `lsp.startServer` 调用方拿不到 +会话 ID,因此 Core 把未完成清理的会话记在内部待清理列表,下一次显式启动前最多重试 +一次有界释放,仍未完成就拒绝再启动新进程,并保留原始启动错误。进程内原生调用方 +(`start_lsp_owned`)在注册回调里先拿到会话 ID,启动返回错误时仍持有该 ID,自行重试 +`lsp.destroyServer`。macOS 等非 Windows 平台的释放在期限内轮询根进程退出,因为发出 +SIGKILL 后子进程是异步回收的;Windows 等待整个进程树退出。回归见 `engine.rs` 中的 +`native_owner_keeps_failed_initialize_identity_until_verified_disposal`、 +`wire_owner_retries_failed_initialize_disposal_before_another_start` 和 +`wire_owner_cleans_at_most_one_failed_start_before_rejecting_a_backlog`。 + ### Java 导入安静期与 Windows 跳转缓存 #1052 的两次导入在 Maven 23% 时因连续约 45 秒没有变化的进度通知而被 diff --git a/.agents/notes/implemented/architecture/2026-09-18-java-project-build-and-launch-boundary.md b/.agents/notes/implemented/architecture/2026-09-18-java-project-build-and-launch-boundary.md index c6f29b537e..4b940a7042 100644 --- a/.agents/notes/implemented/architecture/2026-09-18-java-project-build-and-launch-boundary.md +++ b/.agents/notes/implemented/architecture/2026-09-18-java-project-build-and-launch-boundary.md @@ -101,6 +101,13 @@ JDT 直启流程。继承插件的库模块、只有测试入口的模块和入 原问题换成一次不确定的错误运行。JDT 对模块化项目返回的 `module/name.Type` 会转换为 JVM 需要的 `-m module/name.Type`。 +`java.main` 收到 `javaLaunch` 时同样按 JDT 直启处理,不再以 Maven reactor 字段 +作为准入条件:Core 保留 JDT 返回的类路径与模块路径,只有 Maven 项目且请求没有 +`buildPrepared` 回执时才追加原有资源处理步骤,Gradle 和无构建系统的目录直接从 +JDT 路径启动。没有 `javaLaunch` 的单文件计划保持原有的编译后运行。不要为了 +Gradle 再单独编译当前文件,否则同工程的其他类和依赖会缺失。回归见 +`java_launch_without_maven_consumes_jdt_paths_without_recompiling_one_file`。 + ### 阶段 D 的 Provider 资源准备 macOS 已把资源步骤切入 Maven Provider 的公开项目任务:先保存文档、等待当前 diff --git a/.agents/notes/implemented/architecture/2026-09-21-java-entrypoints-owned-by-jdt.md b/.agents/notes/implemented/architecture/2026-09-21-java-entrypoints-owned-by-jdt.md index f538c6d4c0..528d4b19c0 100644 --- a/.agents/notes/implemented/architecture/2026-09-21-java-entrypoints-owned-by-jdt.md +++ b/.agents/notes/implemented/architecture/2026-09-21-java-entrypoints-owned-by-jdt.md @@ -267,12 +267,15 @@ JDT 尚未完成发现时,已有确认入口可沿用上次生成结果;没 悄悄改变返回格式,所以版本必须锁定,并用契约测试和真实 JDT 测试盯住。 - 插件在内部出错时可能返回空列表,产品层无法和“确实没有入口”区分。只能靠 状态机不让失败覆盖旧结果、真实 JDT 测试和日志关联降低风险。 -- 传给 `vscode.java.resolveMainClass` 的作用域必须是解析符号链接之后的工作区 - 目录。JDT 把项目放在规范路径(例如 macOS 的 `/private/tmp`、`/private/var`), - Java Debug 插件再按路径前缀逐字比较“项目是否在作用域内”;如果作用域写的是 - `/tmp` 或 `/var` 这样的链接路径,所有项目都会被过滤,结果是一个不带任何诊断 - 的空列表,运行时表现为“当前文件没有 main 方法”。因此 Rust 引擎在发请求前用 - `java_entrypoint_scope_uri` 解析工作区路径,目录无法解析时才原样发送。平台 +- `vscode.java.resolveMainClass` 使用当前 JDT 会话的完整查询(空 arguments), + 然后由既有 Core normalizer 按打开的工作区与解析链接后的目录筛选源码归属。 + 2026-11-03 Windows 实机中,同一会话的路径查询返回空,完整查询和项目名查询 + 都返回 Main。检查打包的 Java Debug 0.53.2 字节码确认:路径查询先用项目自身 + 所在目录缩小搜索范围,plain Java 的隐式项目位于 JDT 可写缓存,因此在检查 + 链接源码前就被过滤。仅解析工作区链接仍不能修复此问题。 + 不按空结果猜测源码、不新增 Main,也不绑定不稳定的 JDT 项目名;使用上游已有 + 完整查询后仍拒绝相邻或外部工作区的源码。既有链接路径回归继续保护 macOS + `/tmp`、`/var` 等路径;新增真实 plain 文件夹回归保护隐式项目入口发现。平台 代码不要自己拼作用域,也不要假设打开时的路径就是 JDT 看到的路径。 - 同一个根因也影响诊断:JDT 以规范路径发布 `textDocument/publishDiagnostics` (`/private/tmp/...`),宿主却是用 `/tmp/...` 打开的文档,客户端归约器按文本匹配 diff --git a/.agents/notes/implemented/architecture/2026-10-17-build-system-plugin-contract.md b/.agents/notes/implemented/architecture/2026-10-17-build-system-plugin-contract.md index 3e3532d057..b60c495c9e 100644 --- a/.agents/notes/implemented/architecture/2026-10-17-build-system-plugin-contract.md +++ b/.agents/notes/implemented/architecture/2026-10-17-build-system-plugin-contract.md @@ -64,6 +64,8 @@ Rust Core 负责校验声明、识别工程、展开每一条命令行,并把 没有声明的能力不报错,也不会出现在界面上。例如 Cargo fixture 没有声明依赖树,Build 工具窗口就不显示依赖区。 +`build.detect` 对普通文件根或不存在的根保留空实例结果,这属于检测入口的既有兼容边界。共用工作区扫描器后仍在此入口区分根的类型;真实目录的读取、权限或扫描失败继续返回拒绝,不能把所有 I/O 错误当作“未检测到项目”。不要为了修复某个平台的非目录错误而放宽共用扫描器,也不要让宿主按操作系统错误码猜测空结果。回归见 `detection_returns_empty_for_non_directory_and_missing_workspace_roots`。 + 字段全集只写在 `shared/contracts/plugins/v1/README.md` 的 “API level 3: build systems” 一节和 `plugin-manifest.schema.json` 里,本 Note 不重复。四个 fixture 各示范一种模型来源,按能力命名而不是按真实插件命名:`build-static-file`(读项目文件,内容用 Cargo)、`build-command-stdout`(解码命令输出,内容用 Go)、`build-command-output-file`(解码命令写出的文件,内容用 Gradle)、`build-host-integration`(交给宿主集成,内容用 Maven)。`build-provider`、`build-provider-language-server` 分别示范 Provider 的两种写法。 ### 2. Core 与宿主的分工 diff --git a/.agents/skills/write-stable-tests/references/windows-and-rust.md b/.agents/skills/write-stable-tests/references/windows-and-rust.md index d5d7731a17..58919061e6 100644 --- a/.agents/skills/write-stable-tests/references/windows-and-rust.md +++ b/.agents/skills/write-stable-tests/references/windows-and-rust.md @@ -162,6 +162,17 @@ and clones a real local repository. The cache retry then exhausted the existing suite deadline; that secondary timeout does not justify extending the whole suite. Keep every checkout/clone assertion and the existing request deadlines. +`real_jdtls_lists_entrypoints_in_a_plain_java_folder` gets 240 seconds in the +real-JDT lane. Like the Java 25 case, it cold-starts a real JDT LS, waits up to +90 seconds for readiness, then up to 120 seconds for the plain folder's +invisible project to import and list its entry point. Windows run 41817286665 +terminated it at 15.144 seconds under the default watchdog without an +assertion failure, while the same revision passed it in 6.0 seconds on macOS +arm64; the Java 25 case took 39.4 seconds in that run. The budget covers both +in-test deadlines so a silent server fails with the test's own diagnostic +rather than the watchdog. Other real-JDT cases and the suite deadline keep +their budgets. + ## Windows verification Run the PowerShell harness in a real Windows environment. A macOS boundary diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 8d1ba9dbe5..131ff8950f 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -837,6 +837,7 @@ jobs: --max-ms 15000 ` --test-prefix lsp::interface::engine::real_jdt_tests:: ` --test-budget lsp::interface::engine::real_jdt_tests::real_jdtls_discovers_builds_and_launches_java_25_entrypoints=600000 ` + --test-budget lsp::interface::engine::real_jdt_tests::real_jdtls_lists_entrypoints_in_a_plain_java_folder=240000 ` --build-timeout-ms 600000 ` --suite-timeout-ms 1200000 ` --report .artifacts/test-stability/windows-real-jdt.json diff --git a/macos/Tests/LitheTests/PluginSignatureVectorTests.swift b/macos/Tests/LitheTests/PluginSignatureVectorTests.swift new file mode 100644 index 0000000000..ff0d3fbb72 --- /dev/null +++ b/macos/Tests/LitheTests/PluginSignatureVectorTests.swift @@ -0,0 +1,208 @@ +import CryptoKit +import Foundation +import LithePluginPackageSigning +import Testing + +/// Cross-platform acceptance for the package signature: the same fixed +/// vectors answer identically on Swift/CryptoKit and the Windows Rust host. +/// The vectors live in +/// `shared/contracts/plugins/v1/fixtures/signature-vectors.json` and anchor +/// the Ed25519 primitive to the public RFC 8032 test key, so neither +/// platform's own round-trip can drift. +/// +/// CryptoKit signs Ed25519 with fresh randomness, so its signature bytes +/// never equal the deterministic RFC 8032 signatures recorded in the +/// fixture. Swift therefore proves equivalence by verification: a recorded +/// signature verifies only over the exact payload it was made for. +struct PluginSignatureVectorTests { + private struct Fixture: Codable { + struct Ed25519: Codable { + let seedHex: String + let publicKeyHex: String + let messageEmptySignatureHex: String + } + struct CanonicalPayload: Codable { + let keyID: String + let pluginID: String + let pluginVersion: String + let files: [String: String] + let payloadBase64: String + let signatureBase64: String + } + struct ContentDigest: Codable { + let files: [String: String] + let digest: String + } + + let ed25519: Ed25519 + let packageFiles: [String: String] + let canonicalPayload: CanonicalPayload + let contentDigest: ContentDigest + } + + private static func fixture() throws -> Fixture { + let url = DeclarativePluginTestSupport.repositoryRoot + .appendingPathComponent("shared/contracts/plugins/v1/fixtures/signature-vectors.json") + return try JSONDecoder().decode(Fixture.self, from: Data(contentsOf: url)) + } + + private static func bytes(fromHex hex: String) -> Data { + var data = Data() + var index = hex.startIndex + while index < hex.endIndex { + let next = hex.index(index, offsetBy: 2) + data.append(UInt8(hex[index.. Curve25519.Signing.PrivateKey { + let seed = bytes(fromHex: fixture.ed25519.seedHex) + return try #require(try? Curve25519.Signing.PrivateKey(rawRepresentation: seed)) + } + + @Test + func primitiveMatchesTheRFC8032Anchor() throws { + let fixture = try Self.fixture() + let privateKey = try Self.privateKey(from: fixture) + let publicKey = try #require( + try? Curve25519.Signing.PublicKey(rawRepresentation: privateKey.publicKey.rawRepresentation) + ) + #expect(Data(publicKey.rawRepresentation).hex == fixture.ed25519.publicKeyHex) + let recorded = Self.bytes(fromHex: fixture.ed25519.messageEmptySignatureHex) + #expect(publicKey.isValidSignature(recorded, for: Data())) + let fresh = try privateKey.signature(for: Data()) + #expect(publicKey.isValidSignature(fresh, for: Data())) + } + + /// The canonical payload Swift builds from the fixed package is the one + /// the recorded signature covers: the path sorting, token encoding, and + /// file digests are identical across platforms. + @Test + func recordedSignatureCoversTheSwiftCanonicalPayload() throws { + let fixture = try Self.fixture() + let privateKey = try Self.privateKey(from: fixture) + let publicKey = privateKey.publicKey + let root = try makePackage(fixture) + defer { try? FileManager.default.removeItem(at: root) } + + let recordedPayload = try #require(Data(base64Encoded: fixture.canonicalPayload.payloadBase64)) + let recordedSignature = try #require(Data(base64Encoded: fixture.canonicalPayload.signatureBase64)) + #expect(publicKey.isValidSignature(recordedSignature, for: recordedPayload)) + + let document = try PluginPackageSignature.makeDocument( + packageAt: root, + pluginID: fixture.canonicalPayload.pluginID, + pluginVersion: fixture.canonicalPayload.pluginVersion, + privateKey: privateKey, + keyID: fixture.canonicalPayload.keyID + ) + #expect(document.files == fixture.canonicalPayload.files) + try PluginPackageSignature.verify( + packageAt: root, + pluginID: fixture.canonicalPayload.pluginID, + pluginVersion: fixture.canonicalPayload.pluginVersion, + document: document, + publicKey: publicKey + ) + + // The recorded signature over Swift's own payload proves the payload + // bytes match, because Ed25519 accepts no other message. + let recordedDocument = PluginPackageSignature.Document( + keyID: document.keyID, + pluginID: document.pluginID, + pluginVersion: document.pluginVersion, + files: document.files, + signature: fixture.canonicalPayload.signatureBase64 + ) + try PluginPackageSignature.verify( + packageAt: root, + pluginID: fixture.canonicalPayload.pluginID, + pluginVersion: fixture.canonicalPayload.pluginVersion, + document: recordedDocument, + publicKey: publicKey + ) + } + + /// The content digest over the fixed package matches the shared answer, + /// including the non-ASCII file names. + @Test + func contentDigestMatchesTheSharedVector() throws { + let fixture = try Self.fixture() + let root = try makePackage(fixture) + defer { try? FileManager.default.removeItem(at: root) } + + let digest = try PluginPackageSignature.contentDigest(packageAt: root) + #expect(digest == fixture.contentDigest.digest) + } + + /// The signature document of the shared vector also verifies after a + /// write/read round trip through the on-disk format. + @Test + func recordedDocumentVerifiesAfterWriteAndRead() throws { + let fixture = try Self.fixture() + let privateKey = try Self.privateKey(from: fixture) + let root = try makePackage(fixture) + defer { try? FileManager.default.removeItem(at: root) } + + var files: [String: String] = [:] + for (path, digest) in fixture.canonicalPayload.files { + files[path] = digest + } + let document = PluginPackageSignature.Document( + keyID: fixture.canonicalPayload.keyID, + pluginID: fixture.canonicalPayload.pluginID, + pluginVersion: fixture.canonicalPayload.pluginVersion, + files: files, + signature: fixture.canonicalPayload.signatureBase64 + ) + try PluginPackageSignature.write(document, to: root) + let read = try PluginPackageSignature.read(from: root) + try PluginPackageSignature.verify( + packageAt: root, + pluginID: fixture.canonicalPayload.pluginID, + pluginVersion: fixture.canonicalPayload.pluginVersion, + document: read, + trustedKeys: [ + fixture.canonicalPayload.keyID: privateKey.publicKey + ] + ) + + // Any changed file is rejected with the same digest mismatch the + // Windows host reports. + try Data("changed".utf8).write(to: root.appendingPathComponent("plugin.json")) + #expect(throws: PluginPackageSignature.Error.self) { + try PluginPackageSignature.verify( + packageAt: root, + pluginID: fixture.canonicalPayload.pluginID, + pluginVersion: fixture.canonicalPayload.pluginVersion, + document: read, + trustedKeys: [ + fixture.canonicalPayload.keyID: privateKey.publicKey + ] + ) + } + } + + /// Materializes the fixture's package tree with its UTF-8 file contents. + private func makePackage(_ fixture: Fixture) throws -> URL { + let root = FileManager.default.temporaryDirectory + .appendingPathComponent("lithe-signature-vector-\(UUID().uuidString)", isDirectory: true) + for (relativePath, content) in fixture.packageFiles { + let target = root.appendingPathComponent(relativePath) + try FileManager.default.createDirectory( + at: target.deletingLastPathComponent(), + withIntermediateDirectories: true + ) + try Data(content.utf8).write(to: target) + } + return root + } +} + +extension Data { + fileprivate var hex: String { + map { String(format: "%02x", $0) }.joined() + } +} diff --git a/rust/lithe-core/src/build/detect.rs b/rust/lithe-core/src/build/detect.rs index 24f6cf6e8f..67e834dd1c 100644 --- a/rust/lithe-core/src/build/detect.rs +++ b/rust/lithe-core/src/build/detect.rs @@ -11,9 +11,12 @@ use super::manifest::{BuildSystemDeclaration, ModelSource, Nesting, OptionKind, use super::options; use super::outputs::{model_value, read_model, source_marker}; use crate::plugins::declarative::{validate_manifest_value, PluginRejection, Validation}; +use crate::protocol::CoreError; use serde::Deserialize; use serde_json::{json, Value}; use std::collections::{BTreeMap, BTreeSet}; +use std::io::ErrorKind; +use std::path::Path; #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -136,6 +139,32 @@ fn instance( instance } +// Detection historically accepts absent/non-directory roots as an empty view. +// Keep that boundary local: scans of real directories must still report I/O +// failures, and the shared run scanner retains its required-root semantics. +// The check goes through workspace I/O so a remote root, including one opened +// through a host symbolic link, is examined on the owning host rather than in +// the unmaterialized local projection. +fn scan_directory_root( + root: &Path, + scan: impl FnOnce(&Path) -> Result, CoreError>, +) -> Validation> { + match crate::remote::workspace_io::metadata(root) { + Ok(metadata) if !metadata.is_dir() => return Ok(Vec::new()), + Err(error) if matches!(error.kind(), ErrorKind::NotFound | ErrorKind::NotADirectory) => { + return Ok(Vec::new()); + } + Err(error) => { + return Err(PluginRejection::new( + "plugin.build.invalidSelection", + error.to_string(), + )); + } + Ok(_) => {} + } + scan(root).map_err(|error| PluginRejection::new("plugin.build.invalidSelection", error.message)) +} + /// `build.detect`: every instance of every build system the enabled plugins /// declare. Invalid manifests are reported, not fatal; when two plugins /// declare one build-system ID, the higher priority answers for it. @@ -192,8 +221,7 @@ pub(crate) fn detect(request: DetectRequest) -> Validation { if owners.is_empty() { return Ok(json!({ "instances": [], "rejected": rejected, "shadowed": shadowed })); } - let directories = crate::execution::scan(&workspace.path) - .map_err(|error| PluginRejection::new("plugin.build.invalidSelection", error.message))?; + let directories = scan_directory_root(&workspace.path, crate::execution::scan)?; let empty = BTreeMap::new(); let mut seen = BTreeSet::new(); let mut instances = Vec::new(); @@ -243,3 +271,29 @@ pub(crate) fn detect(request: DetectRequest) -> Validation { "shadowed": shadowed, })) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn existing_directory_scan_errors_are_not_empty_detections() { + // A real readable directory passes metadata. Inject the subsequent + // failure so ACL differences and elevated test users cannot bypass it. + let root = Path::new(env!("CARGO_MANIFEST_DIR")); + assert!(root.is_dir()); + for kind in [ + ErrorKind::PermissionDenied, + ErrorKind::NotFound, + ErrorKind::Other, + ] { + let error = scan_directory_root(root, |scanned| { + assert_eq!(scanned, root); + Err(std::io::Error::new(kind, "controlled directory scan failure").into()) + }) + .expect_err("an existing directory's scan failure must reject detection"); + assert_eq!(error.code, "plugin.build.invalidSelection"); + assert_eq!(error.message, "controlled directory scan failure"); + } + } +} diff --git a/rust/lithe-core/src/execution/configuration.rs b/rust/lithe-core/src/execution/configuration.rs index dedceb0056..94f8a92d8a 100644 --- a/rust/lithe-core/src/execution/configuration.rs +++ b/rust/lithe-core/src/execution/configuration.rs @@ -2517,10 +2517,11 @@ pub fn create_launch_plan(request: LaunchPlanRequest) -> Result Result Result String { runtime::execute_json(request) } +/// Starts the existing LSP engine with a native resource owner attached before +/// initialization. The callback only records the ID; it must not call Core. +/// Unlike a wire request, this also preserves ownership when the first write +/// fails and the ordinary start command returns an error. +pub fn start_lsp_owned( + payload: serde_json::Value, + registered: impl FnOnce(&str), +) -> Result { + let request = serde_json::from_value(payload).map_err(|error| { + CoreError::new(ErrorCode::InvalidRequest, "Invalid language-server launch.") + .with_details(error.to_string()) + })?; + let response = lsp::interface::start_server_owned(request, registered)?; + serde_json::to_value(response).map_err(|error| { + CoreError::new( + ErrorCode::Unknown, + "Could not encode language-server launch.", + ) + .with_details(error.to_string()) + }) +} + /// Requests cooperative cancellation of an active operation. /// /// Native Rust hosts use this entry point while the Swift and C++ clients keep diff --git a/rust/lithe-core/src/lsp/interface/engine.rs b/rust/lithe-core/src/lsp/interface/engine.rs index e78d7ff849..56a20bc500 100644 --- a/rust/lithe-core/src/lsp/interface/engine.rs +++ b/rust/lithe-core/src/lsp/interface/engine.rs @@ -969,6 +969,9 @@ pub(super) struct LspEngine { next_session_id: AtomicU64, next_operation_id: AtomicU64, sessions: Mutex>>, + /// Failed wire starts have no returned identity. Retain their cleanup + /// responsibility here and retry disposal before another process starts. + failed_starts: Mutex>, launcher: Arc, } @@ -1193,6 +1196,14 @@ pub fn start_server(request: StartServerRequest) -> Result Result { + engine().start_server_owned(request, registered) +} + /// Performs a bounded graceful shutdown while retaining the session record. pub fn stop_server(request: SessionRequest) -> Result<(), CoreError> { engine().session(&request.session_id)?.stop() @@ -1857,6 +1868,7 @@ impl LspEngine { next_session_id: AtomicU64::new(1), next_operation_id: AtomicU64::new(1), sessions: Mutex::new(BTreeMap::new()), + failed_starts: Mutex::new(BTreeSet::new()), launcher, } } @@ -1869,8 +1881,59 @@ impl LspEngine { } fn start_server(&self, request: StartServerRequest) -> Result { + let mut registered = None; + let result = self.start_server_owned(request, |id| registered = Some(id.to_owned())); + if result.is_err() { + if let Some(id) = registered { + if self.lock_sessions()?.contains_key(&id) { + self.lock_failed_starts()?.insert(id); + // Preserve the original startup error. Incomplete cleanup + // stays owned; an explicit startup retry reaps it before + // any replacement process can be launched. + // log-exempt: Same failure already recorded: this cleanup follows the startup failure returned below and traced by this request's Core failure; residue stays in failed_starts and the next start reports ProcessFailed. + let _ = self.cleanup_failed_start(); + } + } + } + result + } + + fn lock_failed_starts(&self) -> Result>, CoreError> { + self.failed_starts.lock().map_err(|_| { + CoreError::new( + ErrorCode::Unknown, + "Failed startup cleanup lock was poisoned.", + ) + }) + } + + fn cleanup_failed_start(&self) -> Result<(), CoreError> { + // Serialize cleanup attempts, but never hold the session registry or + // protocol-state lock across process disposal. Each retry owns at most + // one two-second disposal; a backlog must not make one call unbounded. + let mut failed = self.lock_failed_starts()?; + if let Some(id) = failed.first().cloned() { + if self.lock_sessions()?.contains_key(&id) { + self.destroy(&id)?; + } + failed.remove(&id); + } + if !failed.is_empty() { + return Err(CoreError::new( + ErrorCode::ProcessFailed, + "Previous language-server startup cleanup is still pending. Retry startup to continue cleanup.", + )); + } + Ok(()) + } + + fn start_server_owned( + &self, + request: StartServerRequest, + registered: impl FnOnce(&str), + ) -> Result { let attempt = startup_attempt(&request); - let result = self.start_server_attempt(request, &attempt); + let result = self.start_server_attempt(request, &attempt, registered); // A session that already reached a terminal result took the attempt; // otherwise the process never started. Cancellation is not a result. match &result { @@ -1887,8 +1950,10 @@ impl LspEngine { &self, request: StartServerRequest, attempt: &AttemptSlot, + registered: impl FnOnce(&str), ) -> Result { validate_start_request(&request)?; + self.cleanup_failed_start()?; if crate::remote::workspace::is_remote() && request.provider_id.eq_ignore_ascii_case("java") { return Err(CoreError::new( @@ -2035,16 +2100,6 @@ impl LspEngine { _ => None, }; - let process = self.launcher.launch(LspProcessSpec { - executable: adaptation - .executable - .unwrap_or_else(|| PathBuf::from(&request.executable_path)), - arguments: adaptation.arguments, - working_directory: workspace_root, - environment: request.environment, - })?; - let process_start_elapsed = startup_started_at.elapsed(); - let initialize_timeout = Duration::from_millis(request.initialize_timeout_milliseconds); let service_ready_idle_timeout = Duration::from_millis(request.service_ready_idle_timeout_milliseconds); @@ -2102,6 +2157,16 @@ impl LspEngine { }, request.plugin_id.is_some(), )?; + let process = self.launcher.launch(LspProcessSpec { + executable: adaptation + .executable + .unwrap_or_else(|| PathBuf::from(&request.executable_path)), + arguments: adaptation.arguments, + working_directory: workspace_root, + environment: request.environment, + })?; + let process_start_elapsed = startup_started_at.elapsed(); + let request_id = (initialize.state.next_request_id - 1).to_string(); let now = Instant::now(); let process_id = process.handle.process_id(); @@ -2268,13 +2333,30 @@ impl LspEngine { self.lock_sessions()? .insert(session_id.clone(), session.clone()); if let Err(error) = check_indexing() { - self.lock_sessions()?.remove(&session_id); - session.active.store(false, Ordering::Release); - // A retired start is cancelled; the process exit must not record it. + // A retired start is cancelled, not a handshake failure. Abandon + // the attempt before `fail` or the process exit can record it. plugin_operations::abandon(attempt); + session.fail( + "indexingChanged", + "initialize", + "Indexing policy changed during language-server startup.", + Some(core_error_detail(&error)), + None, + ); + session.active.store(false, Ordering::Release); session.kill_process(); + // No native identity has been published yet. Forget the session + // only after disposal proves that its process tree has exited. + if session.process.dispose(Duration::from_secs(2)).is_ok() { + self.lock_sessions()?.remove(&session_id); + } else { + registered(&session_id); + } return Err(error); } + // Native owners learn the identity before initialize writes can fail. + // They keep their package barrier until destroy verifies disposal. + registered(&session_id); session.spawn_readers(process.output, process.errors); session.spawn_monitor(); session.spawn_outbound_maintenance(); @@ -2294,12 +2376,20 @@ impl LspEngine { } if let Err(error) = check_indexing() { - self.lock_sessions()?.remove(&session_id); - session.active.store(false, Ordering::Release); - // The readers already run; abandon before the kill so the exit - // they observe finds no attempt to record. + // The readers already run; abandon before `fail` and the kill so + // neither the failure nor the observed exit records the cancel. plugin_operations::abandon(attempt); + session.fail( + "indexingChanged", + "initialize", + "Indexing policy changed during language-server startup.", + Some(core_error_detail(&error)), + None, + ); + session.active.store(false, Ordering::Release); session.kill_process(); + // The native owner already holds this identity. Keep it until + // destroy verifies disposal and returns a positive receipt. return Err(error); } @@ -2330,6 +2420,7 @@ impl LspEngine { "A running language-server session cannot be destroyed.", )); } + session.process.dispose(Duration::from_secs(2))?; self.lock_sessions()?.remove(session_id); Ok(()) } @@ -2690,7 +2781,7 @@ impl RuntimeSession { let response = allocate_raw_request( state.client.clone(), "workspace/executeCommand", - java_entrypoints_command(&java_entrypoint_scope_uri(&self.root_uri)), + java_entrypoints_command(), )?; let request_id = (response.state.next_request_id - 1).to_string(); let now = Instant::now(); @@ -3574,11 +3665,7 @@ impl RuntimeSession { "Java entry-point discovery requires the Java language service.", )); } - allocate_raw_request( - state.client.clone(), - method, - java_entrypoints_command(&java_entrypoint_scope_uri(&self.root_uri)), - )? + allocate_raw_request(state.client.clone(), method, java_entrypoints_command())? } LspSemanticOperation::JavaTestItems => { if self.provider_id != "java" { @@ -5598,7 +5685,7 @@ impl RuntimeSession { let response = match allocate_raw_request( state.client.clone(), JAVA_BUILD_METHOD, - java_entrypoints_command(&java_entrypoint_scope_uri(&self.root_uri)), + java_entrypoints_command(), ) { Ok(response) => response, Err(error) => { @@ -6719,23 +6806,6 @@ fn diagnostics_addressed_to_open_document( Some(message) } -/// The workspace URI that scopes Java entry-point discovery. -/// -/// JDT imports a project at its canonical location, and Java Debug Server -/// keeps only the classes whose project path starts with the scope path. A -/// workspace opened through a symbolic link (`/tmp` or `/var` on macOS) would -/// therefore match no project and silently yield an empty list, so the scope -/// names the resolved directory. A root that cannot be resolved is sent as is. -fn java_entrypoint_scope_uri(root_uri: &str) -> String { - url::Url::parse(root_uri) - .ok() - .and_then(|url| url.to_file_path().ok()) - .and_then(|path| crate::remote::workspace_io::canonicalize(path).ok()) - .and_then(|canonical| url::Url::from_directory_path(canonical).ok()) - .map(|url| url.to_string()) - .unwrap_or_else(|| root_uri.to_string()) -} - /// The workspace directory with symbolic links resolved, when it exists. /// /// Resolving links touches the file system, so it happens here in the engine @@ -8653,6 +8723,118 @@ mod tests { } } + #[test] + fn native_owner_keeps_failed_initialize_identity_until_verified_disposal() { + let server = ScriptedServer::new(); + server.break_input(); + server.block_cleanup(true); + let engine = LspEngine::with_launcher(server.launcher()); + let registered = Mutex::new(None); + let result = engine.start_server_owned(start_request(&server), |id| { + // Registration precedes the very first write, including its failure. + assert!(server.messages().is_empty()); + *registered.lock().unwrap() = Some(id.to_string()); + }); + assert!(result.is_err()); + let id = registered + .into_inner() + .unwrap() + .expect("native owner received the session"); + assert!(engine.session(&id).is_ok()); + assert!(engine.destroy(&id).is_err()); + assert!( + engine.session(&id).is_ok(), + "failed disposal must retain the process owner" + ); + server.block_cleanup(false); + engine + .destroy(&id) + .expect("verified cleanup allows destruction"); + assert!(engine.session(&id).is_err()); + } + + #[test] + fn wire_owner_retries_failed_initialize_disposal_before_another_start() { + let server = ScriptedServer::new(); + server.break_input(); + server.block_cleanup(true); + let engine = LspEngine::with_launcher(server.launcher()); + assert!(engine.start_server(start_request(&server)).is_err()); + let id = engine + .lock_failed_starts() + .unwrap() + .first() + .cloned() + .unwrap(); + let session = engine.session(&id).unwrap(); + let events = session.poll_events().unwrap(); + assert!(events.iter().any(|event| { + event + .error + .as_ref() + .is_some_and(|error| error.code == "transportFailed") + })); + let next_id = engine.next_session_id.load(Ordering::Relaxed); + let error = engine.start_server(start_request(&server)).unwrap_err(); + assert!(matches!(error.code, ErrorCode::ProcessFailed)); + let error = engine + .start_server_owned(start_request(&server), |_| { + panic!("cleanup must precede spawn") + }) + .unwrap_err(); + assert!(matches!(error.code, ErrorCode::ProcessFailed)); + assert_eq!(engine.next_session_id.load(Ordering::Relaxed), next_id); + assert_eq!(engine.lock_sessions().unwrap().len(), 1); + assert!(Arc::ptr_eq(&session, &engine.session(&id).unwrap())); + server.block_cleanup(false); + // The original transport remains broken, but retry first reclaims the + // old owner and also disposes the replacement's failed initialization. + assert!(engine.start_server(start_request(&server)).is_err()); + assert_eq!(engine.next_session_id.load(Ordering::Relaxed), next_id + 1); + assert!(engine.lock_failed_starts().unwrap().is_empty()); + assert!(engine.lock_sessions().unwrap().is_empty()); + } + + #[test] + fn wire_owner_cleans_at_most_one_failed_start_before_rejecting_a_backlog() { + let server = ScriptedServer::new(); + server.break_input(); + let engine = LspEngine::with_launcher(server.launcher()); + let mut ids = BTreeSet::new(); + for _ in 0..2 { + let mut id = None; + assert!(engine + .start_server_owned(start_request(&server), |registered| { + id = Some(registered.to_owned()); + }) + .is_err()); + ids.insert(id.unwrap()); + } + // Simulate two wire starts already in flight before either failure + // established the cleanup barrier. + assert_eq!(ids.len(), 2); + *engine.lock_failed_starts().unwrap() = ids; + let next_id = engine.next_session_id.load(Ordering::Relaxed); + let error = engine.start_server(start_request(&server)).unwrap_err(); + assert!(matches!(error.code, ErrorCode::ProcessFailed)); + assert_eq!(engine.next_session_id.load(Ordering::Relaxed), next_id); + assert_eq!(engine.lock_sessions().unwrap().len(), 1); + assert_eq!(engine.lock_failed_starts().unwrap().len(), 1); + engine.cleanup_failed_start().unwrap(); + assert!(engine.lock_sessions().unwrap().is_empty()); + assert!(engine.lock_failed_starts().unwrap().is_empty()); + } + + #[test] + fn invalid_initial_configuration_is_rejected_before_launch() { + let server = ScriptedServer::new(); + let engine = LspEngine::with_launcher(server.launcher()); + let mut request = start_request(&server); + request.workspace_configuration = Some(json!(["not an object"])); + assert!(engine.start_server(request).is_err()); + assert!(server.launched_spec().is_none()); + } + /// An engine with a scripted server behind it, plus the started session. struct Harness { engine: LspEngine, @@ -11508,6 +11690,7 @@ mod tests { #[test] fn indexing_startup_cancels_when_policy_changes_during_process_launch() { + const CANCELLED_PLUGIN: &str = "io.example.indexing-cancel-launch"; struct RetireOnLaunch { inner: Arc, root: PathBuf, @@ -11547,7 +11730,16 @@ mod tests { ); } } - for initially_configured in [false, true] { + for (initially_configured, cleanup_blocked, native_owner) in [ + (false, false, false), + (true, false, false), + (false, true, false), + (true, true, false), + (false, false, true), + (true, false, true), + (false, true, true), + (true, true, true), + ] { let workspace = TemporaryMavenWorkspace::recursive(&format!( "indexing-startup-retired-{initially_configured}" )); @@ -11565,6 +11757,7 @@ mod tests { process: Arc::new(Mutex::new(None)), }; let server = ScriptedServer::new(); + server.block_cleanup(cleanup_blocked); let engine = LspEngine::with_launcher(Arc::new(RetireOnLaunch { inner: server.launcher(), root: root.clone(), @@ -11575,18 +11768,99 @@ mod tests { request.provider_id = "python".into(); request.root_uri = url::Url::from_directory_path(&root).unwrap().to_string(); request.working_directory = root.to_string_lossy().into_owned(); - match engine.start_server(request) { - Err(error) => assert!(matches!(error.code, ErrorCode::Cancelled)), - Ok(_) => panic!("an obsolete startup must not publish a session"), + request.startup_operation = Some(AttemptHandoff { + plugin_id: CANCELLED_PLUGIN.to_string(), + operation_id: "indexing-cancel-before-registration".to_string(), + elapsed_ms: 5, + }); + let mut registered = None; + let result = if native_owner { + engine.start_server_owned(request, |id| registered = Some(id.to_owned())) + } else { + engine.start_server(request) + }; + assert!(matches!(result.unwrap_err().code, ErrorCode::Cancelled)); + if cleanup_blocked { + let id = if native_owner { + registered.expect("incomplete disposal must reach the native owner") + } else { + engine + .lock_failed_starts() + .unwrap() + .first() + .cloned() + .expect("incomplete wire disposal retains its internal owner") + }; + assert!(engine.destroy(&id).is_err()); + assert!(engine.session(&id).is_ok()); + server.block_cleanup(false); + if native_owner { + engine + .destroy(&id) + .expect("native owner can retry verified disposal"); + } else { + engine + .cleanup_failed_start() + .expect("wire retry confirms disposal"); + assert!(engine.lock_failed_starts().unwrap().is_empty()); + } + } else { + assert!( + registered.is_none(), + "disposed startup needs no native barrier" + ); } assert!(engine.lock_sessions().unwrap().is_empty()); assert!( server.input_was_closed(), "the cancelled startup owns process termination" ); + assert!( + plugin_operations::test_capture::take(CANCELLED_PLUGIN).is_empty(), + "a cancelled start records no plugin operation result" + ); } } + #[test] + fn native_owner_retains_indexing_cancellation_after_registration() { + const CANCELLED_PLUGIN: &str = "io.example.indexing-cancel-registered"; + let workspace = TemporaryMavenWorkspace::recursive("indexing-owned-startup"); + let root = workspace.root.canonicalize().unwrap(); + let mut policy = IndexingPolicyFixture::new(root.clone()); + let server = ScriptedServer::new(); + server.block_cleanup(true); + let engine = LspEngine::with_launcher(server.launcher()); + let mut request = start_request(&server); + request.provider_id = "python".into(); + request.root_uri = url::Url::from_directory_path(&root).unwrap().to_string(); + request.working_directory = root.to_string_lossy().into_owned(); + request.startup_operation = Some(AttemptHandoff { + plugin_id: CANCELLED_PLUGIN.to_string(), + operation_id: "indexing-cancel-after-registration".to_string(), + elapsed_ms: 5, + }); + let mut registered = None; + let result = engine.start_server_owned(request, |id| { + registered = Some(id.to_owned()); + // Revoke between the initial policy check and initialize write. + policy.exclude(&["reactor"]); + }); + assert!(matches!(result.unwrap_err().code, ErrorCode::Cancelled)); + let id = registered.expect("native owner received its session"); + assert!(engine.destroy(&id).is_err()); + assert!(engine.session(&id).is_ok()); + server.block_cleanup(false); + engine + .destroy(&id) + .expect("native owner confirms process disposal"); + assert!(engine.session(&id).is_err()); + assert!( + plugin_operations::test_capture::take(CANCELLED_PLUGIN).is_empty(), + "a cancelled start records no plugin operation result" + ); + } + #[test] fn indexing_released_root_allows_a_standalone_provider_without_old_exclusions() { let workspace = TemporaryMavenWorkspace::recursive("indexing-released-standalone"); @@ -11687,8 +11961,14 @@ mod tests { #[test] fn indexing_watcher_rebuild_publishes_recomputed_git_exclusions_to_java() { - let workspace = TemporaryMavenWorkspace::recursive("indexing-watcher-provider"); - let root = workspace.root.canonicalize().unwrap(); + // This regression owns indexing notifications, not Maven reactor discovery. + // Keep unrelated recursive projects out of the real Git ignore inventory. + let workspace = ScratchDirectory(std::env::temp_dir().join(format!( + "lithe-indexing-watcher-provider-{}", + std::process::id() + ))); + std::fs::create_dir_all(&workspace.0).unwrap(); + let root = workspace.0.canonicalize().unwrap(); std::fs::create_dir_all(root.join("ignored")).unwrap(); std::fs::write(root.join("ignored/hidden.txt"), "hidden").unwrap(); std::fs::write(root.join(".gitignore"), "ignored/\n").unwrap(); @@ -11699,7 +11979,12 @@ mod tests { ) .unwrap(); assert_eq!(git.exit_code, 0, "{}", git.stderr); - let mut harness = Harness::start(|request| workspace.configure(request)); + let mut harness = Harness::start(|request| { + request.provider_id = "java".into(); + request.root_uri = url::Url::from_directory_path(&root).unwrap().to_string(); + request.working_directory = root.to_string_lossy().into_owned(); + request.cache_directory = Some(root.join("cache").to_string_lossy().into_owned()); + }); harness .server .complete_java_initialize(ready_capabilities()); @@ -13106,7 +13391,7 @@ mod tests { .find(|message| message["id"] == request_id) .expect("the discovery request should be recorded"); assert_eq!(request["params"]["command"], "vscode.java.resolveMainClass"); - assert_eq!(request["params"]["arguments"], json!(["file:///workspace"])); + assert_eq!(request["params"]["arguments"], json!([])); // Java 25 forms (no-argument, instance) arrive from JDT like any other // entry; Core must pass them through without judging the signature. @@ -13147,40 +13432,6 @@ mod tests { } } - // Regression: a workspace opened through a symbolic link, as `/tmp` and - // `/var` are on macOS, listed no entry points because JDT places the - // project at the resolved location and the scope named the link. - #[cfg(unix)] - #[test] - fn java_entrypoint_scope_names_the_workspace_a_symbolic_link_resolves_to() { - let stamp = std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .expect("system clock should follow the Unix epoch") - .as_nanos(); - let scratch = ScratchDirectory(std::env::temp_dir().join(format!( - "lithe-entrypoint-scope-{}-{stamp}", - std::process::id() - ))); - let workspace = scratch.0.join("real workspace"); - std::fs::create_dir_all(&workspace).expect("workspace should be creatable"); - let link = scratch.0.join("link"); - std::os::unix::fs::symlink(&workspace, &link).expect("link should be creatable"); - - let scope = java_entrypoint_scope_uri( - url::Url::from_directory_path(&link) - .expect("link converts to a URI") - .as_str(), - ); - let resolved = workspace.canonicalize().expect("workspace canonicalizes"); - assert_eq!( - url::Url::parse(&scope) - .expect("scope is a URI") - .to_file_path() - .expect("scope is a file URI"), - resolved - ); - } - // Regression: JDT publishes diagnostics under the resolved path of a file // the host opened through a symbolic link; matching the URIs textually // dropped every Java error in such a workspace. @@ -13301,13 +13552,6 @@ mod tests { assert!(linked.examined.is_empty()); } - #[test] - fn java_entrypoint_scope_keeps_a_root_that_cannot_be_resolved() { - for root_uri in ["file:///lithe-missing-workspace/app", "untitled:workspace"] { - assert_eq!(java_entrypoint_scope_uri(root_uri), root_uri); - } - } - #[test] fn a_malformed_java_entrypoint_answer_is_an_error_not_an_empty_list() { // Reporting "no entry points" here would let callers wipe a good list. diff --git a/rust/lithe-core/src/lsp/interface/engine_real_jdt_tests.rs b/rust/lithe-core/src/lsp/interface/engine_real_jdt_tests.rs index daab2c2c1c..b617b536f5 100644 --- a/rust/lithe-core/src/lsp/interface/engine_real_jdt_tests.rs +++ b/rust/lithe-core/src/lsp/interface/engine_real_jdt_tests.rs @@ -776,6 +776,68 @@ fn real_jdtls_discovers_builds_and_launches_java_25_entrypoints() { ); } +/// A plain folder becomes an invisible JDT project in its writable cache. +/// The Java Debug Server's path-scoped search omits that project, so discovery +/// must include its entries before Core applies workspace ownership checks. +#[test] +fn real_jdtls_lists_entrypoints_in_a_plain_java_folder() { + let Some(toolchain) = real_jdt_toolchain() else { + return; + }; + let stamp = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .expect("system clock should follow the Unix epoch") + .as_nanos(); + let root = std::env::temp_dir().join(format!( + "lithe-real-jdt-plain-{}-{stamp}", + std::process::id() + )); + let workspace = root.join("plain workspace"); + let source = "src/Main.java"; + std::fs::create_dir_all(workspace.join("src")).expect("fixture source directory"); + let text = "public class Main { public static void main(String[] args) { } }\n"; + std::fs::write(workspace.join(source), text).expect("fixture source"); + let root_uri = url::Url::from_directory_path(&workspace) + .expect("workspace converts to a file URI") + .to_string(); + let installation_before = installation_listing(&toolchain.root); + let engine = LspEngine::new(); + let mut request = real_start_request(&toolchain, &root, &workspace, &root_uri); + // This classic main needs no Java 25 features; use JDT's runtime JDK. + request.java_runtimes.clear(); + let started = engine + .start_server(request) + .expect("real JDTLS should start"); + let _cleanup = RealSmokeCleanup { + engine: &engine, + session_id: started.session_id.clone(), + root, + }; + let session = engine + .session(&started.session_id) + .expect("real JDTLS session should be registered"); + await_real_smoke_ready(&session).unwrap_or_else(|error| panic!("{error}")); + session + .sync_document(SyncDocumentRequest { + session_id: session.id.clone(), + uri: url::Url::from_file_path(workspace.join(source)) + .expect("source converts to a file URI") + .to_string(), + language_id: "java".to_string(), + text: text.to_string(), + content_changes: Vec::new(), + }) + .expect("plain source should open"); + let entrypoints = await_real_entrypoints(&engine, &session, 1); + let entries = entrypoints["entries"].as_array().expect("entry list"); + assert_eq!(entries.len(), 1, "{entrypoints}"); + assert_eq!(entries[0]["sourcePath"], source, "{entrypoints}"); + assert_eq!(entries[0]["mainClass"], "Main", "{entrypoints}"); + assert!(entries[0]["projectName"].is_string(), "{entrypoints}"); + assert_eq!(entrypoints["diagnostics"], json!([]), "{entrypoints}"); + assert_eq!(installation_listing(&toolchain.root), installation_before); +} + /// Regression for a workspace opened through a symbolic link, which is how /// macOS exposes `/tmp` and `/var`. JDT imports the project at its resolved /// location, so an entry-point scope naming the link matched no project and diff --git a/rust/lithe-core/src/lsp/interface/process.rs b/rust/lithe-core/src/lsp/interface/process.rs index 01de042971..dc9ee61a34 100644 --- a/rust/lithe-core/src/lsp/interface/process.rs +++ b/rust/lithe-core/src/lsp/interface/process.rs @@ -17,6 +17,7 @@ use std::path::Path; use std::path::PathBuf; use std::process::{Child, ChildStdin, Command, Stdio}; use std::sync::{Arc, Mutex}; +use std::time::Duration; #[cfg(target_os = "windows")] use std::os::windows::process::CommandExt; @@ -32,9 +33,8 @@ pub struct LspProcessSpec { /// A running language-server process. /// -/// Every method is infallible-by-design except writing: a process that has -/// already exited is a normal state the engine reports through its own events, -/// not an error to propagate from the handle. +/// Exit notification and verified disposal are separate: a dead root may +/// still own descendants. Disposal must succeed before releasing resources. pub trait LspProcessHandle: Send + Sync { /// OS process identifier when the platform exposes one. Scripted test /// handles intentionally return no identifier. @@ -61,6 +61,19 @@ pub trait LspProcessHandle: Send + Sync { fn take_termination_failure(&self) -> Option { None } + + /// Confirms disposal before the engine forgets the owning session. + /// Scripted handles have no descendants and report their own exit. + fn dispose(&self, _timeout: Duration) -> Result<(), CoreError> { + if self.exit_status().is_some() { + Ok(()) + } else { + Err(CoreError::new( + ErrorCode::ProcessFailed, + "Language-server cleanup is incomplete.", + )) + } + } } /// A launched process and the two streams the engine reads on its own threads. @@ -208,6 +221,10 @@ fn windows_batch_env_value(value: &str) -> String { escaped } +/// Interval between exit checks while a native disposal waits for the root. +#[cfg(not(target_os = "windows"))] +const DISPOSAL_POLL_MS: u64 = 10; + struct SystemProcess { input: Mutex>, child: Mutex, @@ -280,6 +297,46 @@ impl LspProcessHandle for SystemProcess { .unwrap_or_else(|e| e.into_inner()) .take() } + + fn dispose(&self, timeout: Duration) -> Result<(), CoreError> { + #[cfg(target_os = "windows")] + self.tree.terminate(timeout).map_err(|error| { + CoreError::new( + ErrorCode::ProcessFailed, + "Language-server process tree did not exit.", + ) + .with_details(error.to_string()) + })?; + // A signalled child is reaped asynchronously, so an immediate status + // read after termination can still report it running. Repeat the + // idempotent kill and poll until the bounded disposal deadline. The + // last kill failure explains a root that outlives the deadline. + #[cfg(not(target_os = "windows"))] + let kill_failure = { + let mut last = None; + let deadline = std::time::Instant::now() + timeout; + while self.exit_status().is_none() && std::time::Instant::now() < deadline { + if let Err(error) = self.terminate_native() { + last = Some(error); + } + std::thread::sleep(Duration::from_millis(DISPOSAL_POLL_MS)); + } + last + }; + #[cfg(target_os = "windows")] + let kill_failure: Option = None; + if self.exit_status().is_none() { + let error = CoreError::new( + ErrorCode::ProcessFailed, + "Language-server root did not exit.", + ); + return Err(match kill_failure { + Some(cause) => error.with_details(cause.to_string()), + None => error, + }); + } + Ok(()) + } } impl SystemProcess { diff --git a/rust/lithe-core/src/lsp/interface/remote_process.rs b/rust/lithe-core/src/lsp/interface/remote_process.rs index 8192e368cd..13e7ac8945 100644 --- a/rust/lithe-core/src/lsp/interface/remote_process.rs +++ b/rust/lithe-core/src/lsp/interface/remote_process.rs @@ -435,6 +435,13 @@ impl LspProcessHandle for RemoteProcess { fn terminate(&self) { self.cleanup(); } + /// The backend owns the remote process tree, so the bounded forced kill + /// request is the final local receipt; it also records the exit. Without + /// it a failed session that never terminated could not be destroyed. + fn dispose(&self, _timeout: Duration) -> Result<(), CoreError> { + self.cleanup(); + Ok(()) + } } pub(super) fn launch(host: Host, spec: LspProcessSpec) -> Result { diff --git a/rust/lithe-core/src/lsp/interface/scripted.rs b/rust/lithe-core/src/lsp/interface/scripted.rs index 7b865cfa5d..d08c796262 100644 --- a/rust/lithe-core/src/lsp/interface/scripted.rs +++ b/rust/lithe-core/src/lsp/interface/scripted.rs @@ -36,6 +36,8 @@ struct ScriptedShared { input_closed: AtomicBool, /// Set when the test wants writes to fail, standing in for a broken pipe. input_broken: AtomicBool, + /// Deterministic refusal of process-tree disposal after the root exits. + cleanup_blocked: AtomicBool, /// Deterministic write barrier used by concurrency-ordering tests. input_pause: Mutex, input_pause_changed: Condvar, @@ -69,6 +71,7 @@ impl ScriptedServer { exit: Mutex::new(None), input_closed: AtomicBool::new(false), input_broken: AtomicBool::new(false), + cleanup_blocked: AtomicBool::new(false), input_pause: Mutex::new(ScriptedInputPause::default()), input_pause_changed: Condvar::new(), spec: Mutex::new(None), @@ -252,6 +255,13 @@ impl ScriptedServer { self.shared.input_broken.store(true, Ordering::Release); } + /// Simulates a descendant that survives the root, without real processes. + pub fn block_cleanup(&self, blocked: bool) { + self.shared + .cleanup_blocked + .store(blocked, Ordering::Release); + } + /// Stops the next engine write before any bytes reach the scripted server. pub fn pause_input(&self) { let mut pause = self.shared.input_pause.lock().unwrap(); @@ -392,6 +402,16 @@ impl LspProcessHandle for ScriptedProcess { *self.shared.exit.lock().unwrap() } + fn dispose(&self, _timeout: Duration) -> Result<(), CoreError> { + if self.shared.cleanup_blocked.load(Ordering::Acquire) || self.exit_status().is_none() { + return Err(CoreError::new( + ErrorCode::ProcessFailed, + "Scripted process cleanup is incomplete.", + )); + } + Ok(()) + } + fn terminate(&self) { let mut exit = self.shared.exit.lock().unwrap(); if exit.is_none() { diff --git a/rust/lithe-core/src/lsp/languages/java_entrypoints.rs b/rust/lithe-core/src/lsp/languages/java_entrypoints.rs index be4078a409..6515ce9f64 100644 --- a/rust/lithe-core/src/lsp/languages/java_entrypoints.rs +++ b/rust/lithe-core/src/lsp/languages/java_entrypoints.rs @@ -19,16 +19,16 @@ pub(crate) const JAVA_RESOLVE_MAIN_CLASS_COMMAND: &str = "vscode.java.resolveMai /// Version of the serialized [`JavaEntrypoints`] shape. pub(crate) const JAVA_ENTRYPOINTS_SCHEMA_VERSION: u32 = 1; -/// `workspace/executeCommand` params that discover entry points under one workspace. +/// `workspace/executeCommand` params that discover the session's Java entries. /// -/// Passing the workspace URI scopes the search to projects inside it instead of -/// every project JDT has imported. Java Debug Server compares that path with -/// each project's canonical location textually, so `scope_uri` must name the -/// workspace with symbolic links resolved or no project matches. -pub(crate) fn java_entrypoints_command(scope_uri: &str) -> Value { +/// The bundled Java Debug Server's path-scoped search excludes invisible +/// projects, whose location is JDT's cache rather than their linked workspace. +/// Its unscoped command includes these projects. The normalizer below still +/// restricts every returned source to the opened workspace or its resolved root. +pub(crate) fn java_entrypoints_command() -> Value { json!({ "command": JAVA_RESOLVE_MAIN_CLASS_COMMAND, - "arguments": [scope_uri], + "arguments": [], }) } @@ -219,13 +219,34 @@ mod tests { } #[test] - fn the_command_is_scoped_to_the_workspace() { + fn the_command_includes_jdt_invisible_projects_before_workspace_filtering() { assert_eq!( - java_entrypoints_command("file:///work/app/"), - json!({ "command": "vscode.java.resolveMainClass", "arguments": ["file:///work/app/"] }) + java_entrypoints_command(), + json!({ "command": "vscode.java.resolveMainClass", "arguments": [] }) ); } + #[test] + fn unscoped_results_keep_only_sources_owned_by_the_open_workspace() { + let result = json!([ + { "mainClass": "Main", "projectName": "invisible-cache-project", "filePath": "/resolved/app/src/Main.java" }, + { "mainClass": "Foreign", "projectName": "other-project", "filePath": "/resolved/app-other/src/Foreign.java" } + ]); + let normalized = + normalize_java_entrypoints("file:///linked/app/", Some("/resolved/app"), &result) + .expect("list result"); + assert_eq!( + normalized.entries, + vec![entry( + "src/Main.java", + "Main", + Some("invisible-cache-project") + )] + ); + assert_eq!(normalized.diagnostics.len(), 1); + assert_eq!(normalized.diagnostics[0].code, "outsideWorkspace"); + } + #[test] fn same_class_names_in_two_modules_stay_separate_entries() { // Maven reactors often repeat `demo.App` per module; the source path, diff --git a/rust/lithe-core/src/project_generators/archive.rs b/rust/lithe-core/src/project_generators/archive.rs index 7628f1a90f..d477cc40b3 100644 --- a/rust/lithe-core/src/project_generators/archive.rs +++ b/rust/lithe-core/src/project_generators/archive.rs @@ -6,49 +6,88 @@ //! bounded regardless of what the headers claim. use crate::plugins::declarative::{PluginRejection, Validation}; +use crate::protocol::CoreError; +use std::collections::HashSet; use std::fs::{self, File, OpenOptions}; use std::io::{self, Read, Write}; use std::path::{Component, Path, PathBuf}; const MAX_ENTRIES: usize = 20_000; const MAX_EXTRACTED_BYTES: u64 = 512 * 1024 * 1024; +const COPY_CHUNK_BYTES: usize = 32 * 1024; +const MAX_DEPTH: usize = 64; +const MAX_PATH_BYTES: usize = 16 * 1024 * 1024; const ARCHIVE_INVALID: &str = "plugin.project.archiveInvalid"; /// `S_IFMT` and `S_IFLNK` of a Unix mode stored in a zip entry. const FILE_TYPE_MASK: u32 = 0o170000; const SYMLINK_TYPE: u32 = 0o120000; +/// Separates invalid archive content from the first typed operation interruption. +#[derive(Debug)] +pub(crate) enum ExtractionError { + /// The archive or destination violates the extraction contract. + Invalid(PluginRejection), + /// Cancellation or timeout detected while all extraction handles are owned. + Interrupted(CoreError), +} + +impl From for ExtractionError { + fn from(error: PluginRejection) -> Self { + Self::Invalid(error) + } +} + +impl From for ExtractionError { + fn from(error: CoreError) -> Self { + Self::Interrupted(error) + } +} + /// Extracts `archive` into `destination`, which must be an existing -/// directory. Returns the number of files written. -pub(crate) fn extract(archive: &Path, destination: &Path) -> Validation { +/// directory. Returns the number of files written after closing its descriptors. +pub(crate) fn extract(archive: &Path, destination: &Path) -> Result { + extract_with_checkpoint(archive, destination, MAX_EXTRACTED_BYTES, &mut checkpoint) +} + +fn checkpoint() -> Result<(), CoreError> { + crate::protocol::cancellation::check() +} + +fn extract_with_checkpoint( + archive: &Path, + destination: &Path, + maximum_bytes: u64, + checkpoint: &mut dyn FnMut() -> Result<(), CoreError>, +) -> Result { + checkpoint()?; let rejected = |message: String| PluginRejection::at(ARCHIVE_INVALID, "archive", message); let destination_metadata = fs::symlink_metadata(destination) .map_err(|error| rejected(format!("The destination cannot be read: {error}")))?; - if !destination_metadata.is_dir() { - return Err(rejected("The destination is not a directory.".into())); + if !real_directory(&destination_metadata) { + return Err(rejected("The destination is not a directory.".into()).into()); } let file = File::open(archive) .map_err(|error| rejected(format!("The archive cannot be read: {error}")))?; let mut zip = zip::ZipArchive::new(file) .map_err(|error| rejected(format!("The download is not a zip archive: {error}")))?; if zip.len() > MAX_ENTRIES { - return Err(rejected("The archive has too many entries.".into())); + return Err(rejected("The archive has too many entries.".into()).into()); } + validate_entries(&mut zip, checkpoint, MAX_ENTRIES, MAX_PATH_BYTES)?; let mut written: u64 = 0; let mut files = 0; for index in 0..zip.len() { + checkpoint()?; let mut entry = zip .by_index(index) .map_err(|error| rejected(format!("Entry {index} cannot be read: {error}")))?; let name = entry.name().to_string(); - let relative = entry - .enclosed_name() - .filter(|path| is_plain_relative(path)) - .ok_or_else(|| rejected(format!("{name} leaves the project directory.")))?; + let relative = relative_entry(&entry)?; let mode = entry.unix_mode(); if mode.is_some_and(|mode| mode & FILE_TYPE_MASK == SYMLINK_TYPE) { - return Err(rejected(format!("{name} is a symbolic link."))); + return Err(rejected(format!("{name} is a symbolic link.")).into()); } let target = destination.join(&relative); ensure_directories(destination, relative.parent().unwrap_or(Path::new(""))) @@ -63,13 +102,28 @@ pub(crate) fn extract(archive: &Path, destination: &Path) -> Validation { .create_new(true) .open(&target) .map_err(|error| rejected(format!("{name} cannot be created: {error}")))?; - let remaining = MAX_EXTRACTED_BYTES - written; - let copied = io::copy(&mut (&mut entry).take(remaining + 1), &mut output) - .map_err(|error| rejected(format!("{name} cannot be extracted: {error}")))?; - if copied > remaining { - return Err(rejected( - "The archive expands beyond the size limit.".into(), - )); + let remaining = maximum_bytes - written; + let mut limited = (&mut entry).take(remaining + 1); + let mut copied = 0u64; + let mut buffer = [0u8; COPY_CHUNK_BYTES]; + loop { + checkpoint()?; + let count = limited + .read(&mut buffer) + .map_err(|error| rejected(format!("{name} cannot be extracted: {error}")))?; + if count == 0 { + break; + } + checkpoint()?; + // Read one byte beyond the budget to detect a dishonest size, but + // never write that sentinel byte into the transaction. + if copied + count as u64 > remaining { + return Err(rejected("The archive expands beyond the size limit.".into()).into()); + } + output + .write_all(&buffer[..count]) + .map_err(|error| rejected(format!("{name} cannot be extracted: {error}")))?; + copied += count as u64; } output .flush() @@ -78,14 +132,138 @@ pub(crate) fn extract(archive: &Path, destination: &Path) -> Validation { files += 1; set_executable(&target, mode).map_err(|error| rejected(format!("{name}: {error}")))?; } + checkpoint()?; Ok(files) } +fn relative_entry(entry: &zip::read::ZipFile<'_>) -> Validation { + let name = entry.name(); + // Reject traversal before ZipArchive normalizes it. Backslashes are path + // separators on Windows, so they cannot be literal names on another host. + let path = name.strip_suffix('/').unwrap_or(name); + if name.contains('\\') || path.split('/').any(|part| matches!(part, "" | "." | "..")) { + return Err(PluginRejection::at( + ARCHIVE_INVALID, + "archive", + format!("{name} leaves the project directory."), + )); + } + entry + .enclosed_name() + .filter(|path| is_plain_relative(path)) + .ok_or_else(|| { + PluginRejection::at( + ARCHIVE_INVALID, + "archive", + format!("{name} leaves the project directory."), + ) + }) +} + +/// Preflights the existing ZIP parser's entries before creating anything. The +/// node budget includes implicit parent directories; the path-byte budget bounds +/// memory even when a few deeply nested names expand into many parent paths. +fn validate_entries( + zip: &mut zip::ZipArchive, + checkpoint: &mut dyn FnMut() -> Result<(), CoreError>, + maximum_entries: usize, + maximum_path_bytes: usize, +) -> Result<(), ExtractionError> { + let mut paths = HashSet::new(); + let mut path_bytes = 0usize; + for index in 0..zip.len() { + checkpoint()?; + let entry = zip.by_index(index).map_err(|error| { + PluginRejection::at( + ARCHIVE_INVALID, + "archive", + format!("Entry {index}: {error}"), + ) + })?; + let relative = relative_entry(&entry)?; + if entry + .unix_mode() + .is_some_and(|mode| mode & FILE_TYPE_MASK == SYMLINK_TYPE) + { + return Err(PluginRejection::at( + ARCHIVE_INVALID, + "archive", + format!("{} is a symbolic link.", entry.name()), + ) + .into()); + } + for path in relative + .ancestors() + .take_while(|path| !path.as_os_str().is_empty()) + { + checkpoint()?; + if paths.insert(path.to_path_buf()) { + path_bytes = path_bytes.saturating_add(path.to_string_lossy().len()); + if paths.len() > maximum_entries || path_bytes > maximum_path_bytes { + return Err(PluginRejection::at( + ARCHIVE_INVALID, + "archive", + "The archive has too many paths or path bytes.", + ) + .into()); + } + } + } + } + Ok(()) +} + fn is_plain_relative(path: &Path) -> bool { - path.components().next().is_some() - && path - .components() - .all(|component| matches!(component, Component::Normal(_))) + let components: Vec<_> = path.components().collect(); + !components.is_empty() + && components.len() <= MAX_DEPTH + && components.iter().all(|component| match component { + Component::Normal(value) => safe_component(value), + _ => false, + }) +} + +fn real_directory(metadata: &fs::Metadata) -> bool { + if !metadata.is_dir() || metadata.file_type().is_symlink() { + return false; + } + #[cfg(windows)] + { + use std::os::windows::fs::MetadataExt; + if metadata.file_attributes() & 0x400 != 0 { + return false; + } + } + true +} + +#[cfg(windows)] +fn safe_component(value: &std::ffi::OsStr) -> bool { + let Some(value) = value.to_str() else { + return false; + }; + let base = value.split('.').next().unwrap_or("").to_ascii_uppercase(); + !value.ends_with(['.', ' ']) + && !value + .chars() + .any(|ch| ch.is_control() || "<>:\"|?*".contains(ch)) + && !matches!( + base.as_str(), + "CON" | "PRN" | "AUX" | "NUL" | "CONIN$" | "CONOUT$" + ) + && !["COM", "LPT"].iter().any(|prefix| { + base.strip_prefix(prefix).is_some_and(|n| { + matches!( + n, + "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "¹" | "²" | "³" + ) + }) + }) +} + +#[cfg(not(windows))] +fn safe_component(_: &std::ffi::OsStr) -> bool { + true } /// Creates each directory below `root` along `relative`, refusing to walk @@ -95,7 +273,7 @@ fn ensure_directories(root: &Path, relative: &Path) -> io::Result<()> { for component in relative.components() { current.push(component); match fs::symlink_metadata(¤t) { - Ok(metadata) if metadata.is_dir() => {} + Ok(metadata) if real_directory(&metadata) => {} Ok(_) => { return Err(io::Error::new( io::ErrorKind::AlreadyExists, @@ -232,4 +410,196 @@ mod tests { fs::create_dir(&destination).unwrap(); assert!(extract(&path, &destination).is_err()); } + + #[test] + fn cancellation_between_chunks_stops_before_the_next_write_or_entry() { + let bytes = vec![b'x'; COPY_CHUNK_BYTES * 3]; + let (directory, path) = + archive(&[("large.txt", &bytes, None), ("later.txt", b"later", None)]); + let destination = directory.path().join("project"); + fs::create_dir(&destination).unwrap(); + let id = format!("archive-chunks-{}", rand::random::()); + let _scope = crate::protocol::cancellation::Scope::begin(Some(id.clone()), Some(3000)); + let result = extract_with_checkpoint(&path, &destination, MAX_EXTRACTED_BYTES, &mut || { + // Observe one completed write, then cancel before another chunk. + if fs::metadata(destination.join("large.txt")) + .is_ok_and(|metadata| metadata.len() >= COPY_CHUNK_BYTES as u64) + { + assert!(crate::protocol::cancellation::cancel(&id)); + } + checkpoint() + }); + assert!(result.is_err()); + let written = fs::metadata(destination.join("large.txt")).unwrap().len(); + assert!(written >= COPY_CHUNK_BYTES as u64); + assert!(written < (COPY_CHUNK_BYTES * 2) as u64); + assert!(!destination.join("later.txt").exists()); + } + + #[test] + fn timeout_between_chunks_preserves_its_first_error_and_closes_the_output() { + let bytes = vec![b'x'; COPY_CHUNK_BYTES * 3]; + let (directory, path) = + archive(&[("large.txt", &bytes, None), ("later.txt", b"later", None)]); + let destination = directory.path().join("project"); + fs::create_dir(&destination).unwrap(); + let result = extract_with_checkpoint(&path, &destination, MAX_EXTRACTED_BYTES, &mut || { + if fs::metadata(destination.join("large.txt")) + .is_ok_and(|metadata| metadata.len() >= COPY_CHUNK_BYTES as u64) + { + // An already reached deadline controls the event order without + // sleeping or relying on the speed of filesystem extraction. + crate::protocol::cancellation::with_cleanup_deadline( + std::time::Duration::ZERO, + checkpoint, + ) + } else { + Ok(()) + } + }); + let Err(ExtractionError::Interrupted(error)) = result else { + panic!("chunk timeout must remain an operation interruption"); + }; + assert!(matches!(error.code, crate::protocol::ErrorCode::TimedOut)); + assert_eq!( + fs::metadata(destination.join("large.txt")).unwrap().len(), + COPY_CHUNK_BYTES as u64 + ); + assert!(!destination.join("later.txt").exists()); + #[cfg(windows)] + { + use std::os::windows::fs::OpenOptionsExt; + // An exclusive reopen proves the timed-out writer released its + // descriptor before the host can start transaction cleanup. + let _closed = OpenOptions::new() + .read(true) + .share_mode(0) + .open(destination.join("large.txt")) + .unwrap(); + } + } + + #[test] + fn rejects_excessive_archive_path_depth_before_creating_any_parent() { + let name = format!("{}/file.txt", vec!["a"; MAX_DEPTH].join("/")); + let (directory, path) = archive(&[(&name, b"no", None)]); + let destination = directory.path().join("project"); + fs::create_dir(&destination).unwrap(); + assert!(extract(&path, &destination).is_err()); + assert_eq!(fs::read_dir(destination).unwrap().count(), 0); + } + + #[test] + fn expanded_byte_budget_counts_actual_written_bytes() { + let bytes = vec![b'x'; COPY_CHUNK_BYTES * 2]; + let (directory, path) = archive(&[("large.txt", &bytes, None)]); + let destination = directory.path().join("project"); + fs::create_dir(&destination).unwrap(); + assert!(extract_with_checkpoint( + &path, + &destination, + COPY_CHUNK_BYTES as u64 + 16, + &mut || Ok(()) + ) + .is_err()); + let written = fs::metadata(destination.join("large.txt")).unwrap().len(); + assert!(written > 0); + assert!(written <= COPY_CHUNK_BYTES as u64 + 16); + } + + #[test] + fn implicit_parents_and_path_bytes_share_the_preflight_budget() { + let (_directory, path) = archive(&[("parent/nested/file.txt", b"no", None)]); + let mut zip = zip::ZipArchive::new(File::open(&path).unwrap()).unwrap(); + assert!(validate_entries(&mut zip, &mut || Ok(()), 2, usize::MAX).is_err()); + // The leaf (22 bytes) and its implicit parents (13 + 6) total 41. + assert!(validate_entries(&mut zip, &mut || Ok(()), 3, 40).is_err()); + assert!(validate_entries(&mut zip, &mut || Ok(()), 3, 41).is_ok()); + } + + #[test] + fn archive_paths_cannot_hide_traversal_in_normalized_components() { + for name in [ + "nested/../file.txt", + "nested/./file.txt", + "nested//file.txt", + "nested\\file.txt", + "/file.txt", + ] { + let (directory, path) = archive(&[("first.txt", b"safe", None), (name, b"no", None)]); + let destination = directory.path().join("project"); + fs::create_dir(&destination).unwrap(); + assert!(extract(&path, &destination).is_err(), "{name}"); + assert_eq!(fs::read_dir(destination).unwrap().count(), 0, "{name}"); + } + } + + #[test] + fn command_reports_stable_cancellation_and_timeout_before_any_write() { + let (directory, path) = archive(&[("file.txt", b"no", None)]); + let destination = directory.path().join("project"); + fs::create_dir(&destination).unwrap(); + let payload = serde_json::json!({"archivePath": path, "destination": destination}); + let id = format!("archive-command-{}", rand::random::()); + { + let _scope = crate::protocol::cancellation::Scope::begin(Some(id.clone()), None); + assert!(crate::protocol::cancellation::cancel(&id)); + let error = crate::project_generators::project_extract_archive_command(payload.clone()) + .unwrap_err(); + assert!(matches!(error.code, crate::protocol::ErrorCode::Cancelled)); + } + crate::protocol::cancellation::with_cleanup_deadline(std::time::Duration::ZERO, || { + let error = + crate::project_generators::project_extract_archive_command(payload).unwrap_err(); + assert!(matches!(error.code, crate::protocol::ErrorCode::TimedOut)); + }); + assert_eq!(fs::read_dir(destination).unwrap().count(), 0); + } + + #[test] + fn existing_hard_link_target_is_never_truncated_or_replaced() { + let (directory, path) = archive(&[("linked.txt", b"untrusted", None)]); + let destination = directory.path().join("project"); + fs::create_dir(&destination).unwrap(); + let outside = directory.path().join("owned.txt"); + fs::write(&outside, b"user bytes").unwrap(); + fs::hard_link(&outside, destination.join("linked.txt")).unwrap(); + assert!(extract(&path, &destination).is_err()); + assert_eq!(fs::read(&outside).unwrap(), b"user bytes"); + assert_eq!( + fs::read(destination.join("linked.txt")).unwrap(), + b"user bytes" + ); + } + + #[cfg(windows)] + #[test] + fn windows_archive_paths_reject_ads_device_names_and_verbatim_normalization() { + for name in [ + "file:stream", + "CON.txt", + "nested/LPT1", + "trailing.", + "space ", + ] { + let (directory, path) = archive(&[(name, b"no", None)]); + let destination = directory.path().join("project"); + fs::create_dir(&destination).unwrap(); + assert!(extract(&path, &destination).is_err(), "{name}"); + assert_eq!(fs::read_dir(destination).unwrap().count(), 0); + } + } + + #[cfg(unix)] + #[test] + fn refuses_existing_symlink_directories_without_touching_their_target() { + let (directory, path) = archive(&[("nested/file.txt", b"no", None)]); + let destination = directory.path().join("project"); + let outside = directory.path().join("outside"); + fs::create_dir(&destination).unwrap(); + fs::create_dir(&outside).unwrap(); + std::os::unix::fs::symlink(&outside, destination.join("nested")).unwrap(); + assert!(extract(&path, &destination).is_err()); + assert_eq!(fs::read_dir(outside).unwrap().count(), 0); + } } diff --git a/rust/lithe-core/src/project_generators/commands.rs b/rust/lithe-core/src/project_generators/commands.rs index 425eb1cc13..5d1b311b36 100644 --- a/rust/lithe-core/src/project_generators/commands.rs +++ b/rust/lithe-core/src/project_generators/commands.rs @@ -199,9 +199,15 @@ pub(crate) fn project_check_name_command(payload: Value) -> Result Result { let payload: ExtractPayload = decode_payload(payload, "project.extractArchive")?; + let result = match archive::extract(&payload.archive_path, &payload.destination) { + Ok(files) => Ok(files), + Err(archive::ExtractionError::Invalid(rejection)) => Err(rejection), + // The extractor has closed its descriptors. Keep the first typed error: + // a second cancellation check would reclassify a timeout as cancellation. + Err(archive::ExtractionError::Interrupted(error)) => return Err(error), + }; Ok(outcome( - archive::extract(&payload.archive_path, &payload.destination) - .map(|files| ("extracted", json!({"files": files}))), + result.map(|files| ("extracted", json!({"files": files}))), )) } diff --git a/rust/lithe-core/src/remote/sessions_integration_tests.rs b/rust/lithe-core/src/remote/sessions_integration_tests.rs index 37ff565fde..93b999353b 100644 --- a/rust/lithe-core/src/remote/sessions_integration_tests.rs +++ b/rust/lithe-core/src/remote/sessions_integration_tests.rs @@ -161,6 +161,42 @@ fn remote_build_detects_host_models_normalizes_diagnostics_and_invalidates_sync( assert_eq!(std::fs::read_dir(placeholder).unwrap().count(), 0); } +/// A remote root opened through a host symbolic link resolves outside the +/// local placeholder; the empty-root boundary must ask the host, not the +/// unmaterialized local projection, before scanning. +#[test] +fn remote_build_detects_a_root_opened_through_a_host_symbolic_link() { + let host = HostFixture::new(); + let root = host.root.join("host"); + std::fs::create_dir_all(root.join("src")).unwrap(); + std::fs::write(root.join("src/main.rs"), "fn main() {}\n").unwrap(); + std::fs::write( + root.join("Cargo.toml"), + "[package]\nname = \"linked-host\"\nversion = \"1.0.0\"\n", + ) + .unwrap(); + let link = host.root.join("opened-link"); + std::os::unix::fs::symlink(&root, &link).unwrap(); + let manifest: Value = serde_json::from_str(include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../shared/contracts/plugins/v1/fixtures/build-static-file.plugin.json" + ))) + .unwrap(); + let detection = host.request_at( + &link, + "build.detect", + json!({"workspaceRoot": host.root.join("placeholder"), + "plugins": [{"manifest": manifest}], "options": {}}), + ); + assert_eq!(detection["status"], "ok", "{detection}"); + let instance = &detection["detection"]["instances"][0]; + assert_eq!(instance["id"], "cargo:.", "{detection}"); + assert_eq!( + instance["model"]["projects"][0]["name"], "linked-host", + "{detection}" + ); +} + #[test] fn remote_maven_build_reads_reactor_and_current_host_test_reports() { let host = HostFixture::new(); diff --git a/rust/lithe-core/src/tests/build_systems.rs b/rust/lithe-core/src/tests/build_systems.rs index 82347cc8c5..685974c60e 100644 --- a/rust/lithe-core/src/tests/build_systems.rs +++ b/rust/lithe-core/src/tests/build_systems.rs @@ -765,6 +765,33 @@ fn detection_applies_nesting_priority_and_rejections() { assert_eq!(gradle["markers"], json!(["android/settings.gradle.kts"])); } +#[test] +fn detection_returns_empty_for_non_directory_and_missing_workspace_roots() { + let workspace = TemporaryWorkspace::new("build-detect-non-directory"); + workspace.write( + "Cargo.toml", + "[package]\nname = \"fixture\"\nversion = \"0.1.0\"\n", + ); + for root in [ + workspace.0.join("Cargo.toml"), + workspace.0.join("missing"), + workspace.0.join("Cargo.toml/missing"), + ] { + let outcome = build_detect_command(json!({ + "workspaceRoot": root.to_string_lossy(), + "plugins": [{"manifest": fixture("build-static-file.plugin.json")}], + })) + .expect("the absolute detection request is well formed"); + assert_eq!(outcome["status"], "ok", "{}: {outcome}", root.display()); + assert_eq!( + outcome["detection"], + json!({"instances": [], "rejected": [], "shadowed": []}), + "{}", + root.display(), + ); + } +} + /// Maven's model comes from the host integration during detection, with the /// reactor's modules as projects and its profiles as option values. #[test] diff --git a/rust/lithe-core/src/tests/run_configuration.rs b/rust/lithe-core/src/tests/run_configuration.rs index df5ad788f2..d23cc4aab3 100644 --- a/rust/lithe-core/src/tests/run_configuration.rs +++ b/rust/lithe-core/src/tests/run_configuration.rs @@ -1734,6 +1734,14 @@ fn maven_test_source_main_uses_the_test_classpath() { #[test] fn plain_java_main_uses_the_jdk_without_maven() { let root = temporary_root("run-config-plain-java-main"); + struct Cleanup(PathBuf); + impl Drop for Cleanup { + fn drop(&mut self) { + crate::execution::generated_layer::forget(&self.0); + let _ = fs::remove_dir_all(&self.0); + } + } + let _cleanup = Cleanup(root.clone()); let source = "src/com/example/WorkerMain.java"; fs::create_dir_all(root.join("src/com/example")).unwrap(); fs::write( @@ -1775,11 +1783,7 @@ fn plain_java_main_uses_the_jdk_without_maven() { "command": "runConfig.createLaunchPlan", "payload": { "root": root, - "configurationId": "java-main:com.example.WorkerMain", - "javaLaunch": { - "mainClass": "injected.Main", - "classPaths": ["/untrusted/classes"] - } + "configurationId": "java-main:com.example.WorkerMain" } }) .to_string(), @@ -1787,8 +1791,9 @@ fn plain_java_main_uses_the_jdk_without_maven() { .unwrap(); assert_eq!(plan["ok"], true, "{plan}"); assert_eq!(plan["data"]["executable"]["toolchain"], "project-jdk"); - // Non-Maven java.main also compiles then runs by its recorded main class; - // project-model metadata is accepted only for Maven-owned sources. + // Without a prepared JDT target, standalone Java compiles then runs by its + // recorded main class. The JDT-path regression separately covers prepared + // unmanaged projects, which must retain upstream dependency/module paths. let output_dir = ".lithe/run/classes/java-main-com.example.WorkerMain"; assert_eq!( plan["data"]["preLaunchSteps"], @@ -1802,8 +1807,6 @@ fn plain_java_main_uses_the_jdk_without_maven() { plan["data"]["arguments"], serde_json::json!(["com.example.WorkerMain"]) ); - - fs::remove_dir_all(root).unwrap(); } #[test] @@ -2052,6 +2055,53 @@ fn stale_plain_java_main_is_rejected_when_the_source_belongs_to_maven() { fs::remove_dir_all(root).unwrap(); } +/// Prepared targets from JDT keep their upstream paths without a Maven marker. +/// No tool is executed: the request already carries the shared launch result. +#[test] +fn java_launch_without_maven_consumes_jdt_paths_without_recompiling_one_file() { + let root = temporary_root("run-config-jdt-non-maven"); + struct Cleanup(PathBuf); + impl Drop for Cleanup { + fn drop(&mut self) { + crate::execution::generated_layer::forget(&self.0); + let _ = fs::remove_dir_all(&self.0); + } + } + let _cleanup = Cleanup(root.clone()); + fs::create_dir_all(root.join(".lithe/run")).unwrap(); + fs::create_dir_all(root.join("src/main/java/example")).unwrap(); + fs::write( + root.join("src/main/java/example/Main.java"), + "package example; class Main { public static void main(String[] args) {} }", + ) + .unwrap(); + seed_generated(&root, serde_json::json!({ + "version": 2, + "configurations": [{ + "id": "java-main:example.Main", "name": "Main", "provider": "java.main", + "execution": "application", "cwd": ".", "toolchains": {"java": "selected-jdk"}, + "extensions": {"java": {"source": "src/main/java/example/Main.java"}, + "maven": {"mainClass": "example.Main", "jvmArguments": [], "programArguments": []}} + }] + }).to_string()); + let response: Value = serde_json::from_str(&execute_json(&serde_json::json!({ + "id": "jdt-non-maven", "command": "runConfig.createLaunchPlan", + "payload": {"root": root, "configurationId": "java-main:example.Main", + "javaLaunch": {"mainClass": "example.Main", "classPaths": ["upstream/classes", "upstream/dependency.jar"], + "modulePaths": ["upstream/modules"]}} + }).to_string())).unwrap(); + assert_eq!(response["ok"], true, "{response}"); + let plan = &response["data"]; + assert_eq!(plan["executable"]["toolchain"], "selected-jdk"); + assert_eq!(plan["arguments"], serde_json::json!(["example.Main"])); + assert_eq!( + plan["classpath"], + serde_json::json!(["upstream/classes", "upstream/dependency.jar"]) + ); + assert_eq!(plan["modulepath"], serde_json::json!(["upstream/modules"])); + assert!(plan["preLaunchSteps"].as_array().is_none_or(Vec::is_empty)); +} + #[test] fn resolve_prefers_a_host_provided_local_document() { let root = temporary_root("run-config-host-local"); diff --git a/shared/contracts/plugins/v1/README.md b/shared/contracts/plugins/v1/README.md index 60f8614143..9e40d06ad3 100644 --- a/shared/contracts/plugins/v1/README.md +++ b/shared/contracts/plugins/v1/README.md @@ -15,6 +15,7 @@ This directory is the cross-platform source of truth: | `fixtures/tool-definition.plugin.json`, `fixtures/toolchain-provider.plugin.json` | Production-shape Core fixtures for tool definitions and a packaged toolchain provider; require explicit new host capabilities, not yet supplied by native products | | `fixtures/keymap-import-provider.plugin.json` | Two independent shortcut import providers sharing one packaged backend; native source access is not implemented yet | | `fixtures/invalid-manifests.json` | Edits to a valid manifest and the rejection code every host must report | +| `fixtures/signature-vectors.json` | Public cross-platform vectors for the package publisher signature: the RFC 8032 test key, a fixed package with non-ASCII file names, its canonical payload, RFC 8032 deterministic signature, and content digest. Both platforms must build the same canonical payload and digest and accept the recorded signature; signers that add randomness, such as CryptoKit, check the signature by verification instead of byte comparison | | `fixtures/command-plans.json` | Golden run/test command expansions and language-server launch plans | | `fixtures/runtime-versions.json` | Golden outcomes of the launch runtime version check | | `fixtures/build-plans.json` | Golden build-system plans and decoded outputs | diff --git a/shared/contracts/plugins/v1/fixtures/signature-vectors.json b/shared/contracts/plugins/v1/fixtures/signature-vectors.json new file mode 100644 index 0000000000..4c47bfd36b --- /dev/null +++ b/shared/contracts/plugins/v1/fixtures/signature-vectors.json @@ -0,0 +1,40 @@ +{ + "schemaVersion": 1, + "description": "Public cross-platform test vectors for the plugin package signature (macOS PluginPackageSignature and the Windows plugin_host signature module). The Ed25519 key is the RFC 8032 test key; it must never sign real packages. Regenerating requires updating both platform tests in the same change.", + "ed25519": { + "seedHex": "9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60", + "publicKeyHex": "d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a", + "messageEmptySignatureHex": "e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b" + }, + "packageFiles": { + "plugin.json": "plugin manifest bytes", + "language-server/bin/server.js": "console.log('server');\n", + "插件/服务器.js": "console.log('非 ASCII 路径');\n", + "日本語/README.md": "# サンプル\n", + "assets/заметки.txt": "заметки\n" + }, + "canonicalPayload": { + "keyID": "lithe-test-v1", + "pluginID": "dev.example.plugin", + "pluginVersion": "0.3.0", + "files": { + "plugin.json": "1ec2dc0f2dacb3b0c43dd9dc6035731249094d080f60394236f68450420e6a29", + "language-server/bin/server.js": "fca7a5298331fc1e306876075edf8f47b791b200b182c841dc250c54d5138760", + "插件/服务器.js": "481e4738eca92d68a48ef69591c5ecb0afd2529a0eba37b489665cd31b457ad5", + "日本語/README.md": "667ec9c9c320a9dee9f64ce35daf3ec27cf5bc06aaa0625253c788301bd5f7af", + "assets/заметки.txt": "d303fa2a84fb9a7d0c0e50cf1c27ff33f8c90cb53d366138929934f4e2e758fb" + }, + "payloadBase64": "c2NoZW1hVmVyc2lvbj0xCmFsZ29yaXRobT1lZDI1NTE5CmtleUlEPWxpdGhlLXRlc3QtdjEKcGx1Z2luSUQ9WkdWMkxtVjRZVzF3YkdVdWNHeDFaMmx1CnBsdWdpblZlcnNpb249TUM0ekxqQQpmaWxlPVlYTnpaWFJ6TDlDMzBMRFF2TkMxMFlMUXV0QzRMblI0ZEE9ZDMwM2ZhMmE4NGZiOWE3ZDBjMGU1MGNmMWMyN2ZmMzNmOGM5MGNiNTNkMzY2MTM4OTI5OTM0ZjRlMmU3NThmYgpmaWxlPWJHRnVaM1ZoWjJVdGMyVnlkbVZ5TDJKcGJpOXpaWEoyWlhJdWFuTT1mY2E3YTUyOTgzMzFmYzFlMzA2ODc2MDc1ZWRmOGY0N2I3OTFiMjAwYjE4MmM4NDFkYzI1MGM1NGQ1MTM4NzYwCmZpbGU9Y0d4MVoybHVMbXB6YjI0PTFlYzJkYzBmMmRhY2IzYjBjNDNkZDlkYzYwMzU3MzEyNDkwOTRkMDgwZjYwMzk0MjM2ZjY4NDUwNDIwZTZhMjkKZmlsZT01by1TNUx1MkwtYWNqZVdLb2VXWnFDNXFjdz00ODFlNDczOGVjYTkyZDY4YTQ4ZWY2OTU5MWM1ZWNiMGFmZDI1MjlhMGViYTM3YjQ4OTY2NWNkMzFiNDU3YWQ1CmZpbGU9NXBlbDVweXM2S3FlTDFKRlFVUk5SUzV0WkE9NjY3ZWM5YzljMzIwYTlkZWU5ZjY0Y2UzNWRhZjNlYzI3Y2Y1YmMwNmFhYTA2MjUyNTNjNzg4MzAxYmQ1ZjdhZgo=", + "signatureBase64": "lFd79pLu83LDn4D8N0cSAtm3jzHGNLIVGBAfS0v4Wzfnim4DLcCOKITqS8v5iOGP951whGhZIZxqdMZULHy+Cw==" + }, + "contentDigest": { + "files": { + "plugin.json": "1ec2dc0f2dacb3b0c43dd9dc6035731249094d080f60394236f68450420e6a29", + "language-server/bin/server.js": "fca7a5298331fc1e306876075edf8f47b791b200b182c841dc250c54d5138760", + "插件/服务器.js": "481e4738eca92d68a48ef69591c5ecb0afd2529a0eba37b489665cd31b457ad5", + "日本語/README.md": "667ec9c9c320a9dee9f64ce35daf3ec27cf5bc06aaa0625253c788301bd5f7af", + "assets/заметки.txt": "d303fa2a84fb9a7d0c0e50cf1c27ff33f8c90cb53d366138929934f4e2e758fb" + }, + "digest": "4dcdacc3e80f23932029638487a3074301d95a6721151a03a010d8633fe55a61" + } +} diff --git a/shared/contracts/rust-core-api.md b/shared/contracts/rust-core-api.md index de62e8e935..924553fd08 100644 --- a/shared/contracts/rust-core-api.md +++ b/shared/contracts/rust-core-api.md @@ -3020,6 +3020,14 @@ session's child process, stdin/stdout/stderr, framing buffer, JSON-RPC request IDs, document versions, pending deadlines, capabilities, diagnostics, and graceful/forced termination. +If ordinary `lsp.startServer` fails after process creation, Core retains any +incomplete disposal in an internal cleanup backlog, since no session identity +was returned to the caller. A subsequent explicit startup attempt retries at +most one bounded disposal and refuses to launch another process while cleanup +remains incomplete. The original startup error is preserved. Native owners +using the in-process registration callback retain their registered identity +even when startup returns an error and retry `lsp.destroyServer` themselves. + JDT LS remains `initializing` until `language/status: ServiceReady`. During this phase Rust reduces changed `$/progress` notifications into throttled JSON log details containing the current phase, percentage, project, observed project @@ -3341,7 +3349,11 @@ and an empty diagnostic context. The round-trip fixture is `javaEntrypoints` invokes Java Debug Server's `vscode.java.resolveMainClass` for the session workspace and returns schema version 1 with deterministic workspace-relative `{ sourcePath, mainClass, -projectName? }` entries plus diagnostics for unusable upstream records. Discovery +projectName? }` entries plus diagnostics for unusable upstream records. +Discovery queries all entries in the owned JDT session, then filters source +paths against the opened workspace and its resolved location. This includes +plain folders represented by invisible projects in JDT's writable cache; +unrelated workspace sources remain excluded. Discovery waits behind pending Maven profile updates and JDT project-configuration jobs, using the same configuration barrier as the following Java build. Up to 128 waiting discovery operations are allowed per session. Their deadlines include diff --git a/shared/platform-feature-matrix/features/build-system-plugins.json b/shared/platform-feature-matrix/features/build-system-plugins.json index 7ee542b80b..8f873d349c 100644 --- a/shared/platform-feature-matrix/features/build-system-plugins.json +++ b/shared/platform-feature-matrix/features/build-system-plugins.json @@ -71,7 +71,8 @@ "shared/contracts/plugins/v1/fixtures/build-run-options.json", "rust/lithe-core/src/build/project_options.rs", "shared/fixtures/build-project-options/validation.json", - "macos/Sources/LitheCoreContracts/Execution/RunConfigurationContracts.swift" + "macos/Sources/LitheCoreContracts/Execution/RunConfigurationContracts.swift", + "rust/lithe-core/src/tests/build_systems.rs" ], "implementationStatus": "partial", "verificationStatus": "pending" @@ -87,5 +88,5 @@ }, "owner": "Extensions", "verification": "macOS 已接入 static、command、hostIntegration、provider 四种模型来源:宿主向 Core 声明 buildSystems 与 buildProviders 能力,插件市场因此列出兼容的 API 3 声明式和 Provider 版本;Provider 进程按插件、构建系统和工作区各自独立,经各自 stdio 用 JSON-RPC(LSP 基础协议)与宿主通信,initialize 协商 capabilities.experimental.litheBuild 后宿主才经 lsp.buildRequest 发送 lithe/build/model、lithe/build/dependencies,回复交给 Core 解码;共享写法只复用同一插件的语言服务器会话;进程只在用户加载模型或依赖时启动,切换工作区、关闭项目窗口、停止执行模块、停用或更新插件、退出应用时停止;ExecutionFeatureGraph.stop 经 BuildSystemService.stop 同时回收已就绪和初始化中的 Provider,停止后的初始化完成也不得重新登记会话;状态写入插件状态目录;每个已启用的构建系统插件在打开工作区后各有一个右侧工具窗口(标题为 displayName、图标为 icon),不依赖识别结果,工作区没有对应工程时窗口内显示未检测到该构建系统,工具栏放运行、参数任务、刷新和 presentation=toolbar 的开关,树顶部是 presentation=tree 的勾选选项,工程下按 category(缺省按 group)分级列出任务,再列测试、目标和依赖;内置 Maven 窗口与共享 Build 窗口已删除,Build Output 显示输出、诊断与测试结果。窗口恢复先激活所属插件模块,激活中的命令面板项禁用;参数任务遵守 workspace/project/target 作用范围与目标标签,模型或工作区变化后清除旧选择。隔离回归覆盖这些边界、窗口布局恢复及包内图标读取前后文件清单与字节不变;多实例的根目录选择器保留每个实例的模型候选和生效值,编辑多选时保留兄弟实例独有的已选值;显式清空按实例根持久化为空覆盖,检测、同步指纹、任务计划和语言服务器导入使用同一覆盖,兄弟编辑或重开不会恢复非空默认值,非空编辑清当前实例标记而共享编辑/重置清该选项全部标记;真实 Core、生产存储与服务回归核对最终 argv 和导入值;列表单选与多选支持 allowCustom 原生输入和移除已选自定义值,文本/文件/目录清空提交显式空字符串,只有重置删除覆盖。插件选项在项目打开、选项修改和模型加载完成后通过 Core build.languageImport 归一化为 mavenContext/javaGradle,与构建计划使用同一生效值,并在 Java 启动前等待同一工作区代次的最新配置;运行时准备后再等一次,覆盖等待期间失效。唯一发布回调优先 Maven 原地热更新,被拒绝时串行恢复重启;停用最后一个 Maven 插件时,仅清除曾带 Maven 输入的同一会话,纯 Gradle 首次启动保持 nil。Gradle 在下次启动生效,取消/重置拒绝旧检测与恢复任务,被动工具路径发现不执行 Wrapper/版本探测;没有对应插件导入输入时兼容原 Maven 设置。命令模型 run 配置尚未接入;buildProviders 2 已接入原生任务 lithe/build/execute,复用工作区进程并校验协议版本、进度/结果、取消/超时和旧结果隔离,真实安装包/工具工作流仍待验收,Provider 无操作系统级沙盒;Windows 宿主尚未调用 build.* 命令。自动化:cargo test -p lithe-core --lib build_systems、cargo test -p lithe-core --lib lsp、scripts/architecture/verify-shared-contracts.sh、./scripts/macos/test/test-macos.sh --filter 'BuildSystemToolWindowTests|RustBuildSystemOperationsTests|BuildSystemServiceTests|PluginMarketplaceServiceTests'。手动验证:安装 fixtures 中 build-static-file、build-command-stdout 形态的插件包,确认每个构建系统各出现一个工具窗口,列出工程、分级任务、选项和依赖,停用插件后窗口消失;执行任务与测试的 argv 与 build-plans.json 一致,停止与输出上限生效;JUnit 报告与 lineMatcher 诊断可跳转到源码;命令模型和项目内 Wrapper 只在用户点击加载或运行后启动;禁用插件后实例消失;Windows 接入后另需验证未信任工作区不启动任何模型命令或 Wrapper;build-provider 形态的自有 Provider 只在用户操作或工作区信任后启动、停用插件时停止,build-provider-language-server 形态复用语言服务器会话而不启动第二个进程;运行前后 app bundle 文件清单不变(scripts/macos/verify/verify-runtime-bundle-immutability.sh)。;新路径选择使用 executableResolution 1 + settings 2,已发布 buildSystems 2 旧字段只作统一候选输入适配:MacBuildToolResolverTests 验证带空格绝对路径、权限与版本失败不回退,BuildSystemServiceTests 验证 Provider 失败不独立发现,RustBuildSystemOperationsTests 验证全局值接入。Cargo 独立仓库以显式本地 Core bridge 验证自选路径用于 metadata 和全部构建/测试/运行/清理;发布前需把独立仓库 sdk.lock.json 的宿主 pin 更新到包含该能力的已发布提交。;回归增加非法存储值不回默认、数组/priority/插入顺序与拒绝循环、宿主注入发现、空设置跳过和被动选择不探测;Language Server/Execution Provider 新清单语法尚未开放,Windows 不声明 executableResolution。;真实 Core + macOS resolver + BuildSystemService 组合回归覆盖前置 Runtime 缺失/版本不足时保留工具或后置 Runtime 的非空 setting 约束,Provider 不发送独立发现请求;全部设置为空时仍可回退。自定义 Runtime 先构造含所选目录的 PATH,再以同一环境探测与执行,同目录 helper 的带空格路径回归通过。;buildProviders 3 增加原生测试执行 lithe/build/test,筛选参数保持类型化,报告复用 JUnit/标准结果解析;旧协议明确拒绝测试,报告解析期间配置失效会取消操作并丢弃迟到结果。原生树已接入按需测试发现,Core 校验完整清单并保留模块身份,运行前重查当前清单;配置/源码/包变化、停用/重开使缓存或进行中的发现失效。真实 Maven 模块编译与单方法测试已有生产 macOS Provider 会话证据;Windows 工作流仍待验收。;buildProviders 4 应用目标准备接入原生 Build 树,构建进度在 Build Output 展示,验证后转交 RunService 解析工具与启动/停止应用;准备期间源码、选项、工作区或停用变化拒绝迟到启动,旧操作 ID 不得停止替换进程;Core 拒绝绝对可执行路径、越界目录/符号链接及超限参数环境。服务编排、调试与 Java/Maven 消费者迁移尚未完成;真实插件/发行包和 Windows 工作流仍待验收。;Run v2 本地层显式保存 Provider 选择器,参数保持原始数组;无 generated.json 也能读回/显示,重复保存保留 ID/其他配置/项目环境;重启重新进入当前 Provider,停止与晚到结果按身份隔离。原生入口保存工作区文档后再准备,Run 窗口在未生成旧配置时仍显示 Provider 输出。;Agent 入口回归从真实本地配置启动,验证准备到进程退出保持公开操作 ID、准备中停止与重启重新准备,旧 ID 不能停止替换操作;Provider 与进程为可控替身,真实插件端到端验收仍待完成。;配套独立仓库 Node/Java SDK 源码补齐协议 2/3/4 的处理器、版本准入与进度;无页面示例经真实 Core 验证非零构建退出码、精确筛选、运行前构建及准备计划、并行工作区、取消工具清理和完整包不变,另保留锁定旧契约的兼容场景与 TypeScript 调用方编译检查。SDK 尚未发布,真实 Maven/JDT 与 Windows 验收仍待完成。 原生 Debug:运行声明引用同包适配器,点击 Build 树 Debug 或保存配置的 Debug 后先保存并构建,验证程序路径/参数/环境交给注册表;停止、源码或配置变化、模型重载、插件停用与工作区切换均丢弃过期结果,解码后的文件别名变化和不可执行文件在平台交接前拒绝。Node/Java SDK 进程的准备协议与 Core 解码有端到端覆盖;真实适配器、Java/JDT、跨插件协作和 Windows 尚未验收。 Maven 独立插件的本地增量已经删除生命周期/插件目标/自定义目标/测试的命令模板,改由 Provider 3 执行;真实 Core C ABI + Java 后端 + Maven 三模块工程验证模块编译、单方法 Surefire 报告和模型共享,受控进程回归覆盖取消、非零退出和输出超限。插件与新版 SDK 已分别提交 Draft PR #7/#4,尚未发布,正式 SDK 锁定仍待更新;生产 macOS Provider 会话已经执行模型、编译和单方法测试,包 SHA-256/权限保持不变;显式 SDK CI 在 Java 8 上通过当前与 3.6.3 Maven 的 55 项开发检查(各自包括 3 项打包);旧 MavenService、Agent/设置/Run/Java 迁移、正式包、完整 macOS UI 与 Windows 验收未完成,保持 partial/pending。 真实原生调试集成:公开 Node SDK Provider 用 Clang 编译 C 程序,经生产 macOS 会话、Core 准备、Registry 明确身份、生产 stdio 传输和 LLDB 命中源码断点、读取 main 栈帧、保留空格参数后继续并退出码 0;包 SHA-256/权限不变,所有本次进程回收。测试显式选择 SDK/工具,完整 UI、正式发行与 Windows 尚未验收,verification 保持 pending。 Build 树应用从文档保存阶段起持有同一可取消运行 ID;保存 gate 下启动新任务/测试或停止、切换工作区、选项/源码/模型/插件失效后,旧保存返回不得启动 Provider、替换新运行或清空新输出;保存失败不启动,成功后才准备。 原生视图隔离回归用真实 Core 与受控 Provider 数据检查深浅主题的测试发现、Debug 入口和 Run 输出;截图仅验证该视图状态,不代替完整发行包或 Windows 实机验收。 实例作用域:用同一工作区的两个独立根验证 Profiles、文件/目录、布尔与文本值独立持久化;编辑、清空或重置 A 不影响 B,重开后任务、静态运行入口、同步和语言导入读取相同根的配置;未声明作用域的插件保留共享行为。旧 Maven 数据迁移与 Windows 运行验收另行完成,保持 partial/pending。 作用域变更的旧 Build 偏好先复制并验证目标,再删除共享源;写入失败阻止默认配置发布并允许重试,已有实例值优先,暂未检测到根的空标记也迁移保留。 工具链候选通过真实 Core 与生产本地文档验证按实例选择 Maven/JDK,Provider 环境保留选中的 JAVA_HOME/PATH 且不转发无关测试凭据;被动导入不探测版本或运行 Wrapper,显式路径失败不能独立发现。Windows 不声明 executableResolution 2,旧 Maven 服务迁移仍待完成。 共享 Build 文档验证工作区/实例默认值、逐根覆盖和本机差异合并;重开和检测不改共享字节,重置本机值恢复继承,外部修改冲突或文档损坏明确失败并保留原始数据。 未选中的自定义候选仅在 allowCustom 选项中展示,不改变选择和模型;真实 Core、生产存储和服务回归通过,新增实例静态入口继承团队默认值。 协议 8 回归覆盖协商拒绝、随执行返回的报告、缺失/损坏失败、模块同名测试隔离、取消/配置变更后拒绝晚到解码,以及普通任务中的测试结果。Maven 开发包用官方已配置测试 Mojo 的报告目录和 Apache Surefire parser,真实 Core/Maven 覆盖带空格自定义目录与非零退出的失败用例,坏 XML/外部实体拒绝,包字节保持不变。Java/Node SDK 同步,正式发布和全部旧 Maven/Java 消费者迁移尚未完成。 本机选项、逐根映射和空多选标记中存在非 Data 存储值时,检测失败并保留原始偏好,不得当缺失键发布默认值。 本机实例默认值继承、逐根覆盖与重置通过真实 Core 和生产存储验证,团队文档字节不变;本机默认值不进入资源复用。 固定宿主 ac24a96af 与 SDK 71667af 的 Java 8 CI(https://github.com/Lithe-IDEA/lithe-plugin-maven/actions/runs/40792694290)在当前 Maven/3.6.3 各 72 项通过,覆盖新原生配置与 Surefire/Failsafe 报告、取消清理和包字节不变;正式发行组合仍待验证。 协议 10 接通带版本协商的类型化运行选项与服务/任务准备(Core、Swift、Node/Java SDK)。原生 Run/Start All 为每个 Maven 服务独立准备,配置 ABA/Stop/重置拒绝旧回复,已停进程输出不能覆盖新会话;Build 树按服务/任务类型发请求;停用和包更新在删除包前停止准备及进程,旧启动注册更新后不可再次使用。后端复用 Maven reactor 和 Mojo 执行器,真实 Core→Maven 验证未安装兄弟模块、精确 argv、cwd、目标撤销和包哈希不变。macOS 无调用者的旧 Maven 桥和工程模型已删除;Windows 当前旧命令消费者、Core 旧实现和正式发行/完整 UI 验收仍待完成。 保存 Provider service/task 引用保留执行类型、稳定配置 ID 和参数,重开后按当前声明重验;独立准备至进程交接保留 Agent 操作身份。 服务所有者使用完整插件包身份;停用其中一个插件不会停止同名构建系统下另一插件的进程。preview 内存检测层保留 Provider 模型摘要,自动识别不写工作区。 后续本机真实 Micronaut HTTP 应用(Platform 4.7.6 / Core 与注解处理器 4.7.14)在 JVM 暂停后经 JDI 恢复,通过 Netty 控制器和编译期注入服务读取未安装的 reactor 兄弟依赖,参数、环境及包字节不变;这是旧固定 CI 之后的本地四步框架增量,不代替 Debug UI、正式包或 Windows 原生验收。 Windows Build 选项编辑与 Agent 共用原生本机存储:开页只读,修改草稿后显式保存/恢复继承;隐藏重开保留草稿。团队/本机两层版本同时检查,冲突、关闭、插件撤销拒绝迟到写入。实例选择独立,工作区多选保留兄弟实例值和显式空选择;无关系统/根/记忆选项与团队文件字节保持。保存后重新检测并使旧模型失效。长选项/模型选择使用有界视口,不启动工具或 Provider。产品能力准入仍关闭,不能据此认定 Windows 完整 Maven 产品迁移完成。", - "notes": "协议 9 测试链路已删除 macOS Maven CLI/报告 adapter,JDT 标识原样传给后端;规范报告按项目隔离并声明覆盖范围,整类重跑清除旧方法、单方法保留兄弟项,参数化调用的完整安全耗时相加。350 项原生回归和真实 Maven Provider 通过;最低运行时新增 CI、完整 UI/JDT、正式发行和 Windows 保持 pending。 Windows 已补独立 Provider 的原生启动解析、Core 会话复用、进度/取消和包/设置/运行时替换基础,受控前端回归覆盖晚到启动、回复先于 IPC 确认与停止失败。产品模型/任务/配置消费者与共享语言会话型 Provider 尚未接入,hostCapabilities 继续不声明 Build 能力,Windows 保持 missing,不能删除旧 Maven 命令。 Windows 工作区域已补经 Core 计划和解码的模型、逐工程依赖、任务和执行内测试报告,受控测试保护工具/设置/包失效、取消、迟到解码及有界历史;独立 Maven 仓库用生产 TypeScript、真实 Core/Provider/reactor 的 7 步集成通过,包字节不变。Core 只读项目工具选择及全量 1434 项回归通过。原生工具适配和 UI/配置/Run 迁移、共享语言会话及 Windows 实机验收仍待完成,准入保持关闭,Windows 继续 missing。 Windows 服务层原生配置读取不依赖可用模型,自动读取项目工具先停止并要求显式产品动作;受控测试覆盖严格解码和失效,真实集成在损坏 POM 下验证来源及包字节不变、秘密不导出、仓库/构建目录不创建。设置页与 Windows 原生写回/配置迁移仍待接入,准入继续关闭。 Windows 服务层新增原生配置准备/提交、读取回执及写后回读;私有 XML 留在有界原生内存,实际窗口/操作令牌在取消、关闭和插件变更时释放,文件替换复用既有文档模块。新增文件回归验证注释/秘密/权限、磁盘冲突、并发创建、链接换向及安装目录只读;草稿/确认 UI、旧数据迁移及 Windows 原生验收仍未完成,产品准入保持关闭。 团队 Build 文档语法已集中到 Core,macOS/Windows 使用相同共享 fixture;检测返回同一作用域/实例根合并的保存值和被拒绝键,显式清空不会恢复默认值。Windows 新增工作区所有者、通用右侧 Build 与底部输出接线,受控点击验证显式加载、模型任务、Stop、重挂载及 10,000 项虚拟列表;插件停用确认等待全部 Build 清理,目录刷新不丢历史进程目标。配置 UI/旧数据迁移、文件观察、声明任务/依赖/报告呈现、Run/Java/Agent 和 Windows 实机仍待完成,准入关闭,Windows 继续 missing。 Windows 插件设置详情已接入通用原生来源编辑器,草稿由工作区持有,明确保存后回读;失败重载/读回撤销基线,跨来源草稿与迟到文件选择得到隔离。对应控件/文件回归不代替 Windows 原生验收,旧数据迁移和产品准入仍待完成。 Windows 通用 Build 入口增加按工作区/模块的声明任务、模型任务分类与显式参数确认,参数逐项保留边界;依赖仅展示 Core/Provider 节点,最多四份内存快照,输入失效/取消拒绝晚到解码。模型事实与进度分别通知,原生配置保存撤销模型后任务树立即清空;目标/Run/Agent/Java、旧数据与正式 Windows 准入仍待完成,不据前端回归标为实机 verified。 Windows 后续基础设施可展示 Core 规范诊断/测试报告及精确模块用例,结果/清单各只保留四份快照,大报告虚拟化且输出不复制报告。Core watch 与执行前指纹核对撤销过期模型,源码编辑撤销发现清单;团队文件变化合并只读检测。外部原生来源文件观察已接通,完整 Run/Java/Agent 与旧数据迁移仍未完成,Build 能力准入保持关闭。 Windows 已保存 Provider 引用通过公共 Core 计划接入现有 Run,各服务直接加载自己的模型并分别取消;交接前重查完整保存选项、工具、工程指纹和原生来源。准备与进程由现有插件/工作区所有者管理,迟到启动确认必须排空。目标树已接显式保存并运行;完整 Run/Debug、Java/Agent、旧数据和实机验收仍待完成,准入继续关闭。 Windows 运行准备现持有独立临时模型/来源租约,Core 校验单次 Profiles/空选择/false;先用 canonical reactor 工具选择,再由 Core 应用该 Run 明确保存的路径;空路径继承 reactor,模型不依赖默认工具可用。关闭临时模型不停止共享后端;启动前只读复验目录,未变时保留身份,漏通知也能发现团队选项变化。原生能力表决定旧框架/模块入口何时切换,当前仍关闭。两端的已保存应用保留协议 4 原始参数,真实新版选项继续按协议 10/11 拒绝旧后端。 Windows 目标树按声明和当前工程列出运行选择器,参数确认后以 Core 稳定 ID 保存并接入现有 Run;原生复用文档 CAS/元数据/原子替换及读回,拒绝包路径和工作区外别名。保存阶段可 Stop/关闭撤销,忽略取消的迟到保存不能启动;首次打开 Run 面板等待目标交接,不取消该启动。大目标列表虚拟化,完整 Debug/JDT 与 Windows 实机仍待验收,准入保持关闭。 Windows Agent 的 Build 查询、重载与执行现复用同一工作区 controller 和 Provider,精确目标转交当前模型/Core,输出/停止使用原有操作 ID;不新增 Maven 特判或后端状态。通用配置写入和完整产品准入未完成,不据此删除旧消费者。" + "notes": "协议 9 测试链路已删除 macOS Maven CLI/报告 adapter,JDT 标识原样传给后端;规范报告按项目隔离并声明覆盖范围,整类重跑清除旧方法、单方法保留兄弟项,参数化调用的完整安全耗时相加。350 项原生回归和真实 Maven Provider 通过;最低运行时新增 CI、完整 UI/JDT、正式发行和 Windows 保持 pending。 Windows 已补独立 Provider 的原生启动解析、Core 会话复用、进度/取消和包/设置/运行时替换基础,受控前端回归覆盖晚到启动、回复先于 IPC 确认与停止失败。产品模型/任务/配置消费者与共享语言会话型 Provider 尚未接入,hostCapabilities 继续不声明 Build 能力,Windows 保持 missing,不能删除旧 Maven 命令。 Windows 工作区域已补经 Core 计划和解码的模型、逐工程依赖、任务和执行内测试报告,受控测试保护工具/设置/包失效、取消、迟到解码及有界历史;独立 Maven 仓库用生产 TypeScript、真实 Core/Provider/reactor 的 7 步集成通过,包字节不变。Core 只读项目工具选择及全量 1434 项回归通过。原生工具适配和 UI/配置/Run 迁移、共享语言会话及 Windows 实机验收仍待完成,准入保持关闭,Windows 继续 missing。 Windows 服务层原生配置读取不依赖可用模型,自动读取项目工具先停止并要求显式产品动作;受控测试覆盖严格解码和失效,真实集成在损坏 POM 下验证来源及包字节不变、秘密不导出、仓库/构建目录不创建。设置页与 Windows 原生写回/配置迁移仍待接入,准入继续关闭。 Windows 服务层新增原生配置准备/提交、读取回执及写后回读;私有 XML 留在有界原生内存,实际窗口/操作令牌在取消、关闭和插件变更时释放,文件替换复用既有文档模块。新增文件回归验证注释/秘密/权限、磁盘冲突、并发创建、链接换向及安装目录只读;草稿/确认 UI、旧数据迁移及 Windows 原生验收仍未完成,产品准入保持关闭。 团队 Build 文档语法已集中到 Core,macOS/Windows 使用相同共享 fixture;检测返回同一作用域/实例根合并的保存值和被拒绝键,显式清空不会恢复默认值。Windows 新增工作区所有者、通用右侧 Build 与底部输出接线,受控点击验证显式加载、模型任务、Stop、重挂载及 10,000 项虚拟列表;插件停用确认等待全部 Build 清理,目录刷新不丢历史进程目标。配置 UI/旧数据迁移、文件观察、声明任务/依赖/报告呈现、Run/Java/Agent 和 Windows 实机仍待完成,准入关闭,Windows 继续 missing。 Windows 插件设置详情已接入通用原生来源编辑器,草稿由工作区持有,明确保存后回读;失败重载/读回撤销基线,跨来源草稿与迟到文件选择得到隔离。对应控件/文件回归不代替 Windows 原生验收,旧数据迁移和产品准入仍待完成。 Windows 通用 Build 入口增加按工作区/模块的声明任务、模型任务分类与显式参数确认,参数逐项保留边界;依赖仅展示 Core/Provider 节点,最多四份内存快照,输入失效/取消拒绝晚到解码。模型事实与进度分别通知,原生配置保存撤销模型后任务树立即清空;目标/Run/Agent/Java、旧数据与正式 Windows 准入仍待完成,不据前端回归标为实机 verified。 Windows 后续基础设施可展示 Core 规范诊断/测试报告及精确模块用例,结果/清单各只保留四份快照,大报告虚拟化且输出不复制报告。Core watch 与执行前指纹核对撤销过期模型,源码编辑撤销发现清单;团队文件变化合并只读检测。外部原生来源文件观察已接通,完整 Run/Java/Agent 与旧数据迁移仍未完成,Build 能力准入保持关闭。 Windows 已保存 Provider 引用通过公共 Core 计划接入现有 Run,各服务直接加载自己的模型并分别取消;交接前重查完整保存选项、工具、工程指纹和原生来源。准备与进程由现有插件/工作区所有者管理,迟到启动确认必须排空。目标树已接显式保存并运行;完整 Run/Debug、Java/Agent、旧数据和实机验收仍待完成,准入继续关闭。 Windows 运行准备现持有独立临时模型/来源租约,Core 校验单次 Profiles/空选择/false;先用 canonical reactor 工具选择,再由 Core 应用该 Run 明确保存的路径;空路径继承 reactor,模型不依赖默认工具可用。关闭临时模型不停止共享后端;启动前只读复验目录,未变时保留身份,漏通知也能发现团队选项变化。原生能力表决定旧框架/模块入口何时切换,当前仍关闭。两端的已保存应用保留协议 4 原始参数,真实新版选项继续按协议 10/11 拒绝旧后端。 Windows 目标树按声明和当前工程列出运行选择器,参数确认后以 Core 稳定 ID 保存并接入现有 Run;原生复用文档 CAS/元数据/原子替换及读回,拒绝包路径和工作区外别名。保存阶段可 Stop/关闭撤销,忽略取消的迟到保存不能启动;首次打开 Run 面板等待目标交接,不取消该启动。大目标列表虚拟化,完整 Debug/JDT 与 Windows 实机仍待验收,准入保持关闭。 Windows Agent 的 Build 查询、重载与执行现复用同一工作区 controller 和 Provider,精确目标转交当前模型/Core,输出/停止使用原有操作 ID;不新增 Maven 特判或后端状态。通用配置写入和完整产品准入未完成,不据此删除旧消费者。 #1478 拆分(Core):build.detect 对不存在或不是目录的工作区根返回空结果;真实目录读取出错时返回错误,不再当作没有检测到构建系统(detection_returns_empty_for_non_directory_and_missing_workspace_roots、existing_directory_scan_errors_are_not_empty_detections)。" } diff --git a/shared/platform-feature-matrix/features/declarative-plugin-contract.json b/shared/platform-feature-matrix/features/declarative-plugin-contract.json index cd1006c3f8..402fba75d2 100644 --- a/shared/platform-feature-matrix/features/declarative-plugin-contract.json +++ b/shared/platform-feature-matrix/features/declarative-plugin-contract.json @@ -22,7 +22,9 @@ "macos/Sources/Lithe/Platform/MacOS/Plugins/MacPluginUIIconLoader.swift", "macos/Sources/Lithe/Views/Workbench/WorkbenchContributionIcon.swift", "macos/Tests/LitheTests/PluginUIIconTests.swift", - "macos/Sources/LitheApplicationKernel/Lifecycle/ModuleRuntime.swift" + "macos/Sources/LitheApplicationKernel/Lifecycle/ModuleRuntime.swift", + "shared/contracts/plugins/v1/fixtures/signature-vectors.json", + "macos/Tests/LitheTests/PluginSignatureVectorTests.swift" ], "implementationStatus": "implemented", "verificationStatus": "pending" @@ -54,6 +56,6 @@ "verificationStatus": "pending" }, "owner": "Extensions", - "notes": "Windows 宿主 v0 已接入契约 v1 的语言与语言服务器链路:plugin_host 模块负责包存储(app_local_data_dir 下的 plugins 与 plugin-state,bundled 从资源目录只读加载)、启动扫描(经 plugins.declarative.validate 携带 hostCapabilities {languages:1, languageServers:[1,2], serverProcess:1, settings:[1,2], ui:[1,2]},拒绝的包隔离并展示原因)、启动计划解析(packaged 入口固定在包内且拒绝 reparse point 与路径逃逸,runtime/systemCommand 走 PATH 与 LITHE__PATH 约定),语言服务器会话仍由共享 Core 的 lsp.startServer 拉起;shared fixtures 的 invalid-manifests.json 全部 154 个用例在 Windows 二进制内断言同一稳定错误码。M2 已补磁盘安装链(快照、installReview 审批、staging、回滚)与最小管理界面;M3 已补声明式设置(settings/languageServers 2 能力声明,全局+项目级存储,immediate 效果经 workspaceConfiguration 下推)、运行/测试计划命令与契约版 PHP bundled 包(随安装器分发,validate/launch/runPlan 端到端测试覆盖)。M4 已补 Web 工具窗口(ui 能力声明提升为 [1,2]):lithe-plugin:// scheme 只服务启用包内普通文件(拒 reparse point、路径逃逸、超 16MiB),响应带 CSP(default-src none、拒 eval/联网/frame)与 nosniff/no-store;window.lithe 桥 v0 提供 context、ui.getState/setState(宿主持有,64KiB 上限)、workspace.openFile 与主题事件,build.*/functions.* 在 Windows 构建系统能力接入前返回 plugin.web.unknownMethod。尚未实现:Worker 扩展清单向契约迁移(Worker 版 PHP 提供 composer scripts 动态运行动作,契约无等价能力,完整迁移推迟;见 Note)、构建系统插件能力与多仓库源市场。决策与切分见 .agents/notes/implemented/architecture/2026-10-22-windows-declarative-plugin-host.md。 后续安全修复已补插件身份传递、运行中和待启动会话排空、跨窗口包变更确认、完整启动前检查及 ui 1 文本/命令入口;目前 WebView 仍为独立窗口,停靠位置、图标、动作状态及布局持久化未完成。", + "notes": "Windows 宿主 v0 已接入契约 v1 的语言与语言服务器链路:plugin_host 模块负责包存储(app_local_data_dir 下的 plugins 与 plugin-state,bundled 从资源目录只读加载)、启动扫描(经 plugins.declarative.validate 携带 hostCapabilities {languages:1, languageServers:[1,2], serverProcess:1, settings:[1,2], ui:[1,2]},拒绝的包隔离并展示原因)、启动计划解析(packaged 入口固定在包内且拒绝 reparse point 与路径逃逸,runtime/systemCommand 走 PATH 与 LITHE__PATH 约定),语言服务器会话仍由共享 Core 的 lsp.startServer 拉起;shared fixtures 的 invalid-manifests.json 全部 154 个用例在 Windows 二进制内断言同一稳定错误码。M2 已补磁盘安装链(快照、installReview 审批、staging、回滚)与最小管理界面;M3 已补声明式设置(settings/languageServers 2 能力声明,全局+项目级存储,immediate 效果经 workspaceConfiguration 下推)、运行/测试计划命令与契约版 PHP bundled 包(随安装器分发,validate/launch/runPlan 端到端测试覆盖)。M4 已补 Web 工具窗口(ui 能力声明提升为 [1,2]):lithe-plugin:// scheme 只服务启用包内普通文件(拒 reparse point、路径逃逸、超 16MiB),响应带 CSP(default-src none、拒 eval/联网/frame)与 nosniff/no-store;window.lithe 桥 v0 提供 context、ui.getState/setState(宿主持有,64KiB 上限)、workspace.openFile 与主题事件,build.*/functions.* 在 Windows 构建系统能力接入前返回 plugin.web.unknownMethod。尚未实现:Worker 扩展清单向契约迁移(Worker 版 PHP 提供 composer scripts 动态运行动作,契约无等价能力,完整迁移推迟;见 Note)、构建系统插件能力与多仓库源市场。决策与切分见 .agents/notes/implemented/architecture/2026-10-22-windows-declarative-plugin-host.md。 后续安全修复已补插件身份传递、运行中和待启动会话排空、跨窗口包变更确认、完整启动前检查及 ui 1 文本/命令入口;目前 WebView 仍为独立窗口,停靠位置、图标、动作状态及布局持久化未完成。 #1478 拆分:新增 fixtures/signature-vectors.json(RFC 8032 测试密钥、含非 ASCII 文件名的固定包、规范载荷、签名与内容摘要),macOS PluginSignatureVectorTests 用同一组向量验证。CryptoKit 的 Ed25519 签名带随机数,macOS 以验签证明规范载荷和摘要一致,不比较签名字节。", "verification": "API 3 共享契约:cargo test -p lithe-core --lib community_build_plugins、cargo test -p lithe-core --lib build_systems、cargo test -p lithe-core --lib declarative_plugins 及 scripts/architecture/verify-shared-contracts.sh,覆盖真实 Maven/Gradle 输出、构建 icon/presentation/category、build.languageImport 的插件选项映射和 ui 2 包内网页清单。Core 校验通过不代表平台宿主已实现;macOS 原生窗口/JDT 接线与可选 WKWebView 分别验收后才由宿主声明对应能力,Windows 仍待接入。macOS:安装 shared/contracts/plugins/v1/fixtures/invalid-manifests.json 中每类错误的包,确认插件管理显示对应错误且不注册模块;合法包启用、禁用无需重启;包内声明的语言服务器可执行文件缺失或为符号链接时拒绝安装;启动后 app bundle 文件清单不变(scripts/macos/verify/verify-runtime-bundle-immutability.sh)。API 2:安装 fixtures 中 node-runtime 形态的包,确认宿主发现满足最低版本的 node 并用它启动入口文件,版本过低的候选不被使用;语言服务器的状态写在 /Lithe/PluginState 下而不是插件包内,卸载后该目录被删除。宿主能力:声明语言但未在 hostIntegration.capabilities 中列出运行、测试或调试、也未提供执行提供方的包,对应入口不可用且宿主不运行内置工具;列出后对应入口恢复。Windows:宿主 v0 已读取该契约(语言与语言服务器范围,按 hostCapabilities 门控),接入验收必须通过同一组共享 fixture,Windows 宿主测试已对 invalid-manifests.json 全量断言;Worker 扩展清单的迁移未完成,宿主 UI 仅完成文本和命令入口,不能用共享校验通过代替界面验收。 macOS API level 2:安装 Hello Lithe 数据包,确认工具窗口、命令面板、工具栏和菜单通过相同注册表显示;移动数据库与插件窗口、隐藏入口及重排后重启恢复;禁用插件后窗口和命令消失,重新启用保留位置与排序;无第三方原生代码载入。Windows UI adapter 仍缺停靠、图标和动作状态等对齐,不能用共享校验通过代替界面验收。 回归:声明与内置/应用动作冲突的合法包在启动时隔离并显示错误;正常退出保留已保存的窗口展开状态,用户主动隐藏才更新该状态;Agent 未启用时可移至底部并恢复入口;首次通过菜单打开 Services 会按需激活数据库。 macOS 图标:宿主语义 ID 与包内 SVG/PNG 在窗口入口、标题栏、工具栏、菜单和命令面板显示;模板着色与品牌原色、亮暗变体、选中/悬停/禁用沿用宿主规范;拒绝未知图标 ID、样式覆盖、包外路径、符号链接、脚本和外部引用;验证资源字节与 bundle 文件清单不变。 原生回归覆盖真实注册窗口标题栏、主工具栏活动/禁用状态、命令面板键盘选择及同一窗口亮→暗→亮切换;品牌图标不随选中着色,模板图标使用宿主选中文字颜色。 macOS 动作状态:确认窗口入口、工具栏、菜单与命令面板共用可用和勾选状态,激活中命令禁用且 Enter/鼠标均不能触发,窗口入口允许取消;同时打开同一插件的两个窗口只构造一次模块,取消其中一个不影响另一个;激活中禁用再启用,确认无资源残留或晚到贡献,旧动作引用不绕过状态校验。 API level 2 工具窗口初始位置接受 left/bottom/right,Rust 校验、macOS 解码及首次显示位置一致,用户保存布局仍覆盖默认声明。 Windows 安全回归:plugin_host::launch 的版本探测必须在父进程退出、后代继承管道时仍有界结束并清理进程树;web 回归验证真实文档来源与工作区文件目标。 Windows 语言资源整合:声明式插件的运行分组、管理页与安装审查使用共享生成词条;中英文回归验证安装名称/版本、程序数量和启停标签,并确认用户值中的占位符保持字面文本。 Windows 宿主修复回归:在 Core startServer 尚未返回时禁用插件,晚到会话必须先停止再拒绝;即时设置携带 pluginId,Core 接受并下推对应会话。缺失 requiredPackagePaths/runtimeRequirements 或 validationArguments 非零退出时拒绝启动。Hello Lithe 文本窗口、菜单、命令面板和工具栏可见,禁用后全部撤销;停靠、图标、动作状态及持久布局仍待接入,保持 partial。" } diff --git a/shared/platform-feature-matrix/features/lsp-lifecycle.json b/shared/platform-feature-matrix/features/lsp-lifecycle.json index 42d5b715dc..16feebd2b7 100644 --- a/shared/platform-feature-matrix/features/lsp-lifecycle.json +++ b/shared/platform-feature-matrix/features/lsp-lifecycle.json @@ -29,7 +29,10 @@ "rust/lithe-core/src/lsp/interface/engine.rs", "macos/Sources/Lithe/Platform/MacOS/Plugins/HostIntegrations/Jdt/MacJdtWorkspaceState.swift", "macos/Tests/LitheTests/MacJdtWorkspaceStateTests.swift", - "macos/Tests/LitheTests/MacBuildProviderSessionsTests.swift" + "macos/Tests/LitheTests/MacBuildProviderSessionsTests.swift", + "rust/lithe-core/src/lsp/interface/process.rs", + "rust/lithe-core/src/lsp/interface/remote_process.rs", + "rust/lithe-core/src/lsp/interface/scripted.rs" ], "implementationStatus": "implemented", "verificationStatus": "pending" @@ -54,6 +57,6 @@ "verificationStatus": "pending" }, "owner": "Language Tooling", - "verification": "在两端启动真实 JDTLS,验证项目准备、重启、超时、取消和资源清理,并确认典型工作流后已安装程序包(macOS app bundle、Windows 安装目录)的文件清单不变。 验证 Maven 导入连续 45 秒无进度只警告、之后 ServiceReady 可正常就绪,且 10 分钟总期限、显式失败和取消仍有效。 检查 JDT LS 启动参数的最大堆高于 1.5 GB,并在待导入模块超过 50 个、且子模块 Maven 坐标重复的聚合工程中确认工作区准备不再以 serviceReadyFailed 终止整个 Java 服务。 macOS #1524:暂停旧模块图清理后请求普通语言能力、后台 Java 维护及文档激活,确认等待结束后才读取缓存或启动新会话;等待期间取消不得重新激活;匹配 operation 的停止应清除 preparing,旧 operation 的停止不得影响新准备。 macOS #1523:通过插件入口启动 Java,确认宿主集成、Maven/Gradle 与缓存参数不丢失,连续失败最多自动启动三次,显式重启可恢复,且包内文件哈希保持不变。 macOS 最终关闭场景:暂停旧模块清理、排队文档和维护激活、关闭项目会话、释放清理;即使 AppModel 保留工作区 URL 与打开文档,也不能重新发布语言能力或启动 LSP。 macOS 生产 RustCoreBridge 与本地协议进程验证插件身份、host services、配置值和 JDT 缓存启动上下文;修复后的 Java ready 与 getOrder 定义导航截图见 evidence。 PR #1573:在两端打开已导入的 Maven 工程,修改 pom.xml(如增加依赖)后确认 JDT -data 目录不变、jdtls 增量更新而不是重新导入整个工作区;Windows 修改 gradle-wrapper.properties 的 distributionUrl 后确认切换到新的 -data 目录。检查 JDT LS 进程参数包含 -XX:+UseParallelGC、-XX:GCTimeRatio=4、-XX:AdaptiveSizePolicyWeight=90、-Xlog:disable 与 -DDetectVMInstallationsJob.disabled=true,导入完成后常驻内存回落。macOS 在大型工程导入期间打字、滚动与补全不掉帧(事件 drain 已移出主线程)。", - "notes": "JDT LS 统一以 -Xmx2048m 启动(#1156):打包的 1.61.0 在待导入模块超过 50 个且最大堆不超过 1.5 GB 时会走带缺陷的分批导入,重复 Maven 坐标会让 null 工程进入 IProject.open 并终止整个 Java 服务;上游修复进入下个里程碑前用这条堆上限规避。代价是语言服务 JVM 的堆上限从 1 GB 提到 2 GB,-Xms 仍为 256m。坐标完全相同的模块仍只有第一个成为 Java 工程,其余由 m2e 跳过。 JDT -data 工作区 key 只按构建文件是否存在、直接 Maven 模块、JDT LS 版本(以及 Windows 的 Gradle wrapper distributionUrl)计算,不再包含修改时间与大小:jdtls 自己检测 pom 与 Gradle 脚本的修改并增量更新。升级到该版本后每个 Java 工程首次打开会重建一次索引。JDT LS 额外以 vscode-java 与上游 CI 的 GC/日志默认值启动,插件同键参数优先。" + "verification": "在两端启动真实 JDTLS,验证项目准备、重启、超时、取消和资源清理,并确认典型工作流后已安装程序包(macOS app bundle、Windows 安装目录)的文件清单不变。 验证 Maven 导入连续 45 秒无进度只警告、之后 ServiceReady 可正常就绪,且 10 分钟总期限、显式失败和取消仍有效。 检查 JDT LS 启动参数的最大堆高于 1.5 GB,并在待导入模块超过 50 个、且子模块 Maven 坐标重复的聚合工程中确认工作区准备不再以 serviceReadyFailed 终止整个 Java 服务。 macOS #1524:暂停旧模块图清理后请求普通语言能力、后台 Java 维护及文档激活,确认等待结束后才读取缓存或启动新会话;等待期间取消不得重新激活;匹配 operation 的停止应清除 preparing,旧 operation 的停止不得影响新准备。 macOS #1523:通过插件入口启动 Java,确认宿主集成、Maven/Gradle 与缓存参数不丢失,连续失败最多自动启动三次,显式重启可恢复,且包内文件哈希保持不变。 macOS 最终关闭场景:暂停旧模块清理、排队文档和维护激活、关闭项目会话、释放清理;即使 AppModel 保留工作区 URL 与打开文档,也不能重新发布语言能力或启动 LSP。 macOS 生产 RustCoreBridge 与本地协议进程验证插件身份、host services、配置值和 JDT 缓存启动上下文;修复后的 Java ready 与 getOrder 定义导航截图见 evidence。 PR #1573:在两端打开已导入的 Maven 工程,修改 pom.xml(如增加依赖)后确认 JDT -data 目录不变、jdtls 增量更新而不是重新导入整个工作区;Windows 修改 gradle-wrapper.properties 的 distributionUrl 后确认切换到新的 -data 目录。检查 JDT LS 进程参数包含 -XX:+UseParallelGC、-XX:GCTimeRatio=4、-XX:AdaptiveSizePolicyWeight=90、-Xlog:disable 与 -DDetectVMInstallationsJob.disabled=true,导入完成后常驻内存回落。macOS 在大型工程导入期间打字、滚动与补全不掉帧(事件 drain 已移出主线程)。 Core:cargo test -p lithe-core --lib failed_initialize、failed_start 与 invalid_initial_configuration_is_rejected_before_launch,确认启动失败的进程确认退出后才允许下一次启动,清理不了时拒绝新启动。", + "notes": "JDT LS 统一以 -Xmx2048m 启动(#1156):打包的 1.61.0 在待导入模块超过 50 个且最大堆不超过 1.5 GB 时会走带缺陷的分批导入,重复 Maven 坐标会让 null 工程进入 IProject.open 并终止整个 Java 服务;上游修复进入下个里程碑前用这条堆上限规避。代价是语言服务 JVM 的堆上限从 1 GB 提到 2 GB,-Xms 仍为 256m。坐标完全相同的模块仍只有第一个成为 Java 工程,其余由 m2e 跳过。 JDT -data 工作区 key 只按构建文件是否存在、直接 Maven 模块、JDT LS 版本(以及 Windows 的 Gradle wrapper distributionUrl)计算,不再包含修改时间与大小:jdtls 自己检测 pom 与 Gradle 脚本的修改并增量更新。升级到该版本后每个 Java 工程首次打开会重建一次索引。JDT LS 额外以 vscode-java 与上游 CI 的 GC/日志默认值启动,插件同键参数优先。 #1478 拆分(Core):启动失败但已注册的会话进入内部积压,下一次启动前最多再 dispose 一次,确认根进程退出后才释放;仍清理不了时以 ProcessFailed 拒绝新启动,避免同一工作区残留多个语言服务器。非法初始配置在启动进程前拒绝。destroy 先在 2 秒内确认进程退出再移除会话:非 Windows 重复 kill 并轮询退出状态,Windows 等进程树终止,远程会话以强制 PROCESS_KILL 回执为准。macOS 仍在终止事件后调用一次 lsp.destroyServer 并忽略错误;目前只有 Core 单测证据,macOS 真实 UI 流程未复验。" } diff --git a/shared/platform-feature-matrix/features/plugin-project-generators.json b/shared/platform-feature-matrix/features/plugin-project-generators.json index 92c1c744f7..996c82277a 100644 --- a/shared/platform-feature-matrix/features/plugin-project-generators.json +++ b/shared/platform-feature-matrix/features/plugin-project-generators.json @@ -13,7 +13,8 @@ "macos/Sources/Lithe/Application/Features/NewProjectFeatureModel.swift", "macos/Sources/Lithe/Services/ProjectGeneration/ProjectGenerationService.swift", "macos/Sources/Lithe/Platform/MacOS/ProjectGeneration/MacProjectGenerationPlatform.swift", - "macos/Tests/LitheTests/ProjectGenerationTests.swift" + "macos/Tests/LitheTests/ProjectGenerationTests.swift", + "rust/lithe-core/src/project_generators/archive.rs" ], "implementationStatus": "implemented", "verificationStatus": "pending" @@ -26,5 +27,6 @@ "verificationStatus": "not-applicable" }, "owner": "Plugin Platform", - "verification": "macOS:从欢迎页和项目切换器点“新建项目”,确认左栏有“新建项目”(Java、空项目)和“生成器”(Maven Archetype、Spring Boot)两组且可搜索。Java 选 Maven、默认 JDK 创建,确认生成 pom.xml(maven.compiler.release 等于所选 JDK 主版本)、.gitignore 和 src/main/java/org/example/Main.java,项目打开后 Main.java 已打开、Build 工具窗口识别 Maven 项目。勾选“创建 Git 仓库”时项目根目录有 .git。Spring Boot 选几个依赖创建,确认从 start.spring.io 下载并解压、mvnw 可执行;把服务器 URL 改成不可达地址时报错且目标目录下没有残留的 .*.lithe-creating-* 临时目录。Maven Archetype 在已安装 mvn 时生成 quickstart 项目,未安装时提示找不到 mvn。停用 Java Support 后,三个条目变灰、创建按钮不可用,只出现一条“启用 Java Support”,点击后条目恢复可用;未安装 Maven 插件时出现“在插件市场中查找”并跳到市场搜索 maven。目标目录已存在时拒绝创建且不改动原目录。Windows:宿主不声明 projectGenerators,需要它的插件在市场中隐藏。" + "verification": "macOS:从欢迎页和项目切换器点“新建项目”,确认左栏有“新建项目”(Java、空项目)和“生成器”(Maven Archetype、Spring Boot)两组且可搜索。Java 选 Maven、默认 JDK 创建,确认生成 pom.xml(maven.compiler.release 等于所选 JDK 主版本)、.gitignore 和 src/main/java/org/example/Main.java,项目打开后 Main.java 已打开、Build 工具窗口识别 Maven 项目。勾选“创建 Git 仓库”时项目根目录有 .git。Spring Boot 选几个依赖创建,确认从 start.spring.io 下载并解压、mvnw 可执行;把服务器 URL 改成不可达地址时报错且目标目录下没有残留的 .*.lithe-creating-* 临时目录。Maven Archetype 在已安装 mvn 时生成 quickstart 项目,未安装时提示找不到 mvn。停用 Java Support 后,三个条目变灰、创建按钮不可用,只出现一条“启用 Java Support”,点击后条目恢复可用;未安装 Maven 插件时出现“在插件市场中查找”并跳到市场搜索 maven。目标目录已存在时拒绝创建且不改动原目录。Windows:宿主不声明 projectGenerators,需要它的插件在市场中隐藏。", + "notes": "#1478 拆分(Core):生成器归档解压先预检全部条目(条目数、展开字节、目录深度 64 层、路径总字节 16 MiB),只经过真实目录(不跟随符号链接,Windows 还拒绝 reparse point),按 32 KiB 分块复制并在块间检查取消;违反约定报 plugin.project.archiveInvalid,取消或超时作为 Core 错误返回且不再写入。Windows 额外拒绝设备名、ADS 和非法字符。macOS 的 project.extractArchive 没有取消作用域,只受预检和上限影响。" } diff --git a/shared/platform-feature-matrix/features/run-discovery.json b/shared/platform-feature-matrix/features/run-discovery.json index 50e1894be9..b1c3fabbe0 100644 --- a/shared/platform-feature-matrix/features/run-discovery.json +++ b/shared/platform-feature-matrix/features/run-discovery.json @@ -29,7 +29,8 @@ "shared/fixtures/run-configuration/argument-text.json", "macos/Sources/LitheCoreContracts/Execution/RunConfigurationContracts.swift", "macos/Sources/Lithe/Services/Debug/DebugLaunchSourceResolver.swift", - "macos/Tests/LitheTests/RunConfigurationIntegrationTests.swift" + "macos/Tests/LitheTests/RunConfigurationIntegrationTests.swift", + "rust/lithe-core/src/lsp/languages/java_entrypoints.rs" ], "implementationStatus": "implemented", "verificationStatus": "pending" @@ -70,5 +71,5 @@ }, "owner": "Run", "verification": "验证 Spring Boot、Java、Maven、Gradle、npm、Cargo、Go、Python 和 Docker Compose 入口识别;Maven 框架 plugin 只在父 POM 声明时,子模块沿 链继承后仍识别为对应服务,父 POM 按 groupId:artifactId:version 完整坐标匹配、仅同名 artifactId 或版本不符的不继承、含未解析 ${...} 表达式的坐标不作数,聚合但未声明 的模块不继承、false 的 plugin 不下传且对更深层级保持阻断、 声明保持不生效、框架 plugin 按完整坐标 groupId:artifactId 识别:每个框架的全部官方坐标组均被接受(Quarkus 的 io.quarkus 与平台再发布的 io.quarkus.platform,Micronaut 3.x 的 io.micronaut.build 与 4+ 的 io.micronaut.maven,Spring Boot 的 org.springframework.boot)、省略 的声明按 Maven 默认组 org.apache.maven.plugins 处理,其他组下的同名插件与含 ${...} 表达式的 group 不识别为框架,子模块的同名自定义 plugin 也不遮蔽父继承的正品;源码根与报告目录的提取同样按完整坐标匹配,build-helper 执行级源根与 Surefire/Failsafe 独立 reportsDirectory 均有官方组与自定义组对照;Java 运行入口缺少主类时 inspect 报 staleJavaEntrypoint 并提示重新生成,重新生成后由 JDT 答案恢复;多模块项目把服务工作目录改成模块目录后,服务仍留在列表中并以该目录启动;填写不存在的目录或 ${workspaceFolder} 等变量时,保存被拒绝并提示原因;在 Windows 确认重新扫描服务使用双箭头刷新图标,配置按语言生态、类型与实例呈现三栏布局,Java 下展示 Maven、Gradle 与 Spring Boot 等已识别类型,Node.js 下展示包管理器与框架;语言切换和外部选中能定位配置,空生态不显示,语言和配置栏不显示重复栏头,生态不显示配置数量;语言侧栏通过拖动阈值折叠和展开,收起与展开阈值不同以避免边界跳动,不显示专门折叠按钮;键盘可调整宽度及恢复展开,保存展开宽度与拖动折叠状态,拖动期间只更新局部宽度和紧凑标记,文字与图标对齐即时切换,结束后保存;语言行、类型行和实例行使用一致的紧凑行高,去掉列表上下留白和选中实例的圆角边距;窄面板自动缩成带提示的图标栏且扩大后恢复,右侧输出保留可用空间,窗口缩放或卸载时清理正在进行的拖动;所选配置的日志、运行状态、顶部停止按钮、清空输出与标准输入均指向其自身会话;保持选中 application 并后台启动服务后,顶部停止仍指向该应用的独立会话,不停止后台服务,左侧使用 SVG 箭头和类型图标,基础设施默认折叠,选择配置自动展开所在分组,运行、停止、编辑和完整名称提示可用;根据 Core 提供的 npm、Gradle 和 Python 元数据展示明确识别的框架图标,构建与测试任务保留工具图标,未知类型回退通用图标;同名自定义 provider 与已知框架分别分组且折叠状态独立,相同已知框架跨 Maven/Gradle provider 合组,项目与基础设施不合组;Java 生态分组使用 Java 文件类型图标,Java 启动类实例使用原始 Class 与 RunnableMark SVG 同画布叠加图标;Maven 启动的框架服务使用 MavenRunConfigurationType 对应的 Maven 图标,Make 外部任务分组使用任务文件夹、实例使用 Shell 配置图标,均保留原始明暗 SVG,运行或失败不改变类型图标,深浅主题均可辨认;macOS Run 缺少配置且可重新生成时,检查空状态文字与链接在深浅主题下按 IDEA 工具窗口样式显示、窄面板不截断,并确认“识别并生成”仍触发原有生成流程;应用语言设为英文而系统语言为中文时,Run 空状态及其他本面板文案仍应显示英文;Run 顶部标题字号、颜色、41pt 高度和底部分隔线应与 Terminal、Git Log 等工具窗口一致;有项目配置或 Current File 正在运行/已有退出结果时,运行、重启、重新扫描和软换行按钮显示在独立的 36pt 操作栏,检查 16pt IDEA 图标、22pt 共享按钮的悬停、按下、选中及禁用状态;操作栏只保留一个运行/重运行动作:首次启动显示 Run,当前配置已运行过后显示 Rerun;右侧固定停止按钮,未运行禁用、运行中启用,两者始终指向当前选中配置;操作栏不重复显示 Running 圆点及状态文字,重运行按钮复用顶部工具栏的绿色 rerun_stroke 图标;标题栏菜单中的清空输出与原操作一致,收起按钮沿用共享样式;仅有 Current File 的项目启动后也可从 Run 操作栏停止,结束后保留重运行入口;Run 内容区不额外插入 Java 项目准备状态行,准备进度和失败入口保留在工作台状态栏;Run 标题、操作栏、配置列表标题、控制台标签底边及两侧纵向分割线统一使用工具窗口边框颜色和 1pt 绘制,左侧图标栏不出现 5pt 实心粗线,栏内分组线与 Git Log 一致使用共享 divider 颜色、22pt 宽度、1pt 高度及上下 3pt 间距;操作按钮组之间使用专用 ActionToolbar.separator,详情编辑按钮的边框由共享按钮样式负责,拖动命中范围保持不变;配置树直接显示分组与数量,不显示 Application types 标题;默认隐藏勾选框,通过更多菜单或右键进入批量选择,退出清空选择;配置单行显示名称,类型及服务地址放到悬停提示,行内仅运行/停止,编辑/固定/打开服务保留在共享右键菜单,固定后显示标记;分组与配置使用共享树行高、缩进及焦点选择样式;Run 范围筛选以固定图标栏呈现,应用范围筛选及当前运行导航使用中性 ToolWindowRun 图标,实际运行操作继续使用绿色 Execute 图标;全部采用 IDEA groups、服务采用 server 图标,固定、应用及任务沿用对应 IDEA 原始资源;检查所有图标的 16pt 尺寸、明暗 SVG 自动切换、提示和筛选,右键勾选范围和配置行勾选共享同一批量选择;配置行使用 IDEA 固定、编辑、运行及停止图标,悬停与点击维持箭头光标;配置过期提示使用共享中性通知表面及警告图标,操作仍可重新识别;Run 标题栏仅显示 Run,移除重复配置名与右侧状态胶囊;Console 和 Configuration details 标签位于运行操作按钮组右侧,配置列表选中项表示当前配置,内容区直接显示日志或详情;配置详情使用共享 13pt 字体、原生 Grid 自适应标签列、可选择且可换行的路径及值,编辑配置按钮复用共享 LitheCommitDialogButtonStyle 与 IDEA EditSource 图标,检查深浅主题、窄列及点击跳转设置,服务链接保留原动作;两个标签使用共享 LitheToolWindowTabStyle,检查 13pt 文字、28pt 标签、原始明暗 SVG、悬停及内容区聚焦/失焦状态,保留标签切换;Run 与 Debug 均启用共享 OutputTextView 的 IDEA 渲染入口,运行日志采用一致的 13pt 字体、1.2 倍行高和 ANSI 配色,不给普通 INFO 日志整行染蓝,源码链接继续跳转;Copy 与 Jump to latest 为共享图标按钮,复制不带 ANSI,向上滚动后可恢复跟随;其他配置恢复状态保留各自提示。 Current File 运行一次后修改未保存并切换编辑标签,重运行应先保存原运行文件再构建启动计划;原文件保存失败时提示错误并中止重启,当前焦点文档不被误保存;调整 Run 面板高度,外层横向操作栏固定为 36pt,剩余高度交给配置树和控制台。 缓存目录不可访问时仍可发现兄弟目录和隐藏源码;可选子目录不可读时保留其旧配置并显示 incompleteProjectScan,不误报删除或新鲜;根目录不可读仍失败,完整重新生成后解除未知基线。 两端 Run 面板显示扫描不完整的共享中英文提示;恢复访问权限后重新识别。 Java 文件枚举达到 8,000 条上限后不再访问后续目录,返回顺序稳定;不可读兄弟目录不阻断结果,完整指纹扫描仍继续遍历。 保存 Maven/Gradle 构建任务后重启,确认用户任务和 Spring Boot 等自动入口同时恢复;再次加载不重复生成。 自动 Spring 服务必须同时具备 Maven 插件和同模块唯一的 JDT 已确认非测试 Spring 入口;继承插件的库模块、只有测试 main 的模块、只有子模块入口的父模块不能成为服务,多入口保留独立 Java 配置。验证传空 paths 不影响确认入口的模块归属、JDT 未就绪保留已确认结果、明确空结果移除自动服务,已有服务 ID 和用户配置保持兼容。 #1562:Windows 普通应用 A/B 独立会话和输出;先启动 A 再 B,停止及重跑 B 不影响 A,切换配置只显示所属输出,关闭项目清理两者。 IDE API 在 primary 忙碌时仍能启动独立应用,同一配置准备期间拒绝重复启动;保存期间会话可见且可停止,停止后不再启动进程,顶部停止不影响后台服务;旧 Debug 回调不能停止重跑后的应用。 缺少工具链时错误只归属目标应用,不覆盖 primary 或后台会话,也不把已运行的目标实例标记为退出。 macOS 通用 Provider 运行发现:无 Java 导入和私有框架属性时,按当前公开声明及目标标签生成 build.provider;名称/执行类型变化保留 ID 和参数、环境、目录覆盖;模型撤回、重排、恢复、停用及重新生成核对指纹,撤回目标不从旧检测层复活。默认项优先 service,不依赖框架名单。 通用 Provider 选项:团队/本机层覆盖运行时 argv、入口与 Build 选项,覆盖空字符串参数、引号、反斜杠、Unicode、false/空数组、显式清空、旧调用者省略、未知/超限字段和重存目录保持;真实 Maven 的保存任务使用按次 Profile,不改默认模型。 旧 Run v2 转换:验证稳定 ID、默认项、两层覆盖和目标唯一性;转换前预检两层,覆盖源文件变化、未改写输入变化、偏好变化、各写入阶段取消、外部修改与回滚冲突。工作区/模型/任务取消及新生成撤销写入资格;只读安装目录和越界链接不写入。真实 Maven 模型中的显式 validate 任务转换后准备,原 ID、Profile、环境和默认模型保持一致。 当前 Provider 归属投影改用 build={pluginID,buildSystemID,root,projectID},生成 Java 数据位于 extensions.java,不再产出 Maven 扩展或 Maven 工具绑定。共享 provider-project-ownership fixture 由 Rust、Swift bridge 与 Windows 映射回归共同读取,覆盖同名类、非标准源码根、角色、稳定身份和 cwd 覆盖;团队/本机伪造 build 身份被当前模型拥有的值替换。原生精确导入查找拒绝错误插件/构建声明/根/项目以及已撤销模型。旧 Windows 生成路径在未提供 Provider 归属时保留,删除前需先迁移真实消费者。 macOS Debug 缺少精确源码路径时,使用通用 Build 归属根加模块路径定位源码;嵌套实例与工作区根实例优先于残留 Maven 字段,当前实例没有源码时不得选择其他实例的同名类。原生源码选择回归不替代 Registry/DAP 与完整产品验收。", - "notes": " Windows普通Java文件的main入口在工作区搜索遗漏时,先保存并让JDT对当前文件确认,再生成命名运行配置;拒绝过期入口、准备失败和工作区切换结果。Java入口源码按容错UTF-8读取(非法字节替换为占位符),GBK项目不再因单个非UTF-8文件导致整个运行列表生成失败,Spring Boot注解等ASCII分类标记不受影响。 macOS 运行就绪要求匹配快照且工具链和配置选择加载完成,加载中的清单不可作为启动许可;受控工具链与快照测试验证完成前后状态,以及 Current File 不被迟到的默认配置覆盖。 远程工作区尚未接入运行配置发现:Core 对 runConfig.inspect 返回 NotSupported,仅 runConfig.selectJava 可用;共享扫描的远程契约与进度见 remote-development-workspace。 识别结果只保存在 Core 进程内存中,宿主不再写入工作区的 .lithe/run/generated.json、.lithe/toolchains/requirements.json、.lithe/project.json 和 .lithe/.gitignore;上次的 Java 入口缓存在应用缓存目录(run-configurations/),旧版本留下的 generated.json 只作只读的上次入口来源。本进程尚未识别的工作区在加载时自动识别(只读扫描、不启动进程),自动识别不提示入口数量;未写 defaultRunConfiguration 时由 Core 优先选声明为 service 的入口。识别前 JDK 选择从 pom.xml、.java-version 与 Maven Wrapper 推导最低版本。 保存过构建任务的工作区重启后仍按 Core requiresGeneration 标记自动识别,保留用户任务并恢复其他检测入口;同一进程完成识别后不重复生成。 macOS 的新运行发现使用独立 providerRuns 快照,Core 删除 mavenRunProvider 框架投影;Windows 仍使用旧生成路径。旧 Maven 用户配置和 reactor/Wrapper/工具需求迁移仍待完成。 新的通用选项保存在 extensions.build-run,复用 v10;完整旧格式迁移仍待完成。 已实现旧 Run v1/v2 与活动偏好的受限转换;自定义工具路径仍等待通用工具接入;v1/v2、可确认的活动偏好和空目标列表已经转换,模块不受支持的运行时选择交给提供者拒绝。转换器与退役偏好回滚记录按稳定 N+2 窗口删除。 两端 Provider 路径只接受完整选择器,Windows 数字端口旧调用拒绝冒充注册表调试。编辑器往返精确 argv 与通用选项,首次偏好文档保留 Java 配置,活动来源修改会回滚且保留外部新字节。 #1558 预集成后续删除归属投影的 mavenReactorPath:当前引用记录四元组并进入完整快照指纹,原生 Java 准备按四元组从同一启用模型取得导入输入。Java 的主类、模块和源码事实保留在 java 命名空间;已有 Java 用户层旧扩展继续按兼容规则读取,属于后续 Java 消费者迁移。首轮 Windows CI 41307483413 的前端通过,两条 Rust/JDT lane 均被同一 Unix 专用工具路径 fixture 阻断,已修正为原生路径并等待重跑;不能标记 Windows 验证通过。" + "notes": "Windows普通Java文件的main入口在工作区搜索遗漏时,先保存并让JDT对当前文件确认,再生成命名运行配置;拒绝过期入口、准备失败和工作区切换结果。Java入口源码按容错UTF-8读取(非法字节替换为占位符),GBK项目不再因单个非UTF-8文件导致整个运行列表生成失败,Spring Boot注解等ASCII分类标记不受影响。 macOS 运行就绪要求匹配快照且工具链和配置选择加载完成,加载中的清单不可作为启动许可;受控工具链与快照测试验证完成前后状态,以及 Current File 不被迟到的默认配置覆盖。 远程工作区尚未接入运行配置发现:Core 对 runConfig.inspect 返回 NotSupported,仅 runConfig.selectJava 可用;共享扫描的远程契约与进度见 remote-development-workspace。 识别结果只保存在 Core 进程内存中,宿主不再写入工作区的 .lithe/run/generated.json、.lithe/toolchains/requirements.json、.lithe/project.json 和 .lithe/.gitignore;上次的 Java 入口缓存在应用缓存目录(run-configurations/),旧版本留下的 generated.json 只作只读的上次入口来源。本进程尚未识别的工作区在加载时自动识别(只读扫描、不启动进程),自动识别不提示入口数量;未写 defaultRunConfiguration 时由 Core 优先选声明为 service 的入口。识别前 JDK 选择从 pom.xml、.java-version 与 Maven Wrapper 推导最低版本。 保存过构建任务的工作区重启后仍按 Core requiresGeneration 标记自动识别,保留用户任务并恢复其他检测入口;同一进程完成识别后不重复生成。 macOS 的新运行发现使用独立 providerRuns 快照,Core 删除 mavenRunProvider 框架投影;Windows 仍使用旧生成路径。旧 Maven 用户配置和 reactor/Wrapper/工具需求迁移仍待完成。 新的通用选项保存在 extensions.build-run,复用 v10;完整旧格式迁移仍待完成。 已实现旧 Run v1/v2 与活动偏好的受限转换;自定义工具路径仍等待通用工具接入;v1/v2、可确认的活动偏好和空目标列表已经转换,模块不受支持的运行时选择交给提供者拒绝。转换器与退役偏好回滚记录按稳定 N+2 窗口删除。 两端 Provider 路径只接受完整选择器,Windows 数字端口旧调用拒绝冒充注册表调试。编辑器往返精确 argv 与通用选项,首次偏好文档保留 Java 配置,活动来源修改会回滚且保留外部新字节。 #1558 预集成后续删除归属投影的 mavenReactorPath:当前引用记录四元组并进入完整快照指纹,原生 Java 准备按四元组从同一启用模型取得导入输入。Java 的主类、模块和源码事实保留在 java 命名空间;已有 Java 用户层旧扩展继续按兼容规则读取,属于后续 Java 消费者迁移。首轮 Windows CI 41307483413 的前端通过,两条 Rust/JDT lane 均被同一 Unix 专用工具路径 fixture 阻断,已修正为原生路径并等待重跑;不能标记 Windows 验证通过。 #1478 拆分(Core):javaEntrypoints 不再向 JDT 传作用域 URI,JDT 列出全部入口(含 invisible project 里的普通 Java 文件夹),Core 只保留当前工作区拥有的源文件。java.main 带 javaLaunch 时直接用 JDT 给出的类路径和模块路径启动,不再单文件重编译;Maven 只在缺少 buildPrepared 回执时补资源步骤。macOS 只在 Java 项目准备时发送 javaLaunch 且总带 buildPrepared,因此 Maven 行为不变,Gradle 的 java.main 改走 JDT 路径。真实 JDT 1.61.0 在 macOS 上通过 real_jdtls_lists_entrypoints_in_a_plain_java_folder;macOS UI 未复验。" }