Skip to content

chore: 全体レビュー後の follow-up (cache prefix 修正 + コメント改善)#424

Merged
MocA-Love merged 1 commit intomainfrom
chore/post-review-followups
Apr 24, 2026
Merged

chore: 全体レビュー後の follow-up (cache prefix 修正 + コメント改善)#424
MocA-Love merged 1 commit intomainfrom
chore/post-review-followups

Conversation

@MocA-Love
Copy link
Copy Markdown
Owner

@MocA-Love MocA-Love commented Apr 24, 2026

概要

upstream 取り込み全体レビュー (6 並列 agent: Codex arch / Codex fork / code-reviewer / security-reviewer / regression-reviewer / general audit) で挙がった follow-up 事項のうち、即対応可能な 3 件を反映した PR です。

変更内容

1. clearGitHubCachesForWorktree の cache 無効化を exact match に

ファイル: `apps/desktop/src/lib/trpc/routers/workspaces/utils/github/cache.ts`

`githubStatusResource` はキーに worktreePath 完全一致を使う (suffix なし) ため、`invalidatePrefix(worktreePath)` では兄弟 worktree を誤マッチするリスクがあった (例: `/foo/bar` の invalidate が `/foo/bar-2::key` にもヒット)。`invalidate()` (exact) に変更。

  • 指摘元: code-reviewer
  • 動作への影響: 現状のパス規約では worktree の兄弟関係で同一 prefix は発生しないので実害ゼロ、防御的修正

2. `applyAiWorkspaceRename` の no-op 判定コメント改善

ファイル: `packages/host-service/src/trpc/router/workspace-creation/utils/ai-workspace-names.ts`

cloud 側の atomic WHERE guard が発火した時、`updateNameFromHost` は pre-update row を返すので `cloudResult.branch` が old branch のままになる。その挙動を前提にした `branch !== deduped` 判定が何を見ているか、なぜそれで正しいかを明文化。

  • 指摘元: code-reviewer / Codex architecture (P2)

3. `updateNameFromHost` の早期 return コメント改善

ファイル: `packages/trpc/src/router/v2-workspace/v2-workspace.ts`

WHERE guard 不一致時に返す row が「pre-update 時点で fetch した row で、fresh read ではない」ことを明示。Codex arch P2 の誤読余地指摘への対応。

  • 指摘元: Codex architecture (P2)

4. plans/done への移動

  • `plans/20260424-upstream-merge-strategy.md` → `plans/done/` (upstream 取り込みシリーズ完遂)

レビュー結果サマリ (全 6 agent)

Reviewer 判定 本 PR で対応
Codex architecture 承認 P2 2 件 反映
Codex fork completeness 条件付き承認 (14/14 OK、誤認訂正済)
regression-reviewer 承認
security-reviewer 条件付き承認 HIGH は #420 に記録 (本 PR 対象外)
code-reviewer 承認 Minor 3 件全て反映
general audit 承認

残 follow-up (別対応)

  • electron-builder.ts の publish.owner が upstream 向き残置 #420 `electron-builder.ts` publish.owner 残置 (予防保全、別 issue)
  • `next` CVE bump (任意)
  • vscode-api openExternal / external.openFileInEditor 境界 (任意)
  • `github-extended.ts` 肥大化分割 (将来整理)
  • `pr-checkout` の pending progress polling 対応 (任意 UX 改善)

Test plan

  • コメント変更のみの 2 ファイルは動作影響なし
  • `cache.ts` は `invalidatePrefix` → `invalidate` の method 差し替え (同一 class、同一 signature)
  • 3 ファイルとも静的解析レベルで型変更なし
  • CI の typecheck / lint 通過確認

Summary by CodeRabbit

バグ修正

  • マルチワークツリー環境において、GitHubステータスキャッシュが不正に削除される問題を修正しました

内部改善

  • ワークスペース名変更処理およびキャッシュ無効化ロジックの関連ドキュメントを更新しました

…ons)

- `clearGitHubCachesForWorktree`: `githubStatusResource.invalidatePrefix` →
  `.invalidate` because the status cache is keyed by the exact worktree path
  (no suffix), so prefix matching could falsely invalidate sibling worktrees
  (e.g. `/foo/bar` vs `/foo/bar-2`). Caught by code-reviewer in the 6/6 review.
