codmap 0.0.51__tar.gz → 0.0.52__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.51/codmap.egg-info → codmap-0.0.52}/PKG-INFO +4 -4
- {codmap-0.0.51 → codmap-0.0.52}/README.md +3 -3
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/__init__.py +2 -2
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/templates/agents_block.md +3 -2
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/templates/agents_block.ru.md +3 -2
- codmap-0.0.52/codemap/extract/named_dispatch.py +481 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/extract/roots.py +17 -4
- {codmap-0.0.51 → codmap-0.0.52}/codemap/model.py +4 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/query.py +34 -10
- {codmap-0.0.51 → codmap-0.0.52/codmap.egg-info}/PKG-INFO +4 -4
- {codmap-0.0.51 → codmap-0.0.52}/codmap.egg-info/SOURCES.txt +2 -0
- {codmap-0.0.51 → codmap-0.0.52}/pyproject.toml +1 -1
- codmap-0.0.52/tests/test_r1c107_named_dispatch.py +265 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c39_edge_resolution.py +6 -6
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c86_incremental_repo_scope.py +37 -0
- {codmap-0.0.51 → codmap-0.0.52}/LICENSE +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/__init__.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/__main__.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/advise/__init__.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/advise/data/feed.json +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/advise/data/matrix.toml +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/advise/refresh.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/advise/render.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/apidiff.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/arch.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/atomic.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/cli.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/artifacts.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/hooks.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/install.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/ratchet.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/state.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/templates/brief.txt +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/templates/claude_hooks.json +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/templates/codex_region.toml +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/templates/contract_head.toml +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/templates/cycles_region.toml +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/templates/github-workflow.yml +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/templates/gitlab-ci.yml +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/templates/mcp_claude.args +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/templates/post-commit.sh +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/templates/ratchet_region.toml +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/devkit/usage.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/diagnostics.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/extract/__init__.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/extract/attrflow.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/extract/behavior.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/extract/dataflow.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/extract/dispatch.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/extract/external.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/extract/griffe_extractor.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/extract/gsource.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/extract/probe.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/extract/union.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/freshness.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/incremental.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/integrations/__init__.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/integrations/base.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/integrations/cocoindex.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/integrations/gate.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/integrations/gitnexus.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/integrations/registry.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/integrations/transport.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/provenance.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/scope.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/__init__.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/_scip_pb2.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/api_surface.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/apidiff.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/architecture.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/audit.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/check.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/ctags.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/currency.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/impact.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/limits.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/livingdocs.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/mcp_server.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/mermaid.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/pack.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/rag.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/review.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/scip.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/semantic.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/server.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/session.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/subsystems.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/serve/vault.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/store.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/tomlio.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codemap/watch.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codmap.egg-info/dependency_links.txt +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codmap.egg-info/entry_points.txt +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codmap.egg-info/requires.txt +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/codmap.egg-info/top_level.txt +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/setup.cfg +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_epistemic.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_fast_field_and_usage.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_gitnexus_router.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_impact_depth.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_integrations.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_issue3_serve_freshness.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_livingdocs.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m0_api_surface.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m11_argcontract.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m12_dataflow.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m15_review.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m16_architecture.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m17_mcp.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m18_freshness.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m1_5_semantics.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m1_query.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m2_views.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m32_watch.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m3_serve.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m4_behavior.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m5_deep.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m6_repo_scope.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m7_dispatch.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_m9_family.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_mcp_surface_contract.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_pack_honesty.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c106_dead_code.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c108_devkit.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c109_namespace_source.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c110_advise.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c111_recipe.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c114_devkit_graph.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c115_agents_block.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c116_known_cycles.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c118_dead_code.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c119_first_build.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c120_dispatch_absorbed.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c121_devkit_trust.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c122_serve_robust.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c124_atomic_writes.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c125_graph_trust.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c126_scope_roles.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c127_require_current.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c132_harness.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c133_pin_links.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c134_refresh_recipe.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c135_advise_generations.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c13_callgraph_accuracy.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c13_grep_vs_graph.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c151_pack_projection.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c16_semantic.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c20_attribute_edges.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c21_flat_layout.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c22_source_visible_refs.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c23_hard_python.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c24_test_mapping.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c25_provenance.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c26_deep_union.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c27_config_honesty.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c28_limit_envelope.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c29_lazy_imports.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c2_ctags.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c30_local_import_calls.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c30f1_reexport_calls.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c30f2_check_scope.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c31_path_origin.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c32_report_json.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c33_query_signature.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c34_signature_kinds.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c35_contract_location.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c36_target_resolution.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c37_rule_mutation.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c38_tool_drift.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c3_arch_contract.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c3_dogfood.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c40_flow_reach.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c41_scope_membership.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c42_deep_tier_stability.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c43_incremental_splice.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c44_absent_answers.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c45_repeat_union.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c46_shadowed_definitions.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c47_incremental_resample.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c48_type_checking_imports.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c49_type_only_cycles.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c4_complexity.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c50_flow_entry_points.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c53_narrowing_declared.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c54_deterministic_rendering.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c55_override_grade.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c56_stub_files.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c57_facade_package.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c58_cycle_tangles.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c59_completeness_drop.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c5_apidiff.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c60_nested_definitions.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c62_phantom_rules.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c63_answer_format.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c64_dependency_probe.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c66_pack_direction.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c68_dotted_imports.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c69_contract_validation.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c6_pack.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c70_check_graph_currency.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c71_attribute_chain_calls.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c72_flat_inference_in_packages.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c73_cli_version.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c74_call_site_conservation.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c75_reexported_class_calls.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c76_contract_table_typo.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c77_gate_probe_battery.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c78_forbidden_chains.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c7_edge_vocab.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c80_tests_through_helpers.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c81_protocol_dispatch.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c82_review_changed_lines.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c83_foreign_graph_paths.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c84_missing_roots.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c85_mcp_graph_currency.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c87_review_path_base.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c89_review_docs.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c8_deadcode.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c90_currency_without_recipe.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c91_route_vocabulary.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c92_sidecar_pair.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c94_root_builds.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c95_r1c96_foreign_trees.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_r1c9_incremental.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_scip_export.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/tests/test_scope.py +0 -0
- {codmap-0.0.51 → codmap-0.0.52}/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.52
|
|
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,9 +54,9 @@ without a release.
|
|
|
54
54
|
|
|
55
55
|
[](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
|
|
56
56
|
|
|
57
|
-
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **
|
|
58
|
-
Python 3.
|
|
59
|
-
wheel smoke
|
|
57
|
+
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1576 tests with no failures in
|
|
58
|
+
the Python 3.12 acceptance run** ([CI](docs/ci.md) runs the full suite on Python 3.11–3.14, including the
|
|
59
|
+
dogfood pass, determinism, wheel smoke, and ctags/SCIP interop with 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 &
|
|
61
61
|
v1 boundaries), **[BACKLOG.md](BACKLOG.md)** (roadmap), and **[research/](research/)** (tool landscape).
|
|
62
62
|
|
|
@@ -18,9 +18,9 @@ without a release.
|
|
|
18
18
|
|
|
19
19
|
[](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
|
|
20
20
|
|
|
21
|
-
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **
|
|
22
|
-
Python 3.
|
|
23
|
-
wheel smoke
|
|
21
|
+
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1576 tests with no failures in
|
|
22
|
+
the Python 3.12 acceptance run** ([CI](docs/ci.md) runs the full suite on Python 3.11–3.14, including the
|
|
23
|
+
dogfood pass, determinism, wheel smoke, and ctags/SCIP interop with 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 &
|
|
25
25
|
v1 boundaries), **[BACKLOG.md](BACKLOG.md)** (roadmap), and **[research/](research/)** (tool landscape).
|
|
26
26
|
|
|
@@ -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 =
|
|
19
|
+
DEVKIT_VERSION = 9
|
|
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 = "
|
|
23
|
+
TEMPLATES_SHA256 = "7b0207095df06222d94e67fa2fa421089be7617aecd9b63f4ad94edfafd10e43"
|
|
24
24
|
|
|
25
25
|
TEMPLATES_DIR = Path(__file__).parent / "templates"
|
|
26
26
|
|
|
@@ -12,8 +12,9 @@ reaches — ask the graph instead of reading files or grepping.
|
|
|
12
12
|
`source` (MCP), instead of opening a long file.
|
|
13
13
|
- Before changing a public function, a model or a signature → `impact` (MCP). Write the reach (modules,
|
|
14
14
|
callers, tests) into the task or the review.
|
|
15
|
-
- Which tests to run for X → `tests` (MCP).
|
|
16
|
-
|
|
15
|
+
- Which tests to run for X → `tests` (MCP). Dispatch by name, such as calls with computed keys or through
|
|
16
|
+
framework-managed registries, can be invisible to static analysis. A missing match does not prove
|
|
17
|
+
the symbol is untested.
|
|
17
18
|
- The shape of the system → `architecture` (MCP) and `communities` (MCP).
|
|
18
19
|
- Before a merge → `git diff main... | codemap review --graph {{graph}}`, and attach the output.
|
|
19
20
|
|
|
@@ -12,8 +12,9 @@ codemap отвечает на вопросы о структуре `{{package}}`
|
|
|
12
12
|
(MCP), вместо чтения длинного файла.
|
|
13
13
|
- Перед изменением публичной функции, модели или сигнатуры → `impact` (MCP). Охват (модули, вызывающие,
|
|
14
14
|
тесты) запишите в задачу или ревью.
|
|
15
|
-
- Какие тесты гонять для X → `tests` (MCP).
|
|
16
|
-
|
|
15
|
+
- Какие тесты гонять для X → `tests` (MCP). Диспетчеризация по имени может быть не видна статическому
|
|
16
|
+
анализу, например при вызовах с вычисляемым ключом или через реестр фреймворка. Отсутствие
|
|
17
|
+
совпадения не доказывает, что символ не протестирован.
|
|
17
18
|
- Форма системы → `architecture` (MCP) и `communities` (MCP).
|
|
18
19
|
- Перед слиянием → `git diff main... | codemap review --graph {{graph}}`, и приложите вывод.
|
|
19
20
|
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
"""Source-only join for literal calls through an internal decorator registry."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import ast
|
|
6
|
+
from collections import Counter, defaultdict
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
from importlib.util import resolve_name
|
|
9
|
+
|
|
10
|
+
from codemap.extract.behavior import _shadow_map
|
|
11
|
+
from codemap.model import Edge, confidence_of
|
|
12
|
+
|
|
13
|
+
_FUNCTIONS = (ast.FunctionDef, ast.AsyncFunctionDef)
|
|
14
|
+
_SCOPES = (*_FUNCTIONS, ast.ClassDef, ast.Lambda, ast.ListComp, ast.SetComp,
|
|
15
|
+
ast.DictComp, ast.GeneratorExp)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _body(node):
|
|
19
|
+
body = node.body
|
|
20
|
+
return body[1:] if ast.get_docstring(node) is not None else body
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _parameters(node, count, *, variadic=False):
|
|
24
|
+
args = node.args
|
|
25
|
+
positional = args.posonlyargs + args.args
|
|
26
|
+
if (len(positional) == count and not node.decorator_list
|
|
27
|
+
and not (args.defaults or args.kwonlyargs)
|
|
28
|
+
and (variadic or not (args.vararg or args.kwarg))):
|
|
29
|
+
return tuple(arg.arg for arg in positional)
|
|
30
|
+
return (None,) * count
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _mapping_slot(node, receiver, key):
|
|
34
|
+
match node:
|
|
35
|
+
case ast.Subscript(value=ast.Attribute(value=ast.Name(id=obj), attr=field),
|
|
36
|
+
slice=ast.Name(id=index)) if obj == receiver and index == key:
|
|
37
|
+
return field
|
|
38
|
+
return None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _registrar(method, receiver, key):
|
|
42
|
+
match _body(method):
|
|
43
|
+
case [ast.FunctionDef(name=name) as decorator, ast.Return(value=ast.Name(id=result))] if name == result:
|
|
44
|
+
handler, = _parameters(decorator, 1)
|
|
45
|
+
if handler in (None, receiver, key) or name in (receiver, key):
|
|
46
|
+
return None
|
|
47
|
+
match _body(decorator):
|
|
48
|
+
case [ast.Assign(targets=[slot], value=ast.Name(id=value)),
|
|
49
|
+
ast.Return(value=ast.Name(id=returned))] if value == returned == handler:
|
|
50
|
+
return _mapping_slot(slot, receiver, key)
|
|
51
|
+
return None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@dataclass(frozen=True)
|
|
55
|
+
class _Dispatcher:
|
|
56
|
+
field: str
|
|
57
|
+
receiver: str
|
|
58
|
+
key: str
|
|
59
|
+
positional_payload: bool
|
|
60
|
+
keyword_payload: bool
|
|
61
|
+
|
|
62
|
+
def literal_key(self, call):
|
|
63
|
+
if not call.args or not isinstance(call.args[0], ast.Constant):
|
|
64
|
+
return None
|
|
65
|
+
key = call.args[0].value
|
|
66
|
+
if not isinstance(key, str):
|
|
67
|
+
return None
|
|
68
|
+
if len(call.args) > 1 and not self.positional_payload:
|
|
69
|
+
return None
|
|
70
|
+
if any(isinstance(arg, ast.Starred) for arg in call.args[1:]):
|
|
71
|
+
return None
|
|
72
|
+
if call.keywords and not self.keyword_payload:
|
|
73
|
+
return None
|
|
74
|
+
if any(kw.arg in (None, self.receiver, self.key) for kw in call.keywords):
|
|
75
|
+
return None
|
|
76
|
+
return key
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _dispatcher(method):
|
|
80
|
+
receiver, key = _parameters(method, 2, variadic=True)
|
|
81
|
+
if receiver is None:
|
|
82
|
+
return None
|
|
83
|
+
match _body(method):
|
|
84
|
+
case [ast.Return(value=ast.Call() as call)] | [ast.Expr(value=ast.Call() as call)]:
|
|
85
|
+
field = _mapping_slot(call.func, receiver, key)
|
|
86
|
+
if not field:
|
|
87
|
+
return None
|
|
88
|
+
positional, keywords = method.args.vararg, method.args.kwarg
|
|
89
|
+
if positional or keywords:
|
|
90
|
+
# Forward each declared payload channel directly and unchanged.
|
|
91
|
+
match call.args:
|
|
92
|
+
case [ast.Starred(value=ast.Name(id=name))] if positional and name == positional.arg:
|
|
93
|
+
pass
|
|
94
|
+
case [] if positional is None:
|
|
95
|
+
pass
|
|
96
|
+
case _:
|
|
97
|
+
return None
|
|
98
|
+
match call.keywords:
|
|
99
|
+
case [ast.keyword(arg=None, value=ast.Name(id=name))] if keywords and name == keywords.arg:
|
|
100
|
+
pass
|
|
101
|
+
case [] if keywords is None:
|
|
102
|
+
pass
|
|
103
|
+
case _:
|
|
104
|
+
return None
|
|
105
|
+
elif any(isinstance(n, ast.NamedExpr) for n in ast.walk(method)):
|
|
106
|
+
# Keep the original direct dispatcher without payload parameters.
|
|
107
|
+
return None
|
|
108
|
+
return _Dispatcher(field, receiver, key, bool(positional), bool(keywords))
|
|
109
|
+
return None
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _scope_nodes(body):
|
|
113
|
+
for node in body:
|
|
114
|
+
yield node
|
|
115
|
+
if isinstance(node, (ast.ListComp, ast.SetComp, ast.DictComp, ast.GeneratorExp)):
|
|
116
|
+
# Comprehension iteration targets are local, but walrus targets escape.
|
|
117
|
+
yield from (n.target for n in ast.walk(node) if isinstance(n, ast.NamedExpr))
|
|
118
|
+
elif not isinstance(node, _SCOPES):
|
|
119
|
+
yield from _scope_nodes(ast.iter_child_nodes(node))
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _bound_names(node):
|
|
123
|
+
match node:
|
|
124
|
+
case ast.Name(id=name, ctx=ast.Store() | ast.Del()) | ast.arg(arg=name):
|
|
125
|
+
return (name,)
|
|
126
|
+
case ast.FunctionDef(name=name) | ast.AsyncFunctionDef(name=name) | ast.ClassDef(name=name):
|
|
127
|
+
return (name,)
|
|
128
|
+
case ast.Import(names=names):
|
|
129
|
+
return tuple(a.asname or a.name.split(".")[0] for a in names)
|
|
130
|
+
case ast.ImportFrom(names=names):
|
|
131
|
+
return tuple(a.asname or a.name for a in names)
|
|
132
|
+
case ast.Global(names=names) | ast.Nonlocal(names=names):
|
|
133
|
+
return names
|
|
134
|
+
case ast.ExceptHandler(name=name) | ast.MatchAs(name=name) | ast.MatchStar(name=name) | ast.MatchMapping(rest=name):
|
|
135
|
+
return (name,) if name else ()
|
|
136
|
+
return ()
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _registry(cls):
|
|
140
|
+
"""Map ordinary method names to the fresh instance dict they share."""
|
|
141
|
+
if cls.bases or cls.keywords or cls.decorator_list:
|
|
142
|
+
return {}, {}
|
|
143
|
+
methods = {n.name: n for n in cls.body if isinstance(n, ast.FunctionDef)}
|
|
144
|
+
counts = Counter(name for n in _scope_nodes(cls.body) for name in _bound_names(n))
|
|
145
|
+
if any(name.startswith("__") and name != "__init__" for name in counts):
|
|
146
|
+
return {}, {}
|
|
147
|
+
init = methods.get("__init__")
|
|
148
|
+
if init is None or counts["__init__"] != 1:
|
|
149
|
+
return {}, {}
|
|
150
|
+
receiver, = _parameters(init, 1)
|
|
151
|
+
fields = {}
|
|
152
|
+
for stmt in _body(init):
|
|
153
|
+
match stmt:
|
|
154
|
+
case ast.Assign(targets=[ast.Attribute() as target], value=value):
|
|
155
|
+
pass
|
|
156
|
+
case ast.AnnAssign(target=ast.Attribute() as target, value=value):
|
|
157
|
+
pass
|
|
158
|
+
case _:
|
|
159
|
+
return {}, {}
|
|
160
|
+
if not isinstance(target.value, ast.Name) or target.value.id != receiver or counts[target.attr]:
|
|
161
|
+
return {}, {}
|
|
162
|
+
if isinstance(value, ast.Dict) and not value.keys:
|
|
163
|
+
fields[target.attr] = target
|
|
164
|
+
elif not isinstance(value, ast.Constant):
|
|
165
|
+
return {}, {}
|
|
166
|
+
|
|
167
|
+
registrars, dispatchers = {}, {}
|
|
168
|
+
for name, method in methods.items():
|
|
169
|
+
if counts[name] != 1 or name in fields or name == "__init__":
|
|
170
|
+
continue
|
|
171
|
+
receiver, key = _parameters(method, 2)
|
|
172
|
+
if receiver is not None and (field := _registrar(method, receiver, key)):
|
|
173
|
+
registrars[name] = field
|
|
174
|
+
if dispatcher := _dispatcher(method):
|
|
175
|
+
dispatchers[name] = dispatcher
|
|
176
|
+
|
|
177
|
+
shared = fields.keys() & set(registrars.values()) & {d.field for d in dispatchers.values()}
|
|
178
|
+
# Any other access to a candidate attribute could mutate or replace the dict.
|
|
179
|
+
supported = {methods[name] for name in registrars.keys() | dispatchers.keys()}
|
|
180
|
+
for stmt in cls.body:
|
|
181
|
+
if stmt in supported:
|
|
182
|
+
continue
|
|
183
|
+
for node in ast.walk(stmt):
|
|
184
|
+
if (isinstance(node, ast.Attribute) and node.attr in shared
|
|
185
|
+
and node is not fields[node.attr]):
|
|
186
|
+
shared.discard(node.attr)
|
|
187
|
+
return ({name: field for name, field in registrars.items() if field in shared},
|
|
188
|
+
{name: dispatcher for name, dispatcher in dispatchers.items() if dispatcher.field in shared})
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@dataclass(frozen=True)
|
|
192
|
+
class _Instance:
|
|
193
|
+
module: str
|
|
194
|
+
name: str
|
|
195
|
+
cls: str
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@dataclass(frozen=True)
|
|
199
|
+
class _Method:
|
|
200
|
+
instance: _Instance
|
|
201
|
+
name: str
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class _Module:
|
|
205
|
+
def __init__(self, mid, tree, *, package=False, imports=None):
|
|
206
|
+
self.id, self.tree = mid, tree
|
|
207
|
+
self.bindings = {}
|
|
208
|
+
self.lines = {}
|
|
209
|
+
self.counts = Counter(name for n in _scope_nodes(tree.body) for name in _bound_names(n))
|
|
210
|
+
# Explicit global writes and a star import can invalidate module bindings.
|
|
211
|
+
for node in ast.walk(tree):
|
|
212
|
+
if isinstance(node, ast.Global):
|
|
213
|
+
self.counts.update(node.names)
|
|
214
|
+
if self.counts["*"]:
|
|
215
|
+
return
|
|
216
|
+
if imports is not None:
|
|
217
|
+
self.bindings.update(imports)
|
|
218
|
+
for stmt in tree.body:
|
|
219
|
+
self.lines.update(dict.fromkeys(_bound_names(stmt), stmt.lineno))
|
|
220
|
+
match stmt:
|
|
221
|
+
case ast.Import() | ast.ImportFrom() if imports is None:
|
|
222
|
+
self.bindings.update(self._imports(stmt, package))
|
|
223
|
+
case ast.Assign(targets=[ast.Name(id=name)], value=value):
|
|
224
|
+
self.bindings[name] = value
|
|
225
|
+
self.lines[name] = stmt.lineno
|
|
226
|
+
case ast.AnnAssign(target=ast.Name(id=name), value=value) if value is not None:
|
|
227
|
+
self.bindings[name] = value
|
|
228
|
+
self.lines[name] = stmt.lineno
|
|
229
|
+
case ast.ClassDef(name=name):
|
|
230
|
+
self.bindings[name] = stmt
|
|
231
|
+
|
|
232
|
+
def _imports(self, stmt, package):
|
|
233
|
+
if isinstance(stmt, ast.Import):
|
|
234
|
+
return {a.asname or a.name.split(".")[0]: a.name if a.asname else a.name.split(".")[0]
|
|
235
|
+
for a in stmt.names}
|
|
236
|
+
parent = self.id if package else self.id.rpartition(".")[0]
|
|
237
|
+
module = stmt.module or ""
|
|
238
|
+
if stmt.level:
|
|
239
|
+
try:
|
|
240
|
+
module = resolve_name("." * stmt.level + module, parent)
|
|
241
|
+
except ImportError:
|
|
242
|
+
return {}
|
|
243
|
+
return {a.asname or a.name: f"{module}.{a.name}" for a in stmt.names}
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class _RegistryIndex:
|
|
247
|
+
def __init__(self, graph, base, index):
|
|
248
|
+
self.modules = {}
|
|
249
|
+
self.classes = {}
|
|
250
|
+
self.registrations = defaultdict(list)
|
|
251
|
+
self.uncertain = set()
|
|
252
|
+
self.mutated = set()
|
|
253
|
+
# A supported class needs an initializer and at least two ordinary methods.
|
|
254
|
+
methods = Counter()
|
|
255
|
+
initializers = set()
|
|
256
|
+
for edge in graph.edges:
|
|
257
|
+
if edge.type == "contains" and graph.nodes[edge.source].kind == "class":
|
|
258
|
+
if graph.nodes[edge.target].kind == "function":
|
|
259
|
+
methods[edge.source] += 1
|
|
260
|
+
if edge.target == edge.source + ".__init__":
|
|
261
|
+
initializers.add(edge.source)
|
|
262
|
+
|
|
263
|
+
def load(mid):
|
|
264
|
+
node = graph.nodes[mid]
|
|
265
|
+
if not node.file or node.extras.get("root") != "core":
|
|
266
|
+
return
|
|
267
|
+
path = base / node.file
|
|
268
|
+
try:
|
|
269
|
+
tree = ast.parse(path.read_bytes())
|
|
270
|
+
except (OSError, SyntaxError, ValueError):
|
|
271
|
+
return
|
|
272
|
+
module = self.modules[mid] = _Module(mid, tree, package=path.name == "__init__.py")
|
|
273
|
+
return module
|
|
274
|
+
|
|
275
|
+
candidates = {cid for cid in initializers if methods[cid] >= 3}
|
|
276
|
+
for mid in sorted({cid.rpartition(".")[0] for cid in candidates} & index.module_set):
|
|
277
|
+
module = load(mid)
|
|
278
|
+
if module is None:
|
|
279
|
+
continue
|
|
280
|
+
for name, stmt in module.bindings.items():
|
|
281
|
+
cid = f"{mid}.{name}"
|
|
282
|
+
if cid in candidates and module.counts[name] == 1 and isinstance(stmt, ast.ClassDef):
|
|
283
|
+
registrars, dispatchers = _registry(stmt)
|
|
284
|
+
if registrars:
|
|
285
|
+
self.classes[cid] = registrars, dispatchers
|
|
286
|
+
if not self.classes:
|
|
287
|
+
return
|
|
288
|
+
for mid in sorted(index.module_set - self.modules.keys()):
|
|
289
|
+
load(mid)
|
|
290
|
+
for module in self.modules.values():
|
|
291
|
+
self._find_mutations(module)
|
|
292
|
+
for module in self.modules.values():
|
|
293
|
+
self._register(graph, module)
|
|
294
|
+
|
|
295
|
+
def _path(self, path, seen):
|
|
296
|
+
if path in self.modules:
|
|
297
|
+
parent, _, name = path.rpartition(".")
|
|
298
|
+
if parent not in self.modules or not self.modules[parent].counts[name]:
|
|
299
|
+
return path
|
|
300
|
+
parent, _, name = path.rpartition(".")
|
|
301
|
+
module = self.modules.get(parent)
|
|
302
|
+
return self._binding(module, name, seen) if module else None
|
|
303
|
+
|
|
304
|
+
def _binding(self, module, name, seen, before=None):
|
|
305
|
+
marker = (module.id, name)
|
|
306
|
+
if (marker in seen or module.counts[name] != 1
|
|
307
|
+
or (before is not None and module.lines.get(name, before) >= before)):
|
|
308
|
+
return None
|
|
309
|
+
seen = seen | {marker}
|
|
310
|
+
value = module.bindings.get(name)
|
|
311
|
+
if isinstance(value, str):
|
|
312
|
+
# `from . import submodule` can name the submodule itself.
|
|
313
|
+
if value == f"{module.id}.{name}" and value in self.modules:
|
|
314
|
+
return value
|
|
315
|
+
return self._path(value, seen)
|
|
316
|
+
if isinstance(value, ast.ClassDef):
|
|
317
|
+
cid = f"{module.id}.{name}"
|
|
318
|
+
return cid if cid in self.classes else None
|
|
319
|
+
if isinstance(value, ast.Call) and not (value.args or value.keywords):
|
|
320
|
+
cls = self._resolve(value.func, module, seen, before=value.lineno)
|
|
321
|
+
if isinstance(cls, str) and cls in self.classes:
|
|
322
|
+
return _Instance(module.id, name, cls)
|
|
323
|
+
# Only a direct bound registrar alias is supported as a value assignment.
|
|
324
|
+
if isinstance(value, ast.Attribute):
|
|
325
|
+
method = self._resolve(value, module, seen, before=value.lineno)
|
|
326
|
+
if isinstance(method, _Method) and method.name in self.classes[method.instance.cls][0]:
|
|
327
|
+
return method
|
|
328
|
+
return None
|
|
329
|
+
|
|
330
|
+
def _resolve(self, expr, module, seen=frozenset(), blocked=frozenset(), before=None):
|
|
331
|
+
if isinstance(expr, ast.Name) and expr.id not in blocked:
|
|
332
|
+
return self._binding(module, expr.id, seen, before)
|
|
333
|
+
if isinstance(expr, ast.Attribute):
|
|
334
|
+
value = self._resolve(expr.value, module, seen, blocked, before)
|
|
335
|
+
if isinstance(value, _Instance):
|
|
336
|
+
return _Method(value, expr.attr)
|
|
337
|
+
if isinstance(value, str) and value in self.modules:
|
|
338
|
+
return self._path(f"{value}.{expr.attr}", seen)
|
|
339
|
+
return None
|
|
340
|
+
|
|
341
|
+
def _find_mutations(self, module):
|
|
342
|
+
for node, blocked, _ in _sites(module.tree, (ast.Attribute, ast.Subscript)):
|
|
343
|
+
receiver = self._resolve(node.value, module, blocked=blocked)
|
|
344
|
+
if isinstance(node.ctx, ast.Load):
|
|
345
|
+
if (isinstance(receiver, _Instance) and isinstance(node, ast.Attribute)
|
|
346
|
+
and node.attr in self.classes[receiver.cls][0].values()):
|
|
347
|
+
# External access can let the mapping escape the supported registrar.
|
|
348
|
+
self.mutated.add(receiver)
|
|
349
|
+
continue
|
|
350
|
+
if isinstance(receiver, _Method):
|
|
351
|
+
self.mutated.add(receiver.instance)
|
|
352
|
+
elif isinstance(receiver, _Instance) or receiver in self.classes:
|
|
353
|
+
self.mutated.add(receiver)
|
|
354
|
+
elif isinstance(receiver, str) and receiver in self.modules and isinstance(node, ast.Attribute):
|
|
355
|
+
value = self._path(f"{receiver}.{node.attr}", frozenset())
|
|
356
|
+
if isinstance(value, (_Instance, _Method)) or value in self.classes:
|
|
357
|
+
self.mutated.add(value.instance if isinstance(value, _Method) else value)
|
|
358
|
+
|
|
359
|
+
def _register(self, graph, module):
|
|
360
|
+
# Count call sites before filtering handlers: an unrepresentable earlier
|
|
361
|
+
# definition may still have registered its function at import time.
|
|
362
|
+
definitions = [n for n in module.tree.body if isinstance(n, _FUNCTIONS)]
|
|
363
|
+
definition_counts = Counter(n.name for n in definitions)
|
|
364
|
+
surviving = {n.name: n for n in definitions}
|
|
365
|
+
handlers = {id(n.decorator_list[0]): n for n in surviving.values()
|
|
366
|
+
if len(n.decorator_list) == 1 and module.counts[n.name] == definition_counts[n.name]}
|
|
367
|
+
for call, blocked, in_function in _sites(module.tree, ast.Call):
|
|
368
|
+
handler = handlers.get(id(call))
|
|
369
|
+
method = self._resolve(call.func, module, blocked=blocked,
|
|
370
|
+
before=None if in_function else call.lineno)
|
|
371
|
+
if not isinstance(method, _Method):
|
|
372
|
+
continue
|
|
373
|
+
field = self.classes[method.instance.cls][0].get(method.name)
|
|
374
|
+
if field is None:
|
|
375
|
+
continue
|
|
376
|
+
key = _literal_key(call)
|
|
377
|
+
if key is None:
|
|
378
|
+
self.uncertain.add((method.instance, field))
|
|
379
|
+
continue
|
|
380
|
+
target = None
|
|
381
|
+
if handler is not None:
|
|
382
|
+
node = graph.nodes.get(f"{module.id}.{handler.name}")
|
|
383
|
+
if (node and node.kind == "function" and node.extras.get("root") == "core"
|
|
384
|
+
and node.lineno in (handler.lineno, call.lineno)):
|
|
385
|
+
target = node.id
|
|
386
|
+
self.registrations[method.instance, key].append((field, target))
|
|
387
|
+
|
|
388
|
+
def consumer_calls(self, module):
|
|
389
|
+
if not self.registrations:
|
|
390
|
+
return
|
|
391
|
+
tree = module.tree
|
|
392
|
+
replaced = _shadow_map(tree)[0]
|
|
393
|
+
|
|
394
|
+
for call, blocked, in_function in _sites(tree, ast.Call, replaced):
|
|
395
|
+
if not in_function:
|
|
396
|
+
continue
|
|
397
|
+
method = self._resolve(call.func, module, blocked=blocked)
|
|
398
|
+
if not isinstance(method, _Method):
|
|
399
|
+
continue
|
|
400
|
+
dispatcher = self.classes[method.instance.cls][1].get(method.name)
|
|
401
|
+
if dispatcher is None or (key := dispatcher.literal_key(call)) is None:
|
|
402
|
+
continue
|
|
403
|
+
field = dispatcher.field
|
|
404
|
+
targets = self.registrations.get((method.instance, key), ())
|
|
405
|
+
if (len(targets) == 1 and targets[0][0] == field and targets[0][1]
|
|
406
|
+
and (method.instance, field) not in self.uncertain
|
|
407
|
+
and method.instance not in self.mutated
|
|
408
|
+
and method.instance.cls not in self.mutated):
|
|
409
|
+
yield call, targets[0][1]
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
def _sites(tree, kinds, replaced=frozenset()):
|
|
413
|
+
"""Expressions paired with enclosing lexical bindings and their evaluation scope."""
|
|
414
|
+
def visit(node, blocked, in_function):
|
|
415
|
+
if id(node) in replaced:
|
|
416
|
+
return
|
|
417
|
+
if isinstance(node, (*_FUNCTIONS, ast.ClassDef)):
|
|
418
|
+
for decorator in node.decorator_list:
|
|
419
|
+
# Keep registrations and avoid attributing decorators to a function body.
|
|
420
|
+
yield from visit(decorator, blocked, False)
|
|
421
|
+
body_bindings = {name for n in _scope_nodes(node.body) for name in _bound_names(n)}
|
|
422
|
+
if isinstance(node, ast.ClassDef):
|
|
423
|
+
# A method's body does not capture the class namespace.
|
|
424
|
+
for stmt in node.body:
|
|
425
|
+
scope = blocked if isinstance(stmt, _FUNCTIONS) else blocked | body_bindings
|
|
426
|
+
yield from visit(stmt, scope, False)
|
|
427
|
+
else:
|
|
428
|
+
names = body_bindings | {name for n in ast.iter_child_nodes(node.args)
|
|
429
|
+
for name in _bound_names(n)}
|
|
430
|
+
if "*" not in names:
|
|
431
|
+
for stmt in node.body:
|
|
432
|
+
yield from visit(stmt, blocked | names, True)
|
|
433
|
+
return
|
|
434
|
+
if isinstance(node, _SCOPES):
|
|
435
|
+
return
|
|
436
|
+
if isinstance(node, kinds):
|
|
437
|
+
yield node, blocked, in_function
|
|
438
|
+
for child in ast.iter_child_nodes(node):
|
|
439
|
+
yield from visit(child, blocked, in_function)
|
|
440
|
+
|
|
441
|
+
yield from visit(tree, frozenset(), False)
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
def _literal_key(call):
|
|
445
|
+
match call:
|
|
446
|
+
case ast.Call(args=[ast.Constant(value=str() as key)], keywords=[]):
|
|
447
|
+
return key
|
|
448
|
+
return None
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def add_named_dispatch(graph, base, index, test_modules, source_for, consumer_imports):
|
|
452
|
+
registries = _RegistryIndex(graph, base, index)
|
|
453
|
+
if not registries.registrations:
|
|
454
|
+
return
|
|
455
|
+
modules = []
|
|
456
|
+
for mid, file, tree, ranges in test_modules:
|
|
457
|
+
# The ordinary consumer resolver also sees local imports. Only direct
|
|
458
|
+
# module imports can serve as stable bindings for this join.
|
|
459
|
+
imports = [stmt for stmt in tree.body if isinstance(stmt, (ast.Import, ast.ImportFrom))]
|
|
460
|
+
symbols, aliases, _ = consumer_imports(ast.Module(body=imports, type_ignores=[]), index)
|
|
461
|
+
module = _Module(mid, tree, imports={**symbols, **aliases})
|
|
462
|
+
modules.append((module, file, ranges))
|
|
463
|
+
registries._find_mutations(module)
|
|
464
|
+
registries._register(graph, module)
|
|
465
|
+
|
|
466
|
+
pairs = set()
|
|
467
|
+
for module, file, ranges in modules:
|
|
468
|
+
for call, target in registries.consumer_calls(module):
|
|
469
|
+
source = source_for(call, module.id, ranges)
|
|
470
|
+
node = graph.nodes[source]
|
|
471
|
+
if node.kind == "function" and node.file == file:
|
|
472
|
+
pairs.add((source, target))
|
|
473
|
+
if not pairs:
|
|
474
|
+
return
|
|
475
|
+
pairs.difference_update(
|
|
476
|
+
(edge.source, edge.target) for edge in graph.edges
|
|
477
|
+
if edge.type == "calls" and (edge.source, edge.target) in pairs
|
|
478
|
+
and confidence_of(edge, strict=False) != "heuristic"
|
|
479
|
+
)
|
|
480
|
+
for source, target in sorted(pairs):
|
|
481
|
+
graph.add_edge(Edge("calls", source, target, extras={"resolution": "named-dispatch"}))
|
|
@@ -135,8 +135,13 @@ def extract_repo(
|
|
|
135
135
|
_reroot_files(graph, _rel_to(Path(core).resolve().parent, base))
|
|
136
136
|
|
|
137
137
|
index = _CoreIndex(graph, core_pkg)
|
|
138
|
+
test_modules = []
|
|
138
139
|
for path in consumers:
|
|
139
|
-
_scan_consumer_root(graph, Path(path).resolve(), index, mode, base)
|
|
140
|
+
_scan_consumer_root(graph, Path(path).resolve(), index, mode, base, test_modules)
|
|
141
|
+
if test_modules:
|
|
142
|
+
from codemap.extract.named_dispatch import add_named_dispatch
|
|
143
|
+
|
|
144
|
+
add_named_dispatch(graph, base, index, test_modules, _source_for, _consumer_imports)
|
|
140
145
|
for path in docs:
|
|
141
146
|
_scan_doc_root(graph, Path(path).resolve(), index, base)
|
|
142
147
|
# R1-C81 D2 again: consumer `typed` calls onto a Protocol method fan out as well.
|
|
@@ -251,7 +256,7 @@ class _CoreIndex:
|
|
|
251
256
|
# -- consumer roots (.py) ----------------------------------------------------
|
|
252
257
|
|
|
253
258
|
def _scan_consumer_root(graph: Graph, root_dir: Path, index: _CoreIndex, mode: str,
|
|
254
|
-
origin: Path | None = None) -> None:
|
|
259
|
+
origin: Path | None = None, test_modules=None) -> None:
|
|
255
260
|
if not root_dir.is_dir():
|
|
256
261
|
return
|
|
257
262
|
label = root_dir.name
|
|
@@ -264,7 +269,7 @@ def _scan_consumer_root(graph: Graph, root_dir: Path, index: _CoreIndex, mode: s
|
|
|
264
269
|
tree = ast.parse(py.read_text(encoding="utf-8"))
|
|
265
270
|
except (OSError, SyntaxError):
|
|
266
271
|
continue
|
|
267
|
-
_scan_consumer_module(graph, py, base, label, tree, index, mode, origin)
|
|
272
|
+
_scan_consumer_module(graph, py, base, label, tree, index, mode, origin, test_modules)
|
|
268
273
|
|
|
269
274
|
|
|
270
275
|
def _module_id(py: Path, base: Path) -> str:
|
|
@@ -275,7 +280,7 @@ def _module_id(py: Path, base: Path) -> str:
|
|
|
275
280
|
return ".".join(parts)
|
|
276
281
|
|
|
277
282
|
|
|
278
|
-
def _scan_consumer_module(graph, py, base, label, tree, index, mode, origin=None) -> None:
|
|
283
|
+
def _scan_consumer_module(graph, py, base, label, tree, index, mode, origin=None, test_modules=None) -> None:
|
|
279
284
|
# the id is the import path (relative to the root's parent); the file is a location
|
|
280
285
|
# (relative to the graph's one origin). They differ whenever a root sits deeper.
|
|
281
286
|
mod_id = _module_id(py, base)
|
|
@@ -306,6 +311,14 @@ def _scan_consumer_module(graph, py, base, label, tree, index, mode, origin=None
|
|
|
306
311
|
if isinstance(n, ast.Attribute) and isinstance(n.value, ast.Attribute)
|
|
307
312
|
}
|
|
308
313
|
func_ranges = _func_ranges(tree) if mode == "full" else []
|
|
314
|
+
if (test_modules is not None and mode == "full" and label == "tests"
|
|
315
|
+
and (py.name.startswith("test_") or py.name.endswith("_test.py"))):
|
|
316
|
+
for _, _, tail in func_ranges:
|
|
317
|
+
owner, _, name = tail.rpartition(".")
|
|
318
|
+
if (name.startswith("test") and (not owner or ("." not in owner and owner.startswith("Test")))
|
|
319
|
+
and graph.nodes[f"{mod_id}.{tail}"].kind == "function"):
|
|
320
|
+
test_modules.append((mod_id, rel, tree, func_ranges))
|
|
321
|
+
break
|
|
309
322
|
# R1-C46: uses in replaced bodies do not belong to the surviving node.
|
|
310
323
|
replaced = _shadow_map(tree)[2]
|
|
311
324
|
# R1-C80 D0: in full mode, a use of the module's own top-level function or class is an
|
|
@@ -208,6 +208,10 @@ RESOLUTIONS: dict[tuple[str, str], dict[str, str]] = {
|
|
|
208
208
|
"means": "route", "confidence": "heuristic",
|
|
209
209
|
"how": "a call on a Protocol method fanned out to every structural implementer — "
|
|
210
210
|
"the receiver is one of them, which one is not known (R1-C81)"},
|
|
211
|
+
("calls", "named-dispatch"): {
|
|
212
|
+
"means": "route", "confidence": "heuristic",
|
|
213
|
+
"how": "literal key matched to a function registered on the same source-bound "
|
|
214
|
+
"registry instance (R1-C107)"},
|
|
211
215
|
("calls", "local"): {"means": "route", "confidence": "exact",
|
|
212
216
|
"how": "a consumer-root call to a def at the level of the same module "
|
|
213
217
|
"(R1-C80); the consumer-root form of `module`"},
|