Skip to content

fix: 严格 review 的 R01–R10(路径扫描/正则误判、TEMP 回显错位、winget 清单、FastCtx 生命周期、后台退出码) - #34

Merged
KannaKuron merged 2 commits into
KannaKuron:mainfrom
KouzakiUmi:fix/strict-review-r01-r10
Oct 23, 2026
Merged

KannaKuron merged 2 commits into
KannaKuron:mainfrom
KouzakiUmi:fix/strict-review-r01-r10

Conversation

@KouzakiUmi

Copy link
Copy Markdown
Contributor

背景

对 dsh-gitbash-shell 全仓做了一轮严格 review(范围是当前全仓,不只增量),覆盖 19 个产品 JS 模块、组合/patch/包清单/发布脚本与相关测试,结论是 10 项确认问题:9 项 P2、1 项 P3,未确认 P0/P1。本 PR 是这些问题的修复。

修复基于 v0.42.2 / 5965fa7 重新 rebase,已吸收上游 dsh-ops 0.4.0 渐进加载的退避检测(OPS_PRESENCE_MARKERS)。

修复清单

编号 严重度 问题 修复
R01 P2 路径字面量扫描器把 ASI 后的合法正则误判成字符串并改写成 Windows 路径,静默改变程序语义 换行后的含混 slash 加整份 no-op 守卫,主扫描与模板插值共用;保留同一行除法与明确正则的原行为
R02 P2 pathEcho 的 whole-value 分支不要求真实 TEMP 根前缀,D:/backup/c/Temp/result.txt 被改写成 /d/backup/tmp/result.txt 只做从开头开始且有段边界的 TEMP 根映射;散文内嵌诊断另保留有边界逻辑
R03 P2 绝对 glob 拆分把 brace alternatives 拆散 把 brace alternatives 留在 pattern 中
R04 P2 native promotion 只检查 lossy,丢弃 chunks[].gapBefore,模型不知道输出有缺口 复用 renderJobRead,同时传播 lossy 与 gapBefore,附可用 spill 路径;Bash promotion 同类遗漏一并修正
R05 P2 winget export 用固定共享临时路径且静默吞异常 ⇒ 无法建立可信清单时仍可能启动安装 每次导出用 UUID 独立路径、只清理本次;检查退出码/JSON/清单结构;无法建立可信 inventory 时结成可见失败,不启动任何安装/升级
R06 P2 FastCtx 开关不可逆、代际所有权缺失、dispose 后可能晚 spawn、tools/call 可能被重放 分离用户开关/peer 让位/载荷不可用三种状态;publication/discovery/lazy connect 用代际所有权约束;异步 spawn 后重验 stopped;后端已发出的 tools/call 不自动重试
R07 P2 设置卡在 scope/ready 变化时沿用脏草稿,迟到的保存回包会误标新 scope scope/ready/镜像值变化时初始化干净草稿但保留用户 dirty 编辑;用 scope + 不透明 draft owner 绑定保存状态
R08 P2 命令扫描把同名目录当成命令(与 issue #31 同源但未覆盖符号链接与无扩展名场景) 默认目录 IO 用 Dirent,命令扫描排除同名目录,仅对候选符号链接检查文件目标
R09 P2 proc.exitCode ?? 0 把合法的 null 伪造成成功退出码,后台 Job 的 detail 显示 exit code: 0 保留 null,缺字段显示 unknown,真实 0/非零/kill 原样
R10 P3 typed native path 误拒合法百分号文件名 仅拒绝展开前缀,绝对路径内部 %/$/~ 保持数据语义

验证

  • npm test:323/323 通过,0 fail / skip / cancel(Windows / Node 24.13.0)
  • 新增三个回归文件:tests/review-core-regressions.mjs、tests/review-native-regressions.mjs、tests/review-native-preview.mjs,并扩充 tests/client-regressions.mjs 与 tests/bridge-regressions.mjs
  • 先红后绿:核心回归旧代码 11 fail、native 普通回归 19 fail、设置卡/桥回归 9 fail;修复后全绿,未降低任何已有断言
  • 全部产品 JS 与新增测试 node --check 通过,npm pack --dry-run --ignore-scripts 通过

rebase 中的一处实质判断

上游 OPS_PRESENCE_MARKERS 只列了 6 个名字(ops_inspect_local_file / ops_grep / ops_bash / ops_read_files / ops_result / ops_load_sdk),但实际 dsh-ops 环境有 10 个 ops_* 工具——ops_batch / ops_glob / ops_replace / ops_run 未收录。

R06 的代际检测原本用 startsWith('ops_')。合并时我采用前缀匹配 + 常量兜底:既覆盖上游关心的 0.4.0 三个常驻名,也覆盖列表尚未收录的名字,避免"后来调用者拿到一个从未在 face 1 常驻的名字"时漏检。上游那条断言 OPS_PRESENCE_MARKERS 内容的测试保留不变。

边界与未覆盖

  • 未操作生产 GUI、未安装/部署、未改生产 profile、未重启宿主
  • 真实受限 token/ACL/IPC 围栏、每个旧 Core、非 CRT 任意解释器、真实磁盘耗尽与跨任务 quota 仍未覆盖
  • winget 相关回归全部是受控 IO,未执行真实软件安装
  • R09 同时存在于 DSH 官方 tool-bash(app.asar 偏移 86825519 处同样为 exit code: ${proc.exitCode ?? 0}),本 PR 只修插件侧镜像,官方侧另行报告

关联

…and fastctx bridge

- R01/R02: path literal scanner no-op guard, TEMP root whole-value mapping
- R03: keep brace alternatives in absolute glob patterns
- R04: native promotion propagates lossy and gapBefore with spill path
- R05: winget inventory uses per-export UUID paths and verifies structure
- R06: fastctx bridge separates user switch, peer yield and payload states
- R07: settings card resets clean draft on scope/ready changes
- R08: default directory IO uses Dirent and excludes same-name dirs
- R09/R10: background outcome null preservation, typed native path percent signs

Tests: review-core-regressions, review-native-regressions, review-native-preview added.
Copilot AI balanced review requested due to automatic review settings October 22, 2026 21:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

成功保存后的草稿仍保持 dirty,后续配置更新会被忽略,再次保存可能覆盖新配置。

1 open issue
What changed in this PR

本 PR 修复 Git Bash 插件严格审查中确认的 R01–R10 问题,涵盖路径处理、工具生命周期、安装清单与执行结果展示。

Changes:

  • 修正路径扫描、TEMP 回显、glob 拆分及命令文件识别。
  • 加固 FastCtx 开关与异步生命周期、winget 清单读取和设置草稿同步。
  • 保留输出缺口与退出码事实,并新增普通回归和真实 Core 预览用例。
File Description
tests/​review-native-regressions.mjs 覆盖输出缺口、退出码和原生路径回归。
tests/​review-native-preview.mjs 新增真实 Core 输出与路径验证。
tests/​review-core-regressions.mjs 覆盖扫描、路径、winget 和 Bash 回归。
tests/​client-regressions.mjs 验证草稿同步与迟到保存响应。
tests/​bridge-regressions.mjs 验证 FastCtx 开关、取消和禁止重放。
src/​toolchain.js 区分命令文件、目录和符号链接。
src/​tool-runner.js 使用独立导出清单并在读取失败时阻止安装。
src/​native-tool.js 在后台提升时保留输出缺口提示。
src/​native-executor.js 允许绝对路径中的字面百分号。
src/​index.js 修正正则识别、TEMP 回显和 glob 拆分。
src/​fastctx-bridge.js 加入代际所有权及实时开关检查。
src/​client.js 按 scope 和草稿所有权管理同步与保存状态。
src/​bash-tool.js 在后台提升时呈现 chunk 缺口。
src/​bash-render.js 保留 null 退出码,缺失值显示 unknown。
package.json 将新增回归与预览文件接入测试脚本。
CHANGELOG.md 记录修复、验证结果及覆盖边界。

Review effort: Balanced

Comment thread src/client.js Outdated
Add 'dirty' state management to bash draft saving logic.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 21:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@KannaKuron
KannaKuron merged commit 54c15f9 into KannaKuron:main Oct 23, 2026
4 checks passed
@KannaKuron

Copy link
Copy Markdown
Owner

Reviewed all ten fixes against the branch — merged as-is. Verified locally (323 tests, 322 pass + 1 platform-gated skip on macOS, matching your Windows run). The prefix-matching decision in R06 is accepted as the conservative bias: standing down gb_* on any ops_* name can only under-publish a duplicate file surface, never corrupt one. Thanks for the red-to-green discipline and the honest null handling in R09 — we will track the upstream tool-bash report and mirror the fix when it lands.

@KouzakiUmi
KouzakiUmi deleted the fix/strict-review-r01-r10 branch October 23, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants