fix(hooks): post-commit hook renders via tree-aware seam (#160 proposal B) - #162
Merged
Conversation
…al B) The hook spawned a per-dir `codeindex scan` subprocess, which hardcodes level="detailed" + child_dirs=[] — every commit touching a hub dir overwrote scan-all's navigation README with a full-subtree dump, and the next scan-all flipped it back. One writer, one world-view: the hook now builds one DirectoryTree and renders affected dirs through _process_directory_with_smartwriter, byte-consistent with scan-all. Inherits #158's 0-symbol skip + stale-README cleanup; newly added source dirs now get a README (old exists() guard skipped them); per-dir subprocess spawn + 120s timeout removed.
Updated by post-commit hook. Update level: affected
This was referenced Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #160
提案 B 实现
run_post_commit_hook不再对每个 affected dir spawncodeindex scan <dir>(hardcode detailed、覆盖 scan-all 层级),改为进程内构建一次DirectoryTree,全部走_process_directory_with_smartwriter(scan-all 同一 seam)——单一 writer 单一世界观,hook 输出与 scan-all byte-consistent。白拿的语义
readme_path.exists()guard 直接跳过新目录)端到端实证(本仓真 hook)
本 commit 触发真实 post-commit hook,
src/codeindex/README_AI.md首次被 hook 写为 (navigation) 71 行——旧路径会写 391 行 detailed dump。漂移在源头消失。测试
tests/test_hook_post_commit.py重写为 tree-aware 契约:navigation 回归测试(bug: post-commit hook 单目录 scan (hardcoded detailed) 覆盖 scan-all 层级化 README —— hub 目录形态震荡 #160 核心)、新目录建索引、0-symbol skip 继承、无 scan subprocess评审注意
codeindex scan <dir>仍是 detailed(提案 C 范围,按 bug: post-commit hook 单目录 scan (hardcoded detailed) 覆盖 scan-all 层级化 README —— hub 目录形态震荡 #160 评论的 YAGNI 判断不做,观察到实际抱怨再议)