codmap 0.0.34__tar.gz → 0.0.35__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. {codmap-0.0.34 → codmap-0.0.35}/PKG-INFO +2 -2
  2. {codmap-0.0.34 → codmap-0.0.35}/README.md +1 -1
  3. {codmap-0.0.34 → codmap-0.0.35}/codemap/cli.py +9 -0
  4. {codmap-0.0.34 → codmap-0.0.35}/codemap/diagnostics.py +55 -1
  5. {codmap-0.0.34 → codmap-0.0.35}/codemap/extract/griffe_extractor.py +2 -1
  6. {codmap-0.0.34 → codmap-0.0.35}/codemap/extract/roots.py +2 -0
  7. {codmap-0.0.34 → codmap-0.0.35}/codemap/incremental.py +2 -0
  8. {codmap-0.0.34 → codmap-0.0.35}/codemap/model.py +31 -1
  9. {codmap-0.0.34 → codmap-0.0.35}/codmap.egg-info/PKG-INFO +2 -2
  10. {codmap-0.0.34 → codmap-0.0.35}/codmap.egg-info/SOURCES.txt +1 -0
  11. {codmap-0.0.34 → codmap-0.0.35}/pyproject.toml +1 -1
  12. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c39_edge_resolution.py +20 -0
  13. codmap-0.0.35/tests/test_r1c91_route_vocabulary.py +147 -0
  14. {codmap-0.0.34 → codmap-0.0.35}/LICENSE +0 -0
  15. {codmap-0.0.34 → codmap-0.0.35}/codemap/__init__.py +0 -0
  16. {codmap-0.0.34 → codmap-0.0.35}/codemap/apidiff.py +0 -0
  17. {codmap-0.0.34 → codmap-0.0.35}/codemap/arch.py +0 -0
  18. {codmap-0.0.34 → codmap-0.0.35}/codemap/extract/__init__.py +0 -0
  19. {codmap-0.0.34 → codmap-0.0.35}/codemap/extract/attrflow.py +0 -0
  20. {codmap-0.0.34 → codmap-0.0.35}/codemap/extract/behavior.py +0 -0
  21. {codmap-0.0.34 → codmap-0.0.35}/codemap/extract/dataflow.py +0 -0
  22. {codmap-0.0.34 → codmap-0.0.35}/codemap/extract/dispatch.py +0 -0
  23. {codmap-0.0.34 → codmap-0.0.35}/codemap/extract/gsource.py +0 -0
  24. {codmap-0.0.34 → codmap-0.0.35}/codemap/extract/probe.py +0 -0
  25. {codmap-0.0.34 → codmap-0.0.35}/codemap/extract/union.py +0 -0
  26. {codmap-0.0.34 → codmap-0.0.35}/codemap/freshness.py +0 -0
  27. {codmap-0.0.34 → codmap-0.0.35}/codemap/integrations/__init__.py +0 -0
  28. {codmap-0.0.34 → codmap-0.0.35}/codemap/integrations/base.py +0 -0
  29. {codmap-0.0.34 → codmap-0.0.35}/codemap/integrations/cocoindex.py +0 -0
  30. {codmap-0.0.34 → codmap-0.0.35}/codemap/integrations/gate.py +0 -0
  31. {codmap-0.0.34 → codmap-0.0.35}/codemap/integrations/gitnexus.py +0 -0
  32. {codmap-0.0.34 → codmap-0.0.35}/codemap/integrations/registry.py +0 -0
  33. {codmap-0.0.34 → codmap-0.0.35}/codemap/integrations/transport.py +0 -0
  34. {codmap-0.0.34 → codmap-0.0.35}/codemap/provenance.py +0 -0
  35. {codmap-0.0.34 → codmap-0.0.35}/codemap/query.py +0 -0
  36. {codmap-0.0.34 → codmap-0.0.35}/codemap/scope.py +0 -0
  37. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/__init__.py +0 -0
  38. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/_scip_pb2.py +0 -0
  39. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/api_surface.py +0 -0
  40. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/apidiff.py +0 -0
  41. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/architecture.py +0 -0
  42. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/audit.py +0 -0
  43. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/check.py +0 -0
  44. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/ctags.py +0 -0
  45. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/currency.py +0 -0
  46. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/impact.py +0 -0
  47. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/limits.py +0 -0
  48. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/livingdocs.py +0 -0
  49. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/mcp_server.py +0 -0
  50. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/mermaid.py +0 -0
  51. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/pack.py +0 -0
  52. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/rag.py +0 -0
  53. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/review.py +0 -0
  54. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/scip.py +0 -0
  55. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/semantic.py +0 -0
  56. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/server.py +0 -0
  57. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/session.py +0 -0
  58. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/subsystems.py +0 -0
  59. {codmap-0.0.34 → codmap-0.0.35}/codemap/serve/vault.py +0 -0
  60. {codmap-0.0.34 → codmap-0.0.35}/codemap/store.py +0 -0
  61. {codmap-0.0.34 → codmap-0.0.35}/codemap/tomlio.py +0 -0
  62. {codmap-0.0.34 → codmap-0.0.35}/codemap/watch.py +0 -0
  63. {codmap-0.0.34 → codmap-0.0.35}/codmap.egg-info/dependency_links.txt +0 -0
  64. {codmap-0.0.34 → codmap-0.0.35}/codmap.egg-info/entry_points.txt +0 -0
  65. {codmap-0.0.34 → codmap-0.0.35}/codmap.egg-info/requires.txt +0 -0
  66. {codmap-0.0.34 → codmap-0.0.35}/codmap.egg-info/top_level.txt +0 -0
  67. {codmap-0.0.34 → codmap-0.0.35}/setup.cfg +0 -0
  68. {codmap-0.0.34 → codmap-0.0.35}/tests/test_epistemic.py +0 -0
  69. {codmap-0.0.34 → codmap-0.0.35}/tests/test_gitnexus_router.py +0 -0
  70. {codmap-0.0.34 → codmap-0.0.35}/tests/test_impact_depth.py +0 -0
  71. {codmap-0.0.34 → codmap-0.0.35}/tests/test_integrations.py +0 -0
  72. {codmap-0.0.34 → codmap-0.0.35}/tests/test_issue3_serve_freshness.py +0 -0
  73. {codmap-0.0.34 → codmap-0.0.35}/tests/test_livingdocs.py +0 -0
  74. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m0_api_surface.py +0 -0
  75. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m11_argcontract.py +0 -0
  76. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m12_dataflow.py +0 -0
  77. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m15_review.py +0 -0
  78. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m16_architecture.py +0 -0
  79. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m17_mcp.py +0 -0
  80. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m18_freshness.py +0 -0
  81. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m1_5_semantics.py +0 -0
  82. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m1_query.py +0 -0
  83. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m2_views.py +0 -0
  84. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m32_watch.py +0 -0
  85. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m3_serve.py +0 -0
  86. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m4_behavior.py +0 -0
  87. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m5_deep.py +0 -0
  88. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m6_repo_scope.py +0 -0
  89. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m7_dispatch.py +0 -0
  90. {codmap-0.0.34 → codmap-0.0.35}/tests/test_m9_family.py +0 -0
  91. {codmap-0.0.34 → codmap-0.0.35}/tests/test_pack_honesty.py +0 -0
  92. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c13_callgraph_accuracy.py +0 -0
  93. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c13_grep_vs_graph.py +0 -0
  94. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c16_semantic.py +0 -0
  95. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c20_attribute_edges.py +0 -0
  96. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c21_flat_layout.py +0 -0
  97. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c22_source_visible_refs.py +0 -0
  98. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c23_hard_python.py +0 -0
  99. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c24_test_mapping.py +0 -0
  100. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c25_provenance.py +0 -0
  101. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c26_deep_union.py +0 -0
  102. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c27_config_honesty.py +0 -0
  103. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c28_limit_envelope.py +0 -0
  104. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c29_lazy_imports.py +0 -0
  105. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c2_ctags.py +0 -0
  106. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c30_local_import_calls.py +0 -0
  107. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c30f1_reexport_calls.py +0 -0
  108. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c30f2_check_scope.py +0 -0
  109. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c31_path_origin.py +0 -0
  110. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c32_report_json.py +0 -0
  111. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c33_query_signature.py +0 -0
  112. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c34_signature_kinds.py +0 -0
  113. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c35_contract_location.py +0 -0
  114. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c36_target_resolution.py +0 -0
  115. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c37_rule_mutation.py +0 -0
  116. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c38_tool_drift.py +0 -0
  117. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c3_arch_contract.py +0 -0
  118. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c3_dogfood.py +0 -0
  119. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c40_flow_reach.py +0 -0
  120. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c41_scope_membership.py +0 -0
  121. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c42_deep_tier_stability.py +0 -0
  122. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c43_incremental_splice.py +0 -0
  123. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c44_absent_answers.py +0 -0
  124. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c45_repeat_union.py +0 -0
  125. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c46_shadowed_definitions.py +0 -0
  126. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c47_incremental_resample.py +0 -0
  127. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c48_type_checking_imports.py +0 -0
  128. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c49_type_only_cycles.py +0 -0
  129. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c4_complexity.py +0 -0
  130. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c50_flow_entry_points.py +0 -0
  131. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c53_narrowing_declared.py +0 -0
  132. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c54_deterministic_rendering.py +0 -0
  133. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c55_override_grade.py +0 -0
  134. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c56_stub_files.py +0 -0
  135. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c57_facade_package.py +0 -0
  136. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c58_cycle_tangles.py +0 -0
  137. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c59_completeness_drop.py +0 -0
  138. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c5_apidiff.py +0 -0
  139. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c60_nested_definitions.py +0 -0
  140. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c62_phantom_rules.py +0 -0
  141. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c63_answer_format.py +0 -0
  142. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c64_dependency_probe.py +0 -0
  143. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c66_pack_direction.py +0 -0
  144. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c68_dotted_imports.py +0 -0
  145. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c69_contract_validation.py +0 -0
  146. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c6_pack.py +0 -0
  147. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c70_check_graph_currency.py +0 -0
  148. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c71_attribute_chain_calls.py +0 -0
  149. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c72_flat_inference_in_packages.py +0 -0
  150. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c73_cli_version.py +0 -0
  151. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c74_call_site_conservation.py +0 -0
  152. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c75_reexported_class_calls.py +0 -0
  153. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c76_contract_table_typo.py +0 -0
  154. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c77_gate_probe_battery.py +0 -0
  155. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c78_forbidden_chains.py +0 -0
  156. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c7_edge_vocab.py +0 -0
  157. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c80_tests_through_helpers.py +0 -0
  158. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c81_protocol_dispatch.py +0 -0
  159. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c82_review_changed_lines.py +0 -0
  160. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c83_foreign_graph_paths.py +0 -0
  161. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c84_missing_roots.py +0 -0
  162. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c85_mcp_graph_currency.py +0 -0
  163. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c86_incremental_repo_scope.py +0 -0
  164. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c87_review_path_base.py +0 -0
  165. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c89_review_docs.py +0 -0
  166. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c8_deadcode.py +0 -0
  167. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c90_currency_without_recipe.py +0 -0
  168. {codmap-0.0.34 → codmap-0.0.35}/tests/test_r1c9_incremental.py +0 -0
  169. {codmap-0.0.34 → codmap-0.0.35}/tests/test_scip_export.py +0 -0
  170. {codmap-0.0.34 → codmap-0.0.35}/tests/test_scope.py +0 -0
  171. {codmap-0.0.34 → codmap-0.0.35}/tests/test_subsystems.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codmap
