Skip to content

feat(indexing): per-language grammar maps + derived import maps (B3+B4) - #25

Merged
ManSio merged 3 commits into
mainfrom
feat/import-map-derivation
Sep 8, 2026
Merged

ManSio merged 3 commits into
mainfrom
feat/import-map-derivation

Conversation

@ManSio

@ManSio ManSio commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Closes: import-map drift (kt/dart/php) + ungated fallback.

B3 — grammar maps wired from universal-engine study

Parser.\CALL_NODES/\IMPORT_NODE_MAP/\ASSIGNMENT_NODE_MAP/\CONDITIONAL_NODE_MAP\ now reflect live tree-sitter grammars verified for 11 languages:

  • calls: \simple_identifier\ (Swift/Kotlin/Dart), Java \method_invocation.name, PHP last-name call rule, Ruby \method\ target
  • imports: C/C++ #include\ regex, Kotlin keyword-import filter, Dart \library_import\ dedup, Ruby
    equire/include\
  • assigns: PHP \�ariable_name\ left, Swift \directly_assignable_expression\
  • conditional: per-language \CONDITIONAL_NODE_MAP\
  • live tests: TestMultiLangCalls (7) + TestMultiLangImports (9) + PHP assign

B4 — single source of truth for import node types

\LANGUAGE_IMPORT_NODES\ is now a derived view of \CodeParser.IMPORT_NODE_MAP\ (was a separate literal). Fallback (mode 2) runs only in the else-branch of _walk_file\ for unmapped ext, double-gated by \MSCODEBASE_LANGUAGE_PACK.

  • \extract_imports_from_file\ reads the flag via \language_pack.is_enabled\ (removes env re-read)
  • dedup moved to a shared path (precise + fallback)
  • lazy derivation via module _getattr_\ (PEP 562) so parser is never imported at module load; the static parser⇄language_imports cycle is registered as deliberate tech debt in _ALLOWED_CORE_CYCLES\ (KNOWN_ISSUES 2026-09-08)
  • tests: TestMapConsistency (3), TestFallbackImports (4), fallback-gate negative controls

Verification

  • targeted: 68 passed (language_imports + call_graph)
  • full suite on branch: 1644 passed / 5 skipped / 91 deselected
  • architecture_linter 4/4 OK, ruff clean, verify_diary 201/0
  • \�erified_from_clean_state: ⚠️ not run (no network for clean clone this session); full local suite green

MSCodeBase Agent added 2 commits September 8, 2026 10:12
…, conditions

Wire CALL_NODES/IMPORT_NODE_MAP/ASSIGNMENT_NODE_MAP/CONDITIONAL_NODE_MAP from universal-engine study into CodeParser walk, verified against live tree-sitter grammars for 11 languages.

- calls: simple_identifier (Swift/Kotlin/Dart), method_invocation name field (Java), PHP *_call_expression last-name rule, Ruby method target
- imports: C/C++ preproc_include regex, Kotlin keyword-import filter, Dart dedup, Ruby call require/include filter
- assigns: variable_name left (PHP), directly_assignable_expression + simple_identifier (Swift), name-node RHS
- conditional: per-language CONDITIONAL_NODE_MAP replaces shared set
- live tests: TestMultiLangCalls (7) + TestMultiLangImports (9) + php assign
…nd language pack flag

Route import extraction through a single source of truth: LANGUAGE_IMPORT_NODES is now a derived view of CodeParser.IMPORT_NODE_MAP instead of a separate literal that had drifted for kt/dart/php.

- parser._walk_file: run fallback (mode 2) only in the else-branch when ext has no map, behind a double gate (else-branch + language_pack.is_enabled inside iter_import_candidate_nodes); main grammar path stays priority
- extract_imports_from_file reads the flag via language_pack.is_enabled (removes env re-read)
- dedup moved out to a shared path used by both precise and fallback modes
- LANGUAGE_IMPORT_NODES: lazy derivation via module __getattr__ (PEP 562) so parser is never imported at module load; static parser<->language_imports cycle registered as deliberate tech debt in _ALLOWED_CORE_CYCLES (KNOWN_ISSUES 2026-09-08)
- tests: TestMapConsistency (card drift), TestFallbackImports (4 integration), fallback-gate negative controls; full suite green
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b955f254-f54c-4ef3-95f8-8e15b2e571b7


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Fix broken '? Fixed' status marker in the B3 diary entry (cp1251 roundtrip dropped the checkmark) and add B3/B4 entries to the current CHANGELOG section across ru/en/zh.
@ManSio
ManSio merged commit ebba73f into main Sep 8, 2026
12 of 13 checks passed
@ManSio
ManSio deleted the feat/import-map-derivation branch September 8, 2026 07:42
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