Skip to content

bug: post-commit hook 单目录 scan (hardcoded detailed) 覆盖 scan-all 层级化 README —— hub 目录形态震荡 #160

Description

@dreamlx

现象

src/codeindex/README_AI.md 的 committed 形态长期是 detailed(~350 行全递归 symbol dump),但 scan-all 对同一目录产出 navigation(~64 行聚合导航)。两者内容差异巨大,每次交替都产生大 diff。最近实证:2026-08-15 01:52 scan-all 写 navigation → 01:56 一个 commit 触发 post-commit hook 写回 detailed,随 PR squash 进 master。

根因(已读码定位)

  1. scan-all 走 tree-aware 路径:DirectoryTree.get_level() 对有 indexed children 的目录判 navigationdirectory_tree.py:182-184
  2. post-commit hook 走的是单目录路径run_post_commit_hook 对每个 affected dir 跑 codeindex scan <dir> --quietcli_hooks.py:493
  3. 单目录 scan hardcode level = "detailed" + child_dirs=[]cli_scan.py:266-268,注释自述 "For single directory scan, always use detailed level")
  4. 于是任何 commit 直接改到 hub 目录(如 src/codeindex/__init__.py 的版本号 bump)→ hook 把 navigation README 覆盖成 detailed

Committed 状态长期偏向 detailed,因为 hook 触发频率远高于人肉 scan-all

影响

修复方向(未定稿)

hook 对 affected dirs 复用 tree-aware seam(_process_directory_with_smartwriter,构建一次 DirectoryTree 后逐目录处理),而非 subprocess 单目录 scan。需评估 hook 的 120s timeout 约束下建 tree 的成本。

来源

#158 实现过程中的 A/B 隔离发现:stash 全部改动后 HEAD 代码同样产 navigation → 确认与 #159 无关、系既有漂移。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions