Skip to content

docs(todo): stale entry 順位 39 削除 + 順位 136 新規 (staleness 検出 hook)#162

Merged
aloekun merged 1 commit into
masterfrom
docs/cleanup-stale-rank-39
May 18, 2026
Merged

docs(todo): stale entry 順位 39 削除 + 順位 136 新規 (staleness 検出 hook)#162
aloekun merged 1 commit into
masterfrom
docs/cleanup-stale-rank-39

Conversation

@aloekun
Copy link
Copy Markdown
Owner

@aloekun aloekun commented May 18, 2026

Summary

  • 順位 39 (takt workflow model フィールド必須化 lint rule) の stale entry を削除 — PR feat(hooks): takt persona-without-model lint rule (順位 39 / D-4) #150takt-workflow-persona-without-model rule として既 land 済
  • 順位 136 (working copy staleness 検出 hook 2 段構え) を新規 Tier 1 として追加 — 本 PR 作業中に実証された failure mode の structural defense

背景: stale entry 削除

memory rule feedback_verify_task_not_already_done.md (todo 着手前に既実装検証 → stale entry 削除に再目的化) の運用事例。Bundle k-2 (順位 124 + 127) 着手前の事前清掃。

調査の過程で、stale entry 候補 3 件のうち以下 2 件は既に削除済と判明:

順位 39 のみが残存していたため本 PR で削除。

背景: 順位 136 新規追加 (本 PR 作業中の root cause 由来)

本セッション (PR cleanup-stale-rank-39 作業中) で、ユーザー対話により以下の failure mode を実証:

  • local working copy が stale parent (master と sibling) のまま docs/todo*.md を読み込み、master 上で既に削除済の entry 2 件を「stale entry として削除する」と誤判定
  • root cause: Claude Code Web との並列セッション運用前提下で master が進んでいたが、local では jj git fetch 未実行で stale parent に居続けた
  • memory rule feedback_verify_task_not_already_done.md は強制力ゼロで再発確実 = feedback_no_unenforced_rules.md 原則 (機械検知できなければルール追加は害悪) の自己事例

structural defense として 2 hook 二段構えを順位 136 として登録:

  • 案 A (予防層): SessionStart hook で jj git fetch + master との lineage を additional context として AI 出力
  • 案 B (最終 backstop): PreToolUse hook で stale parent 時の docs/todo*.md edit を hard block

feedback_no_unenforced_rules.md 例外条件 = 2 つの hook で機械強制可能。ADR-039 experimental pattern 適用予定。

変更内容

ファイル 変更
docs/todo-summary.md 順位 39 行削除 (-1) + 順位 136 行追加 (+1)
docs/todo4.md 順位 39 詳細 entry 削除 (-40)
docs/todo8.md 順位 136 詳細 entry 追加 (+68)

合計: +27 行 (docs only)

検証

順位 39 完了基準を live codebase で確認:

  • takt-workflow-persona-without-model lint rule: .claude/custom-lint-rules.toml:317 に present ✅
  • post-pr-review.yaml supervise step model: sonnet: line 119 に present ✅
  • todo-summary.md table: 順位 38 → 順位 40 へ繋がり (ADR-033 採番管理簡素化に従い gap 許容)

takt pre-push-review: 1 iteration / 2m51s で all("approved") (aggregate)、non-blocking finding 1 件のみ。

Reviewer non-blocking note

順位 136 詳細 entry 内の修正手順コマンドが 案 A (jj rebase -d master) と 案 B (jj git fetch && jj new master) で不整合。実装フェーズで統一する予定 (case で挙動が異なる: 案 A は preserve work / 案 B はユーザーがまだ edit 開始前なので fresh change で問題なし)。reviewer も「ephemeral planning doc の記述揺れ、実コード差分ではないため block しない」と判断、本 PR では現状維持。

Test plan

  • CI green (docs-only)
  • CodeRabbit に actionable comments がない (docs-only delete + addition)
  • 順位 39 削除後、表 (順位 38 → 順位 40) と詳細ファイル (todo4.md) で参照漏れがない
  • 順位 136 追加が table と詳細ファイル (todo8.md) で整合

Summary by CodeRabbit

リリースノート

  • ドキュメント
    • プロジェクトのタスク管理ドキュメントを更新し、完了したタスク項目を削除して残りのタスク一覧を整理しました。
    • ワーキングコピー検出メカニズムの実装に関する新しいドキュメントを追加し、検証要件と完了基準を定義しました。

Review Change Stack

…検出 hook 2 段構え)

## 順位 39 削除

順位 39 (takt workflow `model` フィールド必須化 lint rule) は PR #150 で
`takt-workflow-persona-without-model` rule として実装済のため、todo-summary.md
table 行と todo4.md 詳細 entry を削除。

調査の過程で、stale entry 候補 3 件のうち以下 2 件は既に削除済と判明:

- 順位 104 (ADR-007 amendment): PR #161 で既削除
- 順位 126 (ADR-038 hallucinate codify): PR #156 (Phase E) で ADR-038
  migrate + 詳細 entry 削除済

