Orchestrata Ultimate › Plans › briefs › 2026-10-22-maps-one-load-builder

Brief: maps increment 1 of 4. gen_codebase_map.py --with-full writes both maps in one process (Sonnet builder)

Source: plans/briefs/2026-10-22-maps-one-load-builder.md at 8a2cb42ad · last changed 2026-10-22 · first committed 2026-10-22 · 121 lines.

Prose pending.

Plan text

Brief: maps increment 1 of 4. gen_codebase_map.py --with-full writes both maps in one process (Sonnet builder)

Executor: Sonnet builder. cwd /home/mohamed/workspace/wt-MAP-PRECOMMIT. Create branch feat/maps-one-load from HEAD b5468cb1c (item 2: the pre-commit regenerates the maps).

DESIGN_WAIVER: RUL-041

GOAL: python3 scripts/gen_codebase_map.py --with-full writes both maps in one process, byte-identical to today's two steps, in under 40 s instead of 128 s.

Ruling (Mohamed 2026-10-22): "maps should use delta". It ships in small increments:

  1. one process (this brief: the Python change and its proof, no hook edit, no tests, no commit);
  2. the hook calls it;
  3. tests;
  4. commit.

The true per-file delta is a later packet.

Measured (orchestrator, idle machine; do not re-measure)

Code facts (read with the toolkit, verified)

scripts/gen_codebase_map.py:

Toolkit list_symbols(sources, pattern=None, kind=None) -> list[dict]:

Change (exact)

  1. _load_ast_toolkit(): as the first statement of the body, return sys.modules["_gen_map_ast_toolkit"] when it is already present. _class_map and the new builder then share one module object. Leave the rest unchanged.
  2. Module constant, in the hook's order: FULL_TREES = ("src/orchestrata_ultimate", "scripts", "rtm", "end2end", "tools", "harness", "architecture", "features", "specs", "claude").
  3. build_full_map(toolkit) -> str: lines joined with "\n", plus a trailing "\n".
    • Six header lines, byte-exact. Copy them from .claude/hooks/inject-codebase-map.sh lines 86–91; they contain em dashes:
      • # Full symbol skeleton — src/ + scripts/ (class / function / method signatures)
      • (empty line)
      • > ON-DEMAND tier (auto-generated with docs/CODEBASE_MAP.md; NOT @imported).
      • > Read in ranges (grep -n first) — never whole.
      • (empty line)
      • a line of three backticks
    • Then, for each tree in FULL_TREES where (ROOT / tree).is_dir():
      • ### symbols: {tree}/;
      • one line per row of toolkit.list_symbols([tree]). Pass the relative string unchanged, in {file}:{line}: {signature} form;
      • an empty line;
      • {len(rows)} symbol(s).
    • Then a closing line of three backticks.
  4. main() with "--with-full" in sys.argv[1:]:
    1. First os.chdir(ROOT), because the relative tree strings resolve against cwd.
    2. Write the header map exactly as today.
    3. Get the shared toolkit from _load_ast_toolkit(). If that returns None, treat the count as 0.
    4. Build the full text and count the lines containing : def or : class .
    5. If the count is at least 1000, write it with dump_text_atomic(ROOT / "docs" / "CODEBASE_MAP_FULL.md", text).
    6. Otherwise write nothing, and print to stderr the hook's exact text:
      • when the file exists and is non-empty: [codebase-map] WARNING: symbol generation produced {count} signatures; KEPT the existing docs/CODEBASE_MAP_FULL.md. Re-run: bash .claude/hooks/inject-codebase-map.sh
      • otherwise: [codebase-map] WARNING: symbol generation produced {count} signatures and there is no existing docs/CODEBASE_MAP_FULL.md. The on-demand tier is UNAVAILABLE — use scripts/serialize_codebase_ast.py directly.
    • Without the flag, main() behaves exactly as today.
  5. Leave the cache off. Do NOT call configure_parse_cache or configure_repo_root.

FILES:

scripts/gen_codebase_map.py
plans/briefs/2026-10-22-maps-one-load-builder.md

CONSTRAINTS:

DONE WHEN: VERIFY's log shows all of these:

Your final message is the log's lines verbatim, plus git diff --stat, and nothing else.

VERIFY: bash /tmp/claude-1001/-home-mohamed/829ea13c-8ceb-4f51-9b28-672fef74daca/scratchpad/prove-full.sh /home/mohamed/workspace/wt-MAP-PRECOMMIT > /tmp/claude-maps-prove.log 2>&1; echo "PROVE-EXIT $?" >> /tmp/claude-maps-prove.log