Repository navigation
feat(remote): 远程工作区信任按目标与主机真实路径记录(S01/S02/S04) - #140
Merged
Merged
Conversation
- 新增 lithe_remote::client::trust:信任键是连接目标加工作区在主机上的 真实路径。目标只保留决定落点的字段(SSH 目的地、端口、User/Port/ ProxyJump 选项,容器引擎、程序、容器名、用户,以及主机账号 uid), IdentityFile、超时、工作目录、环境变量不参与;换主机、账号、别名、端口、 跳板或容器后一律重新询问,本地信任与远程信任互不继承。 - 信任位置只覆盖本目标,永远不提供 `/`,也没有“全部信任”;同一路径不能 同时信任与不信任;决策文件有大小、目标数、条目数、跳数、字段长度上限, 重复键、未知字段、未知版本都按解析失败处理,失败时不改动任何内容。 - 新增 remote.workspaceTrust / remote.editWorkspaceTrust:Core 通过打开的 连接解析真实路径后再查或记录决策,符号链接和主机解析到别处的写法拿不到 别的工作区的决策;返回 projectCodeAllowed,供构建、运行、测试计划使用。 决策文件只存在本机用户偏好目录(toolchains/remote-trust.json),由原生 客户端原子写入,不写到主机;没有变化的编辑返回 null 文档。撤销不需要连接。 - 协议:HostCapabilities 新增 userId(内核给出的数字账号,不取环境变量), 旧服务端不返回该字段,升级后需重新确认一次。 - 为挂接连接与命令,改动超出 remote crate:workspace 的连接记录信任目标、 新增 trust 模块;core 新增两个命令与分发;rust-core-api.md 与远程协议 文档同步。
- 传输进程写完错误信息立刻退出时,客户端看到退出后马上读尾部缓冲, 读 stderr 的线程可能还没把管道里最后的内容读进来,诊断里就缺了 “not found” 这类原因(a_missing_server_reports_the_transport_output 在 Linux 上三轮挂两轮)。 - 标准错误尾部改为带“已读到结尾”标记的 StderrTail;握手失败时先等传输 退出,再在同一个 2 秒宽限内等读到结尾。传输留下的进程一直占着管道时, 到期就用已有内容,不会多等。 - 补两个单测:读到结尾后内容完整;只保留最后 8 KiB,期限已过时立即返回。
xiaoyumuxi
marked this pull request as ready for review
November 20, 2026 21:36
This was referenced Nov 20, 2026
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
1lck/Lithe-IDEA#2231(远程开发完整设计)R0 中 Core 侧的远程工作区信任:S01(信任按目标与主机真实路径记录)、S02(不继承本地决定,也不提供“信任所有远程工作区”)、S04(决定存在本机用户目录,不写到主机或工作区)。同时修了两处在验证本 PR 时发现的测试可靠性问题。AskPass(#137)和容量/S27 边界(#138)都已合入 main,本 PR 直接从 main 开分支。
类型
remote.workspaceTrust、remote.editWorkspaceTrust两个 Core 命令改动说明
信任模型(
crates/remote/src/client/trust.rs新文件){ hops, userId? }:destination、port、portOption、user、proxyJump,选项按 ssh 的规则取第一个Port、User、ProxyJump;容器跳是engine、program、container、user。userId是服务端在server.hello里报告的数字账号。dev@box与box+User=dev)也按不同目标处理,宁可多问一次,不猜测等价。fs.realPath。打开符号链接时,用的是链接指向的那个目录的决定。offeredLocation)是工作区的父目录,父目录是/时为null。主机根目录既不提供,也不接受为位置。.、..,也没有结尾/。/当位置。Core 命令(
crates/workspace/src/trust.rs、crates/core的command.rs、dispatcher/remote.rs)remote.workspaceTrust { document, sessionId?, workspace? }(sessionId和workspace必须同时给):toolchains/remote-trust.json,上限 262144 字节)。workspaceTrust { state, workspace, location, offeredLocation, target }和projectCodeAllowed(等于state == "trusted")。remote.editWorkspaceTrust:decision { sessionId, workspace, trusted, location?, label? }记录一个决定。location: true会同时把offeredLocation加进受信任位置;trusted: false时带location,或没有可提供的位置时带location,都会被拒绝。revoke { target, list, path }删除一项,不需要连接目标主机。目标下的条目删空后,目标本身也删掉;删除不存在的项不算改动。{ changed, document, decisions }。没有改动时document为null,客户端不得因此创建文件。parse_failed,带details.field;主机返回的真实路径不规范也是parse_failed。invalid_request,带details.field。workspace_not_found,会话已关闭是connection_closed,都从远程调用原样透传。Connection在建立时保存trust_target;ContainerEngine::name改为pub(crate),供目标序列化使用。协议(
crates/remote/src/protocol/methods.rs、server/platform/mod.rs、contracts/remote-workspace-protocol-v1.md)server.hello的capabilities新增可选的userId(服务端进程的数字 uid)。缺少这个字段的旧服务端照常可用,只是目标里不带userId。持久会话测试在负载下超时(
rust/Cargo.toml)persistence的 12 个测试会成片失败。这是既有问题,43e3f27 上同样能复现。sha2开opt-level = 3:空闲 74 ms,满载 369 ms,persistence一轮从约 15 秒降到约 4 秒。release 构建不受影响。握手失败时的诊断(
crates/remote/src/client/session.rs)a_missing_server_reports_the_transport_output在 Linux 上三轮失败两轮。StderrTail(Mutex+Condvar)。握手失败时先等传输进程退出,再在同一个 2 秒宽限里等读到结尾。from_streams建立的会话,一开始就视为已结束。测试
client/trust.rs:8 个单测,覆盖目标归一(只保留决定落点的字段、取第一个选项)、精确匹配、显式决定优先于位置、根目录不作为位置、上限,以及各类无效文档。crates/core/src/tests/remote_sessions.rs:remote_workspace_trust_keys_the_host_real_path_on_the_connected_target走真实会话,覆盖这些情况:location时被拒绝(受信任位置的判定在client/trust.rs单测里覆盖);null文档;connection_closed;client/session.rs:读到结尾后内容完整;只保留最后 8 KiB,期限已过时立即返回。已知限制与后续
userId。升级后同一台主机的目标会多出userId,已有决定会重新询问一次。trustEveryWorkspace不作用于远程工作区;remote.workspaceTrust,不再拿本地占位根目录去查信任;projectCodeAllowed接进构建、运行、测试计划;--target x86_64-pc-windows-msvc的 clippy。信任逻辑不分平台,但远端服务只在 Unix 上运行。验证
rust:1.100-slim):cargo test --locked -p lithe-remote -p lithe-workspace --all-features连跑 3 轮全部通过;--test server连跑 10 轮全部通过;--test persistence连跑 2 轮全部通过;cargo clippy --locked -p lithe-remote -p lithe-workspace --all-targets --all-features -D warnings无告警。lithe-remote全部通过(单元 82 项,persistence 一轮约 3.2 秒);lithe-workspace22 项通过;lithe-core --lib remote55 项通过;lithe-core全部库测试 878 项通过(在两个 fix 提交之前运行;两个 fix 不涉及 core);--target x86_64-pc-windows-msvc对 remote、workspace、core、platform、platform-tests、git-host 运行 clippy,无告警。cargo fmt --all -- --check;scripts/rust-core/verify-rust-core-comments.sh检查 remote、workspace、core;node scripts/logging/generate-log-events.mjs --check(145 个事件,没有新增);node scripts/rust-core/verify-platform-tests.mjs;node --test scripts/rust-core/*.test.mjs(16 项);范围检查
rust/crates/remote/以外的改动和原因:rust/Cargo.toml:只为 dev profile 的sha2设置优化级别,修复测试超时。rust/crates/workspace/(trust.rs、sessions.rs、test_support.rs、lib.rs):Core 命令要通过会话解析目标和真实路径,会话表在这个包里;trust.rs只做请求解析和转调 remote 包。rust/crates/core/(command.rs、dispatcher/remote.rs、tests/remote_sessions.rs):登记两个命令和它们的端到端测试。rust/contracts/rust-core-api.md、rust/contracts/remote-workspace-protocol-v1.md:命令文档和userId字段。parse_failed、invalid_request、workspace_not_found、connection_closed,一码一义。toolchains/remote-trust.json),不写入主机、工作区或安装包,不影响代码签名和增量更新。