Skip to content

feat: codebase map, Azure reader, type-aware ingestion, SonarCloud security gate#10

Merged
cmdaltctr merged 13 commits into
masterfrom
fix/fix-codebase-map-review
Jun 28, 2026
Merged

feat: codebase map, Azure reader, type-aware ingestion, SonarCloud security gate#10
cmdaltctr merged 13 commits into
masterfrom
fix/fix-codebase-map-review

Conversation

@cmdaltctr

Copy link
Copy Markdown
Owner

Summary

  • Codebase map MCP tool (get_codebase_map): builds a compact codebase map from file types, code communities, document communities, cross-links, and architectural hubs. Uses Magika for file-type detection with suffix fallback. Cached per git commit hash.
  • Azure Document Intelligence reader (azure_reader.py): opt-in cloud OCR backend with lazy SDK import and automatic fallback to local parser chain. Controlled by DOCUMENT_BACKEND env var.
  • Type-aware ingestion: Magika label → tree-sitter language mapping for semantically coherent code chunking via CodeSplitter.
  • SonarCloud security gate: CI workflow for automated code quality, security, and coverage analysis on PRs. Local sonar CLI for pre-commit secrets scanning.

Bug fixes (codebase map review)

ID Severity Fix
H1 HIGH Path boundary validation via relative_to(Path.cwd())
H2 HIGH Fetch real ChromaDB collection instead of build_document_graph(None)
H3 HIGH Store inheritance on graph nodes; fix class regex for class Foo:
M1 MED CODEBASE_MAP_MAX_FILES/MAX_DEPTH limits, 30s Magika timeout
M2 MED Cache files added to .gitignore
M3 MED Shared _EXCLUDED_DIRS between Magika and suffix scanners

Documentation

  • ADR-022: Code graph via tree-sitter AST extraction
  • ADR-023: Document graph via embedding similarity
  • ADR-024: Dual deployment modes (local vs Azure)
  • TDR-001: Fix codebase map dead code and boundary validation
  • TDR-002: SonarCloud security gate via GitHub Actions
  • TDR-003: Suppress Jupyter warning by installing ipywidgets

Test plan

  • 556 tests pass (uv run pytest -m "not slow" -v)
  • 3 new regression tests for inheritance edges, document graph collection, path boundary
  • 3 integration tests updated for boundary check (chdir pattern)
  • SonarCloud secrets scan clean on src/, tests/, .env.example
  • SonarCloud CI workflow passes on PR
  • Deferred: manual tests and experiments (tasks 8.1-8.8 in openspec/changes/fix-codebase-map-review/tasks.md)

OpenSpec

  • openspec/changes/add-fast-context-codebase-map/ — original feature proposal
  • openspec/changes/fix-codebase-map-review/ — review fixes

🤖 Generated with Claude Code

cmdaltctr added 13 commits June 28, 2026 18:49
…ation and graph fixes

Add get_codebase_map MCP tool that builds a compact codebase map from
file types, code communities, document communities, cross-links, and
architectural hubs.

Components:
- codebase_map.py: Magika file-type detection, suffix fallback, caching
- code_graph.py: tree-sitter AST extraction, NetworkX graph, Louvain
- doc_graph.py: embedding similarity edges, metadata edges, heading edges

Fixes applied during implementation review:
- H1: Path boundary validation via relative_to(Path.cwd())
- H2: Fetch real ChromaDB collection instead of build_document_graph(None)
- H3: Store inheritance on graph nodes, fix _get_inheritance(), fix class
  regex to match classes without parentheses
- M1: CODEBASE_MAP_MAX_FILES/MAX_DEPTH limits, 30s Magika timeout
- M2: Cache files added to .gitignore
- M3: Shared _EXCLUDED_DIRS between Magika and suffix scanners

ADR-022: Code graph via tree-sitter AST extraction
ADR-023: Document graph via embedding similarity
OpenSpec: add-fast-context-codebase-map, fix-codebase-map-review
…gestion

- azure_reader.py: Azure Document Intelligence backend with lazy SDK import
  and automatic fallback to local parser chain
- ingestion.py: type-aware chunking using Magika label to tree-sitter
  language mapping for code files
- ADR-024: Dual deployment modes (local vs azure)
- test_mcp_tools: add get_codebase_map tool registration check
- test_metadata_extractor: adjust assertions for updated metadata fields
- test_async_ingest_responsiveness: fix timing assertions
- sonar-project.properties: project key, source/test dirs, exclusions
- .github/workflows/sonarcloud.yml: runs on PR and push to master
  with coverage report generation
- SONAR_TOKEN stored as GitHub Actions secret (not in code)
- opencode.json: add sonarqube MCP server (token via env vars, not hardcoded)
- .sonarlint/connectedMode.json: link IDE to SonarCloud org cmdaltctr
Consolidate sonarcloud.yml into ci.yml as a second job so all checks
appear under a single CI workflow in PR checks.
- Help tests failed in CI due to rich ANSI escape codes in output
- Add _strip_ansi helper to clean --help output before assertions
- Remove pdf-liteparse matrix variant (liteparse is now a core dep)
- Slow tests now run on macOS via os check instead of extra
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@cmdaltctr
cmdaltctr merged commit cf6734f into master Jun 28, 2026
3 of 4 checks passed
@cmdaltctr
cmdaltctr deleted the fix/fix-codebase-map-review branch June 28, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant