Skip to content

bug: plan-routing-consistency 測試掃到 gitignored .spectra/ snapshot — 乾淨 checkout 綠、跑過 spectra 的本機必紅 #335

Description

@kiki830621

Problem

scripts/tests/plan-routing-consistency/test.sh#317 的修正,a4f0723 / e90bae0 引入)在乾淨 checkout 上 22/22 通過,但在任何跑過 spectra CLI 的本機工作區上必定失敗

✗ no file restates idd-all's Plan routing without deferring to it
   .spectra/snapshots/2026-05-10-add-idd-all-chain-skill/specs/idd-orchestrator-modes/spec.md:216

Root cause

該測試的檔案掃描用的是檔案系統遍歷,不是 git 的檔案清單:

grep -rliE --include='*.md' -- 'Plan[ -]tier|…' "$1" 2>/dev/null \
  | grep -v '/CHANGELOG.md$' \
  | grep -v '/openspec/changes/archive/'

排除清單有 CHANGELOG 與 archive,沒有 .spectra/ —— 而 .gitignore 第 1 行就是 .spectra/。spectra CLI 在本機累積的 snapshot(歷史 spec 的凍結副本)含有舊版的 Plan routing 敘述,被當成「未 defer 的 restatement」抓出來。

失敗方向是最壞的那種:CI 綠、本機紅,且紅的原因與被測的行為無關。

Expected

測試的掃描範圍與 git 追蹤範圍一致 —— 要嘛用 git ls-files '*.md' 取代 grep -r,要嘛在排除清單加上 .gitignore 涵蓋的路徑。前者更根本:任何「掃全 repo 找違規敘述」的測試都不該看得到 gitignored 內容,否則每個人的本機 artifact 都會變成別人的假陽性。

Actual

  • origin/main worktree:PASS: 22 / FAIL: 0
  • 同一個 commit、有 .spectra/snapshots/ 的工作區:FAIL: 1
  • 失敗檔案被 .gitignore:1 忽略、不在任何 commit 裡

Impact

  • plugins/issue-driven-dev/scripts/tests/plan-routing-consistency/test.sh —— 第 127 行附近的掃描
  • 同 pattern 的其他測試(若有)—— 值得 grep 一下 scripts/tests/*/test.sh 裡所有 grep -r 的呼叫點,看還有誰掃根目錄而不過濾 gitignore

Acceptance criteria

  • 在含 .spectra/snapshots/ 的工作區上,該 suite 與乾淨 checkout 結果一致
  • 掃描範圍以 git ls-files 或等價機制界定,不依賴檔案系統狀態
  • 檢查其他 grep -r 型測試是否同樣暴露

Source

Surfaced during rebase of PR #318 onto main 3.0.0(2026-09-07)。rebase 後全套測試 53 suites 紅 1,bisect 確認該失敗與 PR 內容無關(我的 commit 碰該檔 0 次;純 main worktree 22/22 過)。

Refs #317

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions