Repository navigation
feat(remote): 远程连接生命周期写入日志 v2(S34) - #136
Merged
Merged
Conversation
Lithe-IDEA#2231 S34:每次远程连接用随机连接 id 标识,按日志目录 记录连接、认证结果、上传与校验、部署、转发、中断和清理,不记录 主机、用户名、路径、远端输出、令牌或认证回答。 - client/connection_log.rs:ConnectionLog 跟踪一次连接,状态按 打开 → 关闭中 → 断开 → 释放推进,同一连接的每个结局只记一次; ended 区分 shutdown、lost、detached、closed。 - launch:安装步骤(mkdir/write/verify/rename)失败时记录分类, 部署结果区分上传与复用、sha256 与身份校验,上传时才记字节数。 - session:常驻会话记录 transport、persistent、resumed;读循环 结束时记录中断原因,Drop 时记录清理结果。 - forward:开始时记录本地端口、绑定范围和目标类型,移除时记录 接受的连接数和持续时间;转发失败事件带上连接 id。 - workspace/sessions.rs:探测结果映射为互不重复的失败分类 (probe/authentication/network/connect),取消不算失败。 - 日志目录 remote.json 新增对应事件并重新生成 catalog_generated.rs。 - 测试 tests/connection_log.rs:用 Core 的日志目录校验每条记录, 覆盖上传与复用、校验失败、常驻会话分离与恢复、远端被杀、端口 转发、握手失败、连接前取消,并断言记录里没有路径、HOME、用户名、 主机地址、令牌和远端输出。lithe-diagnostics 只作为 dev-dependency。
xiaoyumuxi
marked this pull request as ready for review
November 20, 2026 16:24
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 侧的连接日志部分,对应设计里的 S34,以及测试要求“日志里不出现秘密(S12、S34)”。连接安全部分已在 #134 合入。
类型
改动说明
代码改动集中在
rust/crates/remote/,没有新增 crate、没有挪动模块。必须改动的外部文件见下方“范围检查”。连接日志(
client/connection_log.rs,新文件)ConnectionLog::begin生成随机连接 id,所有事件只用这个 id 标识连接,不写主机、用户名、路径、远端输出、令牌或认证回答。连接 id 和用户起的连接名之间的对应由桌面端 R1 记录(ConnectRequest目前没有连接名)。outcome=cancelled的 finished 事件,不算失败。新增事件(
rust/logging/events/remote.json)remote.connection.connect(span:.started/.finished/.failed)remote.connection.shell_startedremote.server.deploy_finishedremote.connection.interruptedremote.connection.cleanedremote.forward.startedremote.forward.removed已有的
remote.forward.accept_failed、remote.forward.connection_failed增加可选的connection字段。catalog_generated.rs由node scripts/logging/generate-log-events.mjs重新生成。接线(
client/launch.rs、client/session.rs、client/forward.rs、failure_log.rs)launch多一个&ConnectionLog参数。安装按步骤(mkdir、write、verify、rename)区分,部署失败的error_code为install-mkdir、install-write、install-verify、install-rename、unsafe-<原因>等;握手失败只记stage=handshake和error_domain=remote,远端 stderr 不进日志。ConnectOptions新增可选的log。会话关闭时先标记为关闭中,读循环结束时才据此判断是不是中断;Drop时记录清理结果。failure_log钩子交给 Core 的helper_failures写入日志 v2,remote包仍不依赖 Core 的 crate。lithe-diagnostics只作为 dev-dependency,给测试校验日志目录。workspace 接线(
crates/workspace/src/sessions.rs)ProbeStatus映射成互不重复的失败分类(unsupported-platform、authentication-failed、host-key-rejected、unreachable、failed)。认证结果只记分类,不记回答内容;Core 自身的错误用ErrorCode的稳定名;取消不算失败。已知限制与后续
user@host,并在导出时处理。log/<name>.log)仍是eprintln!文本,不是日志 v2 事件,本 PR 没有迁移。rust/contracts/remote-workspace-protocol-v1.md仍未跟上 feat(remote): 远程连接安全(SSH 选项白名单、安装校验、会话令牌、日志轮转) #134(sessionToken、INVALID_SESSION_TOKEN、空闲规则、远端自算哈希),需要单独更新。验证
cargo test -p lithe-remote --all-features在最新 main(83a9f92)上连跑 3 轮全部通过,每轮 137 项:单元 68、connection_log 7、persistence 12、processes 8、run_directories 7、server 21、terminals 3、tunnels 6、watch_and_walk 5。测试结束后没有遗留lithe-remote-server进程。tests/connection_log.rs(7 项)用 Core 的日志目录(core_events::prepare)校验每条记录,覆盖:首次上传与再次复用的完整事件序列、SHA-256 不符时的install-verify失败、常驻会话分离后恢复再关闭、远端被 SIGKILL 记为中断、端口转发的端口与连接数、握手失败不带远端输出、连接前取消不算失败。每项都断言记录里没有/、HOME、用户名、127.0.0.1、令牌、密钥和远端输出。cargo test -p lithe-workspace:22 项通过(新增失败分类互不重复的测试);cargo test -p lithe-core helper_failures:2 项通过。cargo clippy --all-targets --all-features -D warnings,以及--target x86_64-pc-windows-msvc的 Windows lint,均无告警。cargo fmt --all -- --check、node scripts/logging/generate-log-events.mjs --check(145 个事件,remote 17 个)通过;提交前还跑过scripts/rust-core/verify-rust-core-comments.sh的 remote 和 workspace、node scripts/rust-core/verify-platform-tests.mjs、node --test scripts/rust-core/*.test.mjs(16 项)和测试稳定性检查,均通过。范围检查
rust/crates/remote/。必须改动的外部文件只有:日志目录rust/logging/events/remote.json、生成的rust/crates/diagnostics/src/catalog_generated.rs、rust/Cargo.lock(新增 dev-dependency),以及 workspace 的接线rust/crates/workspace/src/sessions.rs和rust/crates/workspace/src/probe/tests.rs。