Skip to content

fix(tooling): anchor the Biome worktree exclusion so lint runs inside a worktree (#444) - #445

Merged
ceilf6 merged 4 commits into
developfrom
fix/biome-worktree-root-lint
Aug 2, 2026
Merged

fix(tooling): anchor the Biome worktree exclusion so lint runs inside a worktree (#444)#445
ceilf6 merged 4 commits into
developfrom
fix/biome-worktree-root-lint

Conversation

@ceilf6

@ceilf6 ceilf6 commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Linked Issue Or Context

Summary

  • biome.json: !!**/.claude/worktrees!!.claude/worktrees.

Biome matches the traversal root by absolute path, so a **/-prefixed pattern also matches the worktree itself when Biome runs from inside one. pnpm lint there reported Checked 0 files and exited 1 — the gate looked like it ran and failed without having inspected a single file, and pre-commit / pre-push went down with it. That is the same class of misdirection #439 was opened about, in the opposite direction.

Anchoring keeps the original direction intact: from the root checkout Biome still refuses to descend into a nested worktree, so its nested root biome.json no longer aborts the run.

Rejected alternative: !!**/.claude/worktrees/** also works, but Biome's own lint/suspicious/useBiomeIgnoreFolder warns on it and its safe fix rewrites it back to the broken form — pnpm lint:fix would silently reinstate the bug.

.gitignore deliberately keeps **/: git has no equivalent reverse failure, so it can afford to also cover a worktree created under a subdirectory's .claude/. The stale comment claiming the two patterns are aligned is corrected to say why they now differ.

Impact Scope

  • biome.json — one files.includes entry.
  • .gitignore — comment only, no rule change.
  • scripts/tests/workflow-rules.test.mjs — tightened the existing config assertion, added one behavioural test.
  • CHANGELOG.md[Unreleased] → Fixed.

No application code. Blast radius is the local gates plus CI's pnpm lint step.

GitNexus Impact Summary

  • Risk level: LOW
  • Critical skeleton changes: none — classifyContractPaths returns no critical entry for this diff (repo-harness covers .github/workflows/, .claude/workflows/, .claude/skills/, .githooks/, scripts/workflows/; scripts/tests/ is only a test pattern). Contract Guard is advisory here by its own rules.
  • GitNexus impact: detect_changes reports no symbol-level change — the diff is one config value, one comment block, one changelog entry, and test-only code. context on the touched surface finds no importer: biome.json is read by the Biome binary, not by repo code, and the new test's only in-repo dependency is node_modules/.bin/biome. There is no call graph to trace, so no impact query applies.
  • Verification: pnpm quality:precommit (lint / typecheck / test / test:workflows) and the full pnpm quality:local pre-push gate both passed from inside a worktree — which is itself the fix under test; on develop the same command exits 1 at biome check ..

Verification

Both directions are pinned by biome ignores a nested worktree from the root but still checks one from inside, which runs the real binary against a synthetic project root in a temp dir. It asserts on which run reports a planted noDoubleEquals error, not on a file count — a count would also be satisfied by Biome checking only the config files.

Falsification: restoring !!**/.claude/worktrees fails 2 tests (the behavioural one and the tightened config assertion); dropping the exclusion entirely reproduces #439's nested-root-configuration abort.

Manual: biome check . from inside the worktree — 422 files before/after the fix vs. Checked 0 files + exit 1 on develop.

The test skips on Windows (shim name differs) and when node_modules/.bin/biome is absent; CI's check job runs it on Linux after pnpm install.

Checklist

  • I have linked an issue or explained why this PR stands alone.
  • I have kept the diff focused on the stated change.
  • I have run pnpm quality:precommit, or explained why it could not run.
  • I have run pnpm quality:local for critical skeleton changes, or explained why it could not run.
  • I have updated docs or tests when behavior, public APIs, or Harness contracts changed.
  • For critical skeleton changes, I have filled the GitNexus impact summary with concrete results.

#439's exclusion was `!!**/.claude/worktrees`. Biome matches the traversal root
by absolute path, so when Biome runs *from* a worktree under that path the root
matches its own exclusion: `biome check .` reports "Checked 0 files", exits 1,
and takes pre-commit and pre-push with it. The gate looks like it ran and failed
without having inspected a single file — the same class of misdirection #439 was
opened about.

Anchoring the pattern (no `**/`) keeps the original direction working: from the
root checkout Biome still refuses to descend into a nested worktree, so its
nested root biome.json no longer aborts the run. Reverting either half fails the
tests below.

Biome's own `useBiomeIgnoreFolder` rules out the other candidate fix,
`!!**/.claude/worktrees/**`: it works, but Biome warns on it and its safe fix
rewrites it back to the broken form, so `pnpm lint:fix` would silently reinstate
the bug.

`.gitignore` keeps `**/` on purpose — git has no equivalent reverse failure, so
it can afford to also cover a worktree created under a subdirectory's `.claude/`.
The two patterns are now deliberately different and say so.

Adds a behavioural test that runs the real binary against a synthetic project
root in a temp dir, asserting both directions from the traversal evidence
(which run reports the planted error) rather than from a file count.

Refs #444

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 2, 2026 08:43

Copilot AI left a comment

Copy link
Copy Markdown

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ ceilf6/repo-guard

代码评审报告: fix(tooling): anchor the Biome worktree exclusion so lint runs inside a worktree (#444)

风险等级:
处理建议: 评论
决策摘要: 修复方向正确、证据充分(行为测试跑真实 biome 二进制并同时钉住两个方向),可以合并;合并前只需确认 CI 的 pnpm lint 对新测试的调用排版为绿,并明确「子目录 worktree 不再被 biome 排除」这一有意的覆盖收窄。

级联分析

  • 变更符号: 无代码符号。biome.json files.includes[15].gitignore 注释块、workflow-rules.test.mjs 两处测试。
  • 受影响流程: pnpm lint / lint:fix / formatbiome check .)→ quality:precommitquality:ci.github/workflows/ci.yml:28)、pre-commit / pre-push 钩子;pnpm test:workflowspackage.json:40)新增一个会真实 spawn biome 的用例。
  • 变更集外调用方: 无。全仓文本搜索 \.claude/worktrees 只命中 biome.json:62.gitignore:60、本测试文件与 CHANGELOG,无文档/skill/hook 中的过期 !!**/.claude/worktrees 引用 (text search)。@biomejs/biome 是根 devDependency(package.json:78),因此 CI pnpm installnode_modules/.bin/biome 存在,新测试在 Linux CI 上会真实执行而不是静默 skip (已核对)。
  • 置信度: medium(无代码图谱可用,结论基于 checkout 内文件核对与文本搜索;无法在此环境执行 biome 验证运行时行为)

