Repository navigation
feat(toolchain): 支持项目内工具环境解释器链接链校验与本机信任存储 - #93
Merged
Merged
Conversation
- project.rs/snapshot.rs:projectCodeAllowed != true 保持返回 projectCodeRequiresAction 且不暴露探针目标;projectKind == "environment" 要求 home、中间父目录、环境内 requires 标记与存在的 pathPrepend 目录留在工作区和 home 内,允许叶子可执行文件经单跳或多跳软链指向外部常规可执行文件并保留字面 executable 路径;wrapper 仍要求链接目标留在工作区根内;pathPrepend 记为 missing 的跨平台目录安全跳过 - discovery.rs/automatic.rs/resolution.rs:discoveryPlan 新增平台过滤后的 projectFiles,candidates 新增根级 project 候选,resolve 新增 projectCandidates 并在全部候选跳过时保留最高层跳过原因 - catalog.rs:toolchains/global.json 新增规范化与去重的 trustedWorkspaces,支持通过 catalogState 查询 projectCodeAllowed、通过 editCatalog 的 workspaceTrust 原子变更工作区信任 - 更新契约、schema、fixture、协议更新记录,并修正 toolchains/README.md 与 capabilities-and-versions.md 的过时宿主能力说明 Refs 1lck/Lithe-IDEA#2122
34 of 40 tasks
Mucheen
marked this pull request as ready for review
November 18, 2026 06:45
按目录组件判定最近声明,并在解析无结果时保留首个失败原因。 跳过无法表示的可选项目路径,避免它阻断有效的固定选择。 补齐合成事实回归并同步工具链接口说明。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
在 Unix(macOS / Linux)上,
.venv、venv等项目虚拟环境中的解释器入口(如.venv/bin/python)通常是指向系统或包管理器基础解释器的单跳或多跳符号链接。此前 Core 的project_selection(rust/crates/toolchain/src/resolution/project.rs)只要遇到canonicalPath != path就一律返回unsafePath,导致项目内虚拟环境无法被工具链四层选择解析;同时toolchains.discoveryPlan、toolchains.candidates和toolchains.resolve尚未把平台过滤后的项目内projectFile候选声明及校验状态结构化暴露给宿主,本机全局目录toolchains/global.json也缺少规范化的工作区信任列表,且toolchains/README.md与capabilities-and-versions.md仍残留多处已过时的平台与宿主能力描述。改动 / Changes
rust/crates/toolchain/src/resolution/project.rs:projectCodeAllowed != true时,所有projectFile候选严格返回projectCodeRequiresAction,且在candidates.project与resolve.projectCandidates中不发出executable探针目标,确保宿主绝不对未信任工作区代码运行版本探针。projectKind == "environment"(声明了home,如.venv):环境根目录home、从home到叶子可执行文件之间的全部中间父目录(如.venv/bin、.venv/Scripts;缺失事实或软链逃逸均按unsafePath失败关闭)、环境内requires标记文件以及实际存在的pathPrepend目录,其canonicalPath均必须留在工作区根与home目录之内;叶子可执行文件path允许是常规可执行文件或指向工作区内/工作区外常规可执行文件的单跳或多跳符号链接(宿主事实证实path与最终canonicalPath均为file且executable: true),在探测前先校验exports与pathPrepend,探测与最终selection.executable(及${executable}导出)严格保留字面路径path(如<root>/.venv/bin/python),使虚拟环境保有自身的pyvenv.cfg/sys.prefix。projectKind == "wrapper"(无home):允许工作区根之内的符号链接并保留字面路径,指向工作区根之外的软链仍拒绝为unsafePath;仅在调用方要求minimumVersion时强制版本探针。rust/crates/toolchain/src/resolution/snapshot.rs:environment_selection处理跨平台pathPrepend(如同时声明${home}/bin与${home}/Scripts)时,跳过宿主已显式观测为kind: "missing"的目录;未观测到事实或软链逃逸home的目录仍按unsafePath失败关闭。output新增projectCandidates字段。rust/crates/toolchain/src/resolution/discovery.rs:toolchains.discoveryPlan的每个工具新增按目标platform过滤后的projectFiles: [{ id?, projectKind, path, home?, requires }],宿主无需重复解析插件清单即可沿祖先链观测目录、标记文件与可执行入口。rust/crates/toolchain/src/resolution/automatic.rs:toolchains.candidates返回新增根级project: [{ candidateID, projectKind, path, home?, executable?, version?, reason? }](global: true时为空数组,不混入外部安装列表installations)。rust/crates/toolchain/src/resolution.rs:toolchains.resolve返回新增最近声明层的projectCandidates;当所有层均跳过且无选中结果时,outcome.reason保留最高优先级候选的跳过原因(如projectCodeRequiresAction、unsafePath、notExecutable、probeFailed),仅在各层均为空时返回notFound。.lithe/)rust/crates/toolchain/src/catalog.rs、rust/contracts/toolchain-global-v1.schema.json、rust/fixtures/toolchain-global-catalog.json:toolchains/global.json新增可选trustedWorkspaces(最多 256 个规范化绝对路径,按目标平台分隔符与大小写策略去重排序,空列表省略以保持旧文档格式兼容)。toolchains.catalogState支持可选workspaceRoot参数并返回projectCodeAllowed: bool(不传workspaceRoot时省略该字段以兼容既有调用)。toolchains.editCatalog支持可选workspaceTrust: { workspace, trusted }原子增删工作区信任,与 SDKtools注册互不覆盖;缺省文档上撤销信任返回changed: false, document: null且不落盘空文件。rust/contracts/rust-core-api.md:同步更新toolchains.catalogState、editCatalog、discoveryPlan、candidates、resolve的契约说明。shared/plugins/contract/v1/toolchains/README.md:补齐项目环境符号链接链校验、projectFiles、candidates.project、resolve.projectCandidates与pathPrepend规则,并修正开头“Windows has no toolchain adapter and does not advertisetoolDefinitions”等过时表述。shared/plugins/reference/domains/toolchains.md:中英文同步更新选择顺序、Core 命令表、本机文档说明与桌面端现状(commandInstallers已声明、语言服务器{kind: "tool"}已接通工具链解析、pin 保存已实现)。shared/plugins/reference/capabilities-and-versions.md:中英文同步将指向已停用preview分支的pluginhost.go链接改为main,将commandInstallers、vcsProviders、sourceSettings(0/1)、litheVcs更新为桌面端已声明状态,并按desktop/internal/pluginhost/pluginhost.go的Declared()注释更新脚注¹中语言服务器、系统命令、构建提供者与 VCS 提供者的未呈现范围说明。shared/plugins/reference/protocol-changelog.md:登记本次toolDefinitions0 内补充说明,并将指向preview分支的计划文档链接更新为main。rust/crates/toolchain/src/catalog.rs、rust/crates/core/src/tests/toolchain_resolution.rs:覆盖 Unix(macos、linux)与 Windows(windows)下的单跳/多跳外部软链.venv、Windows 复制式与软链式.venv\Scripts\...、.venv根目录软链逃逸被拒、bin/Scripts中间父目录软链逃逸或漏观测被拒、requires标记软链逃逸被拒、pathPrepend软链逃逸探测前被拒、目标不可执行被拒、projectCodeAllowed: false拦截与授权后字面路径/exports/pathPrepend保留,以及纯内联合成插件dev.lithe.test.runtime-support全链路测试。不在本 PR 范围内 / Out of scope
1lck/Lithe-IDEA仓库配套 PR 中实现,关联1lck/Lithe-IDEA#2122)。1lck/Lithe-IDEA#2128)。io.github.lithe-idea.python-support本体(在独立插件仓库Lithe-IDEA/lithe-plugin-python维护)。类型专属:feat
多平台对齐
Lithe 的目标是 macOS 与 Windows 能力对齐。必须选下面一项:
platform-specific),理由:范围检查 / Scope checks
功能矩阵 / Feature matrix
N/A:本仓库为
Lithe-core-rust,跨平台功能矩阵位于宿主仓库1lck/Lithe-IDEA并在对应桌面端 PR 中同步更新。插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查,本次改动零具体插件依赖dev.lithe.test.*)和 Core 契约 fixture(dev.lithe.fixture.*);没有读取具体插件的插件包、仓库检出、构建产物或清单,没有使用真实插件 ID,没有“缺少插件时跳过”的测试UI 验证 / UI evidence
N/A:纯 Rust Core 策略、契约与文档改动,不包含界面视图代码(桌面端 UI 无头截图在配套桌面端 PR 提供)。
统一日志系统 / Structured logging
N/A:纯确定性 JSON 策略计算模块(无 I/O、无进程生命周期或新增日志目录事件);
node scripts/logging/generate-log-events.mjs --check校验通过。界面文案 / i18n
N/A:Core 仅返回稳定结构化状态码(如
projectCodeRequiresAction、unsafePath、notExecutable、probeFailed),不包含宿主界面文案。逻辑归属 / Logic placement
性能与内存 / Performance and memory
N/A:无常驻后台任务、子进程、轮询或无界缓存;
trustedWorkspaces(上限 256)、filesystem事实与祖先链(上限 64)均有显式常数上界。设置 / Settings
N/A:本 PR 提供
toolchains.catalogState/editCatalog与candidates/resolve底层契约数据,设置页 UI 交互在桌面端仓库实现。插件契约 / Plugin contract
shared/plugins/reference/protocol-changelog.md)scripts/desktop/build-desktop-core.sh的PINNED_CORE_REVISION升级在桌面端仓库 PR 合入本 PR 后执行lithe/host/*宿主方法或通知发行包与资源 / Bundle and resources
N/A:Core 不执行任何文件写入;
toolchains/global.json仍位于宿主平台用户偏好存储目录(toolchains/global.json),不写入已安装应用包或工作区.lithe/。无用代码与重构 / Dead code and refactoring
resolution.rs内联项目候选收集逻辑已合并至project::collect_project_file_choices)验证 / Verification
node shared/plugins/scripts/verify-docs.mjs./scripts/rust-core/verify-rust-core-comments.sh toolchain corenode scripts/rust-core/verify-platform-tests.mjsnode --test scripts/rust-core/*.test.mjscargo fmt --manifest-path rust/Cargo.toml --all -- --checkcargo clippy --manifest-path rust/Cargo.toml -p lithe-toolchain -p lithe-core -p lithe-execution -p lithe-plugin-manifest -p lithe-plugin-output-links --all-targets --all-features -- -D warningscargo clippy --manifest-path rust/Cargo.toml -p lithe-toolchain --all-targets --target x86_64-pc-windows-msvc -- -D warningscargo test --manifest-path rust/Cargo.toml -p lithe-toolchain -p lithe-core -p lithe-execution -p lithe-plugin-manifest -p lithe-plugin-output-linksPlatform::Unix与Platform::Windows规则向量未能执行的检查和原因:
lithe-platform/lithe-platform-tests原生测试未在本机直接执行(本次改动位于平台参数化的纯数据校验模块lithe-toolchain,不涉及#[cfg(windows)]系统调用,已在同一测试套件内同时覆盖macos、linux、windows三套路径/大小写规则并通过x86_64-pc-windows-msvc目标 clippy 检查)。提交前确认 / Final checks
main创建;目标分支:main.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图