## 順位 136 新規追加 (Tier 1)

本セッション (PR cleanup-stale-rank-39 作業中) で実証された failure mode:
local working copy が stale parent (master と sibling) のまま docs/todo*.md を
読み込み、master 上で既に削除済の entry 2 件を「stale entry として削除する」と
誤判定。memory rule `feedback_verify_task_not_already_done.md` は強制力ゼロで
再発確実 (memory rule 全般の限界、`feedback_no_unenforced_rules.md` 原則の
自己事例)。Claude Code Web との並列セッション運用前提下では構造的再発確実。

structural defense として 2 hook 二段構え:

- 案 A (予防層): SessionStart hook で `jj git fetch` + master との lineage を
  additional context として AI 出力
- 案 B (最終 backstop): PreToolUse hook で stale parent 時の docs/todo*.md edit
  を hard block

`feedback_no_unenforced_rules.md` 例外条件 = 2 つの hook で機械強制可能。
ADR-039 experimental pattern 適用予定。
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

📝 Walkthrough

Walkthrough

PR removes completed "takt workflow model field required lint rule" task from task tracking across docs/todo-summary.md and docs/todo4.md. Concurrently, introduces new task "working copy staleness detection 2-stage hook" in docs/todo8.md with design, work plan, and open blockers documented.

Changes

Task Backlog Update and New Staleness Hook Specification