问题发现

  1. [中] biome 侧对子目录下的 worktree 失去排除,#439 在该位置可复发,且文档未说明

    • 证据: .gitignore:55-57 的新注释明确保留 **/ 的理由是「在子目录里启动 Claude Code 时 worktree 会落在该子目录的 .claude/ 下」;而 biome.json:62 改为锚定后只覆盖仓库根。两处依据互相矛盾——issue #444 的理由是「该目录只可能出现在仓库根」,.gitignore 注释则说它可能出现在子目录。若 worktree 落在 packages/*/.claude/worktrees/,从根跑 biome check . 会重新命中 #439 的 nested-root-configuration 中止(.gitignore 对此无能为力:biome 不读 .gitignore,这正是 #439 记录的结论)。
    • 受影响调用方/流程: 根检出下的 pnpm lintquality:precommit / quality:ci / pre-commit / pre-push。
    • 最小可行修复: 不改模式(现有取舍是对的:**/ 的反向失效更严重,!!**/.claude/worktrees/** 会被 useBiomeIgnoreFolder 的 safe fix 改回坏形式)。在 biome.json 旁的注释或 CHANGELOG 里补一句「子目录下的 worktree 不在 biome 排除范围内,仍会触发 #439」,并把两处注释与 #444 的「只可能出现在仓库根」表述统一;如判断子目录场景真实存在,另开 follow-up。
  2. [低] 新测试的调用参数排版可能不是 Biome 的输出形态,需靠 CI lint 确认

    • 证据: scripts/tests/workflow-rules.test.mjs:558-560 写成 test('…', {\n skip: …,\n}, () => {。第二个参数是会硬换行的对象字面量、最后一个参数才是函数,这不属于 Prettier/Biome 识别的 test-call 形态(要求第二参为函数),last-argument hugging 通常会因非末位参数强制换行而回退为全参数展开。全仓仅此一处这种排版(scripts/workflows/contract-check.mjs:254 是对象作为末位参数的合法 hug)。我在此环境无法执行 biome,无法给出确定结论。
    • 受影响调用方/流程: pnpm lint → 整个 quality:ci(若命中,PR 会让 CI 红,且讽刺地卡在它要修的那道门禁上)。
    • 最小可行修复: 在分支上跑一次 pnpm lint;若报格式差异,按 biome format --write 的输出(全参数展开)提交,或改用条件 test.skip 避免 options 对象。CI 绿则本条作废。

行级发现

  • [biome.json:62] 锚定后只覆盖仓库根的 .claude/worktrees.gitignore:55-57 的新注释同时声称 worktree 可能落在子目录的 .claude/ 下——请在此处(或 CHANGELOG)明确子目录 worktree 仍会触发 #439 的 nested-root-config 中止,别让读者以为两条规则等价保护。
  • [scripts/tests/workflow-rules.test.mjs:558] test(name, {…}, fn) 的中间对象参数排版很可能不是 Biome 的格式化输出(本仓无同形先例),会让 pnpm lint 失败;跑一次 pnpm lint 确认,必要时采用 biome format --write 的全参数展开写法。

Karpathy 评审

  • 假设: 关键假设「biome 按绝对路径匹配遍历根」已被行为测试固化,不再只存在于注释里,这点做得好。未言明的假设是「worktree 只会出现在仓库根」——它与 .gitignore 注释冲突(发现 1)。
  • 简洁性: 一行配置改动 + 一个行为测试,没有引入抽象、flag 或间接层。拒绝 !!**/.claude/worktrees/** 的理由(lint:fix 的 safe fix 会把 bug 写回来)是有价值的、可验证的取舍记录。
  • 结构质量: 无退化。测试文件 801 行,未跨 1000 行边界;新用例自带 setup/teardown(finallyrmSync),不污染仓库;复用真实 biome.json 而非手写 stub 是正确选择。
  • 变更范围: 完全对齐 #444,无夹带重构或格式噪声。CHANGELOG 与既有条目风格一致。
  • 验证: 强于变更风险。行为测试同时钉住 #439(根不下钻)与 #444(worktree 内仍检查),且断言的是「哪一次运行报出 noDoubleEquals」而非文件计数——这排除了「只检查了配置文件」的假阳性。配置形状断言在二进制缺席/Windows 上仍生效,是合理的双层防护而非重复。作者给出的证伪路径(还原 **/ 挂 2 个测试)可信。

缺失覆盖

  • 子目录 worktree(如 packages/x/.claude/worktrees/b)从根运行 biome check . 的行为无覆盖:要么加一个断言其当前行为(会中止)并标注为已知限制,要么在注释中声明该场景不受支持。
  • 无(也不必要)覆盖 skip 分支;但请确认 CI 日志中该用例确实是 pass 而非 skip——node --test 的 skip 不会让 test:workflows 变红,这道新门禁的价值完全依赖它在 CI 上真实执行。

Comment thread biome.json
"!!**/docs",
"!!**/benchmarks",
"!!**/.claude/worktrees"
"!!.claude/worktrees"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

锚定后只覆盖仓库根的 .claude/worktrees.gitignore:55-57 的新注释同时声称 worktree 可能落在子目录的 .claude/ 下——请在此处(或 CHANGELOG)明确子目录 worktree 仍会触发 #439 的 nested-root-config 中止,别让读者以为两条规则等价保护。

// (#444). Skipped when the binary is absent (no `pnpm install`) or on Windows,
// where the shim name differs — CI runs this on Linux.
const biomeBin = join('node_modules', '.bin', 'biome');
test('biome ignores a nested worktree from the root but still checks one from inside', {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

test(name, {…}, fn) 的中间对象参数排版很可能不是 Biome 的格式化输出(本仓无同形先例),会让 pnpm lint 失败;跑一次 pnpm lint 确认,必要时采用 biome format --write 的全参数展开写法。

repo-guard on #445: the .gitignore comment justifies keeping `**/` by saying a
worktree can land under a subdirectory's .claude/, while #444 argues the
anchored Biome pattern is fine because it only lands at the repo root. Both
cannot be true, and a reader could take the two rules for equivalent protection.

The narrower Biome coverage is a known limitation, not an oversight: a
subdirectory worktree still trips #439's nested-root-configuration abort from a
root `biome check .`. Recording that, with the workaround and with why neither
alternative pattern is available.

Refs #444

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ceilf6

ceilf6 commented Aug 2, 2026

Copy link
Copy Markdown
Owner Author

repo-guard 的两条都已处理:

发现 1(中,文档矛盾) — 已在 7c44e91 记录。两条规则确实不等价,.gitignore 与 CHANGELOG 现在都明说:子目录下的 worktree 只被 git 忽略,从仓库根跑 biome check . 仍会撞上 #439 的 nested-root-configuration 中止;这是已知限制,规避方式是把 worktree 移回仓库根的 .claude/worktrees/。同时写下了为什么两个替代模式都不可用(**/ 的反向失效更严重;!!**/.claude/worktrees/** 会被 biome 自己的 useBiomeIgnoreFolder safe fix 改回坏形式,pnpm lint:fix 一跑就把 bug 写回来)。没有改模式本身——评审也认为现有取舍是对的。

发现 2(低,排版) — 已作废。pnpm lint 在分支上是绿的(check (20) / check (22) 均 pass),test(name, {…}, fn) 这个形态就是 biome format --write 的输出:提交前跑过一次 biome check --write,它只调整了这段的缩进,没有强制展开。

「确认是 pass 而非 skip」 — 已核对 CI 日志(run 30740333031),两个 node 版本上都是真实执行:

check (20)  ok 29 - biome ignores a nested worktree from the root but still checks one from inside
check (22)  ok 29 - biome ignores a nested worktree from the root but still checks one from inside

不带 # SKIP 标记,node_modules/.bin/biome 在 CI 的 pnpm install 之后确实存在。

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ ceilf6/repo-guard

代码评审报告: fix(tooling): anchor the Biome worktree exclusion so lint runs inside a worktree (#444)

风险等级:
处理建议: 请求修改
决策摘要: biome 锚定修复本身正确、有行为级测试覆盖,可以合并;但这个 PR 同时提交了 .gitnexus/lbug.gitnexus/meta.json 的索引漂移(+146/−121),这与仓库自己的文档规则冲突且不在声明范围内,去掉这两个文件后即可合入。

级联分析

  • 变更符号: 无代码符号。biome.jsonfiles.includes 一项(!!**/.claude/worktrees!!.claude/worktrees,biome.json:62)、.gitignore 注释、scripts/tests/workflow-rules.test.mjs 新增断言与一个行为测试、CHANGELOG 一条、.gitnexus/* 生成物。
  • 受影响流程: pnpm lint / pnpm lint:fix(package.json:35-36)→ .githooks 的 pre-commit / pre-push → CI pnpm quality:ci(.github/workflows/ci.yml:28,含 pnpm test:workflows,因此新行为测试会在 Linux + pnpm install 后真实执行)。
  • 变更集外调用方: biome.json 只被 biome 二进制读取,仓库内无 importer(grep 确认除测试外无引用);turbo test 按 workspace 包运行,不会被嵌套 worktree 波及;.gitnexus/* 由 gitnexus 工具与本地 agent 消费。仓库内没有其它工具配置排除 .claude/worktrees(全仓 grep worktrees 仅命中本次测试、contract-check.mjs:89 的提示文案和历史 plan 文档)。
  • 置信度: medium — 配置、CI、脚本、文档均已在 checkout 中读过;但本环境无法执行 biome,"遍历根按绝对路径匹配" 这一核心机制依赖 issue #444 的实测记录和作者报告的门禁运行,属 (inferred/作者证据),未由我复算。

问题发现

  1. [中] .gitnexus/* 索引漂移超出 PR 声明范围,且与仓库明文规则冲突

    • 证据: diff 含 .gitnexus/meta.json +146/−121 与二进制 .gitnexus/lbugdocs/knowledge-contract.md:65-70 写明「contributors should not include index-only churn in ordinary PRs… Only commit .gitnexus/* changes when the task explicitly refreshes the repository knowledge base, changes the Harness/GitNexus contract, or a maintainer requests a canonical index update」,docs/oss-harness-engineering-workflow.md:134 同义。本 PR 三者都不属于。PR 的 Impact Scope 只列了 4 个文件并写「No application code」,完全没有提到这两个文件,与实际 6 文件的变更集不符。另外 .gitnexus/meta.json:2 把共享种子索引的 repoPath/Users/a86198/Desktop/FrontAgent 改成 /Users/a86198/Desktop/resume/refs/FrontAgent/.claude/worktrees/biome-worktree-lint —— 指向一个用完即弃的 worktree 目录,作为仓库内 canonical seed 比原值更差。(索引内容本身与当前树一致:抽查 packages/core/src/filesense/path-grounding.tsbenchmarks/eval/tasks-deep.json 均存在,所以问题是范围与规则,不是内容错误。)
    • 受影响调用方/流程: 使用仓库种子索引的本地 code intelligence 与 agent 流程;以及 review 可读性(267 行生成物淹没了 4 行真实变更)。
    • 最小可行修复: 从本 PR 撤掉这两个文件(git restore --source=origin/develop -- .gitnexus 后 amend/push),其余不动。
  2. [低] 行为测试隐式依赖 noDoubleEquals 规则保持启用,失效时会给出误导性失败

    • 证据: scripts/tests/workflow-rules.test.mjs:568-577 把真实 biome.json 复制进临时工程,再用 /noDoubleEquals/u 判定「谁检查了 worktree」(:585-589、:598-602)。若日后有人在 biome.jsonsuspicious 段关掉 noDoubleEquals(该段已经关了 5 条规则),worktree 那次运行不再输出该规则名,测试会以 worktree contents must still be checked (#444) 失败 —— 但遍历行为其实完好。这正是 #439/#444 抱怨的那类「报错指向错误的原因」。
    • 受影响调用方/流程: pnpm test:workflows(本地门禁与 CI check job)。
    • 最小可行修复: 在断言前先从已解析的 biomeConfig 确认该规则未被禁用(现成的 biomeConfig 变量在同文件 :526 已有先例),或改用测试自己固定的规则配置作为探针,让规则被关闭时以明确信息失败。

行级发现

  • [.gitnexus/meta.json:2] 共享种子索引的 repoPath 被写成一次性 worktree 的本机绝对路径;这两个 .gitnexus/* 文件应整体退出本 PR,而不是就地改回旧路径。
  • [scripts/tests/workflow-rules.test.mjs:598] 该断言把「worktree 被遍历」等同于「输出里出现 noDoubleEquals」;先断言复制进 fixture 的配置确实启用了这条规则,否则规则被禁用时会伪装成 #444 回归。

Karpathy 评审

  • 假设: 核心假设「biome 对遍历根按绝对路径匹配、对显式子路径按相对路径匹配」已在 issue #444 中实测并由 :558-606 的行为测试固化,未留在注释层面。被接受的已知限制(子目录下的 worktree 只被 git 忽略、仍会触发 #439 中止)在 .gitignore:60-65 与 CHANGELOG:18 明确写出,没有伪装成等价保护。
  • 简洁性: 修复是单个配置值,方向正确;被否掉的 !!**/.claude/worktrees/** 连同 useBiomeIgnoreFolder safe fix 会写回坏形式的理由也记录在案。唯一多余处是同一段论证现在存在三份(.gitignore:55-65、CHANGELOG.md:18、测试注释 :550-556),模式再变一次就要同步三处;不构成阻塞。
  • 结构质量: 无新增分支、wrapper 或抽象层;测试新增的是一个自包含、临时目录内自清理(:603-605 finally)的用例,没有污染既有 helper。workflow-rules.test.mjs 已超 800 行,但本次增量有清晰的用例边界,不构成新的拆分要求。
  • 变更范围: 4 个文件符合目标;.gitnexus/lbug.gitnexus/meta.json 属于范围外的生成物漂移(见发现 1),且 PR 正文的 Impact Scope 未如实包含它们。
  • 验证: 行为测试同时钉住两个方向,并刻意避开文件计数这一会被「只检查了配置文件」满足的弱证据,取证方式合理;CI 在 Linux 上带 pnpm install 运行,跳过条件(Windows / 无二进制)不会掩盖 CI 覆盖。作者声称的证伪路径(还原 **/ 使 2 个测试失败)我无法在本环境复算。

缺失覆盖

  • 已知限制「子目录 .claude/worktrees 不在 biome 排除范围」没有任何断言或探测:若未来 biome 改变匹配语义使该限制消失或恶化,仓库不会有信号。可选补一条记录当前语义的测试或在 issue 中登记跟踪。
  • 无二进制时 pnpm test:workflows 会静默跳过该行为测试,本地门禁在未 pnpm install 的环境下不构成保护;CI 已覆盖,属可接受的剩余风险,但值得知晓。
  • 本次评审未能执行 biome,!!.claude/worktrees 在根检出方向仍然阻断嵌套配置(#439)这一点,最终依赖 CI 的 check job 结果确认。

Comment thread .gitnexus/meta.json Outdated
"repoPath": "/Users/a86198/Desktop/FrontAgent",
"lastCommit": "51fd4bbaf69ea926cd670f6708dbbbc6b5b52327",
"indexedAt": "2026-07-12T08:26:27.526Z",
"repoPath": "/Users/a86198/Desktop/resume/refs/FrontAgent/.claude/worktrees/biome-worktree-lint",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

共享种子索引的 repoPath 被写成一次性 worktree 的本机绝对路径;这两个 .gitnexus/* 文件应整体退出本 PR,而不是就地改回旧路径。

const worktreeOutput = `${fromWorktree.stdout}${fromWorktree.stderr}`;
// With a `**/` pattern this run reports "Checked 0 files" and exits 1 —
// the gate looks like it ran and failed, without inspecting anything.
assert.match(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

该断言把「worktree 被遍历」等同于「输出里出现 noDoubleEquals」;先断言复制进 fixture 的配置确实启用了这条规则,否则规则被禁用时会伪装成 #444 回归。

… rule

repo-guard on #445, both findings.

The .gitnexus/* churn was swept in by a blanket `git add -A`: the pre-push
gate runs `gitnexus analyze`, which rewrites the index and stamps `repoPath`
with wherever it ran — here a throwaway worktree, a strictly worse value for a
committed seed index than the one on develop. docs/knowledge-contract.md
reserves `.gitnexus/*` commits for tasks that explicitly refresh the knowledge
base; this is not one. Restored from develop, so the PR's net diff no longer
touches them.

The behavioural test reads "did biome traverse here?" off a planted
noDoubleEquals diagnostic. Disabling that rule — the `suspicious` group already
disables five — would make the worktree run report nothing and fail with
"worktree contents must still be checked (#444)", blaming traversal for a config
edit. That is the misdirected-error failure mode both #439 and #444 were opened
about. It now fails on the real cause, naming the rule and the fix.

Refs #444

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ceilf6

ceilf6 commented Aug 2, 2026

Copy link
Copy Markdown
Owner Author

两条都已处理(e1d9f2c),PR 净 diff 回到声明的 4 个文件。

发现 1(中,.gitnexus/* 越界) — 确认是我的错误:pre-push 门禁会跑 gitnexus analyze,它重写索引并把 repoPath 盖成运行目录(这里是一个用完即弃的 worktree,作为提交进仓库的种子索引比 develop 上的值更差),而我用了一次性的 git add -A 把它扫了进来。docs/knowledge-contract.md:65-70 明确只在显式刷新知识库时才提交 .gitnexus/*,本 PR 不属于。已 git restore --source=origin/develop -- .gitnexus,两个文件退出本 PR;Impact Scope 无需修改,它现在与实际变更集一致。

发现 2(低,探针规则) — 已修。测试用「有没有报出 noDoubleEquals」判定 biome 是否遍历过 worktree;这条规则一旦被关掉(suspicious 段已经关了 5 条),worktree 那次运行不报任何东西,测试会以 worktree contents must still be checked (#444) 失败,把一次配置改动说成遍历回归——正是 #439/#444 抱怨的「报错指向错误原因」。现在先从 biome.json 断言该规则未被禁用,失败信息直接点名规则与修法。

证伪已验证:把 noDoubleEquals 置为 off,测试以新断言的信息失败,而不是以误导性的遍历信息失败。

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ ceilf6/repo-guard

代码评审报告: fix(tooling): anchor the Biome worktree exclusion so lint runs inside a worktree (#444)

风险等级:
处理建议: 评论
决策摘要: ** 可以合并——修复与 issue #444 提出的方案一致、方向正确,且由一个跑真实 biome 二进制的双向行为测试兜底;剩余问题都是注释与守卫的健壮性,不阻塞。

级联分析

  • 变更符号: 原始模型未提供结构化级联字段。
  • 受影响流程: 原始模型未提供结构化级联字段。
  • 变更集外调用方: unknown
  • 置信度: degraded

问题发现

  1. [低] 探针守卫只识别字符串形式的规则关闭
    • 证据: scripts/tests/workflow-rules.test.mjs:568-573assert.notEqual(linterRules?.suspicious?.noDoubleEquals, 'off') 保护「用 noDoubleEquals 当遍历探针」这一前提。Biome 同时支持对象形式 {"level": "off"},也支持用 suspicious.recommended: false 或顶层 recommended: false 关闭整组。这三种写法都能绕过守卫。
    • 受影响调用方/流程: 只影响本测试的失败信息质量。绕过后行为测试仍会失败,但报的是 worktree contents must still be checked (#444),正是这个守卫想避免的误导性错误——和 #439/#444 的失败模式同构。
    • 最小可行修复: 归一化后再断言,例如取 typeof rule === 'string' ? rule : rule?.level,必要时一并断言 linterRules?.recommended !== false
  2. [低] 被否决方案的结论以事实口吻写进注释,但没有测试覆盖
    • 证据: .gitignore:63 断言 !!**/.claude/worktrees/**「两边都成立」,只因 useBiomeIgnoreFolder 的 safe fix 会改回坏形式才被否决。falsification 只覆盖了 !!.claude/worktrees!!**/.claude/worktrees 两种形式;/** 后缀形式没有断言保护。若该结论有偏差(/** 后缀在按绝对路径匹配遍历根时可能同样命中),后来的维护者会据此重新引入 #444
    • 受影响调用方/流程: 未来对 biome.json 排除规则的修改决策。
    • 最小可行修复: 把措辞降为「实测于 biome 2.4.16」或直接说明未纳入回归覆盖;更彻底的做法是在行为测试里加一轮该形式的断言。
  3. [低] 同一份理由复制在四处,而本 PR 修的正是它上一次漂移
    • 证据: .gitignore:53-65scripts/tests/workflow-rules.test.mjs:531-535、同文件 550-556CHANGELOG.md:18 各自完整复述了「biome 锚定 / git 保留 **/」的推理。PR 描述里明确写到「stale comment claiming the two patterns are aligned is corrected」——上一版正是因为同样的复述而与实现脱节。
    • 受影响调用方/流程: 后续修改该排除规则时的注释同步成本。
    • 最小可行修复: 保留 .gitignore 里 2-3 行结论 + 指向 #444 与行为测试,把完整推导只留在测试注释这一处。属于取舍建议,不必在本次合并前处理。

行级发现

  • [scripts/tests/workflow-rules.test.mjs:570] 守卫只比对字符串 'off'{"level": "off"}suspicious.recommended: false 都能绕过并让下方行为断言报出误导性失败;归一化取 level 后再断言。
  • [.gitignore:63] !!/.claude/worktrees/`「两边都成立」这一结论没有回归测试覆盖,却写成了后人可直接采纳的事实;建议限定为特定 biome 版本的实测结论,或补一条断言。

Karpathy 评审

  • 假设: 模型输出需要归一化为固定 Markdown 契约。
  • 简洁性: 已提取 summary、finding、evidence 与 fix;原始 prose 不再附在评论中,避免占用下游解析与代理上下文。
  • 变更范围: 原始模型未提供结构化范围字段。
  • 验证: 需要查看 CI、测试或人工 CR 证据补强合并信心。

缺失覆盖

  • 输出未命中 Repo Guard Markdown 契约;建议补充真实模型质量评估覆盖。

Comment thread scripts/tests/workflow-rules.test.mjs Outdated
// this is not a hypothetical edit.
const linterRules = JSON.parse(readFileSync('biome.json', 'utf8')).linter?.rules;
assert.notEqual(
linterRules?.suspicious?.noDoubleEquals,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

守卫只比对字符串 'off'{"level": "off"}suspicious.recommended: false 都能绕过并让下方行为断言报出误导性失败;归一化取 level 后再断言。

Comment thread .gitignore Outdated
# 子目录下的 worktree(如 packages/x/.claude/worktrees/b)只被 git 忽略,不在
# biome 的排除范围内——从仓库根跑 `biome check .` 仍会撞上 #439 的
# nested-root-configuration 中止。已知限制,不是疏漏:`**/` 的反向失效(worktree
# 里所有门禁全灭)比它更严重,而 `!!**/.claude/worktrees/**` 虽然两边都成立,却会

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

!!/.claude/worktrees/`「两边都成立」这一结论没有回归测试覆盖,却写成了后人可直接采纳的事实;建议限定为特定 biome 版本的实测结论,或补一条断言。

…-pattern claim

repo-guard on #445, both low findings.

The probe guard only recognised the string form `"off"`. Biome also accepts
`{ level: "off" }` and dropping the recommended preset at either the group or
the linter level; all three slipped past it and left the behavioural assertion
to fail with "worktree contents must still be checked (#444)" — blaming
traversal for a config edit, the exact misdirection the guard exists to prevent.
Normalised, and each bypass verified to fail on the guard instead.

The .gitignore comment stated as fact that `!!**/.claude/worktrees/**` satisfies
both directions. That was measured, not covered by a test — the falsification
path only exercises the anchored and `**/`-prefixed forms. Marked as a
biome 2.4.16 measurement to re-verify on upgrade, so a later maintainer does not
adopt it as a settled conclusion and reintroduce #444.

Refs #444

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ceilf6
ceilf6 dismissed github-actions[bot]’s stale review August 2, 2026 10:21

Superseded: e1d9f2c 撤掉了越界的 .gitnexus 生成物并修了探针守卫;repo-guard 在 e1d9f2c 上的复审结论为「可以合并」,6483e7b 又补完了其余两条低风险项。

@ceilf6
ceilf6 merged commit 74fcf53 into develop Aug 2, 2026
8 checks passed

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ ceilf6/repo-guard

代码评审报告: fix(tooling): anchor the Biome worktree exclusion so lint runs inside a worktree (#444)

风险等级:
处理建议: 评论
决策摘要: 可以合并——修复方向与 #444 的根因和验收标准一致,且被一个跑真实 biome 二进制的双向行为测试钉住;两处非阻塞问题是「探针守卫仍有一个绕过口」和「子目录 worktree 的覆盖收窄没有任何回归信号」。

级联分析

  • 变更符号: 无。diff 只有一个 files.includes 配置值(biome.json:62)、一段注释(.gitignore:53-66)、一条 CHANGELOG 条目和纯测试代码;没有导出符号签名变化。
  • 受影响流程: pnpm lint = biome check .package.json:35)→ quality:precommit / quality:ci / quality:localpackage.json:28-30)→ .githooks/pre-commit.githooks/pre-push(两者都只调用这两个 pnpm 脚本)→ CI check job(.github/workflows/ci.yml:25-28,ubuntu-latest,Node 20/22,pnpm install --frozen-lockfile 后跑 quality:ci)。PR 声称「CI 在 Linux 上装完依赖后会跑这个新测试」,已核对属实:test:workflowsquality:ci 链上(package.json:29,40),skip 条件(win32 / 缺 node_modules/.bin/biome)在该 job 上都不成立。
  • 变更集外调用方: 无 (text search)。全仓只有一个 biome.json(Glob),biome check 只在根脚本 package.json:35-36 出现,其余命中都在 docs/plans 和 CHANGELOG 里;旧模式串 **/.claude/worktrees 在变更集外没有任何残留引用(Grep)。biome.json 由 biome 二进制读取,无仓内 importer。
  • 置信度: medium — 无代码图谱,结论来自 Read/Grep (text search);核心行为断言(biome 2.4.16 对遍历根按绝对路径匹配、锚定模式两个方向都成立)我无法在本次评审中执行验证,只能依赖 PR 内的实测记录和新测试在 CI 上的执行。

问题发现

  1. [中] 子目录 worktree 的排除覆盖被收窄,且没有留下任何自动信号

    • 证据: biome.json:62!!**/.claude/worktrees 改为 !!.claude/worktrees,只锚定项目根。.gitignore:60-66 明确承认 packages/x/.claude/worktrees/b 仍被 git 忽略但不在 biome 排除范围内,从仓库根跑 biome check . 仍会撞上 #439 的 nested-root-configuration 中止。仓库确实是 monorepo(packages/apps/desktop),在子目录启动 Claude Code 是 .gitignore 自己给 **/ 保留的理由,所以这条路径不是纯理论。
    • 受影响调用方/流程: 仓库根 pnpm lint → pre-commit / pre-push / CI quality:ci。失败形态正是 #439 抱怨过的误导性报错(报配置问题而不是 worktree)。
    • 最小可行修复: 不必在本 PR 改模式(**/ 的反向失效更严重,取舍成立)。最小动作是开一个 follow-up issue 记录这个已知缺口,或在 scripts/tests/workflow-rules.test.mjs 的配置断言旁加一行注释级 TODO 指向它,避免这条限制只活在 .gitignore 注释里。
  2. [低] 探针守卫仍留了一个与它要防的编辑同类的绕过口

    • 证据: scripts/tests/workflow-rules.test.mjs:571-581 覆盖了 noDoubleEquals: "off"{ level: "off" }rules.recommended: falsesuspicious.recommended: false 四种写法,但读的是 linter?.rules,没有看 linter.enabled。若 biome.jsonlinter.enabled 被设为 false(或将来加 overrides 关掉该规则),worktree 那次运行不再报 noDoubleEquals,测试会以 worktree contents must still be checked (#444) 失败——正是这段守卫想避免的「报错指向错误原因」。
    • 受影响调用方/流程: pnpm test:workflows(本地门禁 + CI check)的可诊断性;不影响当前行为,biome.json:4-5 现在是 "enabled": true
    • 最小可行修复: 在同一处多读一层并加一条断言,如 const linter = JSON.parse(...).linter;assert.notEqual(linter?.enabled, false, probeMessage);

行级发现

  • [biome.json:62] 锚定后不再覆盖子目录下的 .claude/worktrees(如 packages/x/.claude/worktrees/b),从仓库根跑 biome check . 会重现 #439 的 nested-root-configuration 中止;取舍本身合理,但建议补一个 follow-up issue 编号,别让这条限制只留在 .gitignore 注释里。
  • [scripts/tests/workflow-rules.test.mjs:571] 这里只读 linter?.ruleslinter.enabled: false 能绕过全部三条探针守卫并让失败信息指向 traversal 而非真实原因;顺手多读一层 linter,加一条 assert.notEqual(linter?.enabled, false, probeMessage)

Karpathy 评审

  • 假设: 关键假设「biome 对遍历根按绝对路径匹配、对显式子路径按相对路径匹配」是 biome 2.4.16 的实测行为而非文档契约,PR 已在 .gitignore:65-66 显式标注「换 biome 版本后要重新验证再采信」,并用行为测试而非文字承诺来兜底——这是这个 PR 处理隐藏假设最好的部分。被接受但未自动化的假设是「子目录 worktree 不会真出现」。
  • 简洁性: 方案是单字符级别的最小修复(去掉 **/),没有引入新抽象、新层或新配置开关。测试用真实 biome.json 而不是手写 stub,是恰当的证据选择。
  • 结构质量: 无退化。没有新分支、新 flag、新 wrapper,也没有把逻辑放到错误层。测试文件从 ~520 行增至 ~627 行,仍在可扫描范围内,新增块自带边界清晰的注释。同一份 rationale 现在同时存在于 .gitignore 注释、测试注释和 CHANGELOG,属于可接受的重复(与该仓库既有的长解释性注释风格一致),但下次改模式时三处都要同步。
  • 变更范围: 与既定目标严格对齐——一个配置值、一段解释、一条 CHANGELOG、两处测试。没有夹带无关重构或格式噪声。
  • 验证: 强度匹配风险。行为测试断言的是「哪一次运行报出被种下的 noDoubleEquals」而不是文件计数,这个选择正确地排除了「只检查了配置文件」的假通过;根方向的假通过(检查 0 文件但退出 0)由 assert.equal(fromRoot.status, 0) 间接挡住,因为 biome 在 0 文件时退出 1。可证伪性成立:把模式改回 !!**/.claude/worktrees 会让配置断言和行为断言同时失败。

缺失覆盖

  • 子目录 worktree(<subdir>/.claude/worktrees/<name>)从仓库根跑 biome check . 的行为没有测试,也没有 issue 记录;这是本 PR 相对 #442 主动收窄的那部分覆盖。
  • !!**/.claude/worktrees/** 会被 useBiomeIgnoreFolder 的 safe fix 改回坏形式」是拒绝备选方案的核心理由,但只有人工实测记录、没有回归覆盖;biome 升版后这条结论需要重新验证(.gitignore:65-66 已自陈这一点)。
  • 探针守卫未覆盖 linter.enabled: falseoverrides 关规则两种配置编辑(见 finding 2)。

Comment thread biome.json
"!!**/docs",
"!!**/benchmarks",
"!!**/.claude/worktrees"
"!!.claude/worktrees"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

锚定后不再覆盖子目录下的 .claude/worktrees(如 packages/x/.claude/worktrees/b),从仓库根跑 biome check . 会重现 #439 的 nested-root-configuration 中止;取舍本身合理,但建议补一个 follow-up issue 编号,别让这条限制只留在 .gitignore 注释里。

// Biome accepts three ways to switch the probe off — `"off"`, `{ level:
// "off" }`, and dropping the recommended preset at either level — so check
// all of them rather than the one spelling in use today.
const linterRules = JSON.parse(readFileSync('biome.json', 'utf8')).linter?.rules;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

这里只读 linter?.ruleslinter.enabled: false 能绕过全部三条探针守卫并让失败信息指向 traversal 而非真实原因;顺手多读一层 linter,加一条 assert.notEqual(linter?.enabled, false, probeMessage)

@ceilf6
ceilf6 deleted the fix/biome-worktree-root-lint branch August 2, 2026 10:22
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.

在 .claude/worktrees/ 下的 worktree 里 pnpm lint 检查 0 个文件(#439 修复的反向失效)

2 participants