- `applyAiWorkspaceRename`: clarify the no-op detection comment to explain
  *why* `cloudResult.branch !== deduped` is the correct signal (cloud returns
  the pre-update row when the atomic WHERE guard fires).
- `updateNameFromHost`: clarify the early-return comment to spell out that we
  intentionally return the pre-update `workspace` row (not a fresh read) so
  the caller can observe the guard firing.
- Move `plans/20260424-upstream-merge-strategy.md` → `plans/done/` now that
  the PR #398-#418 + #417 series is complete.

Related:
- #420 (electron-builder publish.owner residue — logged, not fixed in this PR)
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 23bf2d35-af0b-4106-9ce6-f8146ad2630c

📥 Commits

Reviewing files that changed from the base of the PR and between ca82d46 and d61a1a1.

📒 Files selected for processing (4)
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/github/cache.ts
  • packages/host-service/src/trpc/router/workspace-creation/utils/ai-workspace-names.ts
  • packages/trpc/src/router/v2-workspace/v2-workspace.ts
  • plans/done/20260424-upstream-merge-strategy.md

📝 Walkthrough

Walkthrough

キャッシュ無効化ロジックがプレフィックスベースから完全一致ベースに変更され、複数のコメント説明が並行リネーム競争状態の意味論を明確化され、上流マージ戦略の包括的な計画ドキュメントが追加されました。

Changes

Cohort / File(s) Summary
GitHub キャッシュ無効化
apps/desktop/src/lib/trpc/routers/workspaces/utils/github/cache.ts
clearGitHubCachesForWorktreeinvalidatePrefix(worktreePath) から githubStatusResource.invalidate(worktreePath) への正確なキー無効化に変更。兄弟ワークツリーの状態エントリの誤削除を防止。
ワークスペースリネームドキュメント
packages/host-service/src/trpc/router/workspace-creation/utils/ai-workspace-names.ts, packages/trpc/src/router/v2-workspace/v2-workspace.ts
並行リネーム競争状態における UPDATE ガード動作と cloudResult.branch !== deduped ロールバック信号の説明を明確化。機能変更なし。
上流マージ戦略計画
plans/done/20260424-upstream-merge-strategy.md
82 コミット分類、PR 分割提案(PR #2#6)、詳細なメタデータ、静的回帰検証対象、事前・実施・事後チェックリスト、未解決課題を含む新しい計画ドキュメント。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 キャッシュの精密さよ、兄弟ツリーは無事
競争を語るコメント、明確に光る
上流の地図も広がり、82 の足跡
マージ戦略、整然と並ぶ道
✨ 細部に注ぎし愛、すべて整う

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは PR の主な変更内容(cache 無効化の修正とコメント改善)を正確に要約しており、実装内容と一致しています。
Description check ✅ Passed PR description には、テンプレートの主要セクション(Description、Type of Change、Testing)が含まれており、変更内容が詳細に説明されています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/post-review-followups

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 24, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d61a1a138e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// githubStatusResource is keyed by the exact worktreePath (no suffix), so
// invalidate() rather than invalidatePrefix() avoids matching sibling
// worktrees whose paths share this prefix (e.g. /foo/bar vs /foo/bar-2).
githubStatusResource.invalidate(worktreePath);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use prefix invalidation for GitHub status cache

githubStatusResource keys are not always the exact worktree path: fetchGitHubPRStatus stores branch workspace entries as "${worktreePath}::${branchName}". Switching clearGitHubCachesForWorktree to invalidate(worktreePath) only clears the exact key, so force-refresh and post-mutation clears can leave branch-scoped status entries untouched, causing stale GitHub status to persist until TTL expiry for branch workspaces. Please invalidate by worktree prefix (or explicitly clear both exact and branch-suffixed keys).

Useful? React with 👍 / 👎.

@MocA-Love MocA-Love merged commit f870913 into main Apr 24, 2026
12 of 13 checks passed
@MocA-Love MocA-Love deleted the chore/post-review-followups branch April 24, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant