GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: populate 中の entry drop で null を返し部分 file list の流出を型で遮断 (#407 Finding 2) by ymnao · Pull Request #443 · ymnao/scripta

Conversation

@ymnao

@ymnao ymnao commented Jul 30, 2026

Copy link
Copy Markdown
Owner

概要

populateFileListCache が返す file list が walk 中の workspace close で部分的になりうるのに「完全な list」として扱われ、searchFilesImpl 等が truncated: false のまま不完全な検索結果を返す契約の穴を、戻り値の型で封鎖した。#407 Finding 1/3 と同じ「fail-open を型で強制的に閉じる」方針の延長。

関連 Issue

#407 の Finding 2 のみを消化(Finding 4 は未着手のため #407 は open 継続)。
レビューで surface した派生 finding は #442 で追跡。

移行 Stage

  • Stage 3: 全文検索(ripgrep sidecar)

変更内容

  • populateFileListCache の戻り値を Promise<readonly string[] | null> に変更。従来 1 条件だった epoch guard を 2 分岐に分割
    • entry 生存 + epoch bump → 従来どおり sortWalkResult(result)。walk の isStale は entry 生存のみを見ており epoch bump では止まらないため walk は完走している。性能劣化ゼロ(ここを null にすると完走した walk を捨てて再 walk になる)
    • entry drop / 入れ替わり (current !== e) → null。walk が途中で打ち切られた可能性があり、部分 list かどうかを区別できない
  • collectMdFilesForWorkspace を Promise<MdFiles | null> にし、4 caller(searchFilesImpl / searchFilenamesImpl / scanUnresolvedWikilinksImpl / scanBacklinksImpl)が既存の isStale bail に合流する形で空応答を返す
  • caller 側の null check 忘れは分割代入が型エラーになるため型が pin する(mutation 検証で TS2339 を実確認、runtime test は不要)
  • entry 入れ替わり(drop → 再 acquire)経路の test を追加。新 entry は epoch 0 で epochAtStart と一致するため、identity で判定していないと guard を素通りして部分 list が新 entry の cache に格納される(修正前より悪い cache poisoning)

動作確認

  • unit test 全 2868 件 PASS(vitest run)
  • mutation 検証 5 種すべて kill(下記エビデンス参照)
  • typecheck 3 configs / biome clean
  • codex-review security 観点 verdict: pass
  • e2e はローカル実行不可(sandbox の listen EPERM)→ CI で確認
検証エビデンス

リスク分類

tier: medium — classify-risk.sh の reasons は空(high 条件に該当せず、doc-only でもないため既定の medium)

実行した検証

種別 コマンド 結果
テスト ./node_modules/.bin/vitest run PASS 2868 passed / 2 skipped (133 files)
テスト(対象絞り) ./node_modules/.bin/vitest run electron/main/ipc/search-cache.test.ts electron/main/ipc/search.test.ts PASS 180 passed
mutation 検証 python3 scratchpad/s143-mutate.py / s143-mutate2.py 5 変異すべて KILLED(下表)
Lint ./node_modules/.bin/biome check <変更 3 ファイル> clean(No fixes applied)
型チェック tsc --noEmit -p tsconfig.node.json / tsconfig.web.json / tsconfig.e2e.json 3/3 OK
レビュー /simplify(reuse / simplification / efficiency / altitude の 4 観点並列) 2 findings(コメント重複、いずれも fixed)
レビュー code-reviewer サブエージェント(fable)round 1 Critical 0 / Warning 1 (fixed) / Suggestion 2
レビュー code-reviewer サブエージェント(fable)round 2 Critical 0 / Warning 1 (→ #442) / Suggestion 1 (Tier3 dismiss)
レビュー codex-review security PASS({"perspective":"security","verdict":"pass","findings":[]})
e2e pnpm test:e2e / pnpm test:e2e:electron 未実施(ローカルは listen EPERM で実行不可)→ CI の e2e / electron-e2e job で確認

mutation 検証の内訳

変異 内容 結果
A entry drop 分岐を旧挙動(配列を返す)に戻す KILLED(2 tests failed)
B entry 生存 + epoch bump 分岐を null にする KILLED(1 test failed)
C 2 分岐の戻り値を入れ替える KILLED(3 tests failed)
D caller の null check を削除 KILLED(`search.ts(510,10): error TS2339: Property 'io' does not exist on type 'MdFiles
E current !== e を current === undefined に弱化 KILLED(新規追加の swap test が failed)

変異 E は code-reviewer round 1 の Warning そのもので、指摘時点では既存 test を全通過していた。test 追加後に kill されることを実行確認済み。

レビュー指摘と対応

# 観点 Finding 対応
1 /simplify simplification search-cache.ts:203 — null 契約の同一説明が 4 箇所に重複 fixed(先頭の契約コメントに集約、97845f7)
2 /simplify simplification search-cache.test.ts:285 — 2 つの expect に対しコメントが 2 段積み fixed(97845f7)
3 /simplify altitude search-cache.ts:239 — null は entry identity からの推測であり walk 自身が事実を返す方が深い Tier3 判定(現 call site では正しく機能し、将来 walk closure が増えたときの網羅性の話)。ただし round 2 Warning と同一機構だったため #442 に統合
4 code-reviewer round 1 Warning search-cache.test.ts:294 — entry 入れ替わり経路が未 pin、current === undefined への弱化変異が全 test を通過 fixed(test 追加 + 変異 E の kill を確認、97845f7)
5 code-reviewer round 2 Warning search-cache.ts:239 — watcher restart 中は walk が完走しているのに null → [] が live-preview の fileMap に sticky に載る (b) #442 起票
6 code-reviewer round 2 Suggestion search-cache.test.ts:332 — 相乗り test に walk 呼び出し回数カウンタが無い Tier3 判定(現状は正しく相乗りしており、将来 dedupe が退行したときの検出力の話)

/simplify の reuse / efficiency 観点はいずれも finding なし。efficiency 観点は「entry drop 時に walk 結果を捨てる無駄」について、walkMdFiles の abort 機構が本 diff の変更範囲外で pre-existing なため消費される readdir 回数は旧コードと同一であることを実コードで確認している。

追跡先

backlog delta: 起票 1 件 / 本 PR で close 0 件 / 現在 open 18 件

Finding (file:line — summary) 行き先 URL / 記録
electron/main/ipc/search-cache.ts:239 — watcher restart 中の完走 walk を破棄 (b) issue 起票 #442

Draft 判定

  • 判定: normal
  • 根拠: step 4 — (a) 未 fix の finding は残っておらず、(b) 対象は populate 中の watcher restart で完走した walk が破棄され wikilink が未解決表示のまま残る #442 として起票済み、(c) 対応しない finding は 0 件

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ymnao added 2 commits July 30, 2026 00:37
@ymnao
fix: populate 中の entry drop で null を返し部分 file list の流出を型で遮断 (#407 Fin…
ac623b3
…ding 2)

- populateFileListCache の epoch guard 失敗を 2 分岐に分割。entry 生存 +
  epoch bump は walk 完走なので従来どおり sortWalkResult を返し (性能劣化ゼロ)、
  entry drop / 入れ替わりのみ null を返す
- caller の walk は entry 生存を isStale の baseline にしているため、entry
  drop 後の walk 結果は部分 list になりうる。従来は完全な list として扱われ
  truncated=false のまま不完全な検索結果が返る経路があった
- collectMdFilesForWorkspace を Promise<MdFiles | null> にし、4 caller が
  既存の isStale bail に合流する形で空応答を返す
- caller 側の null 忘れは分割代入が型エラーになるため型が pin する
  (mutation 検証で TS2339 を確認)
@ymnao
test: entry 入れ替わり (drop → 再 acquire) 経路を pin してコメント重複を整理
97845f7
- code-reviewer Warning: `current !== e` を `current === undefined` に弱化する
  変異が既存 test を全通過していた。drop → 再 acquire した新 entry は epoch 0 で
  epochAtStart と一致するため、変異下では部分 list が新 entry の cache に格納される
  (修正前より悪い cache poisoning)。この経路の test を追加し変異が kill されることを確認
- /simplify: null 契約の同一説明が 4 箇所に重複していたため先頭の契約コメントに集約
@ymnao
ymnao merged commit 6a0a9c0 into main Jul 30, 2026
9 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@ymnao
ymnao deleted the fix/populate-file-list-partial-contract branch July 30, 2026 14:46
@ymnao ymnao mentioned this pull request Jul 31, 2026
refactor: e2e launch fixture に env オプションを追加し 2 spec を fixture 経由へ統一 #445
Merged
4 of 11 tasks
@ymnao ymnao mentioned this pull request Oct 12, 2026
chore: v0.8.0 リリース準備 #632
Merged
4 of 11 tasks
ymnao added a commit that referenced this pull request Oct 12, 2026
@ymnao @claude
chore: v0.8.0 リリース準備 (#632)
9d003d3
* chore: v0.8.0 リリース準備

- package.json の version を 0.7.0 → 0.8.0 に上げる
- CHANGELOG.md に v0.8.0 のエントリを追加する (#283 〜 #631、170 commit)
  - Electron 44 で macOS の最小要件が 13 (Ventura) に上がることを冒頭に明記する
    (同梱 Electron 44.5.1 の LSMinimumSystemVersion が 13.0)
  - リリース後、tap 側で Cask の depends_on macos を :ventura に上げてから
    autobump を手動実行する (docs/parity-checklist.md §11)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: v0.8.0 の CHANGELOG をコミットの実態に合わせて直す

- hard link (#601) は検索結果の stale 対策で、ワークスペース外アクセスの封鎖では
  ないので Security から Fixed へ移す
- 漏れていた #414 / #443 / #623 と CI actions の更新を足す
- #461 の 3 経路 (別タブのファイルへの書き込み・rename 前パスの復活・
  ウィンドウを閉じたときの保存漏れ) を分けて書く
- #444 を wikilink がすべて未解決になる症状として、#622 を Fixed として書き直す
- electron-builder の完全一致固定に出所 (#283) と理由を添える
- [0.8.0] / [0.7.0] の参照リンク定義を足し、README の Electron 版を v44 に直す

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: v0.8.0 の CHANGELOG の #623 / #443 の記述を実測条件と実際の UI に合わせる

- #623 の「1 秒以上」に実測条件 (キャッシュ 1 万件・イベント 1000 件) を添え、
  コミットに無い git checkout の例を外す
- #443 の「すべて表示した」は実在しない UI 文言なので、打ち切りの通知が
  出ないという実挙動で書く

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@ymnao
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.