codmap 0.0.46__tar.gz → 0.0.48__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 (223) hide show
  1. {codmap-0.0.46/codmap.egg-info → codmap-0.0.48}/PKG-INFO +9 -2
  2. {codmap-0.0.46 → codmap-0.0.48}/README.md +8 -1
  3. {codmap-0.0.46 → codmap-0.0.48}/codemap/advise/__init__.py +14 -5
  4. {codmap-0.0.46 → codmap-0.0.48}/codemap/advise/refresh.py +33 -5
  5. {codmap-0.0.46 → codmap-0.0.48}/codemap/cli.py +59 -31
  6. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/__init__.py +2 -2
  7. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/hooks.py +3 -2
  8. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/install.py +73 -14
  9. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/templates/agents_block.md +4 -1
  10. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/templates/agents_block.ru.md +4 -1
  11. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/templates/post-commit.sh +5 -5
  12. codmap-0.0.48/codemap/devkit/usage.py +213 -0
  13. {codmap-0.0.46 → codmap-0.0.48}/codemap/extract/behavior.py +125 -8
  14. {codmap-0.0.46 → codmap-0.0.48}/codemap/freshness.py +8 -3
  15. {codmap-0.0.46 → codmap-0.0.48}/codemap/model.py +9 -3
  16. {codmap-0.0.46 → codmap-0.0.48}/codemap/query.py +9 -2
  17. {codmap-0.0.46 → codmap-0.0.48}/codemap/scope.py +7 -3
  18. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/audit.py +2 -2
  19. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/check.py +9 -2
  20. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/currency.py +35 -3
  21. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/impact.py +11 -8
  22. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/limits.py +52 -7
  23. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/mcp_server.py +108 -107
  24. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/pack.py +1 -0
  25. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/semantic.py +5 -1
  26. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/server.py +2 -2
  27. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/session.py +160 -88
  28. {codmap-0.0.46 → codmap-0.0.48}/codemap/store.py +10 -2
  29. {codmap-0.0.46 → codmap-0.0.48/codmap.egg-info}/PKG-INFO +9 -2
  30. {codmap-0.0.46 → codmap-0.0.48}/codmap.egg-info/SOURCES.txt +6 -0
  31. {codmap-0.0.46 → codmap-0.0.48}/pyproject.toml +4 -2
  32. {codmap-0.0.46 → codmap-0.0.48}/tests/test_epistemic.py +1 -1
  33. codmap-0.0.48/tests/test_fast_field_and_usage.py +126 -0
  34. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m3_serve.py +6 -3
  35. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m4_behavior.py +4 -4
  36. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m6_repo_scope.py +1 -1
  37. codmap-0.0.48/tests/test_mcp_surface_contract.py +241 -0
  38. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c108_devkit.py +1 -1
  39. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c110_advise.py +1 -1
  40. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c114_devkit_graph.py +1 -1
  41. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c119_first_build.py +10 -0
  42. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c121_devkit_trust.py +2 -2
  43. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c125_graph_trust.py +4 -1
  44. codmap-0.0.48/tests/test_r1c132_harness.py +105 -0
  45. codmap-0.0.48/tests/test_r1c133_pin_links.py +138 -0
  46. codmap-0.0.48/tests/test_r1c134_refresh_recipe.py +77 -0
  47. codmap-0.0.48/tests/test_r1c135_advise_generations.py +110 -0
  48. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c28_limit_envelope.py +2 -0
  49. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c39_edge_resolution.py +2 -2
  50. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c53_narrowing_declared.py +4 -2
  51. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c63_answer_format.py +2 -1
  52. codmap-0.0.46/codemap/devkit/usage.py +0 -103
  53. {codmap-0.0.46 → codmap-0.0.48}/LICENSE +0 -0
  54. {codmap-0.0.46 → codmap-0.0.48}/codemap/__init__.py +0 -0
  55. {codmap-0.0.46 → codmap-0.0.48}/codemap/__main__.py +0 -0
  56. {codmap-0.0.46 → codmap-0.0.48}/codemap/advise/data/feed.json +0 -0
  57. {codmap-0.0.46 → codmap-0.0.48}/codemap/advise/data/matrix.toml +0 -0
  58. {codmap-0.0.46 → codmap-0.0.48}/codemap/advise/render.py +0 -0
  59. {codmap-0.0.46 → codmap-0.0.48}/codemap/apidiff.py +0 -0
  60. {codmap-0.0.46 → codmap-0.0.48}/codemap/arch.py +0 -0
  61. {codmap-0.0.46 → codmap-0.0.48}/codemap/atomic.py +0 -0
  62. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/artifacts.py +0 -0
  63. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/ratchet.py +0 -0
  64. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/state.py +0 -0
  65. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/templates/brief.txt +0 -0
  66. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/templates/claude_hooks.json +0 -0
  67. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/templates/codex_region.toml +0 -0
  68. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/templates/contract_head.toml +0 -0
  69. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/templates/cycles_region.toml +0 -0
  70. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/templates/github-workflow.yml +0 -0
  71. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/templates/gitlab-ci.yml +0 -0
  72. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/templates/mcp_claude.args +0 -0
  73. {codmap-0.0.46 → codmap-0.0.48}/codemap/devkit/templates/ratchet_region.toml +0 -0
  74. {codmap-0.0.46 → codmap-0.0.48}/codemap/diagnostics.py +0 -0
  75. {codmap-0.0.46 → codmap-0.0.48}/codemap/extract/__init__.py +0 -0
  76. {codmap-0.0.46 → codmap-0.0.48}/codemap/extract/attrflow.py +0 -0
  77. {codmap-0.0.46 → codmap-0.0.48}/codemap/extract/dataflow.py +0 -0
  78. {codmap-0.0.46 → codmap-0.0.48}/codemap/extract/dispatch.py +0 -0
  79. {codmap-0.0.46 → codmap-0.0.48}/codemap/extract/griffe_extractor.py +0 -0
  80. {codmap-0.0.46 → codmap-0.0.48}/codemap/extract/gsource.py +0 -0
  81. {codmap-0.0.46 → codmap-0.0.48}/codemap/extract/probe.py +0 -0
  82. {codmap-0.0.46 → codmap-0.0.48}/codemap/extract/roots.py +0 -0
  83. {codmap-0.0.46 → codmap-0.0.48}/codemap/extract/union.py +0 -0
  84. {codmap-0.0.46 → codmap-0.0.48}/codemap/incremental.py +0 -0
  85. {codmap-0.0.46 → codmap-0.0.48}/codemap/integrations/__init__.py +0 -0
  86. {codmap-0.0.46 → codmap-0.0.48}/codemap/integrations/base.py +0 -0
  87. {codmap-0.0.46 → codmap-0.0.48}/codemap/integrations/cocoindex.py +0 -0
  88. {codmap-0.0.46 → codmap-0.0.48}/codemap/integrations/gate.py +0 -0
  89. {codmap-0.0.46 → codmap-0.0.48}/codemap/integrations/gitnexus.py +0 -0
  90. {codmap-0.0.46 → codmap-0.0.48}/codemap/integrations/registry.py +0 -0
  91. {codmap-0.0.46 → codmap-0.0.48}/codemap/integrations/transport.py +0 -0
  92. {codmap-0.0.46 → codmap-0.0.48}/codemap/provenance.py +0 -0
  93. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/__init__.py +0 -0
  94. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/_scip_pb2.py +0 -0
  95. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/api_surface.py +0 -0
  96. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/apidiff.py +0 -0
  97. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/architecture.py +0 -0
  98. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/ctags.py +0 -0
  99. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/livingdocs.py +0 -0
  100. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/mermaid.py +0 -0
  101. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/rag.py +0 -0
  102. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/review.py +0 -0
  103. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/scip.py +0 -0
  104. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/subsystems.py +0 -0
  105. {codmap-0.0.46 → codmap-0.0.48}/codemap/serve/vault.py +0 -0
  106. {codmap-0.0.46 → codmap-0.0.48}/codemap/tomlio.py +0 -0
  107. {codmap-0.0.46 → codmap-0.0.48}/codemap/watch.py +0 -0
  108. {codmap-0.0.46 → codmap-0.0.48}/codmap.egg-info/dependency_links.txt +0 -0
  109. {codmap-0.0.46 → codmap-0.0.48}/codmap.egg-info/entry_points.txt +0 -0
  110. {codmap-0.0.46 → codmap-0.0.48}/codmap.egg-info/requires.txt +0 -0
  111. {codmap-0.0.46 → codmap-0.0.48}/codmap.egg-info/top_level.txt +0 -0
  112. {codmap-0.0.46 → codmap-0.0.48}/setup.cfg +0 -0
  113. {codmap-0.0.46 → codmap-0.0.48}/tests/test_gitnexus_router.py +0 -0
  114. {codmap-0.0.46 → codmap-0.0.48}/tests/test_impact_depth.py +0 -0
  115. {codmap-0.0.46 → codmap-0.0.48}/tests/test_integrations.py +0 -0
  116. {codmap-0.0.46 → codmap-0.0.48}/tests/test_issue3_serve_freshness.py +0 -0
  117. {codmap-0.0.46 → codmap-0.0.48}/tests/test_livingdocs.py +0 -0
  118. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m0_api_surface.py +0 -0
  119. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m11_argcontract.py +0 -0
  120. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m12_dataflow.py +0 -0
  121. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m15_review.py +0 -0
  122. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m16_architecture.py +0 -0
  123. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m17_mcp.py +0 -0
  124. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m18_freshness.py +0 -0
  125. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m1_5_semantics.py +0 -0
  126. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m1_query.py +0 -0
  127. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m2_views.py +0 -0
  128. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m32_watch.py +0 -0
  129. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m5_deep.py +0 -0
  130. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m7_dispatch.py +0 -0
  131. {codmap-0.0.46 → codmap-0.0.48}/tests/test_m9_family.py +0 -0
  132. {codmap-0.0.46 → codmap-0.0.48}/tests/test_pack_honesty.py +0 -0
  133. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c109_namespace_source.py +0 -0
  134. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c111_recipe.py +0 -0
  135. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c115_agents_block.py +0 -0
  136. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c116_known_cycles.py +0 -0
  137. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c118_dead_code.py +0 -0
  138. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c120_dispatch_absorbed.py +0 -0
  139. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c122_serve_robust.py +0 -0
  140. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c124_atomic_writes.py +0 -0
  141. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c126_scope_roles.py +0 -0
  142. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c127_require_current.py +0 -0
  143. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c13_callgraph_accuracy.py +0 -0
  144. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c13_grep_vs_graph.py +0 -0
  145. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c16_semantic.py +0 -0
  146. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c20_attribute_edges.py +0 -0
  147. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c21_flat_layout.py +0 -0
  148. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c22_source_visible_refs.py +0 -0
  149. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c23_hard_python.py +0 -0
  150. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c24_test_mapping.py +0 -0
  151. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c25_provenance.py +0 -0
  152. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c26_deep_union.py +0 -0
  153. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c27_config_honesty.py +0 -0
  154. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c29_lazy_imports.py +0 -0
  155. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c2_ctags.py +0 -0
  156. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c30_local_import_calls.py +0 -0
  157. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c30f1_reexport_calls.py +0 -0
  158. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c30f2_check_scope.py +0 -0
  159. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c31_path_origin.py +0 -0
  160. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c32_report_json.py +0 -0
  161. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c33_query_signature.py +0 -0
  162. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c34_signature_kinds.py +0 -0
  163. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c35_contract_location.py +0 -0
  164. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c36_target_resolution.py +0 -0
  165. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c37_rule_mutation.py +0 -0
  166. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c38_tool_drift.py +0 -0
  167. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c3_arch_contract.py +0 -0
  168. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c3_dogfood.py +0 -0
  169. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c40_flow_reach.py +0 -0
  170. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c41_scope_membership.py +0 -0
  171. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c42_deep_tier_stability.py +0 -0
  172. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c43_incremental_splice.py +0 -0
  173. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c44_absent_answers.py +0 -0
  174. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c45_repeat_union.py +0 -0
  175. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c46_shadowed_definitions.py +0 -0
  176. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c47_incremental_resample.py +0 -0
  177. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c48_type_checking_imports.py +0 -0
  178. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c49_type_only_cycles.py +0 -0
  179. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c4_complexity.py +0 -0
  180. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c50_flow_entry_points.py +0 -0
  181. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c54_deterministic_rendering.py +0 -0
  182. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c55_override_grade.py +0 -0
  183. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c56_stub_files.py +0 -0
  184. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c57_facade_package.py +0 -0
  185. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c58_cycle_tangles.py +0 -0
  186. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c59_completeness_drop.py +0 -0
  187. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c5_apidiff.py +0 -0
  188. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c60_nested_definitions.py +0 -0
  189. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c62_phantom_rules.py +0 -0
  190. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c64_dependency_probe.py +0 -0
  191. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c66_pack_direction.py +0 -0
  192. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c68_dotted_imports.py +0 -0
  193. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c69_contract_validation.py +0 -0
  194. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c6_pack.py +0 -0
  195. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c70_check_graph_currency.py +0 -0
  196. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c71_attribute_chain_calls.py +0 -0
  197. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c72_flat_inference_in_packages.py +0 -0
  198. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c73_cli_version.py +0 -0
  199. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c74_call_site_conservation.py +0 -0
  200. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c75_reexported_class_calls.py +0 -0
  201. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c76_contract_table_typo.py +0 -0
  202. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c77_gate_probe_battery.py +0 -0
  203. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c78_forbidden_chains.py +0 -0
  204. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c7_edge_vocab.py +0 -0
  205. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c80_tests_through_helpers.py +0 -0
  206. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c81_protocol_dispatch.py +0 -0
  207. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c82_review_changed_lines.py +0 -0
  208. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c83_foreign_graph_paths.py +0 -0
  209. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c84_missing_roots.py +0 -0
  210. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c85_mcp_graph_currency.py +0 -0
  211. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c86_incremental_repo_scope.py +0 -0
  212. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c87_review_path_base.py +0 -0
  213. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c89_review_docs.py +0 -0
  214. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c8_deadcode.py +0 -0
  215. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c90_currency_without_recipe.py +0 -0
  216. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c91_route_vocabulary.py +0 -0
  217. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c92_sidecar_pair.py +0 -0
  218. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c94_root_builds.py +0 -0
  219. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c95_r1c96_foreign_trees.py +0 -0
  220. {codmap-0.0.46 → codmap-0.0.48}/tests/test_r1c9_incremental.py +0 -0
  221. {codmap-0.0.46 → codmap-0.0.48}/tests/test_scip_export.py +0 -0
  222. {codmap-0.0.46 → codmap-0.0.48}/tests/test_scope.py +0 -0
  223. {codmap-0.0.46 → codmap-0.0.48}/tests/test_subsystems.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codmap