Layer / File(s) Summary
Task removal and summary index update
docs/todo-summary.md, docs/todo4.md
Completed "takt workflow model field required lint rule" task (rank 39) is removed from todo-summary.md priority table and full entry removed from todo4.md. New "working copy staleness detection" task is added to todo-summary.md at rank 136.
New staleness detection hook task specification and planning
docs/todo8.md
New task "working copy staleness detection 2-stage hook" added with dual-approach design: SessionStart-based fetch with AI context output (fail-open on timeout), and PreToolUse-based edit hard-block for todo files when master is ahead (fail-closed with recovery steps). Includes implementation work plan (existing hook verification, timeout design, lineage calculation, context output format, edit-block implementation in validator, ADR-039 proposal, dogfood, derived-project verification), completion criteria (initial state awareness, stale edit prevention, kill-switch mechanism, derived-project support), and known blockers (timeout UX tradeoffs, trunk-based master-detection assumptions).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • aloekun/claude-code-hook-test#133: Both PRs modify the "recommended execution order" workflow centered on docs/todo-summary.md—PR #133 restructures and updates anchors, while this PR changes task row order and updates linked todo entries for completed and new tasks.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、主な変更内容(順位39の削除と順位136の追加)を明確に要約している。ドキュメント更新の焦点が正確に反映されている。
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.


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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/todo8.md`:
- Around line 377-407: Summary: The two proposal sections use different
recommended jj commands; pick one and make the docs consistent. Fix: decide
whether the canonical remediation is "jj rebase -d master" or "jj git fetch &&
jj new master", then update both the SessionStart/案 A recommendation (currently
shows "jj rebase -d master") and the PreToolUse/案 B remediation (currently shows
"jj git fetch && jj new master") to the chosen command so both sections match;
ensure the chosen command appears in the SessionStart hook description (案 A) and
the PreToolUse block message (案 B) and update any near-text (e.g., fetch hint)
to reflect the single standard command.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f1b3d813-d19c-4de1-bde0-11e03a66bc5d

📥 Commits

Reviewing files that changed from the base of the PR and between 07ccc48 and b45377a.

📒 Files selected for processing (3)
  • docs/todo-summary.md
  • docs/todo4.md
  • docs/todo8.md
💤 Files with no reviewable changes (1)
  • docs/todo4.md

Comment thread docs/todo8.md
Comment on lines +377 to +407
#### 設計決定 (案 A + B)

**案 A: SessionStart hook で `jj git fetch` + lineage 報告**

- 配置: `src/hooks-session-start/` (既存があれば拡張、なければ新設)
- 動作:
1. `jj git fetch --quiet` を timeout 付き (3 秒) で実行
2. `master..@-` / `@-..master` の commit 数を比較
3. additional context として AI に出力 (例):
```text
[working-copy-freshness]
@: lmzvnwlu (parent: #159)
master: #161 (2 commits ahead of @-)
warning: working copy is behind master; recommend `jj rebase -d master`
```
- kill-switch: `hooks-config.toml` の `[session_start]` section に `enabled` flag
- 最適化: `.git/FETCH_HEAD` mtime を確認して「5 分以内なら fetch skip」 (network cost 抑制)
- fail-open: fetch timeout / 失敗時は warning なしで pass-through (block しない、AI 操作は継続可能)

**案 B: PreToolUse hook で stale 時の `docs/todo*.md` edit を block**

- 配置: 既存 `src/hooks-pre-tool-validate/` に統合 (~30 行追加)
- 動作: Edit / Write の対象が `docs/todo*.md` 系列のとき、master と @- の lineage 確認 → master が ahead なら hard block
- block message:
```text
❌ working copy parent (#X) is N commits behind master (#Y).
docs/todo*.md は state を反映する artifact のため、master と同期した状態で編集すること。
修正手順: `jj git fetch && jj new master`
```
- scope 限定: `docs/todo*.md` のみ block (コード / config までは過剰、false positive リスク)
- 案 A と異なり、本 hook は fail-closed (lineage 判定不能なら block) で安全側に倒す
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify command consistency in the implemented hooks

# Check SessionStart hook implementation for rebase command
fd -e rs -e toml . src/hooks-session-start/ --exec rg -n "rebase|new master"

# Check PreToolUse hook implementation for recommended recovery command  
fd -e rs . src/hooks-pre-tool-validate/ --exec rg -n "jj git fetch|jj new|jj rebase" -A 2 -B 2

Repository: aloekun/claude-code-hook-test

Length of output: 2879


🏁 Script executed:

# Check if the hook directories exist and their current content
ls -la src/ 2>/dev/null | grep -i hook || echo "No hook directories found in src/"

# Check if docs/todo8.md exists and read lines 377-407
if [ -f "docs/todo8.md" ]; then
  wc -l docs/todo8.md
  echo "--- Lines 377-407 ---"
  sed -n '377,407p' docs/todo8.md
fi

# Search for any hook implementation files
fd -type f -name "*hook*" 2>/dev/null | head -20

Repository: aloekun/claude-code-hook-test

Length of output: 1928


🏁 Script executed:

# Search more broadly for hook-related code
rg -l "SessionStart|session_start|PreToolUse|pre.*tool" --type rs --type toml 2>/dev/null | head -10

Repository: aloekun/claude-code-hook-test

Length of output: 55


🏁 Script executed:

# Check git log to see if hooks were recently added or discussed
git log --all --oneline --grep="hook" -i 2>/dev/null | head -10 || echo "Git history unavailable"

Repository: aloekun/claude-code-hook-test

Length of output: 1108


🏁 Script executed:

# Check implementation details in hooks-session-start
ls -la src/hooks-session-start/
echo "--- Files in hooks-session-start ---"
find src/hooks-session-start/ -type f | head -20

# Check hooks-pre-tool-validate
ls -la src/hooks-pre-tool-validate/
echo "--- Files in hooks-pre-tool-validate ---"
find src/hooks-pre-tool-validate/ -type f | head -20

Repository: aloekun/claude-code-hook-test

Length of output: 749


🏁 Script executed:

# Search for any implementation of the recommended commands
rg "jj rebase.*master|jj new master|jj git fetch" src/hooks-session-start/ src/hooks-pre-tool-validate/ 2>/dev/null || echo "No matches found in hook implementations"

# Look for documentation or block messages in the hooks
rg "working.copy.freshness|working-copy|behind master|修正手順" src/ 2>/dev/null | head -20

Repository: aloekun/claude-code-hook-test

Length of output: 228


🏁 Script executed:

# Read the actual hook implementations
echo "=== hooks-session-start/src/main.rs ===" 
wc -l src/hooks-session-start/src/main.rs
head -50 src/hooks-session-start/src/main.rs

echo ""
echo "=== hooks-pre-tool-validate/src/main.rs ===" 
wc -l src/hooks-pre-tool-validate/src/main.rs
head -50 src/hooks-pre-tool-validate/src/main.rs

Repository: aloekun/claude-code-hook-test

Length of output: 3475


🏁 Script executed:

# Search for any existing block messages or recommendations in the implementations
rg "recommend|修正手順|behind|freshness|lineage" src/hooks-session-start/src/ src/hooks-pre-tool-validate/src/ 2>/dev/null || echo "No matching patterns found"

# Check if rebase or new commands are mentioned anywhere in the hook code
rg "rebase.*master|new.*master" src/hooks-session-start/src/ src/hooks-pre-tool-validate/src/ 2>/dev/null || echo "No command references found in implementation"

Repository: aloekun/claude-code-hook-test

Length of output: 146


実装時に案 A と案 B の推奨コマンドを統一してください。

Line 390 で jj rebase -d master を推奨していますが、Line 404 では jj git fetch && jj new master を提示しています。現在は提案段階ですが、実装の際にどちらのコマンドを標準とするか決定し、両方の説明を一致させてください。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/todo8.md` around lines 377 - 407, Summary: The two proposal sections use
different recommended jj commands; pick one and make the docs consistent. Fix:
decide whether the canonical remediation is "jj rebase -d master" or "jj git
fetch && jj new master", then update both the SessionStart/案 A recommendation
(currently shows "jj rebase -d master") and the PreToolUse/案 B remediation
(currently shows "jj git fetch && jj new master") to the chosen command so both
sections match; ensure the chosen command appears in the SessionStart hook
description (案 A) and the PreToolUse block message (案 B) and update any
near-text (e.g., fetch hint) to reflect the single standard command.

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