codmap 0.0.27__tar.gz → 0.0.29__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 (163) hide show
  1. {codmap-0.0.27/codmap.egg-info → codmap-0.0.29}/PKG-INFO +4 -3
  2. {codmap-0.0.27 → codmap-0.0.29}/README.md +3 -2
  3. {codmap-0.0.27 → codmap-0.0.29}/codemap/cli.py +79 -18
  4. {codmap-0.0.27 → codmap-0.0.29}/codemap/extract/roots.py +45 -2
  5. {codmap-0.0.27 → codmap-0.0.29}/codemap/model.py +6 -1
  6. {codmap-0.0.27 → codmap-0.0.29}/codemap/query.py +87 -23
  7. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/mcp_server.py +10 -6
  8. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/session.py +2 -1
  9. {codmap-0.0.27 → codmap-0.0.29/codmap.egg-info}/PKG-INFO +4 -3
  10. {codmap-0.0.27 → codmap-0.0.29}/codmap.egg-info/SOURCES.txt +3 -0
  11. {codmap-0.0.27 → codmap-0.0.29}/pyproject.toml +1 -1
  12. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c63_answer_format.py +45 -0
  13. codmap-0.0.29/tests/test_r1c80_tests_through_helpers.py +120 -0
  14. codmap-0.0.29/tests/test_r1c83_foreign_graph_paths.py +125 -0
  15. codmap-0.0.29/tests/test_r1c84_missing_roots.py +126 -0
  16. {codmap-0.0.27 → codmap-0.0.29}/LICENSE +0 -0
  17. {codmap-0.0.27 → codmap-0.0.29}/codemap/__init__.py +0 -0
  18. {codmap-0.0.27 → codmap-0.0.29}/codemap/apidiff.py +0 -0
  19. {codmap-0.0.27 → codmap-0.0.29}/codemap/arch.py +0 -0
  20. {codmap-0.0.27 → codmap-0.0.29}/codemap/diagnostics.py +0 -0
  21. {codmap-0.0.27 → codmap-0.0.29}/codemap/extract/__init__.py +0 -0
  22. {codmap-0.0.27 → codmap-0.0.29}/codemap/extract/attrflow.py +0 -0
  23. {codmap-0.0.27 → codmap-0.0.29}/codemap/extract/behavior.py +0 -0
  24. {codmap-0.0.27 → codmap-0.0.29}/codemap/extract/dataflow.py +0 -0
  25. {codmap-0.0.27 → codmap-0.0.29}/codemap/extract/dispatch.py +0 -0
  26. {codmap-0.0.27 → codmap-0.0.29}/codemap/extract/griffe_extractor.py +0 -0
  27. {codmap-0.0.27 → codmap-0.0.29}/codemap/extract/gsource.py +0 -0
  28. {codmap-0.0.27 → codmap-0.0.29}/codemap/extract/probe.py +0 -0
  29. {codmap-0.0.27 → codmap-0.0.29}/codemap/extract/union.py +0 -0
  30. {codmap-0.0.27 → codmap-0.0.29}/codemap/freshness.py +0 -0
  31. {codmap-0.0.27 → codmap-0.0.29}/codemap/incremental.py +0 -0
  32. {codmap-0.0.27 → codmap-0.0.29}/codemap/integrations/__init__.py +0 -0
  33. {codmap-0.0.27 → codmap-0.0.29}/codemap/integrations/base.py +0 -0
  34. {codmap-0.0.27 → codmap-0.0.29}/codemap/integrations/cocoindex.py +0 -0
  35. {codmap-0.0.27 → codmap-0.0.29}/codemap/integrations/gate.py +0 -0
  36. {codmap-0.0.27 → codmap-0.0.29}/codemap/integrations/gitnexus.py +0 -0
  37. {codmap-0.0.27 → codmap-0.0.29}/codemap/integrations/registry.py +0 -0
  38. {codmap-0.0.27 → codmap-0.0.29}/codemap/integrations/transport.py +0 -0
  39. {codmap-0.0.27 → codmap-0.0.29}/codemap/provenance.py +0 -0
  40. {codmap-0.0.27 → codmap-0.0.29}/codemap/scope.py +0 -0
  41. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/__init__.py +0 -0
  42. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/_scip_pb2.py +0 -0
  43. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/api_surface.py +0 -0
  44. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/apidiff.py +0 -0
  45. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/architecture.py +0 -0
  46. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/audit.py +0 -0
  47. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/check.py +0 -0
  48. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/ctags.py +0 -0
  49. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/currency.py +0 -0
  50. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/impact.py +0 -0
  51. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/limits.py +0 -0
  52. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/livingdocs.py +0 -0
  53. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/mermaid.py +0 -0
  54. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/pack.py +0 -0
  55. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/rag.py +0 -0
  56. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/review.py +0 -0
  57. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/scip.py +0 -0
  58. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/semantic.py +0 -0
  59. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/server.py +0 -0
  60. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/subsystems.py +0 -0
  61. {codmap-0.0.27 → codmap-0.0.29}/codemap/serve/vault.py +0 -0
  62. {codmap-0.0.27 → codmap-0.0.29}/codemap/store.py +0 -0
  63. {codmap-0.0.27 → codmap-0.0.29}/codemap/tomlio.py +0 -0
  64. {codmap-0.0.27 → codmap-0.0.29}/codemap/watch.py +0 -0
  65. {codmap-0.0.27 → codmap-0.0.29}/codmap.egg-info/dependency_links.txt +0 -0
  66. {codmap-0.0.27 → codmap-0.0.29}/codmap.egg-info/entry_points.txt +0 -0
  67. {codmap-0.0.27 → codmap-0.0.29}/codmap.egg-info/requires.txt +0 -0
  68. {codmap-0.0.27 → codmap-0.0.29}/codmap.egg-info/top_level.txt +0 -0
  69. {codmap-0.0.27 → codmap-0.0.29}/setup.cfg +0 -0
  70. {codmap-0.0.27 → codmap-0.0.29}/tests/test_epistemic.py +0 -0
  71. {codmap-0.0.27 → codmap-0.0.29}/tests/test_gitnexus_router.py +0 -0
  72. {codmap-0.0.27 → codmap-0.0.29}/tests/test_impact_depth.py +0 -0
  73. {codmap-0.0.27 → codmap-0.0.29}/tests/test_integrations.py +0 -0
  74. {codmap-0.0.27 → codmap-0.0.29}/tests/test_issue3_serve_freshness.py +0 -0
  75. {codmap-0.0.27 → codmap-0.0.29}/tests/test_livingdocs.py +0 -0
  76. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m0_api_surface.py +0 -0
  77. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m11_argcontract.py +0 -0
  78. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m12_dataflow.py +0 -0
  79. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m15_review.py +0 -0
  80. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m16_architecture.py +0 -0
  81. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m17_mcp.py +0 -0
  82. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m18_freshness.py +0 -0
  83. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m1_5_semantics.py +0 -0
  84. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m1_query.py +0 -0
  85. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m2_views.py +0 -0
  86. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m32_watch.py +0 -0
  87. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m3_serve.py +0 -0
  88. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m4_behavior.py +0 -0
  89. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m5_deep.py +0 -0
  90. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m6_repo_scope.py +0 -0
  91. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m7_dispatch.py +0 -0
  92. {codmap-0.0.27 → codmap-0.0.29}/tests/test_m9_family.py +0 -0
  93. {codmap-0.0.27 → codmap-0.0.29}/tests/test_pack_honesty.py +0 -0
  94. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c13_callgraph_accuracy.py +0 -0
  95. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c13_grep_vs_graph.py +0 -0
  96. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c16_semantic.py +0 -0
  97. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c20_attribute_edges.py +0 -0
  98. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c21_flat_layout.py +0 -0
  99. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c22_source_visible_refs.py +0 -0
  100. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c23_hard_python.py +0 -0
  101. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c24_test_mapping.py +0 -0
  102. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c25_provenance.py +0 -0
  103. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c26_deep_union.py +0 -0
  104. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c27_config_honesty.py +0 -0
  105. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c28_limit_envelope.py +0 -0
  106. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c29_lazy_imports.py +0 -0
  107. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c2_ctags.py +0 -0
  108. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c30_local_import_calls.py +0 -0
  109. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c30f1_reexport_calls.py +0 -0
  110. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c30f2_check_scope.py +0 -0
  111. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c31_path_origin.py +0 -0
  112. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c32_report_json.py +0 -0
  113. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c33_query_signature.py +0 -0
  114. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c34_signature_kinds.py +0 -0
  115. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c35_contract_location.py +0 -0
  116. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c36_target_resolution.py +0 -0
  117. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c37_rule_mutation.py +0 -0
  118. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c38_tool_drift.py +0 -0
  119. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c39_edge_resolution.py +0 -0
  120. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c3_arch_contract.py +0 -0
  121. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c3_dogfood.py +0 -0
  122. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c40_flow_reach.py +0 -0
  123. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c41_scope_membership.py +0 -0
  124. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c42_deep_tier_stability.py +0 -0
  125. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c43_incremental_splice.py +0 -0
  126. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c44_absent_answers.py +0 -0
  127. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c45_repeat_union.py +0 -0
  128. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c46_shadowed_definitions.py +0 -0
  129. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c47_incremental_resample.py +0 -0
  130. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c48_type_checking_imports.py +0 -0
  131. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c49_type_only_cycles.py +0 -0
  132. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c4_complexity.py +0 -0
  133. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c50_flow_entry_points.py +0 -0
  134. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c53_narrowing_declared.py +0 -0
  135. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c54_deterministic_rendering.py +0 -0
  136. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c55_override_grade.py +0 -0
  137. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c56_stub_files.py +0 -0
  138. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c57_facade_package.py +0 -0
  139. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c58_cycle_tangles.py +0 -0
  140. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c59_completeness_drop.py +0 -0
  141. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c5_apidiff.py +0 -0
  142. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c60_nested_definitions.py +0 -0
  143. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c62_phantom_rules.py +0 -0
  144. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c64_dependency_probe.py +0 -0
  145. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c66_pack_direction.py +0 -0
  146. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c68_dotted_imports.py +0 -0
  147. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c69_contract_validation.py +0 -0
  148. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c6_pack.py +0 -0
  149. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c70_check_graph_currency.py +0 -0
  150. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c71_attribute_chain_calls.py +0 -0
  151. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c72_flat_inference_in_packages.py +0 -0
  152. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c73_cli_version.py +0 -0
  153. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c74_call_site_conservation.py +0 -0
  154. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c75_reexported_class_calls.py +0 -0
  155. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c76_contract_table_typo.py +0 -0
  156. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c77_gate_probe_battery.py +0 -0
  157. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c78_forbidden_chains.py +0 -0
  158. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c7_edge_vocab.py +0 -0
  159. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c8_deadcode.py +0 -0
  160. {codmap-0.0.27 → codmap-0.0.29}/tests/test_r1c9_incremental.py +0 -0
  161. {codmap-0.0.27 → codmap-0.0.29}/tests/test_scip_export.py +0 -0
  162. {codmap-0.0.27 → codmap-0.0.29}/tests/test_scope.py +0 -0
  163. {codmap-0.0.27 → codmap-0.0.29}/tests/test_subsystems.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codmap