3
- Version: 0.0.46
3
+ Version: 0.0.48
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
@@ -54,7 +54,7 @@ without a release.
54
54
 
55
55
  [![CI](https://github.com/kogriv/codemap/actions/workflows/ci.yml/badge.svg)](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
56
56
 
57
- **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1476 tests with no failures on
57
+ **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1523 tests with no failures on
58
58
  Python 3.11–3.14** ([in CI](docs/ci.md): the full suite including the dogfood pass, a determinism check, a
59
59
  wheel smoke test, and ctags/SCIP interop against the real CLIs), warm serve surface with 32 ops (29 exposed
60
60
  as MCP tools), and SCIP export. See **[DESIGN.md](DESIGN.md)** (product design &
@@ -236,6 +236,13 @@ codemap watch ./pkg -o graph.json &
236
236
  codemap serve --graph graph.json --watch
237
237
  ```
238
238
 
239
+ The local MCP server uses the permissions of the process that starts it. Use it with a
240
+ trusted client and graph. `--source-root` bounds `source` reads. `diff(base)` reads an
241
+ explicit baseline graph, and `check(root)` reads a contract from the selected directory.
242
+ `semantic_search` can invoke an installed adapter only when explicitly enabled in
243
+ `codemap.toml`. `reload` replaces the in-memory snapshot from the configured graph path.
244
+ The MCP server does not sandbox these operations from one another.
245
+
239
246
  ## What it answers
240
247
 
241
248
  - **Structure & API** — public surface, signatures, docstrings, deprecation.
@@ -18,7 +18,7 @@ without a release.
18
18
 
19
19
  [![CI](https://github.com/kogriv/codemap/actions/workflows/ci.yml/badge.svg)](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
20
20
 
21
- **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1476 tests with no failures on
21
+ **Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1523 tests with no failures on
22
22
  Python 3.11–3.14** ([in CI](docs/ci.md): the full suite including the dogfood pass, a determinism check, a
23
23
  wheel smoke test, and ctags/SCIP interop against the real CLIs), warm serve surface with 32 ops (29 exposed
24
24
  as MCP tools), and SCIP export. See **[DESIGN.md](DESIGN.md)** (product design &
@@ -200,6 +200,13 @@ codemap watch ./pkg -o graph.json &
200
200
  codemap serve --graph graph.json --watch
201
201
  ```
202
202
 
203
+ The local MCP server uses the permissions of the process that starts it. Use it with a
204
+ trusted client and graph. `--source-root` bounds `source` reads. `diff(base)` reads an
205
+ explicit baseline graph, and `check(root)` reads a contract from the selected directory.
206
+ `semantic_search` can invoke an installed adapter only when explicitly enabled in
207
+ `codemap.toml`. `reload` replaces the in-memory snapshot from the configured graph path.
208
+ The MCP server does not sandbox these operations from one another.
209
+
203
210
  ## What it answers
204
211
 
205
212
  - **Structure & API** — public surface, signatures, docstrings, deprecation.
@@ -104,14 +104,17 @@ class Catalog:
104
104
  CURRENT = "current"
105
105
 
106
106
 
107
- def _served_dir(cdir: Path) -> Path:
108
- """The generation ``current`` names, or the cache itself for a pair written before generations existed."""
107
+ def _served_dir(cdir: Path) -> tuple[Path, str | None]:
108
+ """The generation ``current`` names, or the cache itself for a pair written before generations existed; and a
109
+ note when ``current`` names a generation that is not there (R1-C135: said, not silently replaced)."""
109
110
  try:
110
111
  name = (cdir / CURRENT).read_text(encoding="utf-8").strip()
111
112
  except OSError:
112
- return cdir
113
+ return cdir, None
113
114
  gen = cdir / name
114
- return gen if name.startswith("gen-") and "/" not in name and gen.is_dir() else cdir
115
+ if name.startswith("gen-") and "/" not in name and gen.is_dir():
116
+ return gen, None
117
+ return cdir, f"cache pointer `{CURRENT}` names {name!r}, which is not there; run `codemap advise --refresh`"
115
118
 
116
119
 
117
120
  def cache_dir() -> Path:
@@ -146,7 +149,13 @@ def load(cache: Path | None = None, packaged: Path | None = None) -> Catalog:
146
149
  cdir = cache if cache is not None else cache_dir()
147
150
  if not cdir.is_dir():
148
151
  return cat
149
- cm, cf, cerrs = _read_pair(_served_dir(cdir))
152
+ for _ in range(3): # R1-C135: one file there and the other gone = a publish in between
153
+ served, note = _served_dir(cdir)
154
+ cm, cf, cerrs = _read_pair(served)
155
+ if (cm is None) == (cf is None):
156
+ break
157
+ if note:
158
+ cat.notes.append(note)
150
159
  cat.notes.extend(f"cache ignored: {e}" for e in cerrs)
151
160
  m, f, src = pm, pf, {"matrix": "packaged", "feed": "packaged"}
152
161
  if cm is not None and cm.get("meta", {}).get("as_of", "") > pm.get("meta", {}).get("as_of", ""):
@@ -57,10 +57,18 @@ def refresh(base: str | None = None, cache: Path | None = None) -> dict:
57
57
  return out
58
58
 
59
59
 
60
+ #: R1-C135: a generation is removed only once it is this old and `current` does not name it — a reader that took
61
+ #: its path a moment ago, or a second publisher that has just pointed `current` at it, still finds it whole.
62
+ GRACE_SECONDS = 600
63
+
64
+
60
65
  def publish_pair(cdir: Path, mraw: bytes, fraw: bytes) -> None:
61
66
  """Publish matrix + feed as one generation (R1-C124): both files go to a new directory, then the pointer
62
67
  file ``current`` is replaced atomically. A failure before that leaves the previous pair served whole; a reader
63
- never sees one file of one generation beside the other file of another."""
68
+ never sees one file of one generation beside the other file of another.
69
+
70
+ Old generations are collected by :func:`collect`, not all at once (R1-C135): two publishers each removing
71
+ every generation but its own left `current` naming a removed one."""
64
72
  import shutil
65
73
  import tempfile
66
74
 
@@ -74,11 +82,31 @@ def publish_pair(cdir: Path, mraw: bytes, fraw: bytes) -> None:
74
82
  except BaseException:
75
83
  shutil.rmtree(gen, ignore_errors=True)
76
84
  raise
77
- for old in cdir.glob("gen-*"): # previous generations, and any torn leftovers
78
- if old.is_dir() and old.name != gen.name:
79
- shutil.rmtree(old, ignore_errors=True)
80
- for legacy in ("matrix.toml", "feed.json"): # a pre-0.0.46 pair at the top level
85
+ collect(cdir)
86
+ for legacy in ("matrix.toml", "feed.json"): # a pre-0.0.46 pair at the top level (load retries a split read)
81
87
  try:
82
88
  (cdir / legacy).unlink()
83
89
  except FileNotFoundError:
84
90
  pass
91
+
92
+
93
+ def collect(cdir: Path, now: float | None = None) -> list[str]:
94
+ """Remove generations `current` does not name *now* and that are older than :data:`GRACE_SECONDS`; the names."""
95
+ import shutil
96
+ import time
97
+
98
+ now = time.time() if now is None else now
99
+ try:
100
+ served = (cdir / CURRENT).read_text(encoding="utf-8").strip()
101
+ except OSError:
102
+ served = None
103
+ gone = []
104
+ for old in sorted(cdir.glob("gen-*")):
105
+ try:
106
+ young = now - old.stat().st_mtime < GRACE_SECONDS
107
+ except OSError:
108
+ continue
109
+ if old.is_dir() and old.name != served and not young:
110
+ shutil.rmtree(old, ignore_errors=True)
111
+ gone.append(old.name)
112
+ return gone
@@ -92,19 +92,20 @@ def _emit_answer(text: str) -> None:
92
92
  print(f"_answer format {ANSWER_FORMAT} · schema {SCHEMA_VERSION}_")
93
93
 
94
94
 
95
- def _graph_from(args):
95
+ def _graph_from(args, *, snapshot: bool = False):
96
96
  if getattr(args, "build", None):
97
- return extract(args.build, deep=getattr(args, "deep", False))
97
+ graph = extract(args.build, deep=getattr(args, "deep", False))
98
+ return (graph, None) if snapshot else graph
98
99
  if getattr(args, "graph", None):
99
100
  if not os.path.exists(args.graph):
100
101
  # R1-C119: said before any work, with the command that makes one.
101
102
  raise SystemExit(f"error: no graph at {args.graph} — build it first: "
102
103
  f"`codemap build <package> -o {args.graph}`")
103
- graph = store.load(args.graph)
104
+ graph, mtime = store.load_snapshot(args.graph)
104
105
  if getattr(args, "func", None) not in (_cmd_check, _cmd_serve):
105
106
  _warn_if_behind(args.graph, graph, args)
106
107
  _warn_if_newer_tool(args.graph, graph)
107
- return graph
108
+ return (graph, mtime) if snapshot else graph
108
109
  raise SystemExit("error: need --graph <file> or --build <path>")
109
110
 
110
111
 
@@ -175,6 +176,7 @@ def _cmd_build(args) -> int:
175
176
  except OSError as exc:
176
177
  print(f"error: cannot create the directory for {args.out}: {exc.strerror}", file=sys.stderr)
177
178
  return 2
179
+ input_scope = _resolve_scope_quietly(args) if args.out else None
178
180
  if args.consumer or args.docs:
179
181
  core_graph = None
180
182
  if getattr(args, "incremental", False) and args.out:
@@ -224,12 +226,17 @@ def _cmd_build(args) -> int:
224
226
  # rebuild it, and so the graph's age is meaningful to `serve`/stats.
225
227
  # M19.A: also record the input scope manifest (scope_id + profile + git).
226
228
  from codemap.freshness import write_meta
227
- base = (str(roots_base(args.path, tuple(args.consumer or ()),
228
- tuple(args.docs or ())))
229
- if (args.consumer or args.docs) else None)
230
- write_meta(args.out, argv=getattr(args, "_argv", []),
231
- cwd=os.getcwd(), target=graph.target, scope=scope,
232
- roots_base=base)
229
+ base = str(roots_base(args.path, tuple(args.consumer or ()), tuple(args.docs or ())))
230
+ recipe_out = getattr(args, "recipe_output", None)
231
+ recipe = (_build_recipe(args, out=recipe_out, incremental=args.incremental)
232
+ if recipe_out else getattr(args, "_argv", []))
233
+ try:
234
+ write_meta(args.out, argv=recipe, cwd=os.getcwd(), target=graph.target, scope=scope,
235
+ roots_base=base, strict=bool(recipe_out), source_verified=bool(
236
+ input_scope and scope and input_scope["scope_id"] == scope["scope_id"]))
237
+ except OSError as exc:
238
+ print(f"error: could not write staged build recipe: {exc}", file=sys.stderr)
239
+ return 2
233
240
  if incr_info is not None:
234
241
  # R1-C92: a full build that had a reason says it — computed, never shown, before.
235
242
  why = f" ({incr_info['reason']})" if incr_info.get("reason") else ""
@@ -396,14 +403,11 @@ def _incremental_core(args, repeat):
396
403
  deep=args.deep, repeat=repeat)
397
404
 
398
405
 
399
- def _watch_build_argv(args) -> list[str]:
400
- """The build recipe this watch replays — recorded in the sidecar, not the watch argv.
401
-
402
- M18 writes ``argv`` beside the graph so ``codemap refresh`` can rebuild it. If a watch
403
- recorded its *own* argv there, `refresh` would start a watcher instead of rebuilding —
404
- a loop that never returns. So the sidecar gets the equivalent single build.
405
- """
406
- argv = ["build", args.path, "-o", args.out, "--incremental"]
406
+ def _build_recipe(args, *, out, incremental: bool) -> list[str]:
407
+ """Single build replay for a watcher or a graph published from a staging file."""
408
+ argv = ["build", args.path, "-o", out]
409
+ if incremental:
410
+ argv.append("--incremental")
407
411
  if args.deep:
408
412
  argv.append("--deep")
409
413
  if (getattr(args, "repeat", None) or 1) > 1:
@@ -417,6 +421,10 @@ def _watch_build_argv(args) -> list[str]:
417
421
  return argv
418
422
 
419
423
 
424
+ def _watch_build_argv(args) -> list[str]:
425
+ return _build_recipe(args, out=args.out, incremental=True)
426
+
427
+
420
428
  def _watch_start_is_stale(out: str, scope_id: str) -> bool:
421
429
  """Does the graph at ``out`` predate the tree we are about to watch? (M3.2)
422
430
 
@@ -902,27 +910,43 @@ def _cmd_refresh(args) -> int:
902
910
  raise SystemExit(f"error: the recorded recipe beside {args.graph} is not repeated — {problem}; "
903
911
  f"rebuild by hand with `codemap build <package> -o {args.graph}`")
904
912
  cwd = meta.get("cwd")
905
- if cwd and os.path.isdir(cwd):
906
- os.chdir(cwd) # recorded argv may use paths relative to the build cwd
913
+ if cwd:
914
+ os.chdir(cwd) # recorded argv may use paths relative to the build cwd; _recipe_problem checked from it
907
915
  print(f"rebuilding {args.graph} …", file=sys.stderr)
908
916
  return main(meta["argv"])
909
917
 
910
918
 
911
919
  def _recipe_problem(meta: dict, graph: str) -> str | None:
912
- """Why a sidecar's ``argv`` is not a rebuild of ``graph`` (R1-C125): `refresh` repeats it as a command, and
913
- the sidecar is a file anyone can edit. Only `build`, writing back to this same graph, is repeated."""
920
+ """Why a sidecar's ``argv`` is not a rebuild of ``graph`` (R1-C125, R1-C134): `refresh` repeats it as a command,
921
+ and the sidecar is a file anyone can edit. Only `build`, writing back to this same graph, is repeated.
922
+
923
+ The recipe is read by the very parser that will run it — a repeated `-o`, an abbreviated `--ou`, an attached
924
+ `-oX` mean to the check what they mean to `build` — and from the working directory it will run in.
925
+ """
926
+ import contextlib
927
+ import io
914
928
  argv = meta.get("argv")
915
929
  if not isinstance(argv, list) or not argv or not all(isinstance(a, str) for a in argv):
916
930
  return "it is not a list of arguments"
917
931
  if argv[0] != "build":
918
932
  return f"it runs `{argv[0]}`, not `build`"
919
- out = next((argv[i + 1] for i, a in enumerate(argv[:-1]) if a in ("-o", "--out")), None)
920
- out = out or next((a.split("=", 1)[1] for a in argv if a.startswith("--out=")), None)
921
- if out is None:
933
+ try:
934
+ with contextlib.redirect_stderr(io.StringIO()) as err:
935
+ args = build_parser().parse_args(argv)
936
+ except SystemExit:
937
+ last = err.getvalue().strip().splitlines()
938
+ return f"`build` does not take it ({last[-1] if last else 'unparsable'})"
939
+ if args.command != "build":
940
+ return f"it runs `{args.command}`, not `build`"
941
+ if args.recipe_output:
942
+ return "a published rebuild recipe cannot redirect its own recorded output"
943
+ if not args.out:
922
944
  return "it writes no graph file"
923
- cwd = meta.get("cwd") if isinstance(meta.get("cwd"), str) else os.getcwd()
924
- if (Path(cwd) / out).resolve() != Path(graph).resolve():
925
- return f"it writes {out!r}, not this graph"
945
+ cwd = meta.get("cwd")
946
+ if cwd is not None and not (isinstance(cwd, str) and os.path.isdir(cwd)):
947
+ return f"its working directory {cwd!r} is not a directory here"
948
+ if (Path(cwd or os.getcwd()) / args.out).resolve() != Path(graph).resolve():
949
+ return f"it writes {args.out!r}, not this graph"
926
950
  return None
927
951
 
928
952
 
@@ -1249,7 +1273,8 @@ def _cmd_serve(args) -> int:
1249
1273
  ops over the Model Context Protocol instead (needs the optional `mcp` extra).
1250
1274
  """
1251
1275
  from codemap.serve.session import Session
1252
- session = Session(_graph_from(args), source_root=args.source_root,
1276
+ graph, mtime = _graph_from(args, snapshot=True)
1277
+ session = Session(graph, source_root=args.source_root, served_mtime=mtime,
1253
1278
  graph_path=getattr(args, "graph", None),
1254
1279
  currency_ttl=getattr(args, "currency_ttl", 10.0))
1255
1280
  if getattr(args, "watch", False):
@@ -1296,7 +1321,9 @@ def _start_reload_watcher(session, args) -> bool:
1296
1321
  f"{r.get('reason', env.get('error'))}", file=sys.stderr)
1297
1322
  return False
1298
1323
 
1299
- poller = DebouncedPoller(mtime_probe(args.graph), reload,
1324
+ from codemap.freshness import meta_path
1325
+ graph_probe, meta_probe = mtime_probe(args.graph), mtime_probe(meta_path(args.graph))
1326
+ poller = DebouncedPoller(lambda: (graph_probe(), meta_probe()), reload,
1300
1327
  interval=args.interval, debounce=args.debounce)
1301
1328
  threading.Thread(target=poller.run, kwargs={"cycles": None},
1302
1329
  name="codemap-watch", daemon=True).start()
@@ -1394,6 +1421,7 @@ def build_parser() -> argparse.ArgumentParser:
1394
1421
  "directory name is the package name every node id starts "
1395
1422
  "with — a copy under another name answers to that name.")
1396
1423
  b.add_argument("-o", "--out", help="Write graph.json here (default: stdout JSON).")
1424
+ b.add_argument("--recipe-output", help=argparse.SUPPRESS)
1397
1425
  b.add_argument("--deep", action="store_true",
1398
1426
  help="Deep call resolution via jedi (richer, ~1 min; default fast).")
1399
1427
  b.add_argument("--consumer", action="append", metavar="PATH",
@@ -1669,7 +1697,7 @@ def build_parser() -> argparse.ArgumentParser:
1669
1697
  dx = dks.add_parser("index", help="Write the per-module digest the hooks read.")
1670
1698
  dx.add_argument("--root", default=".")
1671
1699
  dx.add_argument("--graph", default=None)
1672
- dus = dks.add_parser("usage", help="codemap tool calls against grep in local Claude Code transcripts.")
1700
+ dus = dks.add_parser("usage", help="Count codemap MCP, codemap CLI and grep in local Claude Code transcripts.")
1673
1701
  dus.add_argument("--root", default=".")
1674
1702
  dus.add_argument("--days", type=int, default=7)
1675
1703
  dus.add_argument("--transcripts", default=None, help="Transcripts directory (default: Claude Code's for --root).")
@@ -16,11 +16,11 @@ import hashlib
16
16
  from pathlib import Path
17
17
 
18
18
  #: Raised whenever a template changes; adopting projects see "outdated" in `codemap devkit status`.
19
- DEVKIT_VERSION = 7
19
+ DEVKIT_VERSION = 8
20
20
 
21
21
  #: sha256 over the templates (name + content, sorted). The suite recomputes it: a template edited without
22
22
  #: bumping DEVKIT_VERSION and updating this value fails there, in the same commit (D7).
23
- TEMPLATES_SHA256 = "cb015ad787c32b2806f7ec68fecdb7ab86447dd5bb647eeb9ce48764af624a63"
23
+ TEMPLATES_SHA256 = "13012ed7564224f65f411680a07225d4d7ac42aae94467a3ea9daf9386e72499"
24
24
 
25
25
  TEMPLATES_DIR = Path(__file__).parent / "templates"
26
26
 
@@ -56,8 +56,9 @@ def currency_line(root: Path, st: dict) -> str:
56
56
  # R1-C119: a fresh clone has no graph and `refresh` has no recipe to repeat — give the first build.
57
57
  from codemap.devkit import build_args
58
58
  cmd = " ".join(x for x in ("codemap build", st.get("package", "<package>"), build_args(st), "-o", rel) if x)
59
- return (f"absent ({rel} does not exist; build it once: `{cmd}` — after that the post-commit hook "
60
- "keeps it)")
59
+ keeps = ("after that the post-commit hook keeps it" if (st.get("options") or {}).get("hook", True)
60
+ else f"there is no post-commit hook here, so refresh it after changes: `codemap refresh {rel}`")
61
+ return f"absent ({rel} does not exist; build it once: `{cmd}` — {keeps})"
61
62
  meta = read_meta(str(gp)) or {}
62
63
  built = meta.get("built_at")
63
64
  when = f", built {_ago(built)}" if isinstance(built, (int, float)) else ""
@@ -54,7 +54,8 @@ def running_pin() -> list[str]:
54
54
  repository — a `codemap/` package committed there would be what runs.
55
55
  """
56
56
  argv0 = Path(sys.argv[0]) if sys.argv and sys.argv[0] else None
57
- if argv0 is not None and argv0.name == "codemap" and argv0.exists():
57
+ # R1-C133: a pin this codemap writes must pass the check `status` applies to it (a wrapper is not a script)
58
+ if argv0 is not None and argv0.name == "codemap" and argv0.is_file() and _console_script_problem(argv0) is None:
58
59
  # abspath, not resolve: `..` is folded, a venv's symlinked bin is kept as the user named it
59
60
  return [os.path.abspath(argv0)]
60
61
  return [sys.executable, "-I", "-m", "codemap"]
@@ -63,23 +64,73 @@ def running_pin() -> list[str]:
63
64
  _PYTHON = re.compile(r"python(\d+(\.\d+)*)?(\.exe)?")
64
65
 
65
66
 
66
- def _tracked(root: Path, path: Path) -> bool:
67
- """Is ``path`` a file the repository carries (so whoever pushed chose its content)?"""
67
+ def _inside(root: Path, path: str) -> Path | None:
68
+ """``path`` relative to ``root`` as written (``..`` folded, links not followed), or None when outside."""
69
+ p = Path(os.path.abspath(path))
70
+ for base in {Path(os.path.abspath(root)), root.resolve()}:
71
+ try:
72
+ return p.relative_to(base)
73
+ except ValueError:
74
+ continue
75
+ return None
76
+
77
+
78
+ def _carried(root: Path, path: str) -> str | None:
79
+ """Why ``path`` is a file the repository carries — so whoever pushed chose what runs — or None.
80
+
81
+ R1-C133: asked of the path as written *and* of each directory on it, before any link is followed: a tracked
82
+ link ``tools/codemap → /bin/sh`` resolves outside the root, and asking git about the resolved path said
83
+ "not ours". The resolved path is asked too (a link from outside into the repository).
84
+ """
85
+ rels = []
86
+ lexical = _inside(root, path)
87
+ if lexical is not None:
88
+ parts = lexical.parts
89
+ rels += [Path(*parts[:i]).as_posix() for i in range(1, len(parts) + 1)]
68
90
  try:
69
- rel = path.resolve().relative_to(root.resolve())
91
+ rels.append(Path(path).resolve().relative_to(root.resolve()).as_posix())
70
92
  except ValueError:
71
- return False
72
- r = subprocess.run(["git", "-C", str(root), "ls-files", "--error-unmatch", "--", str(rel)],
93
+ pass
94
+ if not rels:
95
+ return None
96
+ r = subprocess.run(["git", "--literal-pathspecs", "-C", str(root), "ls-files", "-s", "-z", "--", *rels],
73
97
  capture_output=True)
74
- return r.returncode == 0
98
+ if r.returncode != 0:
99
+ return "it is inside a directory that is not a git repository, so who wrote it cannot be told"
100
+ listed = {entry.split(b"\t", 1)[1].decode("utf-8", "replace") for entry in r.stdout.split(b"\0") if b"\t" in entry}
101
+ hit = next((rel for rel in rels if rel in listed), None)
102
+ if hit is None:
103
+ return None
104
+ if lexical is not None and hit == lexical.as_posix():
105
+ return "it is a file of this repository"
106
+ return f"`{hit}` on its way is carried by this repository"
107
+
108
+
109
+ #: R1-C133: what an installed console script for codemap holds (pip, pipx, uv write `from codemap.cli import main`)
110
+ _CONSOLE_MARK = b"codemap.cli"
111
+
112
+
113
+ def _console_script_problem(exe: Path) -> str | None:
114
+ """Is ``exe`` (followed to its target) a console script that starts codemap? Asked of the content, not the name."""
115
+ try:
116
+ with open(exe, "rb") as fh:
117
+ head = fh.read(4096 if exe.suffix.lower() != ".exe" else 8 << 20)
118
+ except OSError as exc:
119
+ return f"it cannot be read ({exc.strerror})"
120
+ if exe.suffix.lower() == ".exe":
121
+ ok = _CONSOLE_MARK in head # the launcher carries its script as a stored zip
122
+ else:
123
+ ok = head.startswith(b"#!") and _CONSOLE_MARK in head
124
+ return None if ok else "it is not a console script that starts codemap"
75
125
 
76
126
 
77
127
  def pin_problem(root: Path, pin: list[str] | None) -> str | None:
78
- """Why ``pin`` is not a codemap the devkit may run or write into the hook, or None (R1-C121).
128
+ """Why ``pin`` is not a codemap the devkit may run or write into the hook, or None (R1-C121, R1-C133).
79
129
 
80
130
  `.mcp.json` is a project file: the command in it is whatever the last push said. Accepted are only the
81
131
  shapes the devkit itself writes — the absolute path of a `codemap` console script, or an absolute python
82
- run as `-I -m codemap` — and never a file the repository carries.
132
+ run as `-I -m codemap` — never a file the repository carries, nor one reached through a directory or link
133
+ it carries; and a console script is accepted by what it holds, not by its name.
83
134
  """
84
135
  if not pin or not all(isinstance(a, str) and a for a in pin):
85
136
  return "no command"
@@ -96,8 +147,13 @@ def pin_problem(root: Path, pin: list[str] | None) -> str | None:
96
147
  return f"{shlex.join(pin)!r} is not `<codemap>` or `<python> -I -m codemap`"
97
148
  if not exe.is_file():
98
149
  return f"{pin[0]} does not exist"
99
- if _tracked(root, exe):
100
- return f"{pin[0]} is a file of this repository, not an installed codemap"
150
+ carried = _carried(root, pin[0])
151
+ if carried:
152
+ return f"{pin[0]}: {carried}, not an installed codemap"
153
+ if len(pin) == 1:
154
+ script = _console_script_problem(exe)
155
+ if script:
156
+ return f"{pin[0]}: {script}"
101
157
  return None
102
158
 
103
159
 
@@ -487,10 +543,13 @@ def init(root: Path, *, package: str, consumers: list[str], docs: list[str], age
487
543
  ok, err = _build_graph(root, st, pin)
488
544
  if not ok:
489
545
  notes.append(f"graph build FAILED — {err.splitlines()[-1] if err else 'no message'}")
490
- elif graph.is_file() and unfit != "there is no graph":
491
- notes.append(f"graph rebuilt ({unfit}; fast tier — the post-commit hook builds --deep)")
492
546
  else:
493
- notes.append("graph built (fast tier; the post-commit hook builds --deep)")
547
+ # The hook's --deep rebuild is promised only where there is a hook (tgsh-26, 23.11).
548
+ deep = ("the post-commit hook builds --deep" if hook
549
+ else "no hook: `codemap build … --deep` or `codemap refresh` by hand")
550
+ notes.append(f"graph rebuilt ({unfit}; fast tier — {deep})"
551
+ if graph.is_file() and unfit != "there is no graph"
552
+ else f"graph built (fast tier; {deep})")
494
553
  _contract(root, st, ratchet=ratchet, dry_run=dry_run, notes=notes)
495
554
  if any(o.key == "mcp" and o.status == "created" for o in outcomes):
496
555
  notes.append(".mcp.json names the codemap executable by its absolute path on this machine "
@@ -22,9 +22,12 @@ reaches — ask the graph instead of reading files or grepping.
22
22
  answer is about the older tree.
23
23
  - `resolved.ambiguous` — the short name matched several symbols; ask again by the full name.
24
24
  - `limit.truncated: true` — the list is not complete.
25
+ - In `source`, use code with `result.status: verified`. Rebuild and reload when the
26
+ status is `behind` or `unverified` before relying on the recorded line range.
25
27
 
26
28
  **The architecture contract** — `[architecture]` in `codemap.toml`, run as
27
- `codemap check --graph {{graph}} --root . --require-contract` (exit 2 = broken). `allowed` there is a
29
+ `codemap check --graph {{graph}} --root . --require-contract --require-current`.
30
+ In MCP, set `require_contract` and `require_current`, then read `result.ok`. `allowed` there is a
28
31
  ratchet: every import between two layers must be a listed pair. A red `allowed` means a new dependency
29
32
  between layers: remove the import, or add the pair by hand inside the generated region **with a comment
30
33
  giving the reason**, and let the review judge it. `codemap devkit ratchet --tighten` removes the pairs
@@ -22,9 +22,12 @@ codemap отвечает на вопросы о структуре `{{package}}`
22
22
  о старом дереве.
23
23
  - `resolved.ambiguous` — короткое имя совпало с несколькими символами; спросите по полному имени.
24
24
  - `limit.truncated: true` — список неполный.
25
+ - В `source` используйте код при `result.status: verified`. При `behind` или
26
+ `unverified` пересоберите и перечитайте граф, прежде чем опираться на номера строк.
25
27
 
26
28
  **Контракт архитектуры** — `[architecture]` в `codemap.toml`, запуск
27
- `codemap check --graph {{graph}} --root . --require-contract` (код 2 = нарушен). `allowed` там — храповик:
29
+ `codemap check --graph {{graph}} --root . --require-contract --require-current`.
30
+ В MCP задайте `require_contract` и `require_current` и проверьте `result.ok`. `allowed` там — храповик:
28
31
  каждый импорт между двумя слоями должен быть перечисленной парой. Красный `allowed` — новая зависимость
29
32
  между слоями: уберите импорт или допишите пару руками внутри сгенерированного региона **с комментарием о
30
33
  причине**, и пусть ревью это оценит. `codemap devkit ratchet --tighten` убирает пары, которыми больше никто
@@ -21,16 +21,16 @@ LOG="$ROOT/.codemap/rebuild.log"
21
21
  kind=incremental
22
22
  cp {{graph_sh}} {{graph_next_sh}}
23
23
  cp {{graph_sh}}.meta.json {{graph_next_sh}}.meta.json
24
- nice -n 19 $C build {{package_sh}} --deep --repeat 2 {{build_args}} --incremental -o {{graph_next_sh}} >/dev/null 2>"$LOG.err" &
24
+ nice -n 19 $C build {{package_sh}} --deep --repeat 2 {{build_args}} --incremental -o {{graph_next_sh}} --recipe-output {{graph_sh}} >/dev/null 2>"$LOG.err" &
25
25
  else
26
26
  kind=full
27
- nice -n 19 $C build {{package_sh}} --deep --repeat 2 {{build_args}} -o {{graph_next_sh}} >/dev/null 2>"$LOG.err" &
27
+ nice -n 19 $C build {{package_sh}} --deep --repeat 2 {{build_args}} -o {{graph_next_sh}} --recipe-output {{graph_sh}} >/dev/null 2>"$LOG.err" &
28
28
  fi
29
29
  bpid=$!
30
30
  wait "$bpid"; brc=$?
31
- if [ "$brc" -eq 0 ]; then
32
- mv {{graph_next_sh}}.meta.json {{graph_sh}}.meta.json
33
- mv {{graph_next_sh}} {{graph_sh}}
31
+ if [ "$brc" -eq 0 ] &&
32
+ mv {{graph_next_sh}}.meta.json {{graph_sh}}.meta.json 2>>"$LOG.err" &&
33
+ mv {{graph_next_sh}} {{graph_sh}} 2>>"$LOG.err"; then
34
34
  [ "$kind" = full ] && touch .codemap/last_full
35
35
  $C devkit index --root "$ROOT" >/dev/null 2>>"$LOG.err"
36
36
  echo "$(date -Is) $(git log --oneline -1 | cut -c1-60) $kind ok $(( $(date +%s)-start ))s" >> "$LOG"