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: 完走した walk を entry 入れ替わりで破棄せず wikilink 未解決化を防ぐ (#442) by ymnao · Pull Request #444 · ymnao/scripta

Conversation

@ymnao

@ymnao ymnao commented Jul 30, 2026

Copy link
Copy Markdown
Owner

概要

populate 中に watcher restart が重なると、完走した walk の結果が捨てられて wikilink が全て未解決表示になる問題を直す。打ち切りの判定を entry identity からの「推測」ではなく、walk 自身が報告する「事実」にした。

watcher:start は同一 window で stopWatcherForWindow(= entry drop)→ acquireFileListCache(新 entry)を同期区間で実行するため、walk の isStale(entry 生存を見る)には観測窓が無く walk は必ず完走する。にもかかわらず populate 解決時に current !== e が成立して null になり、searchFilenames の [] が renderer 側 live-preview の fileMap に fileTreeVersion キーで格納され、次の file tree 変更まで全 wikilink が未解決表示のまま残っていた(dev の StrictMode 二重 mount では毎回この窓が開く)。

関連 Issue

closes #442

移行 Stage

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

変更内容

  • walkMdFiles の戻り値を Promise<"completed" | "aborted"> にし、再帰全段で aborted を伝播する
  • populateFileListCache の walk 契約を () => Promise<readonly string[] | null> に変更。null は「walk 自身が打ち切りを報告した」事実だけを意味する
  • populate は result === null を最上部で弾き、格納パスに部分 list が到達する経路を制御フローで消す。格納条件は current === e && epoch === epochAtStart の 1 条件に集約し、完走した walk は entry が入れ替わっていても捨てずに返す(格納だけ見送る)
  • watcher 非稼働経路も打ち切り時は部分 list を sort して返さず null に揃える(caller 4 箇所は既存の isStale bail に合流済みで無変更)
  • 副産物: 従来コメントで規約化していた「walk closure の isStale ≡ entry 消失」という暗黙の結合が型で強制される

動作確認

  • unit: 2875 passed / 2 skipped(133 files)
  • typecheck: node / web / e2e の 3 tsconfig すべて OK
  • mutation 検証(下記エビデンス参照)
  • e2e はローカル実行不可(listen EPERM)→ CI で確認
検証エビデンス

リスク分類

tier: medium — classify-risk.sh の reasons は空(security 境界 / agent-config への抵触なし)

実行した検証

種別 コマンド 結果
テスト ./node_modules/.bin/vitest run PASS 2875 passed / 2 skipped(133 files)
テスト(対象 2 file) ./node_modules/.bin/vitest run electron/main/ipc/search.test.ts electron/main/ipc/search-cache.test.ts PASS 187 passed
型チェック tsc --noEmit -p tsconfig.node.json / tsconfig.web.json / tsconfig.e2e.json 3 本とも PASS
Lint biome check --write electron/main/ipc/search*.ts PASS(round 1 で 1 file 自動整形)
レビュー codex-review security PASS / 0 findings
レビュー /simplify 4 観点(reuse / simplification / efficiency / altitude、sonnet 並列) 3 findings(2 fixed / 1 skipped)
レビュー code-reviewer(fable)round 1 Critical 0 / Warning 1 / Suggestion 3
レビュー code-reviewer(fable)round 2 Critical 0 / Warning 0 / Suggestion 4

mutation 検証(変異 → 落ちた test)

変異 結果
current !== e を return null に戻す(旧挙動) 3 test fail
格納条件から identity 判定を落とす 1 test fail
populate の result === null early return を外す 3 test fail
outcome === "aborted" ? null : arr を return arr(#407 Finding 2 の regression) 1 test fail(round 1 では 0 fail = vacuous だったため test を書き直した)
再帰段の return "aborted" 握り潰し 2 test fail
入口(readdir 前)の isStale check 削除 1 test fail

レビュー指摘と対応

# Finding 対応
1 /simplify(simplification): populate の「格納を見送る」2 分岐が同じ return を持つ (a) fix — 格納条件を 1 つの if に統合(d4dedb7)
2 /simplify(simplification): test helper の初回判定フラグが不要 (a) fix — mockImplementationOnce へ(d4dedb7)
3 /simplify(simplification): "completed" | "aborted" は boolean で足りる skip — 再帰伝播箇所の可読性を優先(agent 自身も優先度低と付記)
4 code-reviewer R1 [Warning] search.test.ts — abort 統合 test に outcome === "aborted" ? null : arr への検出力がない (a) fix — 変異を当てて主張を確認(全 test 通過)した上で、部分 list が非空になる構成に書き直し(20bd543)
5 code-reviewer R1 [Suggestion] CacheEntry.inFlight のコメントが旧契約のまま (a) fix(20bd543)
6 code-reviewer R1 [Suggestion] entry なし経路の null 透過に pin が無い (a) fix — 1 本追加(20bd543)
7 code-reviewer R1 [Suggestion] readdir spy が walk の check 粒度に結合 対応なし — 落ちる方向が false failure(安全側)であることを agent も明記
8 code-reviewer R2 [Suggestion] 再帰伝播 test のコメントが実際の変異空間と対応していない (a) fix(4bd8605)
9 code-reviewer R2 [Suggestion] 入口 isStale check に kill できる変異が無い (a) fix — readdir 未発火を pin する test を追加(4bd8605)
10 code-reviewer R2 [Suggestion] searchFilesImpl の caller コメントが旧契約のまま (a) fix(4bd8605)
11 code-reviewer R2 [Suggestion] walk が reject した場合の pin が無い 対応なし — 本 diff 由来ではない既存 gap(finally 節は変更前から存在)

追跡先

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

本 PR で fix しない finding((b) 起票 / (c) 対応しない): なし

Draft 判定

  • 判定: normal
  • 根拠: step 4 — Tier1/Tier2 の残 finding は 0 件。確認された指摘はすべて本 PR で fix 済み((b)/(c) の候補なし)

Sorry, something went wrong.

Uh oh!

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

All reactions
ymnao added 4 commits July 31, 2026 00:21
@ymnao
fix: walk の打ち切りを自己申告にして完走 walk の破棄をやめる (#442)
2cf7bf4
- walkMdFiles が `"completed" | "aborted"` を返し、再帰全段で aborted を伝播する
- populate に渡す walk 契約を `() => Promise<readonly string[] | null>` にし、
  打ち切りの事実だけを null で報告する
- populateFileListCache は null を最上部で弾き、entry identity (`current !== e`) は
  「cache に格納するか」の判定のみに戻す。完走した walk は entry 入れ替わり時も返す
- watcher restart (release → acquire が同期区間) と populate が重なると、完走した
  walk が捨てられて searchFilenames が [] を返し、renderer の fileMap が空のまま
  残留して全 wikilink が未解決表示になっていた
- watcher 非稼働経路も打ち切り時は部分 list を返さず null に揃える
@ymnao
refactor: populate の格納判定を 1 条件に畳み、readdir spy helper を mockImplementa…
d4dedb7
…tionOnce へ

- /simplify 指摘: 「格納を見送る」2 分岐が同じ return を持っていたため、
  格納条件 (entry 同一 + epoch 一致) 側を 1 つの if に統合
- test helper の初回判定フラグを削除 (mockImplementationOnce の消費後は
  元実装への call-through に戻るため自前管理が不要)
@ymnao
test: abort 統合 test の部分 list を非空にして vacuous pin を解消する (#442)
20bd543
- code-reviewer 指摘: abort test の workspace が root 直下 1 file だったため、
  打ち切り時点の部分 list が常に空。populate 経路の遮断行
  (`outcome === "aborted" ? null : arr`) を `return arr` に変異させても
  全 test が通過していた
- root .md 2 件 + subdir を置き、readdir spy で file → dir 順に並べ替えてから
  2 回目 (subdir) の readdir で release する構成に変更。fs の返却順に依存せず
  打ち切り時点の out が非空になる
- entry なし経路 (watcher 非稼働) の null 透過も 1 本 pin
- CacheEntry.inFlight の旧契約コメントを新契約の文言へ更新
@ymnao
test: 入口 isStale check を pin し、再帰伝播 test のコメントを変異空間に合わせる
4bd8605
- code-reviewer round 2 指摘: walkMdFiles の入口 (readdir 前) check は
  post-readdir check と結果が同じで kill できる変異が無かった。
  「readdir を 1 回も撃たない」ことだけが区別点なので spy で pin する
- 再帰伝播 test のコメントが「深い段の abort を握り潰すと deep.md が入る」と
  書いていたが、実際に落ちるのは戻り値 assert の方。実際の変異に合わせて修正
- searchFilesImpl の caller コメントを新契約 (打ち切りの報告) の文言へ更新
@ymnao
ymnao merged commit 65a0f13 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/walk-reports-abort-fact branch July 30, 2026 15:52
@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.

populate 中の watcher restart で完走した walk が破棄され wikilink が未解決表示のまま残る

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.