Orchestrata Ultimate › Plans › briefs › 2026-10-22-precommit-regenerates-maps-builder

Brief — every commit carries a fresh codebase map, so new worktrees start clean (Sonnet builder)

Source: plans/briefs/2026-10-22-precommit-regenerates-maps-builder.md at 8a2cb42ad · last changed 2026-10-22 · first committed 2026-10-22 · 83 lines.

Prose pending.

Plan text

Brief — every commit carries a fresh codebase map, so new worktrees start clean (Sonnet builder)

Executor: Sonnet builder (Claude Code builder agent). Worktree (cwd): /home/mohamed/workspace/wt-MAP-PRECOMMIT, branch fix/precommit-regenerates-maps, off origin/master 4ac0db570. The venv is provisioned (uv sync --dev with env/toolchain.env sourced). The tree is clean.

DESIGN_WAIVER: RUL-030

Ruling (Mohamed 2026-10-22, option "A"): keep the maps tracked, as RUL-030 requires, and have the pre-commit hook regenerate them whenever a commit stages Python. Then a checkout of any commit matches its maps.

GOAL: a new worktree and a new session leave git status clean.

Measured (orchestrator, 2026-10-22):

Design (decided):

  1. scripts/hooks/pre-commit: after the ruff stage has re-staged files, check git diff --cached --name-only --diff-filter=ACMRD. If it lists any *.py:
    • run HOOK_REPO_ROOT="$PROJECT_ROOT" bash "$PROJECT_ROOT/.claude/hooks/inject-codebase-map.sh";
    • then git add docs/CODEBASE_MAP.md docs/CODEBASE_MAP_FULL.md. If regeneration fails, the commit still goes through: print one WARN: line naming the failure, and never block. Do not change the ADR-0101 walls ledger fields.
  2. scripts/worktrees.py _copy_untracked_config: stop copying docs/CODEBASE_MAP_FULL.md, and remove that bullet from the docstring. The file is tracked, so every checkout already has it.
  3. Nothing else changes: not the map generator, not the session hook, not the RUL-030 registry.

This commit stages scripts/worktrees.py, so the new pre-commit regenerates the maps in this same commit. That is the one-time catch-up; do not regenerate or stage the maps by hand.

Read Python with the AST toolkit (scripts/serialize_codebase_ast.py symbols|source|refs --no-daemon), never by hand. Shell and markdown can be read directly.

CONSTRAINTS:

FILES:

scripts/hooks/pre-commit
scripts/worktrees.py
tests/scripts/test_hooks_pre_commit.py
tests/scripts/test_worktrees.py
tests/scripts/test_worktrees_provision.py
docs/CODEBASE_MAP.md
docs/CODEBASE_MAP_FULL.md
reports/precommit-walls.ndjson
plans/briefs/2026-10-22-precommit-regenerates-maps-builder.md

The two maps and the ledger are written only by the hooks, never by hand.

DONE WHEN:

VERIFY (time budget agreed with Mohamed before dispatch; cap every run with timeout 300):

REPORT