codmap 0.0.33__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.
- {codmap-0.0.33 → codmap-0.0.35}/PKG-INFO +2 -2
- {codmap-0.0.33 → codmap-0.0.35}/README.md +1 -1
- {codmap-0.0.33 → codmap-0.0.35}/codemap/cli.py +78 -13
- {codmap-0.0.33 → codmap-0.0.35}/codemap/diagnostics.py +55 -1
- {codmap-0.0.33 → codmap-0.0.35}/codemap/extract/griffe_extractor.py +2 -1
- {codmap-0.0.33 → codmap-0.0.35}/codemap/extract/roots.py +8 -1
- {codmap-0.0.33 → codmap-0.0.35}/codemap/incremental.py +48 -7
- {codmap-0.0.33 → codmap-0.0.35}/codemap/model.py +35 -2
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/currency.py +46 -5
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/session.py +4 -2
- {codmap-0.0.33 → codmap-0.0.35}/codmap.egg-info/PKG-INFO +2 -2
- {codmap-0.0.33 → codmap-0.0.35}/codmap.egg-info/SOURCES.txt +3 -0
- {codmap-0.0.33 → codmap-0.0.35}/pyproject.toml +1 -1
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c39_edge_resolution.py +20 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c44_absent_answers.py +7 -2
- codmap-0.0.35/tests/test_r1c86_incremental_repo_scope.py +195 -0
- codmap-0.0.35/tests/test_r1c90_currency_without_recipe.py +86 -0
- codmap-0.0.35/tests/test_r1c91_route_vocabulary.py +147 -0
- {codmap-0.0.33 → codmap-0.0.35}/LICENSE +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/__init__.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/apidiff.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/arch.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/extract/__init__.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/extract/attrflow.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/extract/behavior.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/extract/dataflow.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/extract/dispatch.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/extract/gsource.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/extract/probe.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/extract/union.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/freshness.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/integrations/__init__.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/integrations/base.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/integrations/cocoindex.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/integrations/gate.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/integrations/gitnexus.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/integrations/registry.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/integrations/transport.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/provenance.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/query.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/scope.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/__init__.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/_scip_pb2.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/api_surface.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/apidiff.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/architecture.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/audit.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/check.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/ctags.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/impact.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/limits.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/livingdocs.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/mcp_server.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/mermaid.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/pack.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/rag.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/review.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/scip.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/semantic.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/server.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/subsystems.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/serve/vault.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/store.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/tomlio.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codemap/watch.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codmap.egg-info/dependency_links.txt +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codmap.egg-info/entry_points.txt +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codmap.egg-info/requires.txt +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/codmap.egg-info/top_level.txt +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/setup.cfg +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_epistemic.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_gitnexus_router.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_impact_depth.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_integrations.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_issue3_serve_freshness.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_livingdocs.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m0_api_surface.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m11_argcontract.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m12_dataflow.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m15_review.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m16_architecture.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m17_mcp.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m18_freshness.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m1_5_semantics.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m1_query.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m2_views.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m32_watch.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m3_serve.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m4_behavior.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m5_deep.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m6_repo_scope.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m7_dispatch.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_m9_family.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_pack_honesty.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c13_callgraph_accuracy.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c13_grep_vs_graph.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c16_semantic.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c20_attribute_edges.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c21_flat_layout.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c22_source_visible_refs.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c23_hard_python.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c24_test_mapping.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c25_provenance.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c26_deep_union.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c27_config_honesty.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c28_limit_envelope.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c29_lazy_imports.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c2_ctags.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c30_local_import_calls.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c30f1_reexport_calls.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c30f2_check_scope.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c31_path_origin.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c32_report_json.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c33_query_signature.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c34_signature_kinds.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c35_contract_location.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c36_target_resolution.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c37_rule_mutation.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c38_tool_drift.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c3_arch_contract.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c3_dogfood.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c40_flow_reach.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c41_scope_membership.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c42_deep_tier_stability.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c43_incremental_splice.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c45_repeat_union.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c46_shadowed_definitions.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c47_incremental_resample.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c48_type_checking_imports.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c49_type_only_cycles.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c4_complexity.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c50_flow_entry_points.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c53_narrowing_declared.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c54_deterministic_rendering.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c55_override_grade.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c56_stub_files.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c57_facade_package.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c58_cycle_tangles.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c59_completeness_drop.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c5_apidiff.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c60_nested_definitions.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c62_phantom_rules.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c63_answer_format.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c64_dependency_probe.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c66_pack_direction.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c68_dotted_imports.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c69_contract_validation.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c6_pack.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c70_check_graph_currency.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c71_attribute_chain_calls.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c72_flat_inference_in_packages.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c73_cli_version.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c74_call_site_conservation.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c75_reexported_class_calls.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c76_contract_table_typo.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c77_gate_probe_battery.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c78_forbidden_chains.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c7_edge_vocab.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c80_tests_through_helpers.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c81_protocol_dispatch.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c82_review_changed_lines.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c83_foreign_graph_paths.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c84_missing_roots.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c85_mcp_graph_currency.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c87_review_path_base.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c89_review_docs.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c8_deadcode.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_r1c9_incremental.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_scip_export.py +0 -0
- {codmap-0.0.33 → codmap-0.0.35}/tests/test_scope.py +0 -0
- {codmap-0.0.33 → 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.
|
|
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
|
[](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
|
|
46
46
|
|
|
47
|
-
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **
|
|
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
|
[](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
|
|
10
10
|
|
|
11
|
-
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **
|
|
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 &
|
|
@@ -98,12 +98,21 @@ def _graph_from(args):
|
|
|
98
98
|
if getattr(args, "graph", None):
|
|
99
99
|
graph = store.load(args.graph)
|
|
100
100
|
if getattr(args, "func", None) not in (_cmd_check, _cmd_serve):
|
|
101
|
-
_warn_if_behind(args.graph, graph)
|
|
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
|
|
|
106
|
-
def
|
|
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
|
+
|
|
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
|
|
|
109
118
|
`check` prints its own currency line and `serve` puts it in every envelope; every
|
|
@@ -111,11 +120,18 @@ def _warn_if_behind(path: str, graph) -> None:
|
|
|
111
120
|
current or unknown, so stdout and exit codes never change.
|
|
112
121
|
"""
|
|
113
122
|
from codemap.serve.currency import graph_currency
|
|
114
|
-
|
|
123
|
+
prov = graph.provenance or {}
|
|
124
|
+
c = graph_currency(path, prov.get("scope_id"), roots=prov.get("roots"),
|
|
125
|
+
target=graph.target, base=getattr(args_for_currency, "source_root", None))
|
|
115
126
|
if c.get("status") == "behind":
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
127
|
+
counts = (f" ({c.get('added', 0)} added, {c.get('changed', 0)} changed, "
|
|
128
|
+
f"{c.get('removed', 0)} removed since it was built)" if "changed" in c else "")
|
|
129
|
+
print(f"[warning] {path} is behind its source tree{counts} — answers describe the "
|
|
130
|
+
"older tree; rebuild", file=sys.stderr)
|
|
131
|
+
elif c.get("status") == "unknown":
|
|
132
|
+
# R1-C90 D2: "could not check" is said, once — silence read as "current".
|
|
133
|
+
print(f"[note] could not check {path} against the source tree: {c.get('reason')}",
|
|
134
|
+
file=sys.stderr)
|
|
119
135
|
|
|
120
136
|
|
|
121
137
|
def _refuse_bad_roots(args) -> bool:
|
|
@@ -148,12 +164,11 @@ def _cmd_build(args) -> int:
|
|
|
148
164
|
if _refuse_bad_roots(args):
|
|
149
165
|
return 2
|
|
150
166
|
if args.consumer or args.docs:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
#
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
"single-package only)", file=sys.stderr)
|
|
167
|
+
core_graph = None
|
|
168
|
+
if getattr(args, "incremental", False) and args.out:
|
|
169
|
+
# R1-C86 D1: the core is updated incrementally; the consumer and doc scans
|
|
170
|
+
# (deterministic `ast`, ~6 s on bquant) rerun in full on top of it.
|
|
171
|
+
core_graph, incr_info = _incremental_core(args, repeat)
|
|
157
172
|
graph = extract_repo(
|
|
158
173
|
args.path,
|
|
159
174
|
consumers=tuple(args.consumer or ()),
|
|
@@ -161,6 +176,7 @@ def _cmd_build(args) -> int:
|
|
|
161
176
|
mode=args.mode,
|
|
162
177
|
deep=args.deep,
|
|
163
178
|
repeat=repeat,
|
|
179
|
+
core_graph=core_graph,
|
|
164
180
|
)
|
|
165
181
|
elif getattr(args, "incremental", False) and args.out:
|
|
166
182
|
graph, incr_info = _incremental_build(args)
|
|
@@ -295,6 +311,54 @@ def _incremental_build(args):
|
|
|
295
311
|
repeat=repeat)
|
|
296
312
|
|
|
297
313
|
|
|
314
|
+
def _core_subgraph(graph, offset: str = ""):
|
|
315
|
+
"""The core part of a repo-scoped graph: core nodes, and edges whose source is one (R1-C86).
|
|
316
|
+
|
|
317
|
+
``offset`` is the core's parent relative to the graph's path base (R1-C31). A repo
|
|
318
|
+
build re-roots core files by it, and `extract_repo` will do so again, so it is
|
|
319
|
+
stripped here or an unchanged core would come back with the prefix twice.
|
|
320
|
+
"""
|
|
321
|
+
import copy
|
|
322
|
+
from codemap.model import Graph
|
|
323
|
+
core = Graph(target=graph.target)
|
|
324
|
+
core.provenance = dict(graph.provenance or {})
|
|
325
|
+
core.provenance.pop("roots", None)
|
|
326
|
+
pre = f"{offset}/" if offset not in ("", ".") else ""
|
|
327
|
+
for nid, n in graph.nodes.items():
|
|
328
|
+
if (n.extras or {}).get("root", "core") == "core":
|
|
329
|
+
n = copy.copy(n)
|
|
330
|
+
if pre and n.file and n.file.startswith(pre):
|
|
331
|
+
n.file = n.file[len(pre):]
|
|
332
|
+
core.nodes[nid] = n
|
|
333
|
+
core.edges = [e for e in graph.edges if e.source in core.nodes]
|
|
334
|
+
return core
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def _incremental_core(args, repeat):
|
|
338
|
+
"""Update the core of an existing repo-scoped graph at ``args.out`` (R1-C86 D1).
|
|
339
|
+
|
|
340
|
+
Returns ``(core_graph or None, info)``; None means "build the core in full" (first
|
|
341
|
+
build, no sidecar scope, a different target, or a graph that was not repo-scoped).
|
|
342
|
+
"""
|
|
343
|
+
from codemap.freshness import read_meta
|
|
344
|
+
from codemap.incremental import update_graph
|
|
345
|
+
from codemap.scope import resolve_scope
|
|
346
|
+
old_meta = read_meta(args.out)
|
|
347
|
+
old_scope = (old_meta or {}).get("scope")
|
|
348
|
+
if not (Path(args.out).exists() and old_scope):
|
|
349
|
+
return None, {"mode": "full", "affected": []}
|
|
350
|
+
old_graph = store.load(args.out)
|
|
351
|
+
if old_graph.target != Path(args.path).resolve().name or \
|
|
352
|
+
not (old_graph.provenance or {}).get("roots"):
|
|
353
|
+
return None, {"mode": "full", "affected": []}
|
|
354
|
+
from codemap.extract.roots import _rel_to
|
|
355
|
+
consumers, docs = tuple(args.consumer or ()), tuple(args.docs or ())
|
|
356
|
+
new_scope = resolve_scope(args.path, consumers=consumers, docs=docs)
|
|
357
|
+
offset = _rel_to(Path(args.path).resolve().parent, roots_base(args.path, consumers, docs))
|
|
358
|
+
return update_graph(_core_subgraph(old_graph, offset), args.path, old_scope, new_scope,
|
|
359
|
+
deep=args.deep, repeat=repeat)
|
|
360
|
+
|
|
361
|
+
|
|
298
362
|
def _watch_build_argv(args) -> list[str]:
|
|
299
363
|
"""The build recipe this watch replays — recorded in the sidecar, not the watch argv.
|
|
300
364
|
|
|
@@ -1120,7 +1184,8 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
1120
1184
|
"only changed modules (R1-C9). Byte-identical to a full build on "
|
|
1121
1185
|
"the fast tier; on --deep it carries the earlier build's jedi "
|
|
1122
1186
|
"sample forward (docs/incremental.md). Much faster on --deep. "
|
|
1123
|
-
"
|
|
1187
|
+
"With --consumer/--docs the core is updated and the consumer and "
|
|
1188
|
+
"doc scans rerun in full (R1-C86).")
|
|
1124
1189
|
b.add_argument("--repeat", type=int, default=1, metavar="N",
|
|
1125
1190
|
help="--deep only: run the jedi layer N times and union the samples. "
|
|
1126
1191
|
"One deep build is one sample (a real edge was present in 75%% "
|
|
@@ -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
|
|
|
@@ -105,9 +105,14 @@ def extract_repo(
|
|
|
105
105
|
mode: str = "thin",
|
|
106
106
|
deep: bool = False,
|
|
107
107
|
repeat: int = 1,
|
|
108
|
+
core_graph: Graph | None = None,
|
|
108
109
|
) -> Graph:
|
|
109
110
|
"""Build a repo-scoped graph: core package + consumer roots + doc roots.
|
|
110
111
|
|
|
112
|
+
``core_graph`` (R1-C86): an already-built core graph — the incremental path updates the
|
|
113
|
+
core and hands it here, so the consumer and doc scans have one implementation for
|
|
114
|
+
full and incremental builds.
|
|
115
|
+
|
|
111
116
|
``core`` is analysed exactly as the single-package extractor (griffe, plus the
|
|
112
117
|
behavioral pass when ``deep``, unioned over ``repeat`` samples — R1-C45).
|
|
113
118
|
``consumers`` and ``docs`` are extra root directories scanned for references into
|
|
@@ -120,7 +125,7 @@ def extract_repo(
|
|
|
120
125
|
if problems:
|
|
121
126
|
raise ValueError("; ".join(problems))
|
|
122
127
|
|
|
123
|
-
graph = extract(core, deep=deep, repeat=repeat)
|
|
128
|
+
graph = core_graph if core_graph is not None else extract(core, deep=deep, repeat=repeat)
|
|
124
129
|
core_pkg = graph.target
|
|
125
130
|
for node in graph.nodes.values():
|
|
126
131
|
node.extras.setdefault("root", "core")
|
|
@@ -147,6 +152,8 @@ def extract_repo(
|
|
|
147
152
|
"docs": sorted(_rel_to(Path(p).resolve(), base) for p in docs),
|
|
148
153
|
"mode": mode,
|
|
149
154
|
}})
|
|
155
|
+
from codemap.model import check_routes
|
|
156
|
+
check_routes(graph) # R1-C91 D2
|
|
150
157
|
return graph
|
|
151
158
|
|
|
152
159
|
|
|
@@ -73,7 +73,12 @@ _BEHAVIOR_REF_RES = frozenset({"name", "annotation"})
|
|
|
73
73
|
# Node-extras keys owned by the two jedi-sensitive passes (spliced for unaffected).
|
|
74
74
|
# `shadows` (R1-C46) is stamped by the behavioral pass too, so an unaffected module keeps
|
|
75
75
|
# it — or the fast tier's byte-identity to a full build (R1-C9) breaks on it.
|
|
76
|
-
|
|
76
|
+
# R1-C86: `calls_nested` (calls inside nested defs, counted on the owner) and
|
|
77
|
+
# `calls_shadowed` (on the module node) are stamped by the same pass and were missing,
|
|
78
|
+
# so every unaffected module with a nested def lost them: on a bquant commit replay, 26
|
|
79
|
+
# nodes differed from a full build. A guard now derives the set from the passes.
|
|
80
|
+
_BEHAVIORAL_EXTRAS = ("calls", "control", "complexity", "attr_access", "shadows",
|
|
81
|
+
"calls_nested", "calls_shadowed")
|
|
77
82
|
# Old edge types whose target landing in a changed/removed module makes the source
|
|
78
83
|
# module stale (it must re-resolve). Only the spliced passes matter here — and the serve
|
|
79
84
|
# layer reads the same set to know which ops answer from a spliced class (R1-C44).
|
|
@@ -84,7 +89,26 @@ _DEP_EDGE_TYPES = SPLICED_EDGE_TYPES
|
|
|
84
89
|
_FULL_FALLBACK_FRACTION = 0.5
|
|
85
90
|
|
|
86
91
|
|
|
87
|
-
def
|
|
92
|
+
def _package_prefix(package_path, scope: dict, target_pkg: str) -> str:
|
|
93
|
+
"""The package's path relative to the scope root (R1-C86 D0).
|
|
94
|
+
|
|
95
|
+
In git mode the scope root is the repository root, so ``research/shared`` or
|
|
96
|
+
``src/pkg``; in fs mode it is the package's parent, so just ``pkg``. Falls back to
|
|
97
|
+
the package name when the root is unknown or the package is not under it.
|
|
98
|
+
"""
|
|
99
|
+
import os
|
|
100
|
+
root = scope.get("root") if scope else None
|
|
101
|
+
if root:
|
|
102
|
+
try:
|
|
103
|
+
rel = os.path.relpath(Path(package_path).resolve(), Path(root).resolve())
|
|
104
|
+
except ValueError:
|
|
105
|
+
rel = ""
|
|
106
|
+
if rel and not rel.startswith(".."):
|
|
107
|
+
return rel.replace("\\", "/")
|
|
108
|
+
return target_pkg
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _path_to_module(rel_path: str, target_pkg: str, prefix: str | None = None) -> str | None:
|
|
88
112
|
"""Map a scope file path to a package module id, or None if it's not package code.
|
|
89
113
|
|
|
90
114
|
``bquant/analysis/pipeline.py`` → ``bquant.analysis.pipeline``;
|
|
@@ -95,8 +119,13 @@ def _path_to_module(rel_path: str, target_pkg: str) -> str | None:
|
|
|
95
119
|
p = rel_path.replace("\\", "/")
|
|
96
120
|
if not p.endswith(".py"):
|
|
97
121
|
return None
|
|
98
|
-
|
|
99
|
-
|
|
122
|
+
prefix = prefix or target_pkg
|
|
123
|
+
# R1-C86 D0: the scope path is relative to the scope root (the git root in git mode),
|
|
124
|
+
# and the package may sit below it — `research/shared/m.py` is `shared.m`.
|
|
125
|
+
if p != prefix + ".py" and not p.startswith(prefix + "/"):
|
|
126
|
+
return None
|
|
127
|
+
parts = [target_pkg] + p[len(prefix) + 1:].split("/") if p.startswith(prefix + "/") else []
|
|
128
|
+
if not parts:
|
|
100
129
|
return None
|
|
101
130
|
if parts[-1] == "__init__.py":
|
|
102
131
|
parts = parts[:-1]
|
|
@@ -143,6 +172,11 @@ def _affected_modules(old_graph, new_graph, base_mods, changed_removed, module_o
|
|
|
143
172
|
def _splice_unaffected(new_graph, old_graph, unaffected, module_of) -> None:
|
|
144
173
|
"""Copy the two jedi passes' output for unaffected modules from the old graph."""
|
|
145
174
|
for e in old_graph.edges:
|
|
175
|
+
# R1-C86: an edge from a node that no longer exists (a removed module's function)
|
|
176
|
+
# resolves, by longest prefix, to the package's root module — which is unaffected —
|
|
177
|
+
# and was copied forward. A full build has no such edge.
|
|
178
|
+
if e.source not in new_graph.nodes:
|
|
179
|
+
continue
|
|
146
180
|
keep = False
|
|
147
181
|
if e.type == "calls" and e.extras.get("resolution") in _BEHAVIOR_CALL_RES:
|
|
148
182
|
keep = module_of(e.source) in unaffected
|
|
@@ -225,9 +259,10 @@ def update_graph(old_graph: Graph, package_path, old_scope: dict, new_scope: dic
|
|
|
225
259
|
{"mode": "full", "affected": [], "reason": reason}
|
|
226
260
|
|
|
227
261
|
d = diff_scopes(old_scope, new_scope)
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
262
|
+
prefix = _package_prefix(package_path, new_scope, target_pkg)
|
|
263
|
+
changed = {m for p in d["changed"] if (m := _path_to_module(p, target_pkg, prefix))}
|
|
264
|
+
added = {m for p in d["added"] if (m := _path_to_module(p, target_pkg, prefix))}
|
|
265
|
+
removed = {m for p in d["removed"] if (m := _path_to_module(p, target_pkg, prefix))}
|
|
231
266
|
|
|
232
267
|
# No package .py file changed → a single-package graph is unaffected (doc/consumer
|
|
233
268
|
# edits don't touch it). Return the old graph untouched.
|
|
@@ -267,10 +302,16 @@ def update_graph(old_graph: Graph, package_path, old_scope: dict, new_scope: dic
|
|
|
267
302
|
stats = {"runs": 1}
|
|
268
303
|
unaffected = module_ids - affected
|
|
269
304
|
_splice_unaffected(graph, old_graph, unaffected, module_of)
|
|
305
|
+
# R1-C86 D2: the Protocol fan-out (R1-C81 D2) ran inside add_behavioral_layer, before
|
|
306
|
+
# the spliced deep calls existed; run it again so they fan out too (idempotent).
|
|
307
|
+
from codemap.extract.dispatch import add_protocol_dispatch
|
|
308
|
+
add_protocol_dispatch(graph)
|
|
270
309
|
if repeat > 1:
|
|
271
310
|
# `unstable` describes the artifact a reader holds, not the part this tick
|
|
272
311
|
# touched: recount over recomputed and spliced edges alike.
|
|
273
312
|
stats = {"runs": repeat, "unstable": _count_seen(graph)}
|
|
274
313
|
graph.provenance = build_provenance(tier=tier, inputs=graph.provenance.get("inputs"),
|
|
275
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
|
|
276
317
|
return graph, {"mode": "incremental", "affected": sorted(affected)}
|
|
@@ -132,7 +132,10 @@ SCHEMA_VERSION = "0.13"
|
|
|
132
132
|
# cached `--currency-ttl` seconds, `checked_seconds_ago`); `stats` shows it beside
|
|
133
133
|
# `freshness` (R1-C85, docs/design/mcp_graph_currency.md); `review` names the doc pages a
|
|
134
134
|
# diff changes (`changed_docs`, R1-C89, docs/design/review_docs.md).
|
|
135
|
-
|
|
135
|
+
# 10 — `currency` says how it was checked (`via`: `recipe` or the graph's provenance roots,
|
|
136
|
+
# R1-C90), so a graph built elsewhere is `current`/`behind` where it was `unknown`; repo-scoped
|
|
137
|
+
# `build --incremental` is applied (R1-C86).
|
|
138
|
+
ANSWER_FORMAT = 10
|
|
136
139
|
|
|
137
140
|
# Closed vocabulary of edge types (R1-C7). Node ``kind`` is deliberately an OPEN set
|
|
138
141
|
# (DESIGN §2 — new entity kinds may appear), but edges are TYPED: every relationship
|
|
@@ -191,6 +194,9 @@ RESOLUTIONS: dict[tuple[str, str], dict[str, str]] = {
|
|
|
191
194
|
"means": "route", "confidence": "heuristic",
|
|
192
195
|
"how": "a call on a Protocol method fanned out to every structural implementer — "
|
|
193
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`"},
|
|
194
200
|
("calls", "typed"): {"means": "route", "confidence": "exact",
|
|
195
201
|
"how": "a consumer-root call on an expression typed by a constructor "
|
|
196
202
|
"or a return annotation (R1-C81)"},
|
|
@@ -211,6 +217,9 @@ RESOLUTIONS: dict[tuple[str, str], dict[str, str]] = {
|
|
|
211
217
|
"how": "the symbol is named as a value (dict entry, default=…)"},
|
|
212
218
|
("references", "doc"): {"means": "site", "confidence": "exact",
|
|
213
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)"},
|
|
214
223
|
("references", "imported"): {"means": "route", "confidence": "exact",
|
|
215
224
|
"how": "a consumer root names an imported core symbol"},
|
|
216
225
|
("reads", "string-key"): {"means": "route", "confidence": "exact",
|
|
@@ -242,7 +251,7 @@ def resolution_of(edge, *, strict: bool = True) -> dict[str, str] | None:
|
|
|
242
251
|
``None`` is a legitimate answer (``contains`` has no route), and it is distinct from
|
|
243
252
|
a value the table does not know. Under ``strict`` that one raises — a silent unknown
|
|
244
253
|
is how an open vocabulary pretends to be closed — and this is the form the guard test
|
|
245
|
-
|
|
254
|
+
uses; the builders check a whole graph with :func:`check_routes` (R1-C91). Reading a *foreign* graph passes ``strict=False`` and gets an
|
|
246
255
|
``unknown`` grade instead: refusing to open an artifact from another version is a
|
|
247
256
|
worse answer than saying which part of it this build cannot grade.
|
|
248
257
|
"""
|
|
@@ -265,6 +274,30 @@ def confidence_of(edge, *, strict: bool = True) -> str | None:
|
|
|
265
274
|
return row["confidence"] if row else None
|
|
266
275
|
|
|
267
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
|
+
|
|
268
301
|
# The subset of EDGE_TYPES an incremental build splices from the old graph for modules
|
|
269
302
|
# it did not recompute (``incremental.py``) — and therefore the classes a deep+incremental
|
|
270
303
|
# graph answers from an *earlier* build's jedi sample (R1-C43). Lives with the vocabulary
|
|
@@ -33,7 +33,45 @@ def recipe_scope_args(argv: list[str]) -> tuple[str, list[str], list[str]]:
|
|
|
33
33
|
return ns.path, ns.consumer, ns.docs
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
def
|
|
36
|
+
def _via_roots(graph_scope_id: str, roots: dict | None, target: str | None,
|
|
37
|
+
base: str | None, why: str) -> dict:
|
|
38
|
+
"""R1-C90: no usable recipe — check from the graph's own recorded roots under ``base``.
|
|
39
|
+
|
|
40
|
+
A graph built on another machine records its roots relative to its path base
|
|
41
|
+
(R1-C25/R1-C31) and its input identity; the scope id depends on file content and
|
|
42
|
+
relative paths, not on where the tree lives, so the same roots under this directory
|
|
43
|
+
give a comparable id.
|
|
44
|
+
"""
|
|
45
|
+
from pathlib import Path
|
|
46
|
+
b = Path(base or os.getcwd())
|
|
47
|
+
if roots:
|
|
48
|
+
core = b / roots.get("core", "")
|
|
49
|
+
consumers = tuple(b / c for c in roots.get("consumers") or ())
|
|
50
|
+
docs = tuple(b / d for d in roots.get("docs") or ())
|
|
51
|
+
elif target:
|
|
52
|
+
core, consumers, docs = b / target, (), ()
|
|
53
|
+
else:
|
|
54
|
+
return {"status": "unknown", "reason": why}
|
|
55
|
+
if not core.is_dir() or any(not p.is_dir() for p in (*consumers, *docs)):
|
|
56
|
+
return {"status": "unknown",
|
|
57
|
+
"reason": f"{why}; the graph's roots are not under {b} "
|
|
58
|
+
"(run from the directory the graph's paths are relative to, or "
|
|
59
|
+
"pass --source-root)"}
|
|
60
|
+
try:
|
|
61
|
+
from codemap.scope import resolve_scope
|
|
62
|
+
now = resolve_scope(str(core), consumers=tuple(map(str, consumers)),
|
|
63
|
+
docs=tuple(map(str, docs)))
|
|
64
|
+
except (Exception, SystemExit) as exc:
|
|
65
|
+
return {"status": "unknown", "reason": f"{why}; resolving the roots failed ({exc})"}
|
|
66
|
+
via = f"provenance roots under {b}"
|
|
67
|
+
if now["scope_id"] == graph_scope_id:
|
|
68
|
+
return {"status": "current", "scope_id": graph_scope_id, "via": via}
|
|
69
|
+
return {"status": "behind", "recorded": graph_scope_id, "current": now["scope_id"],
|
|
70
|
+
"via": via}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def graph_currency(graph_path: str, graph_scope_id: str | None, *, roots: dict | None = None,
|
|
74
|
+
target: str | None = None, base: str | None = None) -> dict:
|
|
37
75
|
"""Is the graph at ``graph_path`` the tree it would be judged as? (R1-C70)
|
|
38
76
|
|
|
39
77
|
``{"status": "current" | "behind" | "unknown", …}``. Design ``check_graph_currency.md`` D1:
|
|
@@ -48,10 +86,12 @@ def graph_currency(graph_path: str, graph_scope_id: str | None) -> dict:
|
|
|
48
86
|
"reason": "the graph records no input identity (`provenance.scope_id`)"}
|
|
49
87
|
meta = read_meta(graph_path)
|
|
50
88
|
if not meta or not meta.get("argv"):
|
|
51
|
-
return
|
|
89
|
+
return _via_roots(graph_scope_id, roots, target, base,
|
|
90
|
+
"no build recipe beside the graph")
|
|
52
91
|
cwd = meta.get("cwd")
|
|
53
92
|
if not cwd or not os.path.isdir(cwd):
|
|
54
|
-
return
|
|
93
|
+
return _via_roots(graph_scope_id, roots, target, base,
|
|
94
|
+
f"the recorded build directory is gone ({cwd})")
|
|
55
95
|
try:
|
|
56
96
|
from codemap.scope import diff_scopes, resolve_scope
|
|
57
97
|
path, consumers, docs = recipe_scope_args(meta["argv"])
|
|
@@ -61,7 +101,8 @@ def graph_currency(graph_path: str, graph_scope_id: str | None) -> dict:
|
|
|
61
101
|
except (Exception, SystemExit) as exc: # argparse exits on a recipe it cannot read
|
|
62
102
|
return {"status": "unknown", "reason": f"the recorded scope could not be resolved ({exc})"}
|
|
63
103
|
if now["scope_id"] == graph_scope_id:
|
|
64
|
-
return {"status": "current", "scope_id": graph_scope_id}
|
|
104
|
+
return {"status": "current", "scope_id": graph_scope_id, "via": "recipe"}
|
|
65
105
|
d = diff_scopes(meta.get("scope") or {}, now)
|
|
66
106
|
return {"status": "behind", "recorded": graph_scope_id, "current": now["scope_id"],
|
|
67
|
-
"added": len(d["added"]), "removed": len(d["removed"]), "changed": len(d["changed"])
|
|
107
|
+
"added": len(d["added"]), "removed": len(d["removed"]), "changed": len(d["changed"]),
|
|
108
|
+
"via": "recipe"}
|
|
@@ -513,8 +513,10 @@ class Session:
|
|
|
513
513
|
"compare against"}
|
|
514
514
|
else:
|
|
515
515
|
from codemap.serve.currency import graph_currency
|
|
516
|
-
|
|
517
|
-
|
|
516
|
+
prov = self.graph.provenance or {}
|
|
517
|
+
res = graph_currency(self.graph_path, prov.get("scope_id"),
|
|
518
|
+
roots=prov.get("roots"), target=self.graph.target,
|
|
519
|
+
base=self.source_root)
|
|
518
520
|
if res.get("status") == "behind":
|
|
519
521
|
res["hint"] = ("the source tree changed since this graph was built — "
|
|
520
522
|
"rebuild it, then `reload` (or run `serve --watch`)")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codmap
|
|
3
|
-
Version: 0.0.
|
|
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
|
[](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
|
|
46
46
|
|
|
47
|
-
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **
|
|
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 &
|
|
@@ -157,9 +157,12 @@ tests/test_r1c82_review_changed_lines.py
|
|
|
157
157
|
tests/test_r1c83_foreign_graph_paths.py
|
|
158
158
|
tests/test_r1c84_missing_roots.py
|
|
159
159
|
tests/test_r1c85_mcp_graph_currency.py
|
|
160
|
+
tests/test_r1c86_incremental_repo_scope.py
|
|
160
161
|
tests/test_r1c87_review_path_base.py
|
|
161
162
|
tests/test_r1c89_review_docs.py
|
|
162
163
|
tests/test_r1c8_deadcode.py
|
|
164
|
+
tests/test_r1c90_currency_without_recipe.py
|
|
165
|
+
tests/test_r1c91_route_vocabulary.py
|
|
163
166
|
tests/test_r1c9_incremental.py
|
|
164
167
|
tests/test_scip_export.py
|
|
165
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.
|
|
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
|
|