3
- Version: 0.0.34
3
+ Version: 0.0.35
4
4
  Summary: Static analyzer that turns a package's source into a queryable code graph.
5
5
  Author-email: kogriv <kogriv@gmail.com>
6
6
  License-Expression: MIT
@@ -44,7 +44,7 @@ and a **SCIP index** for interop with Sourcegraph / Glean and other precise-code
44
44
 
45
45
  [![CI](https://github.com/kogriv/codemap/actions/workflows/ci.yml/badge.svg)](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
46
46
 
47
- **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1264 tests with no failures on
47
+ **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1273 tests with no failures on
48
48
  Python 3.11–3.14** ([in CI](docs/ci.md): the full suite including the dogfood pass, a determinism check, a
49
49
  wheel smoke test, and ctags/SCIP interop against the real CLIs), warm serve surface with 31 ops (28 exposed
50
50
  as MCP tools), and SCIP export. See **[DESIGN.md](DESIGN.md)** (product design &
@@ -8,7 +8,7 @@ and a **SCIP index** for interop with Sourcegraph / Glean and other precise-code
8
8
 
9
9
  [![CI](https://github.com/kogriv/codemap/actions/workflows/ci.yml/badge.svg)](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
10
10
 
11
- **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1264 tests with no failures on
11
+ **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1273 tests with no failures on
12
12
  Python 3.11–3.14** ([in CI](docs/ci.md): the full suite including the dogfood pass, a determinism check, a
13
13
  wheel smoke test, and ctags/SCIP interop against the real CLIs), warm serve surface with 31 ops (28 exposed
14
14
  as MCP tools), and SCIP export. See **[DESIGN.md](DESIGN.md)** (product design &
@@ -99,10 +99,19 @@ def _graph_from(args):
99
99
  graph = store.load(args.graph)
100
100
  if getattr(args, "func", None) not in (_cmd_check, _cmd_serve):
101
101
  _warn_if_behind(args.graph, graph, args)
102
+ _warn_if_newer_tool(args.graph, graph)
102
103
  return graph
103
104
  raise SystemExit("error: need --graph <file> or --build <path>")
104
105
 
105
106
 
107
+ def _warn_if_newer_tool(path: str, graph) -> None:
108
+ """R1-C91 D4: a cold read of a graph from a newer codemap says so, once, on stderr."""
109
+ from codemap.diagnostics import newer_tool_diagnostic
110
+ d = newer_tool_diagnostic(graph)
111
+ if d:
112
+ print(f"[warning] {path}: {d['message']} {d['consequence']}", file=sys.stderr)
113
+
114
+
106
115
  def _warn_if_behind(path: str, graph, args_for_currency=None) -> None:
107
116
  """R1-C85 D4: a cold read of a graph behind its tree says so, once, on stderr.
108
117
 
@@ -24,6 +24,7 @@ MODULE_COUNT_MISMATCH = "module_count_mismatch"
24
24
  SCOPE_MEMBERSHIP = "scope_membership"
25
25
  DEEP_TIER_UNSTABLE = "deep_tier_unstable"
26
26
  INCREMENTAL_DEEP_SPLICE = "incremental_deep_splice"
27
+ GRAPH_FROM_NEWER_TOOL = "graph_from_newer_tool"
27
28
 
28
29
  #: A ``warning`` invalidates the conclusions a surface draws from the graph — read them as
29
30
  #: unknown. A ``note`` states a fact about how the graph was built and invalidates nothing.
@@ -370,13 +371,66 @@ def module_count_diagnostic(graph) -> dict | None:
370
371
  }
371
372
 
372
373
 
374
+ def _version_tuple(v) -> tuple[int, ...] | None:
375
+ import re
376
+ m = re.match(r"(\d+(?:\.\d+)*)", str(v or ""))
377
+ return tuple(int(x) for x in m.group(1).split(".")) if m else None
378
+
379
+
380
+ def _running_version() -> str | None:
381
+ import codemap
382
+ return getattr(codemap, "__version__", None)
383
+
384
+
385
+ def newer_tool_diagnostic(graph, running: str | None = None) -> dict | None:
386
+ """Say when the graph was built by a newer codemap than the one reading it (R1-C91 D3).
387
+
388
+ Same schema, so it loads without a word — and the reader grades every route it does
389
+ not know as `unknown`, which `min_confidence` then drops. Measured on a consumer's
390
+ server: code 0.0.27 over a 0.0.34 graph, 2380 edges `unknown`, and `tool_restart_needed`
391
+ silent because it compares the running code with the *installed* one, never with the
392
+ graph. Either piece of evidence fires it: a newer recorded version, or routes this
393
+ build's table cannot grade (an uninstalled source tree has no version to compare).
394
+ """
395
+ from codemap.model import unrecognised_routes
396
+ running = running if running is not None else _running_version()
397
+ built_by = ((graph.provenance or {}).get("tool") or {}).get("version")
398
+ b, r = _version_tuple(built_by), _version_tuple(running)
399
+ newer = b is not None and r is not None and b > r
400
+ unknown = unrecognised_routes(graph)
401
+ if not newer and not unknown:
402
+ return None
403
+ edges = sum(unknown.values())
404
+ parts = []
405
+ if newer:
406
+ parts.append(f"this graph was built by codemap {built_by}, and codemap {running} is "
407
+ "reading it")
408
+ if unknown:
409
+ listed = ", ".join(f"{k} ({n})" for k, n in unknown.items())
410
+ parts.append(f"{edges} edge(s) carry routes this codemap does not know: {listed}")
411
+ # Not newer, yet unknown routes: an older graph with a route since retired, or an
412
+ # uninstalled reader — rebuilding with this codemap is the remedy either way.
413
+ remedy = (f"read it with codemap {built_by} or newer (restart a long-running server)"
414
+ if newer else "rebuild it with this codemap")
415
+ return {
416
+ "code": GRAPH_FROM_NEWER_TOOL,
417
+ "severity": WARNING,
418
+ "built_by": built_by,
419
+ "running": running,
420
+ "unrecognised": unknown,
421
+ "consequence": ("Edges with an unknown route are graded `unknown` and dropped by "
422
+ "`min_confidence`; answers keep the shape of the older code."),
423
+ "message": "; ".join(parts) + f" — {remedy}.",
424
+ }
425
+
426
+
373
427
  def diagnostics(graph) -> list[dict]:
374
428
  """Every diagnostic that applies to ``graph`` (empty list when it looks sound)."""
375
429
  checks = (import_graph_diagnostic(graph), namespace_target_diagnostic(graph),
376
430
  cross_root_diagnostic(graph), schema_diagnostic(graph),
377
431
  unread_inputs_diagnostic(graph), module_count_diagnostic(graph),
378
432
  scope_membership_diagnostic(graph), deep_tier_diagnostic(graph),
379
- incremental_splice_diagnostic(graph))
433
+ incremental_splice_diagnostic(graph), newer_tool_diagnostic(graph))
380
434
  return [d for d in checks if d is not None]
381
435
 
382
436
 
@@ -35,7 +35,7 @@ from codemap.extract.gsource import (DOTTED_IMPORT_HINT, NESTED_IMPORT_HINT, mod
35
35
  module_identity)
36
36
  from codemap.extract.union import merge_samples
37
37
  from codemap.provenance import build_provenance
38
- from codemap.model import Edge, Graph, Node
38
+ from codemap.model import Edge, Graph, Node, check_routes
39
39
 
40
40
  # griffe object kinds we turn into definition nodes (aliases handled separately).
41
41
  _NODE_KINDS = {"module", "class", "function", "attribute"}
@@ -266,6 +266,7 @@ def extract(package_path: str | Path, *, deep: bool = False, repeat: int = 1) ->
266
266
  graph.provenance = build_provenance(tier="deep" if deep else "fast",
267
267
  inputs=graph.provenance.get("inputs"),
268
268
  samples=stats)
269
+ check_routes(graph) # R1-C91 D2: every build guards the route table
269
270
  return graph
270
271
 
271
272
 
@@ -152,6 +152,8 @@ def extract_repo(
152
152
  "docs": sorted(_rel_to(Path(p).resolve(), base) for p in docs),
153
153
  "mode": mode,
154
154
  }})
155
+ from codemap.model import check_routes
156
+ check_routes(graph) # R1-C91 D2
155
157
  return graph
156
158
 
157
159
 
@@ -312,4 +312,6 @@ def update_graph(old_graph: Graph, package_path, old_scope: dict, new_scope: dic
312
312
  stats = {"runs": repeat, "unstable": _count_seen(graph)}
313
313
  graph.provenance = build_provenance(tier=tier, inputs=graph.provenance.get("inputs"),
314
314
  incremental=True, samples=stats)
315
+ from codemap.model import check_routes
316
+ check_routes(graph) # R1-C91 D2: the splice carries old edges forward
315
317
  return graph, {"mode": "incremental", "affected": sorted(affected)}
@@ -194,6 +194,9 @@ RESOLUTIONS: dict[tuple[str, str], dict[str, str]] = {
194
194
  "means": "route", "confidence": "heuristic",
195
195
  "how": "a call on a Protocol method fanned out to every structural implementer — "
196
196
  "the receiver is one of them, which one is not known (R1-C81)"},
197
+ ("calls", "local"): {"means": "route", "confidence": "exact",
198
+ "how": "a consumer-root call to a def at the level of the same module "
199
+ "(R1-C80); the consumer-root form of `module`"},
197
200
  ("calls", "typed"): {"means": "route", "confidence": "exact",
198
201
  "how": "a consumer-root call on an expression typed by a constructor "
199
202
  "or a return annotation (R1-C81)"},
@@ -214,6 +217,9 @@ RESOLUTIONS: dict[tuple[str, str], dict[str, str]] = {
214
217
  "how": "the symbol is named as a value (dict entry, default=…)"},
215
218
  ("references", "doc"): {"means": "site", "confidence": "exact",
216
219
  "how": "a documentation file names the symbol"},
220
+ ("references", "local"): {"means": "route", "confidence": "exact",
221
+ "how": "a consumer root names a def at the level of the same module "
222
+ "without calling it (R1-C80)"},
217
223
  ("references", "imported"): {"means": "route", "confidence": "exact",
218
224
  "how": "a consumer root names an imported core symbol"},
219
225
  ("reads", "string-key"): {"means": "route", "confidence": "exact",
@@ -245,7 +251,7 @@ def resolution_of(edge, *, strict: bool = True) -> dict[str, str] | None:
245
251
  ``None`` is a legitimate answer (``contains`` has no route), and it is distinct from
246
252
  a value the table does not know. Under ``strict`` that one raises — a silent unknown
247
253
  is how an open vocabulary pretends to be closed — and this is the form the guard test
248
- and the extractor use. Reading a *foreign* graph passes ``strict=False`` and gets an
254
+ uses; the builders check a whole graph with :func:`check_routes` (R1-C91). Reading a *foreign* graph passes ``strict=False`` and gets an
249
255
  ``unknown`` grade instead: refusing to open an artifact from another version is a
250
256
  worse answer than saying which part of it this build cannot grade.
251
257
  """
@@ -268,6 +274,30 @@ def confidence_of(edge, *, strict: bool = True) -> str | None:
268
274
  return row["confidence"] if row else None
269
275
 
270
276
 
277
+ def unrecognised_routes(graph) -> dict[str, int]:
278
+ """``{"type:resolution": edges}`` for every pair this build's table does not know (R1-C91)."""
279
+ out: dict[str, int] = {}
280
+ for e in graph.edges:
281
+ value = e.extras.get("resolution")
282
+ if value is not None and (e.type, value) not in RESOLUTIONS:
283
+ key = f"{e.type}:{value}"
284
+ out[key] = out.get(key, 0) + 1
285
+ return dict(sorted(out.items()))
286
+
287
+
288
+ def check_routes(graph) -> None:
289
+ """Refuse a graph this build produced with a route its own table does not grade (R1-C91 D2).
290
+
291
+ Called by every builder, so every build in the suite guards the table — not a fixture
292
+ list someone has to remember to extend. That list missed R1-C80's `local` for six
293
+ releases, and every repo graph carried 1107 edges graded `unknown` on one tree.
294
+ """
295
+ unknown = unrecognised_routes(graph)
296
+ if unknown:
297
+ raise KeyError(f"this build emitted route(s) its table does not know: {unknown} — add "
298
+ "them to RESOLUTIONS (codemap/model.py) with their meaning and grade")
299
+
300
+
271
301
  # The subset of EDGE_TYPES an incremental build splices from the old graph for modules
272
302
  # it did not recompute (``incremental.py``) — and therefore the classes a deep+incremental
273
303
  # graph answers from an *earlier* build's jedi sample (R1-C43). Lives with the vocabulary
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codmap
3
- Version: 0.0.34
3
+ Version: 0.0.35
4
4
  Summary: Static analyzer that turns a package's source into a queryable code graph.
5
5
  Author-email: kogriv <kogriv@gmail.com>
6
6
  License-Expression: MIT
@@ -44,7 +44,7 @@ and a **SCIP index** for interop with Sourcegraph / Glean and other precise-code
44
44
 
45
45
  [![CI](https://github.com/kogriv/codemap/actions/workflows/ci.yml/badge.svg)](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
46
46
 
47
- **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1264 tests with no failures on
47
+ **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1273 tests with no failures on
48
48
  Python 3.11–3.14** ([in CI](docs/ci.md): the full suite including the dogfood pass, a determinism check, a
49
49
  wheel smoke test, and ctags/SCIP interop against the real CLIs), warm serve surface with 31 ops (28 exposed
50
50
  as MCP tools), and SCIP export. See **[DESIGN.md](DESIGN.md)** (product design &
@@ -162,6 +162,7 @@ tests/test_r1c87_review_path_base.py
162
162
  tests/test_r1c89_review_docs.py
163
163
  tests/test_r1c8_deadcode.py
164
164
  tests/test_r1c90_currency_without_recipe.py
165
+ tests/test_r1c91_route_vocabulary.py
165
166
  tests/test_r1c9_incremental.py
166
167
  tests/test_scip_export.py
167
168
  tests/test_scope.py
@@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
9
9
  # version. README says this plainly, since `pip install codmap` / `import codemap` is a
10
10
  # seam a reader will otherwise hit by surprise.
11
11
  name = "codmap"
12
- version = "0.0.34"
12
+ version = "0.0.35"
13
13
  description = "Static analyzer that turns a package's source into a queryable code graph."
14
14
  readme = "README.md"
15
15
  # M20/D1: measured, not assumed. Each release of the declared range runs the full suite in
@@ -57,6 +57,25 @@ def _consumer_reference_probe(tmp: Path):
57
57
  return extract_repo(core, consumers=(use,), mode="full")
58
58
 
59
59
 
60
+ def _consumer_local_probe(tmp: Path):
61
+ """R1-C91: a consumer helper called and named inside its own module (`local`, R1-C80).
62
+
63
+ The route shipped in 0.0.28 without a row, and this list did not contain a build that
64
+ emitted it, so both directions of the closed-vocabulary check stayed green for six
65
+ releases. The builders now check every graph (D2); this probe keeps the reverse
66
+ direction — every row observed — honest for `local`.
67
+ """
68
+ core = tmp / "lcore"
69
+ core.mkdir()
70
+ (core / "__init__.py").write_text("")
71
+ (core / "m.py").write_text("def act():\n return 1\n")
72
+ use = tmp / "ltests"
73
+ use.mkdir()
74
+ (use / "test_m.py").write_text("from lcore.m import act\n\n\ndef _helper():\n return act()\n\n\n"
75
+ "def test_it():\n _helper()\n\n\nHOOKS = [_helper]\n")
76
+ return extract_repo(core, consumers=(use,), mode="full")
77
+
78
+
60
79
  def _protocol_probe(tmp: Path):
61
80
  """R1-C81: a call on a Protocol method, typed in a consumer, fanned out to its implementer."""
62
81
  core = tmp / "pcore"
@@ -87,6 +106,7 @@ def builds():
87
106
  docs=(FIX / "reporoot" / "docs",), mode="full")
88
107
  out["consumer-ref"] = _consumer_reference_probe(tmp)
89
108
  out["protocol"] = _protocol_probe(tmp)
109
+ out["consumer-local"] = _consumer_local_probe(tmp)
90
110
  return out
91
111
 
92
112
 
@@ -0,0 +1,147 @@
1
+ """R1-C91 — every route the extractor emits is graded; a graph from a newer codemap says so.
2
+
3
+ Design `docs/design/route_vocabulary_drift.md` (pre-registered 66feb01).
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import json
9
+ from pathlib import Path
10
+
11
+ import pytest
12
+
13
+ from codemap import model, store
14
+ from codemap.cli import main
15
+ from codemap.diagnostics import GRAPH_FROM_NEWER_TOOL, diagnostics, newer_tool_diagnostic
16
+ from codemap.extract import extract_repo
17
+ from codemap.query import Query
18
+ from codemap.serve.session import Session
19
+
20
+ FILES = {
21
+ "pkg/__init__.py": "",
22
+ "pkg/core.py": "def act():\n return 1\n",
23
+ "tests/test_a.py": ("from pkg.core import act\n\n\n"
24
+ "def _helper():\n return act()\n\n\n"
25
+ "def test_through_helper():\n assert _helper() == 1\n\n\n"
26
+ "HOOKS = [_helper]\n"),
27
+ }
28
+
29
+
30
+ def _write(root: Path):
31
+ for rel, body in FILES.items():
32
+ p = root / rel
33
+ p.parent.mkdir(parents=True, exist_ok=True)
34
+ p.write_text(body)
35
+
36
+
37
+ def _build(root: Path):
38
+ return extract_repo(str(root / "pkg"), consumers=(str(root / "tests"),), mode="full")
39
+
40
+
41
+ @pytest.fixture
42
+ def repo(tmp_path):
43
+ root = tmp_path / "repo"
44
+ _write(root)
45
+ return root
46
+
47
+
48
+ def _local(graph):
49
+ return {(e.type, e.source, e.target) for e in graph.edges
50
+ if e.extras.get("resolution") == "local"}
51
+
52
+
53
+ # -- D1 -------------------------------------------------------------------------------------
54
+
55
+ def test_E1_local_routes_are_graded_exact_and_survive_min_confidence(repo):
56
+ graph = _build(repo)
57
+ local = _local(graph)
58
+ helper = "tests.test_a._helper"
59
+ assert ("calls", "tests.test_a.test_through_helper", helper) in local
60
+ assert ("references", "tests.test_a", helper) in local, "the fixture must name it uncalled"
61
+ for e in graph.edges:
62
+ if e.extras.get("resolution") == "local":
63
+ assert model.confidence_of(e) == "exact"
64
+ q = Query(graph)
65
+ assert "unknown" not in q.confidence_map()["by_grade"]
66
+ assert "tests.test_a.test_through_helper" in q.callers(helper, min_confidence="exact")
67
+
68
+
69
+ # -- D2 -------------------------------------------------------------------------------------
70
+
71
+ def test_E5_a_builder_refuses_a_route_its_table_does_not_know(repo, monkeypatch):
72
+ for key in (("calls", "local"), ("references", "local")):
73
+ monkeypatch.delitem(model.RESOLUTIONS, key)
74
+ with pytest.raises(KeyError, match="local"):
75
+ _build(repo)
76
+
77
+
78
+ # -- D3 -------------------------------------------------------------------------------------
79
+
80
+ def _stamped(graph, version):
81
+ graph.provenance = {**graph.provenance,
82
+ "tool": {**(graph.provenance.get("tool") or {}), "version": version}}
83
+ return graph
84
+
85
+
86
+ def test_E3_a_newer_builder_is_named(repo):
87
+ graph = _stamped(_build(repo), "99.0.0")
88
+ d = newer_tool_diagnostic(graph, running="0.0.35")
89
+ assert d["code"] == GRAPH_FROM_NEWER_TOOL and d["severity"] == "warning"
90
+ assert d["built_by"] == "99.0.0" and d["running"] == "0.0.35" and d["unrecognised"] == {}
91
+ assert "99.0.0 or newer" in d["message"]
92
+ assert any(x["code"] == GRAPH_FROM_NEWER_TOOL for x in diagnostics(graph))
93
+
94
+
95
+ def test_E3_unknown_routes_are_listed_with_counts(repo):
96
+ graph = _build(repo)
97
+ e = next(e for e in graph.edges if e.extras.get("resolution") == "imported")
98
+ e.extras["resolution"] = "future"
99
+ d = newer_tool_diagnostic(graph, running="0.0.35")
100
+ assert d["unrecognised"] == {f"{e.type}:future": 1}
101
+ assert "rebuild it with this codemap" in d["message"], "not newer: the remedy is a rebuild"
102
+
103
+
104
+ def test_unknown_routes_fire_without_a_running_version(repo):
105
+ graph = _build(repo)
106
+ next(e for e in graph.edges if e.extras.get("resolution")).extras["resolution"] = "future"
107
+ assert newer_tool_diagnostic(graph, running="")["unrecognised"]
108
+
109
+
110
+ def test_E2_an_older_or_equal_graph_with_known_routes_is_silent(repo):
111
+ graph = _build(repo)
112
+ for v in ("0.0.1", "0.0.35"):
113
+ assert newer_tool_diagnostic(_stamped(graph, v), running="0.0.35") is None
114
+
115
+
116
+ def test_the_running_version_compares_by_number_not_by_string(repo):
117
+ graph = _stamped(_build(repo), "0.0.100")
118
+ assert newer_tool_diagnostic(graph, running="0.0.99") is not None
119
+ assert newer_tool_diagnostic(_stamped(graph, "0.0.9"), running="0.0.10") is None
120
+
121
+
122
+ def test_stats_carries_it(repo, tmp_path):
123
+ graph = _stamped(_build(repo), "99.0.0")
124
+ out = Session(graph).handle({"op": "stats"})
125
+ codes = [d["code"] for d in out["result"].get("diagnostics", [])]
126
+ assert GRAPH_FROM_NEWER_TOOL in codes
127
+
128
+
129
+ # -- D4 -------------------------------------------------------------------------------------
130
+
131
+ def test_E3_cold_cli_read_warns_once_and_keeps_stdout(repo, tmp_path, capsys, monkeypatch):
132
+ monkeypatch.chdir(repo)
133
+ g = tmp_path / "g.json"
134
+ assert main(["build", "pkg", "--consumer", "tests", "--mode", "full", "-o", str(g)]) == 0
135
+ capsys.readouterr()
136
+ assert main(["query", "act", "--graph", str(g)]) == 0
137
+ plain = capsys.readouterr()
138
+ assert "graph_from_newer_tool" not in plain.err and "built by codemap" not in plain.err
139
+
140
+ data = json.loads(g.read_text())
141
+ data["provenance"]["tool"]["version"] = "99.0.0"
142
+ g.write_text(json.dumps(data))
143
+ assert main(["query", "act", "--graph", str(g)]) == 0
144
+ stamped = capsys.readouterr()
145
+ lines = [ln for ln in stamped.err.splitlines() if "built by codemap 99.0.0" in ln]
146
+ assert len(lines) == 1 and lines[0].startswith("[warning]")
147
+ assert stamped.out == plain.out
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes