Repository navigation
fix(safety): O127 L3 follows linked-worktree .git file (exec keys no longer missed) [depends #117 #122] - #124
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
QiaolongLi1201
force-pushed
the
fix/o127-linked-worktree-exec-keys
branch
from
October 12, 2026 05:52
acb8408 to
82eb0b4
Compare
…ig.worktree, name keys in last line
…cp remote.*.url by value (PM 口径)
…/merge (HEAD/refs judged by content)
…pace root) as an ancestor-delete target
…pace root (cd / and cd ~ still prompt)
…ir change QA B1: exemption checked only that the first cd operand was the workspace root, so `cd <ws> && cd && node x`, `cd <ws> && cd $HOME && node x`, and similar follow-up cd/pushd/popd/chdir (any operand) stayed silent. Count directory-changing builtins; allow the exemption only when there is at most one. Add P4 regression tests that go red when this guard is reverted.
QiaolongLi1201
force-pushed
the
fix/o127-linked-worktree-exec-keys
branch
from
October 12, 2026 06:18
82eb0b4 to
3ec69ed
Compare
QiaolongLi1201
added a commit
that referenced
this pull request
Oct 12, 2026
QiaolongLi1201
added a commit
that referenced
this pull request
Oct 12, 2026
QiaolongLi1201
added a commit
that referenced
this pull request
Oct 12, 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.
人工实现(不走自举)。O127,P1 safety。
根因
L3 快照
listWatchedProtectedPaths固定监视<cwd>/.git/...。在 linked worktree 里.git是文件(gitdir: <main>/.git/worktrees/<name>),这些路径都不存在,真正的共享 config(commondir)和本 worktree 的 config.worktree/HEAD 完全没进快照 →git config core.sshCommand / core.fsmonitor、config --worktree core.hooksPath改了都不报(实测[])。base 就有,QA 在 #117 复审 N1 发现。改法(
src/safety/protected-path-snapshot.ts)resolveGitDirs(ws):纯 fs 读.git文件 → gitdir →commondir,不在被测仓库跑 git。.git监视逻辑抽成watchGitDir(commonDir);linked 时额外监视.git文件本身、<gitdir>/config.worktree、<gitdir>/HEAD。.git文件 fail-closed:内容改写 →gitlink-rewritten「.git 被改写(worktree 的 gitdir 指向变了)」;gitdir/commondir 不存在或读不了 →gitlink-missing「.git 指向的 gitdir 不存在或读不了」;软链/目录/删除照旧报。.git/worktrees/<n>/HEAD归入 O123 HEAD 规则(内容合法的 commit/checkout 不报)。git config --file --no-includes临时目录解析、解析失败 fail-closed 全部沿用 O117,未放松;事前拦截(fix(safety): O103 pre-block dangling symlinks, curl/wget output, git core.hooksPath #115/O103,protected-paths.ts)未改。测试
test/o127-linked-worktree-exec-keys.spec.mjscore.sshCommand、core.fsmonitor、大小写变体CORE.FsMonitor、remote.origin.uploadpack→ 点名键;config --worktree core.hooksPath→ 报.git/worktrees/<n>/config.worktree;事前:hooksPath、直写 gitdir config.worktree、写.git文件都被findShellProtectedWrites拦。user.name/color.ui、git commit、checkout -b→ 静默。.git改写、gitdir 删除、共享 config 解析失败、.git换软链 → 报并写原因。moss -p(zh/en)在 worktree 里跑git config core.sshCommand …→ exit 9 点名键;git config user.name x→ exit 0。05d9c023)→ 15 failure(s)(共 27 项)。npm run check绿;npm test374 个文件全过。追加:自举 S2 误报(worktree 根目录「受保护路径被拦」)
Blocked: shell /workspace/selfhost-b1/s2-o74-deepseek-flash … (git repository internals),命令cd <worktree 根> && node --test … 2>&1 | tail -25。直调findShellProtectedWrites复现;主仓根目录同样复现,不是 linked worktree 特有,也不是事后快照。单纯git status/ls/cat .git/git log在 worktree 根跑(含-p)本来就不报。node <script>属于「拿不准」(脚本能写任何东西),于是逐个检查命令里提到的路径;cd的目标就是工作区根,被deletesProtectedAncestor(「删掉它就删掉 .git」)判成 git 内部 →-p直接拒。cd的目标从来不是写入对象。protected-paths.ts,最小改动):新增cdOnlyOperands:只出现在纯cd/pushd <dir>位置(无$/反引号/~)、命令其它地方没再出现的路径,在「拿不准」分支里跳过祖先删除规则;正常受保护分类(.git、.ssh、.env…)照旧。确定的写目标、O101 内联代码/脚本扫描、O103 hooksPath 都不变。cd <root> && node x.mjs <root>(含尾斜杠)、node x.mjs <root>、cd <root> && rm -rf <root>、> .git、cd <main>/.git && node x、node -e "rmSync('.git')"。cd && node …无命中)、P2、G3(-p在 worktree 根:git status、ls -la、cat .git、git log、cd <root> && git status、cd <root> && node ro.mjs、cd <root> && node --test … | tail→ exit 0,工具结果与输出无「被拦/已被修改」)。只撤protected-paths.ts→ 3 failure(s)(P1、G3 两条cd && node)。风险
--separate-git-dir、gitdir 不叫.git/...)下 config 路径不匹配isGitConfigPath,会退化成整文件报(更严,可能误报良性键),不会漏报。git config core.sshCommand等非 hooksPath 键本来就不拦(主仓也一样,O103 范围外),本单靠事后 exit 9 覆盖。/…/main/.git/config)。cd / && node x.mjs、cd ~/.. && node x这类 cd 到 home/工作区祖先再跑脚本,以前因「祖先删除」被拦,现在不拦(cd 本身不写;若路径在命令别处出现仍拦)。脚本内容仍由 O101 扫描层检查。10-12 PM 裁定补丁(
82eb0b43)cd/pushd豁免只在目标 realpath == 工作区根时生效。新增 P3:cd <工作区根> && node x不拦;cd / && node x、cd ~ && node x仍提示。撤此修复 → P3 红(cd /被放过)。