luminos/luminos_lib
Jeff Smith 2adbed9d28 feat(ai): implement Phase 3 investigation planning (#8, #9, #10, #11, #74)
Add a planning pass that runs after survey and before dir loops. The
planner classifies directories into priority/shallow/skip tiers and
allocates turns accordingly, replacing the fixed max_turns=14 per
directory with dynamic allocation from a global budget.

Planning pass:
- _PLANNING_SYSTEM_PROMPT in prompts.py with submit_plan tool
- _run_planning() follows the same single-turn pattern as _run_survey()
- submit_plan tool registered in new "planning" scope
- _apply_plan() pure function: band-sorted ordering (leaf-first within
  bands), turn map, skip-dir removal
- _default_plan() fallback when planning is skipped or fails
- Plan cached as plan.json for resumed runs

Dynamic turn allocation:
- Priority dirs: 15-20 turns (capped at 25)
- Shallow dirs: 5 turns
- Default: 10 turns
- Skip dirs: excluded entirely
- Orchestrator passes per-dir max_turns to _run_dir_loop()

Quality instrumentation:
- _TokenTracker._loop_turns counts API calls per dir loop
- completeness field (0.0-1.0) added to dir-scope submit_report
- plan_evaluation.json emitted after dir loops comparing plan predictions
  to actual turn utilization, completeness, and confidence
- Turn utilization logged per directory during investigation

Also fixes _get_child_summaries() to distinguish actual leaf directories
from parents whose children have not been investigated yet, replacing
the misleading "this is a leaf directory" placeholder.

26 new tests (260 total, all passing).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 20:21:49 -06:00
..
__init__.py chore: initial project scaffold 2026-03-30 09:57:11 -06:00
ai.py feat(ai): implement Phase 3 investigation planning (#8, #9, #10, #11, #74) 2026-04-12 20:21:49 -06:00
ast_parser.py refactor: extract AST parsing into luminos_lib/ast_parser.py 2026-03-30 14:34:02 -06:00
cache.py feat: AI investigation is the product, drop zero-dep constraint (#64) 2026-04-11 09:43:47 -06:00
code.py feat: in-place per-file progress for classify, count, and large-file steps 2026-04-06 14:26:37 -06:00
disk.py feat: add -x/--exclude flag to exclude directories from scan and AI analysis 2026-04-06 14:32:12 -06:00
filetypes.py feat(filetypes): expose raw signals to survey, remove classifier bias (#42) 2026-04-06 22:36:14 -06:00
prompts.py feat(ai): implement Phase 3 investigation planning (#8, #9, #10, #11, #74) 2026-04-12 20:21:49 -06:00
recency.py feat: add -x/--exclude flag to exclude directories from scan and AI analysis 2026-04-06 14:32:12 -06:00
report.py feat: add chain-of-thought observability tools 2026-03-30 13:02:19 -06:00
tree.py feat: add -x/--exclude flag to exclude directories from scan and AI analysis 2026-04-06 14:32:12 -06:00