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 — docs: fs:write を atomic 化しない設計判断を明記 (#100 / #133 wontfix) by ymnao · Pull Request #134 · ymnao/scripta

Conversation

@ymnao

@ymnao ymnao commented Jun 3, 2026

Copy link
Copy Markdown
Owner

概要

bug fix issue #100 (writeFile を tmp + rename パターンで atomic 化) および関連の #133 (git.ts:240 を write-file-atomic で原子化) を検討した結果、user workspace files に対しては atomic write を採用しない方針 とした。本 PR は electron/main/ipc/fs.ts:writeFileImpl 直上にその design rationale を comment として記録するだけの docs-only PR (behavior 変更なし)。

関連 Issue

closes #100
(関連: 既に close 済み #133 ─ 同じ rationale)

移行 Stage

該当なし (bug fix 群 [7] の wontfix 判断)

変更内容

  • electron/main/ipc/fs.ts:writeFileImpl 直上に 9 行の design rationale comment を追加
    • なぜ atomic write を採用しないか
    • 何を失うか / 何を得るか
    • app 内部 data 系 (settings.ts / pdf.ts) との分岐ポリシー
    • VS Code 同等の precedent への参照
  • code logic は origin/main と完全同等 (fsp.writeFile 直叩きのまま)

設計判断 (要約)

user workspace files には atomic-rename を採用しない。理由 (microsoft/vscode#195539 と同方針):

失う / 受容するもの 何が起きるか
xattr (Finder タグ / 独自 metadata) inode 置換時に消失 (macOS で local 再現確認済み)
hardlink atomic rename で切れる
symlink rename で破棄され通常 file 化
inode 安定性 外部 file watcher / Dropbox / iCloud / Git working tree が再検出

引き換えに ENOSPC / SIGKILL 中の partial write リスクは残る が、user 編集中ファイルでは metadata 保存と inode 安定性のほうが優先。

scripta の policy split:

対象 実装
user workspace files (fs.ts:writeFileImpl) 直接 fsp.writeFile (本 PR で rationale 化)
app 内部 data (settings.ts / pdf.ts) writeFileAtomic (現状維持)

動作確認

  • pnpm format / pnpm lint / pnpm typecheck / pnpm typecheck:e2e green
  • pnpm test — 1845 passed / 2 skipped
  • pnpm test:e2e (renderer-only) — 143 passed
  • pnpm build 成功
  • pnpm check:legacy-residue green
  • behavior 変更なし (comment-only diff、git diff --shortstat で 9 insertions(+))

経緯 (参考)

  1. 初版で hand-rolled tmp+rename+fsync を実装
  2. /simplify で既存 dep write-file-atomic への置換を適用
  3. code review で macOS xattr 消失 + hardlink/inode 入替の挙動変更を local 再現指摘
  4. Web 調査で VS Code Allow to disable atomic writes for user data microsoft/vscode#195539 が同 tradeoff を「user data folder 内のみ atomic」で結論済みと確認
  5. 同方針に揃え、wontfix-by-design として comment 記録のみで close

スクリーンショット

該当なし (docs-only)

Sorry, something went wrong.

Uh oh!

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

All reactions
@ymnao
docs: writeFileImpl を直接書き込みのままにする理由を明記 (#100 wontfix)
dca9c7a
#100 (writeFile atomic 化) の検討結果、user workspace の .md 編集ファイルには
tmp + rename の atomic write を採用しないと判断。code review で local 再現された
xattr 消失 (macOS Finder タグ等) と、原理上の hardlink/symlink 切断・inode 入れ
替えに伴う外部ツール (Dropbox / iCloud / Git working tree / 外部 file watcher)
への影響が、partial write 防止のメリットを上回るため。

VS Code (microsoft/vscode#195539) でも同じ tradeoff を検討し、
「atomic writes are enabled only for application internal data under vscode
user data folder」「For settings.json that is a symlink we have disabled atomic
writes」と user data folder 内に限定する方針を採用済み。本実装もこれに揃える。

scripta では同方針として:
- user workspace files (fs.ts writeFileImpl) — 直接書き込み (本 PR で comment 化)
- app 内部 data (settings.ts / pdf.ts) — write-file-atomic 継続

将来 atomic 採用したい場面が出たら、symlink/hardlink/xattr 検出による分岐、
または native API (macOS copyfile / Linux setxattr) 経由の xattr 引継ぎ実装が必要。

code 自体は origin/main と同等 (behavior 変更なし)。コメントのみの追加。
Copilot AI review requested due to automatic review settings June 3, 2026 02:35
Copilot AI reviewed Jun 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

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

All reactions
@ymnao
ymnao merged commit 80f3558 into main Jun 3, 2026
7 checks passed

Uh oh!

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

@ymnao
ymnao deleted the fix/fs-write-atomic branch June 3, 2026 02:56
ymnao added a commit that referenced this pull request Jun 5, 2026
@ymnao @claude
docs: CHANGELOG を v0.2.0 リリース内容に更新
0598509
- Fixed にバグ修正クラスタをロールアップ追記 (#116 #117 #120 #124 #130 #131 #132 #134 #135 #136 #137)
- Added に手動アップデートチェック (#98 → #138) を追記
- Dependencies を Phase α 反映の実バージョンに更新
  (electron 42.3.3 / biome 2.4.16 / zustand 5.0.14 / js-yaml 4.2.0 /
   dompurify 3.4.8 / marked 18.0.4 / lucide-react 1.17.0 /
   @codemirror/view 6.43.0 / vite 8.0.14 / vitest 4.1.7)
- リリース日を _(unreleased)_ に、旧リポ表記を scripta-tauri (private) に、
  footer URL を ymnao/scripta に修正

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ymnao added a commit that referenced this pull request Jun 5, 2026
@ymnao @claude
release: v0.2.0 (Electron 版初回リリース) (#61)
be27030
* release: v0.2.0

- package.json:version 0.0.0 → 0.2.0
- CHANGELOG.md 新設(旧 Tauri 版から Electron への完全書き直し版として
  Added / Changed / Fixed / Dependencies / Security / 既知の制限 を記載)

closes #27

* docs: v0.2.0 リリース運用注釈と README の表現を release-ready に更新

レビュー指摘反映:
- README.md: "v0.2.0 を予定" / "リリース後 ... 取得できる予定" を
  リリース後にも valid な表現へ書き換え(merge → tag push 後に
  Releases ページが publish される前提)
- docs/parity-checklist.md § 12: 「必須 4 項目は tag push 前に
  手動検証で pass させ、検証ログを Release Notes に追記する」
  というリリース運用を冒頭に明示

* docs: CHANGELOG リリース日と parity-checklist リリース運用を実態に合わせる

レビュー指摘反映:
- CHANGELOG.md: リリース日を 2026-05-13 → 2026-05-14 (publish/tag 日に揃える)
- docs/parity-checklist.md § 12: release.yml が tag push 後に
  draft Release を `--generate-notes` で自動生成する流れに合わせ、
  「Release Notes 追記 → tag push」を「tag push → draft 自動生成
  → 生成された draft に検証ログ追記 → publish」の正しい順序へ修正

* docs: CHANGELOG を v0.2.0 リリース内容に更新

- Fixed にバグ修正クラスタをロールアップ追記 (#116 #117 #120 #124 #130 #131 #132 #134 #135 #136 #137)
- Added に手動アップデートチェック (#98 → #138) を追記
- Dependencies を Phase α 反映の実バージョンに更新
  (electron 42.3.3 / biome 2.4.16 / zustand 5.0.14 / js-yaml 4.2.0 /
   dompurify 3.4.8 / marked 18.0.4 / lucide-react 1.17.0 /
   @codemirror/view 6.43.0 / vite 8.0.14 / vitest 4.1.7)
- リリース日を _(unreleased)_ に、旧リポ表記を scripta-tauri (private) に、
  footer URL を ymnao/scripta に修正

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

---------

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

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

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.

fix: writeFile を tmp + rename パターンで atomic 化

Uh oh!

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

2 participants

@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.