3
- Version: 0.0.27
3
+ Version: 0.0.29
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, **1180 tests with no failures on
47
+ **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1207 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 &
@@ -170,7 +170,8 @@ Optional extras: `mcp` (Model Context Protocol server), `scip` (protobuf, for SC
170
170
  # build the canonical graph of a package (its directory name is the package name every id starts with)
171
171
  codemap build ./yourpkg -o graph.json
172
172
 
173
- # repo-scoped: add consumers (tests/examples) + docs for blast-radius/impact
173
+ # repo-scoped: add consumers (tests/examples) + docs for blast-radius/impact;
174
+ # one flag per root — a root that is not a directory is refused, exit 2
174
175
  codemap build ./yourpkg --deep --mode full --consumer ./tests --docs ./docs -o graph.json
175
176
 
176
177
  # deep tier: union N independent samples (one build misses a real edge ~1 time in 4)
@@ -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, **1180 tests with no failures on
11
+ **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1207 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 &
@@ -134,7 +134,8 @@ Optional extras: `mcp` (Model Context Protocol server), `scip` (protobuf, for SC
134
134
  # build the canonical graph of a package (its directory name is the package name every id starts with)
135
135
  codemap build ./yourpkg -o graph.json
136
136
 
137
- # repo-scoped: add consumers (tests/examples) + docs for blast-radius/impact
137
+ # repo-scoped: add consumers (tests/examples) + docs for blast-radius/impact;
138
+ # one flag per root — a root that is not a directory is refused, exit 2
138
139
  codemap build ./yourpkg --deep --mode full --consumer ./tests --docs ./docs -o graph.json
139
140
 
140
141
  # deep tier: union N independent samples (one build misses a real edge ~1 time in 4)
@@ -49,7 +49,7 @@ from pathlib import Path
49
49
  from codemap import store
50
50
  from codemap.diagnostics import diagnostics
51
51
  from codemap.extract import extract, extract_repo
52
- from codemap.extract.roots import roots_base
52
+ from codemap.extract.roots import root_problems, roots_base
53
53
  from codemap.provenance import build_provenance
54
54
  from codemap.query import Query
55
55
  from codemap.serve import (
@@ -100,6 +100,19 @@ def _graph_from(args):
100
100
  raise SystemExit("error: need --graph <file> or --build <path>")
101
101
 
102
102
 
103
+ def _refuse_bad_roots(args) -> bool:
104
+ """R1-C84: print every unreadable ``--consumer``/``--docs`` root; True means refuse (exit 2).
105
+
106
+ Checked before anything is built — a `--deep` core pass must not spend minutes on a
107
+ graph that will lack a root — and before ``-o`` is touched.
108
+ """
109
+ problems = root_problems(tuple(getattr(args, "consumer", None) or ()),
110
+ tuple(getattr(args, "docs", None) or ()))
111
+ for p in problems:
112
+ print(f"error: {p}", file=sys.stderr)
113
+ return bool(problems)
114
+
115
+
103
116
  def _cmd_build(args) -> int:
104
117
  incr_info = None
105
118
  repeat = getattr(args, "repeat", None)
@@ -114,6 +127,8 @@ def _cmd_build(args) -> int:
114
127
  print(f"error: --repeat {repeat} needs --deep — the fast tier is byte-stable, so "
115
128
  "repeating it unions identical samples", file=sys.stderr)
116
129
  return 2
130
+ if _refuse_bad_roots(args):
131
+ return 2
117
132
  if args.consumer or args.docs:
118
133
  if getattr(args, "incremental", False):
119
134
  # R1-C44 / D6: the flag used to be swallowed here without a word. Not an
@@ -311,6 +326,8 @@ def _cmd_watch(args) -> int:
311
326
  import argparse as _argparse
312
327
  from codemap.watch import DebouncedPoller, scope_probe
313
328
 
329
+ if _refuse_bad_roots(args):
330
+ return 2
314
331
  consumers = tuple(args.consumer or ())
315
332
  docs = tuple(args.docs or ())
316
333
  build_args = _argparse.Namespace(
@@ -328,7 +345,11 @@ def _cmd_watch(args) -> int:
328
345
  # and it would pollute a pipeline this watcher is composed into. Everything
329
346
  # this command says goes to stderr — stdout stays empty on purpose.
330
347
  with contextlib.redirect_stdout(sys.stderr):
331
- _cmd_build(build_args)
348
+ rc = _cmd_build(build_args)
349
+ if rc != 0:
350
+ # R1-C84: a refusal returns 2 rather than raising (a root deleted while
351
+ # watching); it is a failed rebuild, never "rebuilt".
352
+ raise RuntimeError(f"build exited {rc}")
332
353
  except Exception as exc:
333
354
  # A failed rebuild leaves the previous graph in place, and says so. Silence
334
355
  # here would be the same defect this project keeps fixing: a stale answer
@@ -402,6 +423,8 @@ def _cmd_scope(args) -> int:
402
423
  return 0 if not (d["added"] or d["removed"] or d["changed"]) else 1
403
424
  if not args.path:
404
425
  raise SystemExit("error: scope needs <path> (or --diff A B)")
426
+ if _refuse_bad_roots(args):
427
+ return 2
405
428
  scope = resolve_scope(args.path, consumers=tuple(args.consumer or ()),
406
429
  docs=tuple(args.docs or ()), use_git=not args.no_git)
407
430
  if args.json:
@@ -495,8 +518,10 @@ def _cmd_tests(args) -> int:
495
518
  session = Session(_graph_from(args))
496
519
  op = "covers" if args.covers else "tests"
497
520
  key = "test" if args.covers else "symbol"
498
- env = session.handle({"op": op, "args": {key: args.name,
499
- "depth": args.depth, "cap": args.cap}})
521
+ payload = {key: args.name, "depth": args.depth, "cap": args.cap}
522
+ if not args.covers:
523
+ payload["all_bands"] = args.all_bands
524
+ env = session.handle({"op": op, "args": payload})
500
525
  if not env.get("ok"):
501
526
  print(env.get("error", "not found"), file=sys.stderr)
502
527
  return 1
@@ -512,7 +537,12 @@ def _cmd_tests(args) -> int:
512
537
  print(f"# tests for {r['symbol']} — confidence: {r['confidence']}"
513
538
  + (f", {r['distance']} hop(s) away" if r["distance"] else ""))
514
539
  for row in r["tests"]:
515
- print(f" {row['node_id']}")
540
+ far = f" (distance {row['distance']})" if args.all_bands else ""
541
+ print(f" {row['node_id']}{far}")
542
+ nb = r.get("next_band")
543
+ if nb and not args.all_bands: # R1-C80 D2
544
+ print(f" … {nb['count']} more test(s) at distance {nb['distance']} — "
545
+ "`--all-bands` lists them")
516
546
  for c in r["caveats"]:
517
547
  print(f" · {c}", file=sys.stderr)
518
548
  ids = [row["node_id"] for row in r.get("tests", []) if row.get("node_id")]
@@ -538,26 +568,50 @@ def _local_nodeids(ids: list[str], args) -> tuple[list[str], str | None]:
538
568
  there**: a rewrite that cannot be verified is not printed, and the caveat says which
539
569
  directory the untouched path belongs to instead of leaving the reader to find out from
540
570
  pytest. The op's own payload keeps the graph-relative id, which is the portable one.
571
+
572
+ R1-C83: a graph built on another machine (or another checkout) records a directory
573
+ that is not here. One base was tried, so a line that ran fine from the repo root still
574
+ drew "could not be located", and from anywhere else there was no way to name the root.
575
+ Now ``--source-root`` is the only base when given; otherwise the sidecar's directory if
576
+ it exists here, then the current one — each path against the first base where that
577
+ file is, so nothing unverified is printed.
541
578
  """
542
579
  from codemap.freshness import read_meta
543
580
  meta = read_meta(getattr(args, "graph", None) or "") or {}
544
- base = meta.get("roots_base")
545
- if not base:
546
- return ids, ("paths are relative to the build roots' common directory — run from "
547
- "there, or rebuild with this codemap so the sidecar records it")
548
- out, resolved = [], 0
581
+ recorded = meta.get("roots_base")
582
+ explicit = getattr(args, "source_root", None)
583
+ if explicit:
584
+ bases = [explicit]
585
+ else:
586
+ bases = [b for b in (recorded,) if b and os.path.isdir(b)] + [os.getcwd()]
587
+ out, missing = [], 0
549
588
  for nid in ids:
550
589
  path, sep, tail = nid.partition("::")
551
- full = os.path.join(base, path)
552
- if os.path.exists(full):
553
- out.append(os.path.relpath(full, os.getcwd()) + sep + tail)
554
- resolved += 1
590
+ for b in bases:
591
+ full = os.path.join(b, path)
592
+ if os.path.exists(full):
593
+ out.append(os.path.relpath(full, os.getcwd()) + sep + tail)
594
+ break
555
595
  else:
556
596
  out.append(nid)
557
- if resolved != len(ids):
558
- return out, (f"{len(ids) - resolved} of {len(ids)} path(s) could not be located on "
559
- f"this machine and are printed as the graph stores them — relative to "
560
- f"`{base}`")
597
+ missing += 1
598
+ if missing:
599
+ if explicit:
600
+ return out, (f"{missing} of {len(ids)} path(s) not found under `--source-root "
601
+ f"{explicit}` and are printed as the graph stores them")
602
+ if not recorded:
603
+ return out, ("paths are relative to the build roots' common directory — run from "
604
+ "there, pass `--source-root`, or rebuild with this codemap so the "
605
+ "sidecar records it")
606
+ tried = " and ".join(f"`{b}`" for b in bases)
607
+ away = ("" if os.path.isdir(recorded) else
608
+ f" (the graph was built in `{recorded}`, which is not on this machine)")
609
+ return out, (f"{missing} of {len(ids)} path(s) could not be located under {tried}{away} "
610
+ f"and are printed as the graph stores them — pass `--source-root` with "
611
+ f"the directory the graph's paths are relative to")
612
+ if recorded and not explicit and not os.path.isdir(recorded):
613
+ return out, (f"the graph was built in `{recorded}`, which is not on this machine; "
614
+ f"paths located from the current directory")
561
615
  return out, None
562
616
 
563
617
 
@@ -1081,7 +1135,12 @@ def build_parser() -> argparse.ArgumentParser:
1081
1135
  help="Hops to search back. Beyond 3 the answer is low-confidence "
1082
1136
  "(measured: precision 1.00 at 3 hops, 0.33 at 5).")
1083
1137
  t.add_argument("--cap", type=int, default=25, help="Max tests listed (default 25).")
1138
+ t.add_argument("--all-bands", action="store_true",
1139
+ help="List every band within --depth, not only the nearest (R1-C80).")
1084
1140
  t.add_argument("--format", choices=["text", "json"], default="text")
1141
+ t.add_argument("--source-root", metavar="DIR",
1142
+ help="Directory the graph's paths are relative to on this machine, for the "
1143
+ "printed pytest line (default: the build's own, else the current one).")
1085
1144
  t.set_defaults(func=_cmd_tests)
1086
1145
 
1087
1146
  r = sub.add_parser("report", help="Render a report over the graph.")
@@ -1096,6 +1155,8 @@ def build_parser() -> argparse.ArgumentParser:
1096
1155
  r.add_argument("--min-confidence", choices=["low", "medium", "high"], default=None,
1097
1156
  help="report dead-code: only show candidates at/above this confidence.")
1098
1157
  r.add_argument("--format", choices=["markdown", "json"], default="markdown")
1158
+ r.add_argument("--source-root", metavar="DIR",
1159
+ help="Where codemap.toml is read for `dead-code` (default: current dir).")
1099
1160
  r.set_defaults(func=_cmd_report)
1100
1161
 
1101
1162
  e = sub.add_parser("export", help="Export a view: rag (JSONL) | vault | mermaid | scip | ctags | docs.")
@@ -61,6 +61,32 @@ def roots_base(core: str | Path, consumers=(), docs=()) -> Path:
61
61
  return Path(os.path.commonpath([str(p) for p in parents]))
62
62
 
63
63
 
64
+ def root_problems(consumers=(), docs=()) -> list[str]:
65
+ """Every ``--consumer`` / ``--docs`` root that cannot be read, in words (R1-C84).
66
+
67
+ The scanners skip a root that is not a directory, so a typo or two roots passed in
68
+ one string (`--consumer tests,examples`) built a graph without them, exit 0, and the
69
+ provenance still listed the root as read. Callers refuse on any problem instead.
70
+ An existing empty directory is not a problem: the graph simply has nothing from it.
71
+ """
72
+ problems = []
73
+ for flag, paths in (("--consumer", consumers), ("--docs", docs)):
74
+ for raw in paths:
75
+ p = Path(raw)
76
+ if p.is_dir():
77
+ continue
78
+ if p.exists():
79
+ problems.append(f"`{flag} {raw}`: not a directory")
80
+ continue
81
+ msg = f"`{flag} {raw}`: no such directory"
82
+ parts = [s for s in str(raw).split(",") if s]
83
+ if len(parts) > 1 and all(Path(s).is_dir() for s in parts):
84
+ msg += (" — looks like a list; pass the flag once per root: `"
85
+ + " ".join(f"{flag} {s}" for s in parts) + "`")
86
+ problems.append(msg)
87
+ return problems
88
+
89
+
64
90
  def _reroot_files(graph, offset: str) -> None:
65
91
  """Prefix every node's ``file`` with ``offset`` (the core pass wrote them relative to
66
92
  the core's own parent, which may be below the common origin)."""
@@ -90,6 +116,9 @@ def extract_repo(
90
116
  """
91
117
  if mode not in ("thin", "full"):
92
118
  raise ValueError(f"mode must be 'thin' or 'full', got {mode!r}")
119
+ problems = root_problems(consumers, docs)
120
+ if problems:
121
+ raise ValueError("; ".join(problems))
93
122
 
94
123
  graph = extract(core, deep=deep, repeat=repeat)
95
124
  core_pkg = graph.target
@@ -269,6 +298,14 @@ def _scan_consumer_module(graph, py, base, label, tree, index, mode, origin=None
269
298
  # R1-C46: a use inside a body that a later definition replaced is not a use — it
270
299
  # would attribute a reference (or a call) to code that never runs, in either mode.
271
300
  dead = _shadow_map(tree)[2]
301
+ # R1-C80 D0: in full mode, a use of the module's own top-level function or class is an
302
+ # edge too — a test calling `_vector` in its own module. Without it the walk from a core
303
+ # symbol stopped at the helper. Names that an import also binds are left to the import.
304
+ local_defs = set()
305
+ if mode == "full":
306
+ local_defs = {n.name for n in tree.body
307
+ if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef))}
308
+ local_defs -= set(symbol_map) | set(module_aliases)
272
309
 
273
310
  for node in ast.walk(tree):
274
311
  line = getattr(node, "lineno", None)
@@ -276,8 +313,12 @@ def _scan_consumer_module(graph, py, base, label, tree, index, mode, origin=None
276
313
  continue
277
314
  target = None
278
315
  use_node = node
316
+ local = False
279
317
  if isinstance(node, ast.Name) and node.id in symbol_map:
280
318
  target = index.resolve(symbol_map[node.id])
319
+ elif (isinstance(node, ast.Name) and node.id in local_defs
320
+ and isinstance(node.ctx, ast.Load)):
321
+ target, local = f"{mod_id}.{node.id}", True
281
322
  elif isinstance(node, ast.Attribute) and id(node) not in inner_attr_ids:
282
323
  dotted = _dotted(node)
283
324
  if dotted:
@@ -288,7 +329,9 @@ def _scan_consumer_module(graph, py, base, label, tree, index, mode, origin=None
288
329
  if not target:
289
330
  continue
290
331
  src = _source_for(use_node, mod_id, func_ranges) if mode == "full" else mod_id
291
- entry = uses.setdefault((src, target), {"called": False, "shapes": []})
332
+ if local and (src == target or target not in graph.nodes):
333
+ continue # recursion, or a def the shadow rule dropped
334
+ entry = uses.setdefault((src, target), {"called": False, "shapes": [], "local": local})
292
335
  call_node = call_by_func.get(id(use_node))
293
336
  if call_node is not None:
294
337
  entry["called"] = True
@@ -296,7 +339,7 @@ def _scan_consumer_module(graph, py, base, label, tree, index, mode, origin=None
296
339
 
297
340
  for (src, target), entry in sorted(uses.items()):
298
341
  etype = "calls" if entry["called"] else "references"
299
- extras = {"resolution": "imported"}
342
+ extras = {"resolution": "local" if entry["local"] else "imported"}
300
343
  if etype == "calls" and entry["shapes"]:
301
344
  extras.update(_arg_contract(entry["shapes"]))
302
345
  graph.add_edge(Edge(etype, src, target, extras=extras))
@@ -113,7 +113,12 @@ SCHEMA_VERSION = "0.13"
113
113
  # nested functions, module-level code and class bodies, plus sites in shadowed
114
114
  # bodies that are not walked; the structured answer gains `by_scope` and
115
115
  # `shadowed_not_walked` (R1-C74, docs/design/call_site_conservation.md).
116
- ANSWER_FORMAT = 4
116
+ # 5 — `tests` names the band after the nearest (`next_band`, a "… N more test(s) at distance d"
117
+ # line) and says the nearest band closed the answer instead of "searched N hop(s) back";
118
+ # `--all-bands` lists every band, each row carrying its distance and confidence; a helper
119
+ # function inside a collected test module costs no hop in `tests` and `covers`, so
120
+ # distances move where one sits on the path (R1-C80, docs/design/tests_through_helpers.md).
121
+ ANSWER_FORMAT = 5
117
122
 
118
123
  # Closed vocabulary of edge types (R1-C7). Node ``kind`` is deliberately an OPEN set
119
124
  # (DESIGN §2 — new entity kinds may appear), but edges are TYPED: every relationship
@@ -262,6 +262,16 @@ class Query:
262
262
  self._outbound.setdefault(e.source, []).append((e.target, e.type))
263
263
  self._module_ids = [n.id for n in graph.nodes.values() if n.kind == "module"]
264
264
  self._test_ids = {i for i in self.graph.nodes if self._is_test(i)}
265
+ # R1-C80 D1: non-test functions in a collected test module — transparent to distance.
266
+ self._test_helper_ids = {i for i in self.graph.nodes if self._is_test_helper(i)}
267
+ self._test_function_ids = self._test_ids | self._test_helper_ids
268
+ # D1: a nested def in a test module → the test or helper that contains it.
269
+ self._test_parent = {e.target: e.source for e in graph.edges
270
+ if e.type == "contains" and e.target in self._test_helper_ids
271
+ and e.source in self._test_function_ids}
272
+ self._test_children: dict[str, list[str]] = {}
273
+ for child, parent in sorted(self._test_parent.items()):
274
+ self._test_children.setdefault(parent, []).append(child)
265
275
 
266
276
  # -- lookups -------------------------------------------------------------
267
277
 
@@ -1538,14 +1548,8 @@ class Query:
1538
1548
  the artifact does not carry one framework's naming convention, and so an existing
1539
1549
  graph gains the feature with no rebuild.
1540
1550
  """
1541
- node = self.graph.nodes.get(node_id)
1542
- if node is None or node.kind != "function" or self.root_of(node_id) != "tests":
1543
- return False
1544
- mod = self._module_of(node_id)
1545
- if mod is None or not mod.file:
1546
- return False
1547
- base = mod.file.rsplit("/", 1)[-1]
1548
- if not (base.startswith("test_") or base.endswith("_test.py")):
1551
+ mod = self._collected_module(node_id)
1552
+ if mod is None:
1549
1553
  return False
1550
1554
  tail = node_id[len(mod.id) + 1:].split(".")
1551
1555
  if not tail or not tail[-1].startswith("test"):
@@ -1554,6 +1558,30 @@ class Query:
1554
1558
  return True
1555
1559
  return len(tail) == 2 and tail[0].startswith("Test")
1556
1560
 
1561
+ def _collected_module(self, node_id: str) -> "Node | None":
1562
+ """The module of a function under a ``tests`` root whose file pytest collects, else None."""
1563
+ node = self.graph.nodes.get(node_id)
1564
+ if node is None or node.kind != "function" or self.root_of(node_id) != "tests":
1565
+ return None
1566
+ mod = self._module_of(node_id)
1567
+ if mod is None or not mod.file:
1568
+ return None
1569
+ base = mod.file.rsplit("/", 1)[-1]
1570
+ if not (base.startswith("test_") or base.endswith("_test.py")):
1571
+ return None
1572
+ return mod
1573
+
1574
+ def _is_test_helper(self, node_id: str) -> bool:
1575
+ """R1-C80 D1: a function in a collected test module that is not itself a test.
1576
+
1577
+ Such a helper exists to be called by the tests beside it, so the walk passes through it
1578
+ without spending a hop: a test that calls ``_vector``, which calls the symbol, exercises
1579
+ the symbol as a test that calls it directly does. conftest.py, ``tests/fixtures/`` and
1580
+ shared helper modules are not collected test modules, so they still cost a hop — that is
1581
+ the shared infrastructure where R1-C24 measured precision falling.
1582
+ """
1583
+ return self._collected_module(node_id) is not None and not self._is_test(node_id)
1584
+
1557
1585
  def pytest_nodeid(self, node_id: str) -> str | None:
1558
1586
  """Graph id → the id you can paste after ``pytest`` (design D5).
1559
1587
 
@@ -1566,7 +1594,8 @@ class Query:
1566
1594
  tail = node_id[len(mod.id) + 1:]
1567
1595
  return mod.file + ("::" + "::".join(tail.split(".")) if tail else "")
1568
1596
 
1569
- def _test_caveats(self, *, truncated: int, searched: int, found: bool) -> list[str]:
1597
+ def _test_caveats(self, *, truncated: int, searched: int, found: bool,
1598
+ nearest: int | None = None) -> list[str]:
1570
1599
  """The two labels every answer carries, plus whatever this graph earns.
1571
1600
 
1572
1601
  Both are required (R1-C13): an over-set because reaching a symbol is not
@@ -1594,12 +1623,15 @@ class Query:
1594
1623
  "hop(s). 16% of symbols that coverage.py proves are exercised look "
1595
1624
  "like this — ask for a deeper walk (`depth=6`) for low-confidence "
1596
1625
  "candidates, but do not read silence as 'untested'")
1626
+ elif nearest is not None:
1627
+ # R1-C80 D2: say that the nearest band closed the answer, not that the walk was short.
1628
+ out.append(f"nearest band at distance {nearest}; looked up to depth {searched} for more")
1597
1629
  else:
1598
- out.append(f"searched {searched} hop(s) back")
1630
+ out.append(f"searched {searched} hop(s)")
1599
1631
  return out
1600
1632
 
1601
1633
  def tests_for(self, symbol_id: str, *, depth: int = _TEST_MAX_DEPTH,
1602
- cap: int = _TEST_CAP) -> dict:
1634
+ cap: int = _TEST_CAP, all_bands: bool = False) -> dict:
1603
1635
  """Which tests exercise ``symbol_id`` — nearest band first (R1-C24, axis A10).
1604
1636
 
1605
1637
  Distance 1 is not the question: measured on codemap's own repo, only **18%** of
@@ -1619,6 +1651,7 @@ class Query:
1619
1651
  targets = self._member_ids(symbol_id)
1620
1652
  seen = set(targets)
1621
1653
  frontier = set(targets)
1654
+ bands: list[tuple[int, list[str]]] = []
1622
1655
  for dist in range(1, max(1, depth) + 1):
1623
1656
  nxt: set[str] = set()
1624
1657
  for node in sorted(frontier):
@@ -1626,35 +1659,59 @@ class Query:
1626
1659
  if src not in seen and etype in _TEST_WALK_EDGES:
1627
1660
  seen.add(src)
1628
1661
  nxt.add(src)
1662
+ # R1-C80 D1 (as measured): a def nested in a test or helper is part of its body, so
1663
+ # it leads to its container at no cost. A module-level helper costs a hop like any
1664
+ # other function: made free, it pulled 72–80% coverage-false tests into the nearest
1665
+ # band through shared helpers (design §"Measured", E6).
1666
+ todo = sorted(n for n in nxt if n in self._test_parent)
1667
+ while todo:
1668
+ parent = self._test_parent[todo.pop()]
1669
+ if parent not in seen:
1670
+ seen.add(parent)
1671
+ nxt.add(parent)
1672
+ if parent in self._test_parent:
1673
+ todo.append(parent)
1629
1674
  if not nxt:
1630
- frontier = nxt
1631
1675
  break
1632
1676
  frontier = nxt
1633
1677
  hits = sorted(n for n in nxt if n in self._test_ids)
1634
1678
  if hits:
1635
- return self._tests_envelope(symbol_id, hits, dist, cap, dist)
1636
- return self._tests_envelope(symbol_id, [], None, cap, depth)
1637
-
1638
- def _tests_envelope(self, symbol_id, hits, dist, cap, searched) -> dict:
1639
- shown, truncated = hits[:cap], max(0, len(hits) - cap)
1640
- return {
1679
+ bands.append((dist, hits))
1680
+ # D2: the nearest band is the answer; one more band is only counted.
1681
+ if len(bands) == 2 and not all_bands:
1682
+ break
1683
+ return self._tests_envelope(symbol_id, bands, cap, depth, all_bands)
1684
+
1685
+ def _tests_envelope(self, symbol_id, bands, cap, searched, all_bands=False) -> dict:
1686
+ dist, hits = bands[0] if bands else (None, [])
1687
+ rows = ([(t, d) for d, band in bands for t in band] if all_bands
1688
+ else [(t, dist) for t in hits])
1689
+ shown, truncated = rows[:cap], max(0, len(rows) - cap)
1690
+ nxt = bands[1] if len(bands) > 1 else None
1691
+ out = {
1641
1692
  "symbol": symbol_id,
1642
1693
  "tier": (self.graph.provenance or {}).get("tier"),
1643
1694
  "distance": dist,
1644
1695
  # `unknown` — never "none". A confident empty is the failure this project has
1645
1696
  # now shipped five fixes for (#1 risk:"none", #3, #5, #7, R1-C23).
1646
1697
  "confidence": _TEST_CONFIDENCE.get(dist, "low") if dist else "unknown",
1647
- "tests": [self._test_row(t, dist) for t in shown],
1698
+ "tests": [self._test_row(t, d) for t, d in shown],
1648
1699
  "total_at_distance": len(hits),
1700
+ # R1-C80 D2: the band after the nearest, within `depth` — always present, null if none.
1701
+ "next_band": {"distance": nxt[0], "count": len(nxt[1])} if nxt else None,
1649
1702
  "truncated": truncated,
1650
1703
  "caveats": self._test_caveats(truncated=truncated, searched=searched,
1651
- found=bool(dist)),
1704
+ found=bool(dist), nearest=dist),
1652
1705
  }
1706
+ if all_bands: # D3
1707
+ out["total"] = len(rows)
1708
+ return out
1653
1709
 
1654
1710
  def _test_row(self, node_id: str, dist) -> dict:
1655
1711
  n = self.graph.nodes.get(node_id)
1656
1712
  return {"id": node_id, "node_id": self.pytest_nodeid(node_id),
1657
- "line": getattr(n, "lineno", None), "distance": dist}
1713
+ "line": getattr(n, "lineno", None), "distance": dist,
1714
+ "confidence": _TEST_CONFIDENCE.get(dist, "low") if dist else "unknown"}
1658
1715
 
1659
1716
  def covers(self, test_id: str, *, depth: int = _TEST_MAX_DEPTH,
1660
1717
  cap: int = _TEST_CAP) -> dict:
@@ -1668,12 +1725,19 @@ class Query:
1668
1725
  frontier = {test_id}
1669
1726
  for dist in range(1, max(1, depth) + 1):
1670
1727
  nxt: set[str] = set()
1671
- for node in sorted(frontier):
1672
- for e in self._outbound.get(node, []):
1728
+ todo = sorted(frontier)
1729
+ while todo:
1730
+ node = todo.pop()
1731
+ downs = list(self._outbound.get(node, []))
1732
+ downs += [(c, "calls") for c in self._test_children.get(node, ())] # D1
1733
+ for e in sorted(downs):
1673
1734
  tgt, etype = e
1674
1735
  if tgt in seen or etype not in _TEST_WALK_EDGES:
1675
1736
  continue
1676
1737
  seen.add(tgt)
1738
+ if etype == "calls" and tgt in self._test_parent and node == self._test_parent[tgt]:
1739
+ todo.append(tgt) # R1-C80 D1: a nested def is its container's body
1740
+ continue
1677
1741
  nxt.add(tgt)
1678
1742
  if self.root_of(tgt) == "core":
1679
1743
  out.setdefault(tgt, dist)
@@ -167,13 +167,17 @@ def build_mcp_server(session: "Session", name: str = "codemap") -> Any:
167
167
  return op("callees", {"symbol": symbol, "min_confidence": min_confidence})
168
168
 
169
169
  @server.tool()
170
- def tests(symbol: str, depth: int = 3, cap: int = 25) -> dict:
170
+ def tests(symbol: str, depth: int = 3, cap: int = 25, all_bands: bool = False) -> dict:
171
171
  """Which tests exercise `symbol` — the NEAREST band of test functions that reach
172
- it, as runnable pytest node ids. `confidence` is high/medium by distance and
173
- `unknown` when nothing is found within `depth`: unknown means unknown, never
174
- "untested". Needs a repo-scoped graph (`--consumer tests --mode full`). Raise
175
- `depth` above 3 only for low-confidence candidates."""
176
- return op("tests", {"symbol": symbol, "depth": depth, "cap": cap})
172
+ it, as runnable pytest node ids. A helper function inside a test module costs no
173
+ hop. `next_band` says how many more tests sit at the next distance within `depth`
174
+ (null if none); `all_bands=true` lists every band, each row with its distance.
175
+ `confidence` is high/medium by distance and `unknown` when nothing is found within
176
+ `depth`: unknown means unknown, never "untested". Needs a repo-scoped graph
177
+ (`--consumer tests --mode full`). Raise `depth` above 3 only for low-confidence
178
+ candidates."""
179
+ return op("tests", {"symbol": symbol, "depth": depth, "cap": cap,
180
+ "all_bands": all_bands})
177
181
 
178
182
  @server.tool()
179
183
  def covers(test: str, depth: int = 3, cap: int = 25) -> dict:
@@ -610,7 +610,8 @@ class Session:
610
610
  """R1-C24: which tests exercise a symbol, nearest band first, honestly labelled."""
611
611
  cap = int(args.get("cap", 25))
612
612
  res = self.query.tests_for(
613
- self._canon(args["symbol"]), depth=int(args.get("depth", 3)), cap=cap)
613
+ self._canon(args["symbol"]), depth=int(args.get("depth", 3)), cap=cap,
614
+ all_bands=bool(args.get("all_bands", False)))
614
615
  # These two already say it in their own body (`total_at_distance` + a caveat
615
616
  # line). The envelope block is added anyway: a machine consumer should read one
616
617
  # vocabulary across every limited op, not learn a per-op dialect.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codmap
3
- Version: 0.0.27
3
+ Version: 0.0.29
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, **1180 tests with no failures on
47
+ **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1207 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 &
@@ -170,7 +170,8 @@ Optional extras: `mcp` (Model Context Protocol server), `scip` (protobuf, for SC
170
170
  # build the canonical graph of a package (its directory name is the package name every id starts with)
171
171
  codemap build ./yourpkg -o graph.json
172
172
 
173
- # repo-scoped: add consumers (tests/examples) + docs for blast-radius/impact
173
+ # repo-scoped: add consumers (tests/examples) + docs for blast-radius/impact;
174
+ # one flag per root — a root that is not a directory is refused, exit 2
174
175
  codemap build ./yourpkg --deep --mode full --consumer ./tests --docs ./docs -o graph.json
175
176
 
176
177
  # deep tier: union N independent samples (one build misses a real edge ~1 time in 4)
@@ -151,6 +151,9 @@ tests/test_r1c76_contract_table_typo.py
151
151
  tests/test_r1c77_gate_probe_battery.py
152
152
  tests/test_r1c78_forbidden_chains.py
153
153
  tests/test_r1c7_edge_vocab.py
154
+ tests/test_r1c80_tests_through_helpers.py
155
+ tests/test_r1c83_foreign_graph_paths.py
156
+ tests/test_r1c84_missing_roots.py
154
157
  tests/test_r1c8_deadcode.py
155
158
  tests/test_r1c9_incremental.py
156
159
  tests/test_scip_export.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.27"
12
+ version = "0.0.29"
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