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: hard link を L2 / index に載せず片名前書き込みの stale を塞ぐ (#416) by ymnao · Pull Request #601 · ymnao/scripta

Conversation

@ymnao

@ymnao ymnao commented Oct 5, 2026

Copy link
Copy Markdown
Owner

概要

hard link された md file を L2 ContentCache / InvertedIndex に載せないようにした。これで、片方の名前に書き込んだときにもう片方の名前の検索結果が stale になる問題を塞ぐ (#413 follow-up の Finding 2)。read に使った fd を fstat して nlink === 1 のときだけ L2 / index に取り込む。本文はこれまでどおり検索結果に出す。

Finding 1 (disabled workspace の L2) は #435 で解消済みのため、本 PR では扱わない。

関連 Issue

Closes #416

移行 Stage

  • Stage 0: 雛形 + フロント表示確認
  • Stage 1: ファイル I/O
  • Stage 2: ワークスペース・ファイルツリー・ファイル監視
  • Stage 3: 全文検索(ripgrep sidecar)
  • Stage 4: Git Sync
  • Stage 5: OGP / PDF / アップデート
  • Stage 6: 仕上げ・配布・切り替え

変更内容

  • open-nofollow.ts: readFileUtf8NoFollowWithLinkCount を追加した。O_NOFOLLOW で開いた fd に fh.stat() をかけて { text, nlink } を返す。readFileUtf8NoFollow はこの helper の薄いラッパーにした
  • search.ts (piggyback): nlink === 1 のときだけ L2 set と index indexFile を行う。残る窓 (取り込み後に hard link を作られた場合) の説明はここのコメントを正本にした
  • index-fill.ts (idle fill): nlink !== 1 なら index しない。既存の skipUntilEpochChange 経路に倒れる
  • search.ts (dark assert の readForReindex): nlink !== 1 を検出したら null を返し、その path に applyFsBatch の modify を流して posting / L2 を回収する。残る窓で stale になった posting が violation を出し続けないようにするため
  • doc / コメント: ADR-0011、inverted-index.ts、path-guard.ts、search-cache.ts の hard link に関する記述を実装に合わせた
  • test: helper の nlink、両名前を index しないこと、別名への in-place 書き込み後も hit が残ること、L2 が stale にならないこと、idle fill の skip、dark assert での回収をそれぞれ追加した。win32 の nlink probe も追加した

動作確認

  • vitest run 全体: 141 files passed / 1 skipped、3258 tests passed / 18 skipped
  • 追加 test の mutation 検証を行った (別名書き込み後の hit 維持 test と dark assert 回収 test で、それぞれ mutant が kill されることを確認した)
  • win32 の nlink probe (win32-fs-semantics.test.ts) は Windows 上で一度も実行していない。required ではない win32-fs-probe job の結果を確認してから merge すること
  • e2e (renderer-only / 実 Electron) はローカルでは未実施。CI で確認する
検証エビデンス

リスク分類

tier: medium — reasons なし (classify-risk.sh の出力は {"tier": "medium", "reasons": []})

実行した検証

種別 コマンド 結果
テスト env -u GIT_CONFIG_COUNT ./node_modules/.bin/vitest run PASS: 141 files passed / 1 skipped、3258 passed / 18 skipped
Lint ./node_modules/.bin/biome check PASS (exit 0)
型 tsc --noEmit -p tsconfig.node.json / -p tsconfig.web.json PASS
型 (e2e) pnpm typecheck:e2e 未実施
e2e pnpm test:e2e / pnpm test:e2e:electron 未実施 (CI で確認)
レビュー codex-review security PASS (findings 0)
レビュー /dev レビューループ (simplify + code-reviewer[fable]) 2 周 round1 で 10 件、round2 で 1 件を fix。cap-reached

レビュー指摘と対応

  • codex-review security: findings 0
  • /dev レビューループ: コスト記述の誤り、helper の 1 本化、win32 probe の追加、dark assert で posting を回収すること (3 つのレビューが同じ機構を指摘したため格上げして fix) などを fix した (cdc5486 / 27c8238 / 5db77f8)

追跡先

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

Finding (file:line — summary) 行き先 URL / 記録
electron/main/ipc/search.ts:328 — 書き込み側検出で残る窓を閉じる案 (c) 対応しない 追跡しない (user 指示: (b) 条件 3 を満たさないため対応しない分類を承認)

Draft 判定

  • 判定: normal
  • 根拠: step 4 dismiss — 書き込み側で nlink を検出する案 (simplify Altitude chore: GitHub リポジトリ初期セットアップ(Dependabot / セキュリティ / 設定) #1) を (c) とし、user が承認した

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

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

All reactions
ymnao and others added 4 commits October 5, 2026 22:03
@ymnao @claude
fix: hard link の両名前を L2 / index に載せず片名前書き込みの stale を塞ぐ (#416 Finding 2)
7355efa
- hard link は realpath でも O_NOFOLLOW でも alias と判別できず、app の in-place 書き込み (#100) で片方の名前だけが invalidate されるため、もう片方の posting / L2 が旧内容のまま valid に残っていた
- 取り込み read の fd に fstat を 1 回足して nlink を取り、nlink === 1 のときだけ L2 admission / indexFile を許す (piggyback / idle fill / dark assert 再 index)。検査対象が読んだ object そのものなので path ベース stat の窓が無い
- text は nlink によらず検索結果に出すので結果は落ちない。cache の無い純 scan 経路には fstat を足さない
- 取り込み後に hard link が作られた場合の窓は受容として ADR-0011 / inverted-index / search.ts に記載

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymnao @claude
refactor: hard link 判定の L2 条件と read helper を 1 本化する (#416 Finding 2)
cdc5486
- singleLink が立つのは ioPath 自身の O_NOFOLLOW fd read だけなので、冗長になった readFromVerifiedFd を削除し L2 admission を singleLink 1 変数にした
- 分岐 3 の cache 有無による read helper の出し分けをやめ、常に nlink を取る形にした (fstat 1 回のために分岐とコメントを持たない)
- readFileUtf8NoFollow を WithLinkCount への委譲にして open/close の骨格を 1 本にした
- 残る窓の説明を search.ts の L2 admission コメントに集約し、他は参照にした。旧 helper 名のコメントと、根拠の不完全な「同期処理で stat できない」の記述を直した

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymnao @claude
fix: hard link 判定のコスト記述を実装に合わせ win32 の nlink probe を追加する (#416 Findin…
27c8238
…g 2)

- ADR-0011 の「既 index の file には fstat が乗らない」は誤り (L2 miss なら分岐 3 で払う) なので「L2 hit には乗らない」に直し、hard link file が L2 / index の恩恵を受けない点を明記した
- open-nofollow.ts のモジュールヘッダ「検索 hot path にコストは乗らない」を read 側の fstat 1 回と整合させた
- dark assert の unreadable に nlink !== 1 も計上されることと、violation が立つ条件を doc に追記した
- win32 probe に単一名 file の nlink 1 / hard link 両名前の nlink 2 を追加した。新規 test は win32 skip 配下にしかなく、NTFS で fix が効くかを何も測っていなかった

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymnao @claude
fix: dark assert が nlink !== 1 を検出した path の posting を回収する (#416 Findi…
5db77f8
…ng 2)

- 取り込み後に hard link が作られた残る窓は dark assert の再 index read が唯一検出できる経路だが、null を返すだけで posting が stale のまま残り、検索ごとに同じ violation が上がり続けていた
- 検出した path に applyFsBatch の modify を流し、元の名前自身への event と同じ回収 (L2 evict + index invalidate) をする
- レビュー 3 回 (simplify altitude / code-reviewer / simplify 2 周目) が同じ機構を指摘して収束したため、dev monitor 専用経路だが本 PR で直す

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymnao
ymnao merged commit b670571 into main Oct 5, 2026
18 checks passed

Uh oh!

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

@ymnao
ymnao deleted the fix/hard-link-alias-stale-#416 branch October 5, 2026 16:31
@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.

413 follow-up: alias 系 staleness の残存窓 (disabled workspace の L2 / hard link)

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.