Add optional local structural code-map provider for MAP research (closes #310)#336
Conversation
Implements a deterministic, no-network eval harness that proves MAP minimality is active and isolated without live model calls: - build_doctrine_block() mirrors _minimality_doctrine_block() from map_step_runner so each arm's context can be verified independently. - Three fixture tasks: OVER_BUILD_TRAP (stdlib reuse), SAFETY_GUARD (path-traversal invariant must survive), IRREDUCIBLE (convergence expected; warns not fails on LOC swing). - Contamination check: off arm context must lack <MAP_Minimality_Doctrine>; lite/full/ultra arms must have it — hard FAIL on mismatch. - Safety check: required_patterns must appear in both arm outputs — hard FAIL when a pattern is dropped. - LOC delta: warns (not fails) when treatment adds lines vs baseline. - Report persisted as JSON to .map/eval-runs/minimality/<timestamp>.json. - 28 tests (VC1–VC14); ruff + pyright clean; make check green (3370 tests). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ3wHDow49xBGUwWFPH2mD
Implements `research_eval_compare` module with side-by-side A/B comparison of two ResearchEvidence runs (baseline vs treatment), scoring quality metrics (precision/recall/F1) and exploration-cost metrics (location_count, stale_count, overbroad_count, avg_span) independently so token/LOC reductions cannot mask lower localization quality. - `src/mapify_cli/research_eval_compare.py`: DiscoveryMetrics, ArmScore, CompareReport dataclasses; compare_research_runs() / compare_research_files() public API; default_compare_path(); FIXTURE_* constants for tests. Hard failures: QUALITY_FLOOR (treatment F1 below floor), STALE_REGRESSION (new missing-file paths vs baseline). Advisory warnings: QUALITY_REGRESSION, OVERBROAD_INCREASE. - `tests/test_research_eval_compare.py`: 20 fixture-only tests (VC1-VC11), no live model calls. - `src/mapify_cli/__init__.py`: `mapify research-eval compare` CLI command with --min-file-f1, --min-line-f1, --max-stale-regression, --out flags; exits 0=pass, 1=hard failure, 2=input error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ3wHDow49xBGUwWFPH2mD
#310) Implements mapify_cli.code_map: Python AST-backed deterministic fallback for symbol discovery with no external dependencies. Researchers can query "what functions/classes match <name>?" and receive ResearchEvidence-compatible file/line evidence, reducing cold-start Glob/Grep/Read exploration loops. - `src/mapify_cli/code_map.py`: CodeSymbol, CodeMapIndex, CodeMapQueryResult dataclasses; _SymbolVisitor (AST NodeVisitor for functions/classes/methods); build_python_ast_index() scans *.py files with unsafe-path (symlink) safety guard; query_code_map() returns ranked matches; default_index_path() helper. - `tests/test_code_map.py`: 37 fixture-only tests (VC1-VC10) covering symbol extraction, search ranking, malformed/unsafe file handling, ResearchEvidence compatibility, max_results cap, and CLI command. - `src/mapify_cli/__init__.py`: `mapify code-map query` CLI command with --repo-root, --max-results, --out flags; exits 0=match found, 1=no match. First slice only: Python fallback, no tree-sitter, no MCP/CodeGraph integration, no route recognition, no persistent index, no cloud indexing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ3wHDow49xBGUwWFPH2mD
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis PR adds three new optional subsystems: a Python AST-based structural code-map provider queryable via a new ChangesStructural Code-Map Provider
Minimality A/B Eval Harness
Research Discovery ROI Comparison
Estimated code review effort: 4 (Complex) | ~75 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as code-map query CLI
participant QueryAPI as query_code_map
participant Indexer as build_python_ast_index
CLI->>QueryAPI: query(query, repo_root, max_results)
QueryAPI->>Indexer: build index from repo_root
Indexer-->>QueryAPI: CodeMapIndex(symbols)
QueryAPI->>QueryAPI: search symbols, compute confidence
QueryAPI-->>CLI: CodeMapQueryResult(status, relevant_locations)
CLI->>CLI: print/write ResearchEvidence, set exit code
sequenceDiagram
participant CLI as research-eval compare CLI
participant FileIO as compare_research_files
participant Compare as compare_research_runs
CLI->>FileIO: read baseline/treatment/expected paths
FileIO->>Compare: compare_research_runs(outputs, expected, thresholds)
Compare->>Compare: score arms, check quality floors and stale regression
Compare-->>FileIO: CompareReport(warnings, failures, deltas)
FileIO-->>CLI: CompareReport
CLI->>CLI: print JSON, write --out, exit 1 if not passed
Possibly related issues
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
mapify_cli.code_map: Python AST-backed deterministic structural discovery — no external binaries, MCP servers, or network access.mapify code-map queryCLI command that scans Python files and emits ResearchEvidence-compatible JSON.Files changed
src/mapify_cli/code_map.py— new module:CodeSymbol,CodeMapIndex,CodeMapQueryResultdataclasses;_SymbolVisitor(AST NodeVisitor);build_python_ast_index()with unsafe-path symlink guard;query_code_map()with ranked results;default_index_path()helper.tests/test_code_map.py— 37 tests covering symbol extraction (classes, functions, methods), search ranking (exact→prefix→contains), malformed/unsafe file handling, ResearchEvidence compatibility viaparse_research_locations, max_results cap, and CLI command.src/mapify_cli/__init__.py—mapify code-map querycommand with--repo-root,--max-results,--outflags.First-slice scope
ResearchEvidence compatibility
Output from
as_research_evidence()passes directly intoparse_research_locations()— the existing research-eval pipeline accepts it unchanged.Test plan
uv run pytest tests/test_code_map.py -v→ 37 passeduv run python -m pyright src/mapify_cli/code_map.py tests/test_code_map.py src/mapify_cli/__init__.py→ 0 errorsmake check→ 3427 passed, 4 skippedCloses #310
Generated by Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests