codmap 0.0.45__tar.gz → 0.0.47__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.45/codmap.egg-info → codmap-0.0.47}/PKG-INFO +2 -2
- {codmap-0.0.45 → codmap-0.0.47}/README.md +1 -1
- {codmap-0.0.45 → codmap-0.0.47}/codemap/advise/__init__.py +24 -1
- {codmap-0.0.45 → codmap-0.0.47}/codemap/advise/refresh.py +57 -4
- {codmap-0.0.45 → codmap-0.0.47}/codemap/arch.py +8 -3
- codmap-0.0.47/codemap/atomic.py +33 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/cli.py +71 -8
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/__init__.py +2 -2
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/hooks.py +10 -4
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/install.py +153 -16
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/ratchet.py +1 -1
- codmap-0.0.47/codemap/devkit/state.py +81 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/templates/github-workflow.yml +4 -4
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/templates/gitlab-ci.yml +2 -2
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/templates/post-commit.sh +7 -7
- {codmap-0.0.45 → codmap-0.0.47}/codemap/freshness.py +2 -2
- {codmap-0.0.45 → codmap-0.0.47}/codemap/model.py +73 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/scope.py +25 -1
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/currency.py +4 -4
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/mcp_server.py +2 -1
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/session.py +29 -2
- {codmap-0.0.45 → codmap-0.0.47}/codemap/store.py +5 -4
- {codmap-0.0.45 → codmap-0.0.47/codmap.egg-info}/PKG-INFO +2 -2
- {codmap-0.0.45 → codmap-0.0.47}/codmap.egg-info/SOURCES.txt +10 -0
- {codmap-0.0.45 → codmap-0.0.47}/pyproject.toml +1 -1
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m32_watch.py +1 -1
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c108_devkit.py +15 -5
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c114_devkit_graph.py +14 -5
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c119_first_build.py +10 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c120_dispatch_absorbed.py +22 -0
- codmap-0.0.47/tests/test_r1c121_devkit_trust.py +168 -0
- codmap-0.0.47/tests/test_r1c122_serve_robust.py +85 -0
- codmap-0.0.47/tests/test_r1c124_atomic_writes.py +86 -0
- codmap-0.0.47/tests/test_r1c125_graph_trust.py +99 -0
- codmap-0.0.47/tests/test_r1c126_scope_roles.py +57 -0
- codmap-0.0.47/tests/test_r1c127_require_current.py +48 -0
- codmap-0.0.47/tests/test_r1c133_pin_links.py +138 -0
- codmap-0.0.47/tests/test_r1c134_refresh_recipe.py +77 -0
- codmap-0.0.47/tests/test_r1c135_advise_generations.py +110 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c37_rule_mutation.py +1 -1
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_scope.py +1 -1
- codmap-0.0.45/codemap/devkit/state.py +0 -28
- {codmap-0.0.45 → codmap-0.0.47}/LICENSE +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/__init__.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/__main__.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/advise/data/feed.json +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/advise/data/matrix.toml +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/advise/render.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/apidiff.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/artifacts.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/templates/agents_block.md +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/templates/agents_block.ru.md +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/templates/brief.txt +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/templates/claude_hooks.json +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/templates/codex_region.toml +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/templates/contract_head.toml +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/templates/cycles_region.toml +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/templates/mcp_claude.args +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/templates/ratchet_region.toml +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/devkit/usage.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/diagnostics.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/extract/__init__.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/extract/attrflow.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/extract/behavior.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/extract/dataflow.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/extract/dispatch.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/extract/griffe_extractor.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/extract/gsource.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/extract/probe.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/extract/roots.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/extract/union.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/incremental.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/integrations/__init__.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/integrations/base.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/integrations/cocoindex.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/integrations/gate.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/integrations/gitnexus.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/integrations/registry.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/integrations/transport.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/provenance.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/query.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/__init__.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/_scip_pb2.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/api_surface.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/apidiff.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/architecture.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/audit.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/check.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/ctags.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/impact.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/limits.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/livingdocs.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/mermaid.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/pack.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/rag.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/review.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/scip.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/semantic.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/server.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/subsystems.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/serve/vault.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/tomlio.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codemap/watch.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codmap.egg-info/dependency_links.txt +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codmap.egg-info/entry_points.txt +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codmap.egg-info/requires.txt +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/codmap.egg-info/top_level.txt +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/setup.cfg +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_epistemic.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_gitnexus_router.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_impact_depth.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_integrations.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_issue3_serve_freshness.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_livingdocs.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m0_api_surface.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m11_argcontract.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m12_dataflow.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m15_review.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m16_architecture.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m17_mcp.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m18_freshness.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m1_5_semantics.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m1_query.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m2_views.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m3_serve.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m4_behavior.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m5_deep.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m6_repo_scope.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m7_dispatch.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_m9_family.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_pack_honesty.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c109_namespace_source.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c110_advise.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c111_recipe.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c115_agents_block.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c116_known_cycles.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c118_dead_code.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c13_callgraph_accuracy.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c13_grep_vs_graph.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c16_semantic.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c20_attribute_edges.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c21_flat_layout.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c22_source_visible_refs.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c23_hard_python.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c24_test_mapping.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c25_provenance.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c26_deep_union.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c27_config_honesty.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c28_limit_envelope.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c29_lazy_imports.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c2_ctags.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c30_local_import_calls.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c30f1_reexport_calls.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c30f2_check_scope.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c31_path_origin.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c32_report_json.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c33_query_signature.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c34_signature_kinds.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c35_contract_location.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c36_target_resolution.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c38_tool_drift.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c39_edge_resolution.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c3_arch_contract.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c3_dogfood.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c40_flow_reach.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c41_scope_membership.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c42_deep_tier_stability.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c43_incremental_splice.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c44_absent_answers.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c45_repeat_union.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c46_shadowed_definitions.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c47_incremental_resample.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c48_type_checking_imports.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c49_type_only_cycles.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c4_complexity.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c50_flow_entry_points.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c53_narrowing_declared.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c54_deterministic_rendering.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c55_override_grade.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c56_stub_files.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c57_facade_package.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c58_cycle_tangles.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c59_completeness_drop.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c5_apidiff.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c60_nested_definitions.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c62_phantom_rules.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c63_answer_format.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c64_dependency_probe.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c66_pack_direction.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c68_dotted_imports.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c69_contract_validation.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c6_pack.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c70_check_graph_currency.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c71_attribute_chain_calls.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c72_flat_inference_in_packages.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c73_cli_version.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c74_call_site_conservation.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c75_reexported_class_calls.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c76_contract_table_typo.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c77_gate_probe_battery.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c78_forbidden_chains.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c7_edge_vocab.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c80_tests_through_helpers.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c81_protocol_dispatch.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c82_review_changed_lines.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c83_foreign_graph_paths.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c84_missing_roots.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c85_mcp_graph_currency.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c86_incremental_repo_scope.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c87_review_path_base.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c89_review_docs.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c8_deadcode.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c90_currency_without_recipe.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c91_route_vocabulary.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c92_sidecar_pair.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c94_root_builds.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c95_r1c96_foreign_trees.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_r1c9_incremental.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/tests/test_scip_export.py +0 -0
- {codmap-0.0.45 → codmap-0.0.47}/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.47
|
|
4
4
|
Summary: Static analyzer that turns a package's source into a queryable code graph.
|
|
5
5
|
Author-email: kogriv <kogriv@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -54,7 +54,7 @@ without a release.
|
|
|
54
54
|
|
|
55
55
|
[](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
|
|
56
56
|
|
|
57
|
-
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **
|
|
57
|
+
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1499 tests with no failures on
|
|
58
58
|
Python 3.11–3.14** ([in CI](docs/ci.md): the full suite including the dogfood pass, a determinism check, a
|
|
59
59
|
wheel smoke test, and ctags/SCIP interop against the real CLIs), warm serve surface with 32 ops (29 exposed
|
|
60
60
|
as MCP tools), and SCIP export. See **[DESIGN.md](DESIGN.md)** (product design &
|
|
@@ -18,7 +18,7 @@ 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, **
|
|
21
|
+
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1499 tests with no failures on
|
|
22
22
|
Python 3.11–3.14** ([in CI](docs/ci.md): the full suite including the dogfood pass, a determinism check, a
|
|
23
23
|
wheel smoke test, and ctags/SCIP interop against the real CLIs), warm serve surface with 32 ops (29 exposed
|
|
24
24
|
as MCP tools), and SCIP export. See **[DESIGN.md](DESIGN.md)** (product design &
|
|
@@ -100,6 +100,23 @@ class Catalog:
|
|
|
100
100
|
"age_days": (today - a).days if a else None, "notes": list(self.notes)}
|
|
101
101
|
|
|
102
102
|
|
|
103
|
+
#: R1-C124: the file in the cache that names the served generation directory (``gen-…``).
|
|
104
|
+
CURRENT = "current"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _served_dir(cdir: Path) -> tuple[Path, str | None]:
|
|
108
|
+
"""The generation ``current`` names, or the cache itself for a pair written before generations existed; and a
|
|
109
|
+
note when ``current`` names a generation that is not there (R1-C135: said, not silently replaced)."""
|
|
110
|
+
try:
|
|
111
|
+
name = (cdir / CURRENT).read_text(encoding="utf-8").strip()
|
|
112
|
+
except OSError:
|
|
113
|
+
return cdir, None
|
|
114
|
+
gen = cdir / name
|
|
115
|
+
if name.startswith("gen-") and "/" not in name and gen.is_dir():
|
|
116
|
+
return gen, None
|
|
117
|
+
return cdir, f"cache pointer `{CURRENT}` names {name!r}, which is not there; run `codemap advise --refresh`"
|
|
118
|
+
|
|
119
|
+
|
|
103
120
|
def cache_dir() -> Path:
|
|
104
121
|
base = os.environ.get("XDG_CACHE_HOME") or str(Path.home() / ".cache")
|
|
105
122
|
return Path(base) / "codemap" / "advise"
|
|
@@ -132,7 +149,13 @@ def load(cache: Path | None = None, packaged: Path | None = None) -> Catalog:
|
|
|
132
149
|
cdir = cache if cache is not None else cache_dir()
|
|
133
150
|
if not cdir.is_dir():
|
|
134
151
|
return cat
|
|
135
|
-
|
|
152
|
+
for _ in range(3): # R1-C135: one file there and the other gone = a publish in between
|
|
153
|
+
served, note = _served_dir(cdir)
|
|
154
|
+
cm, cf, cerrs = _read_pair(served)
|
|
155
|
+
if (cm is None) == (cf is None):
|
|
156
|
+
break
|
|
157
|
+
if note:
|
|
158
|
+
cat.notes.append(note)
|
|
136
159
|
cat.notes.extend(f"cache ignored: {e}" for e in cerrs)
|
|
137
160
|
m, f, src = pm, pf, {"matrix": "packaged", "feed": "packaged"}
|
|
138
161
|
if cm is not None and cm.get("meta", {}).get("as_of", "") > pm.get("meta", {}).get("as_of", ""):
|
|
@@ -13,7 +13,7 @@ import urllib.error
|
|
|
13
13
|
import urllib.request
|
|
14
14
|
from pathlib import Path
|
|
15
15
|
|
|
16
|
-
from codemap.advise import DEFAULT_BASE, cache_dir, load, schema_problems
|
|
16
|
+
from codemap.advise import CURRENT, DEFAULT_BASE, cache_dir, load, schema_problems
|
|
17
17
|
|
|
18
18
|
TIMEOUT = 10
|
|
19
19
|
|
|
@@ -51,9 +51,62 @@ def refresh(base: str | None = None, cache: Path | None = None) -> dict:
|
|
|
51
51
|
out["reason"] = (f"downloaded catalog is not newer (matrix {m['meta']['as_of']}, feed {f['as_of']}; "
|
|
52
52
|
f"served {before.meta.get('as_of')}, {before.feed.get('as_of')})")
|
|
53
53
|
return out
|
|
54
|
-
cdir
|
|
55
|
-
(cdir / "matrix.toml").write_bytes(mraw)
|
|
56
|
-
(cdir / "feed.json").write_bytes(fraw)
|
|
54
|
+
publish_pair(cdir, mraw, fraw)
|
|
57
55
|
after = load(cache=cdir)
|
|
58
56
|
out.update(updated=True, after=after.header())
|
|
59
57
|
return out
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
#: R1-C135: a generation is removed only once it is this old and `current` does not name it — a reader that took
|
|
61
|
+
#: its path a moment ago, or a second publisher that has just pointed `current` at it, still finds it whole.
|
|
62
|
+
GRACE_SECONDS = 600
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def publish_pair(cdir: Path, mraw: bytes, fraw: bytes) -> None:
|
|
66
|
+
"""Publish matrix + feed as one generation (R1-C124): both files go to a new directory, then the pointer
|
|
67
|
+
file ``current`` is replaced atomically. A failure before that leaves the previous pair served whole; a reader
|
|
68
|
+
never sees one file of one generation beside the other file of another.
|
|
69
|
+
|
|
70
|
+
Old generations are collected by :func:`collect`, not all at once (R1-C135): two publishers each removing
|
|
71
|
+
every generation but its own left `current` naming a removed one."""
|
|
72
|
+
import shutil
|
|
73
|
+
import tempfile
|
|
74
|
+
|
|
75
|
+
from codemap import atomic
|
|
76
|
+
cdir.mkdir(parents=True, exist_ok=True)
|
|
77
|
+
gen = Path(tempfile.mkdtemp(prefix="gen-", dir=cdir))
|
|
78
|
+
try:
|
|
79
|
+
atomic.write_bytes(gen / "matrix.toml", mraw)
|
|
80
|
+
atomic.write_bytes(gen / "feed.json", fraw)
|
|
81
|
+
atomic.write_text(cdir / CURRENT, gen.name + "\n")
|
|
82
|
+
except BaseException:
|
|
83
|
+
shutil.rmtree(gen, ignore_errors=True)
|
|
84
|
+
raise
|
|
85
|
+
collect(cdir)
|
|
86
|
+
for legacy in ("matrix.toml", "feed.json"): # a pre-0.0.46 pair at the top level (load retries a split read)
|
|
87
|
+
try:
|
|
88
|
+
(cdir / legacy).unlink()
|
|
89
|
+
except FileNotFoundError:
|
|
90
|
+
pass
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def collect(cdir: Path, now: float | None = None) -> list[str]:
|
|
94
|
+
"""Remove generations `current` does not name *now* and that are older than :data:`GRACE_SECONDS`; the names."""
|
|
95
|
+
import shutil
|
|
96
|
+
import time
|
|
97
|
+
|
|
98
|
+
now = time.time() if now is None else now
|
|
99
|
+
try:
|
|
100
|
+
served = (cdir / CURRENT).read_text(encoding="utf-8").strip()
|
|
101
|
+
except OSError:
|
|
102
|
+
served = None
|
|
103
|
+
gone = []
|
|
104
|
+
for old in sorted(cdir.glob("gen-*")):
|
|
105
|
+
try:
|
|
106
|
+
young = now - old.stat().st_mtime < GRACE_SECONDS
|
|
107
|
+
except OSError:
|
|
108
|
+
continue
|
|
109
|
+
if old.is_dir() and old.name != served and not young:
|
|
110
|
+
shutil.rmtree(old, ignore_errors=True)
|
|
111
|
+
gone.append(old.name)
|
|
112
|
+
return gone
|
|
@@ -441,9 +441,14 @@ def known_stale(query, contract: ArchitectureContract) -> dict[str, list[frozens
|
|
|
441
441
|
|
|
442
442
|
|
|
443
443
|
def _absorbing(group: frozenset[str], now: list[set[str]]) -> set[str] | None:
|
|
444
|
-
"""A current tangle that holds
|
|
445
|
-
|
|
446
|
-
|
|
444
|
+
"""A current tangle that holds **all** of ``group`` and more (R1-C120, criterion R1-C123): the known cycle is
|
|
445
|
+
alive inside a larger new one — not gone.
|
|
446
|
+
|
|
447
|
+
A tangle that shares only part of the group is not that: `{a,b,c}` known and `{a,b,d}` now means `c` left the
|
|
448
|
+
cycle, and keeping `{a,b,c}` listed would let a future `a↔c` pass unseen. Such a group is stale; the ratchet
|
|
449
|
+
that tightens it also adds the new `{a,b,d}`, so `{a,b}` stays covered (external audit F-08).
|
|
450
|
+
"""
|
|
451
|
+
return next((m for m in now if group < m), None)
|
|
447
452
|
|
|
448
453
|
|
|
449
454
|
def known_absorbed(query, contract: ArchitectureContract) -> dict[str, list[tuple[frozenset[str], list[str]]]]:
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Atomic file publication (R1-C124): a reader sees the old file or the new one, never a torn one.
|
|
2
|
+
|
|
3
|
+
Written to a temporary file in the target's directory (same filesystem, so the rename is atomic), flushed and
|
|
4
|
+
fsync'd, then ``os.replace``d over the target. A failure at any point before the rename leaves the target as it
|
|
5
|
+
was and removes the temporary file.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import tempfile
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def write_bytes(path: str | Path, data: bytes) -> None:
|
|
16
|
+
path = Path(path)
|
|
17
|
+
fd, tmp = tempfile.mkstemp(prefix=f".{path.name}.", suffix=".tmp", dir=path.parent)
|
|
18
|
+
try:
|
|
19
|
+
with os.fdopen(fd, "wb") as fh:
|
|
20
|
+
fh.write(data)
|
|
21
|
+
fh.flush()
|
|
22
|
+
os.fsync(fh.fileno())
|
|
23
|
+
os.replace(tmp, path)
|
|
24
|
+
except BaseException:
|
|
25
|
+
try:
|
|
26
|
+
os.unlink(tmp)
|
|
27
|
+
except FileNotFoundError:
|
|
28
|
+
pass
|
|
29
|
+
raise
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def write_text(path: str | Path, text: str) -> None:
|
|
33
|
+
write_bytes(path, text.encode("utf-8"))
|
|
@@ -897,13 +897,49 @@ def _cmd_refresh(args) -> int:
|
|
|
897
897
|
raise SystemExit(
|
|
898
898
|
f"error: {what} at {args.graph} — `refresh` repeats a recorded build; make the first one with "
|
|
899
899
|
f"`codemap build <package> -o {args.graph}`")
|
|
900
|
+
problem = _recipe_problem(meta, args.graph)
|
|
901
|
+
if problem:
|
|
902
|
+
raise SystemExit(f"error: the recorded recipe beside {args.graph} is not repeated — {problem}; "
|
|
903
|
+
f"rebuild by hand with `codemap build <package> -o {args.graph}`")
|
|
900
904
|
cwd = meta.get("cwd")
|
|
901
|
-
if cwd
|
|
902
|
-
os.chdir(cwd) # recorded argv may use paths relative to the build cwd
|
|
905
|
+
if cwd:
|
|
906
|
+
os.chdir(cwd) # recorded argv may use paths relative to the build cwd; _recipe_problem checked from it
|
|
903
907
|
print(f"rebuilding {args.graph} …", file=sys.stderr)
|
|
904
908
|
return main(meta["argv"])
|
|
905
909
|
|
|
906
910
|
|
|
911
|
+
def _recipe_problem(meta: dict, graph: str) -> str | None:
|
|
912
|
+
"""Why a sidecar's ``argv`` is not a rebuild of ``graph`` (R1-C125, R1-C134): `refresh` repeats it as a command,
|
|
913
|
+
and the sidecar is a file anyone can edit. Only `build`, writing back to this same graph, is repeated.
|
|
914
|
+
|
|
915
|
+
The recipe is read by the very parser that will run it — a repeated `-o`, an abbreviated `--ou`, an attached
|
|
916
|
+
`-oX` mean to the check what they mean to `build` — and from the working directory it will run in.
|
|
917
|
+
"""
|
|
918
|
+
import contextlib
|
|
919
|
+
import io
|
|
920
|
+
argv = meta.get("argv")
|
|
921
|
+
if not isinstance(argv, list) or not argv or not all(isinstance(a, str) for a in argv):
|
|
922
|
+
return "it is not a list of arguments"
|
|
923
|
+
if argv[0] != "build":
|
|
924
|
+
return f"it runs `{argv[0]}`, not `build`"
|
|
925
|
+
try:
|
|
926
|
+
with contextlib.redirect_stderr(io.StringIO()) as err:
|
|
927
|
+
args = build_parser().parse_args(argv)
|
|
928
|
+
except SystemExit:
|
|
929
|
+
last = err.getvalue().strip().splitlines()
|
|
930
|
+
return f"`build` does not take it ({last[-1] if last else 'unparsable'})"
|
|
931
|
+
if args.command != "build":
|
|
932
|
+
return f"it runs `{args.command}`, not `build`"
|
|
933
|
+
if not args.out:
|
|
934
|
+
return "it writes no graph file"
|
|
935
|
+
cwd = meta.get("cwd")
|
|
936
|
+
if cwd is not None and not (isinstance(cwd, str) and os.path.isdir(cwd)):
|
|
937
|
+
return f"its working directory {cwd!r} is not a directory here"
|
|
938
|
+
if (Path(cwd or os.getcwd()) / args.out).resolve() != Path(graph).resolve():
|
|
939
|
+
return f"it writes {args.out!r}, not this graph"
|
|
940
|
+
return None
|
|
941
|
+
|
|
942
|
+
|
|
907
943
|
def _cmd_route(args) -> int:
|
|
908
944
|
"""Route a capability question to an opt-in external tool (DESIGN §13.1).
|
|
909
945
|
|
|
@@ -1030,7 +1066,14 @@ def _cmd_check(args) -> int:
|
|
|
1030
1066
|
raise SystemExit("error: no [architecture] contract found (--require-contract)")
|
|
1031
1067
|
violations = check_contract(q, contract)
|
|
1032
1068
|
_emit_answer(render_check(q, contract, violations, **kw))
|
|
1033
|
-
|
|
1069
|
+
rc = _check_exit(violations, currency, allow_stale)
|
|
1070
|
+
# R1-C127: `unknown` passes by design (R1-C70: "I cannot tell" is not "behind"); a strict gate can refuse it.
|
|
1071
|
+
if getattr(args, "require_current", False) and currency is not None and currency.get("status") != "current":
|
|
1072
|
+
why = currency.get("reason") or f"{currency.get('status')}"
|
|
1073
|
+
print(f"error: the graph is not known to match its source tree ({why}) — --require-current accepts "
|
|
1074
|
+
"only a graph checked current, or one built in this run (--build)", file=sys.stderr)
|
|
1075
|
+
return 2
|
|
1076
|
+
return rc
|
|
1034
1077
|
|
|
1035
1078
|
|
|
1036
1079
|
def _cmd_advise(args) -> int:
|
|
@@ -1081,7 +1124,19 @@ def _cmd_advise(args) -> int:
|
|
|
1081
1124
|
|
|
1082
1125
|
|
|
1083
1126
|
def _cmd_devkit(args) -> int:
|
|
1084
|
-
"""R1-C108: `codemap devkit …` — design ``docs/design/devkit.md``.
|
|
1127
|
+
"""R1-C108: `codemap devkit …` — design ``docs/design/devkit.md``.
|
|
1128
|
+
|
|
1129
|
+
R1-C121: a refused state or path argument is exit 2 with the reason, before anything is written or run.
|
|
1130
|
+
"""
|
|
1131
|
+
from codemap.devkit.state import StateError
|
|
1132
|
+
try:
|
|
1133
|
+
return _devkit_dispatch(args)
|
|
1134
|
+
except StateError as exc:
|
|
1135
|
+
print(f"error: {exc}", file=sys.stderr)
|
|
1136
|
+
return 2
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
def _devkit_dispatch(args) -> int:
|
|
1085
1140
|
from pathlib import Path as _P
|
|
1086
1141
|
root = _P(args.root)
|
|
1087
1142
|
cmd = args.devkit_cmd
|
|
@@ -1273,7 +1328,11 @@ def _emit(text: str, out: str | None) -> None:
|
|
|
1273
1328
|
|
|
1274
1329
|
|
|
1275
1330
|
def _write_vault(files: dict[str, str], out_dir: str) -> None:
|
|
1276
|
-
|
|
1331
|
+
"""R1-C125: note names come from node ids; none may land outside the vault directory."""
|
|
1332
|
+
base = Path(out_dir).resolve()
|
|
1333
|
+
for rel in files:
|
|
1334
|
+
if not (base / rel).resolve().is_relative_to(base):
|
|
1335
|
+
raise SystemExit(f"error: vault note {rel!r} would be written outside {base}; nothing written")
|
|
1277
1336
|
for rel, content in files.items():
|
|
1278
1337
|
path = base / rel
|
|
1279
1338
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -1558,9 +1617,13 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
1558
1617
|
help="Dir with codemap.toml holding [architecture] (default: cwd).")
|
|
1559
1618
|
ck.add_argument("--require-contract", action="store_true",
|
|
1560
1619
|
help="Fail if no [architecture] contract is present (default: no-op success).")
|
|
1561
|
-
ck.
|
|
1562
|
-
|
|
1563
|
-
|
|
1620
|
+
ck_stale = ck.add_mutually_exclusive_group()
|
|
1621
|
+
ck_stale.add_argument("--allow-stale", action="store_true",
|
|
1622
|
+
help="With --graph: do not fail when the graph is behind its source tree "
|
|
1623
|
+
"(R1-C70); the 'behind' line is still printed.")
|
|
1624
|
+
ck_stale.add_argument("--require-current", action="store_true",
|
|
1625
|
+
help="With --graph: fail unless the graph is checked current — an unknown currency "
|
|
1626
|
+
"(no provenance, roots not found) fails too (R1-C127).")
|
|
1564
1627
|
ck.set_defaults(func=_cmd_check)
|
|
1565
1628
|
|
|
1566
1629
|
# R1-C108: the devkit — adopt codemap in a repository and keep the adoption current.
|
|
@@ -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 = 7
|
|
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 = "cb015ad787c32b2806f7ec68fecdb7ab86447dd5bb647eeb9ce48764af624a63"
|
|
24
24
|
|
|
25
25
|
TEMPLATES_DIR = Path(__file__).parent / "templates"
|
|
26
26
|
|
|
@@ -23,8 +23,13 @@ INDEX = ".codemap/devkit/index.json"
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def _state(root: Path) -> dict:
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
"""The state, or the defaults when there is none — or when it was refused (R1-C121): a hook must not
|
|
27
|
+
follow a committed path out of the repository, and must not break the session either."""
|
|
28
|
+
from codemap.devkit.state import StateError, load_state
|
|
29
|
+
try:
|
|
30
|
+
return load_state(root) or {}
|
|
31
|
+
except StateError:
|
|
32
|
+
return {}
|
|
28
33
|
|
|
29
34
|
|
|
30
35
|
def _graph_path(root: Path, st: dict) -> Path:
|
|
@@ -51,8 +56,9 @@ def currency_line(root: Path, st: dict) -> str:
|
|
|
51
56
|
# R1-C119: a fresh clone has no graph and `refresh` has no recipe to repeat — give the first build.
|
|
52
57
|
from codemap.devkit import build_args
|
|
53
58
|
cmd = " ".join(x for x in ("codemap build", st.get("package", "<package>"), build_args(st), "-o", rel) if x)
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
keeps = ("after that the post-commit hook keeps it" if (st.get("options") or {}).get("hook", True)
|
|
60
|
+
else f"there is no post-commit hook here, so refresh it after changes: `codemap refresh {rel}`")
|
|
61
|
+
return f"absent ({rel} does not exist; build it once: `{cmd}` — {keeps})"
|
|
56
62
|
meta = read_meta(str(gp)) or {}
|
|
57
63
|
built = meta.get("built_at")
|
|
58
64
|
when = f", built {_ago(built)}" if isinstance(built, (int, float)) else ""
|
|
@@ -13,6 +13,7 @@ from __future__ import annotations
|
|
|
13
13
|
|
|
14
14
|
import difflib
|
|
15
15
|
import json
|
|
16
|
+
import re
|
|
16
17
|
import os
|
|
17
18
|
import shlex
|
|
18
19
|
import subprocess
|
|
@@ -23,7 +24,7 @@ from pathlib import Path
|
|
|
23
24
|
from codemap.devkit import DEVKIT_VERSION, build_args, render, sha, template
|
|
24
25
|
from codemap.devkit.artifacts import (CI_MARK, HOOK_MARK, Artifact, ClaudeHooks, JsonKey,
|
|
25
26
|
MarkdownRegion, TomlRegion, WholeFile, canon_json)
|
|
26
|
-
from codemap.devkit.state import STATE, load_state, save_state
|
|
27
|
+
from codemap.devkit.state import STATE, StateError, load_state, path_problem, save_state
|
|
27
28
|
|
|
28
29
|
GRAPH = ".codemap/graph.json"
|
|
29
30
|
GRAPH_NEXT = ".codemap/graph.next.json"
|
|
@@ -47,12 +48,113 @@ def _version() -> str:
|
|
|
47
48
|
# --------------------------------------------------------------------------- the pin
|
|
48
49
|
|
|
49
50
|
def running_pin() -> list[str]:
|
|
50
|
-
"""How to run *this* codemap: its console script, else ``python -m codemap``.
|
|
51
|
+
"""How to run *this* codemap: its console script, else ``python -I -m codemap``.
|
|
52
|
+
|
|
53
|
+
``-I`` (R1-C121): plain ``-m`` puts the working directory first on ``sys.path``, and the hook runs in the
|
|
54
|
+
repository — a `codemap/` package committed there would be what runs.
|
|
55
|
+
"""
|
|
51
56
|
argv0 = Path(sys.argv[0]) if sys.argv and sys.argv[0] else None
|
|
52
|
-
|
|
57
|
+
# R1-C133: a pin this codemap writes must pass the check `status` applies to it (a wrapper is not a script)
|
|
58
|
+
if argv0 is not None and argv0.name == "codemap" and argv0.is_file() and _console_script_problem(argv0) is None:
|
|
53
59
|
# abspath, not resolve: `..` is folded, a venv's symlinked bin is kept as the user named it
|
|
54
60
|
return [os.path.abspath(argv0)]
|
|
55
|
-
return [sys.executable, "-m", "codemap"]
|
|
61
|
+
return [sys.executable, "-I", "-m", "codemap"]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
_PYTHON = re.compile(r"python(\d+(\.\d+)*)?(\.exe)?")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _inside(root: Path, path: str) -> Path | None:
|
|
68
|
+
"""``path`` relative to ``root`` as written (``..`` folded, links not followed), or None when outside."""
|
|
69
|
+
p = Path(os.path.abspath(path))
|
|
70
|
+
for base in {Path(os.path.abspath(root)), root.resolve()}:
|
|
71
|
+
try:
|
|
72
|
+
return p.relative_to(base)
|
|
73
|
+
except ValueError:
|
|
74
|
+
continue
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _carried(root: Path, path: str) -> str | None:
|
|
79
|
+
"""Why ``path`` is a file the repository carries — so whoever pushed chose what runs — or None.
|
|
80
|
+
|
|
81
|
+
R1-C133: asked of the path as written *and* of each directory on it, before any link is followed: a tracked
|
|
82
|
+
link ``tools/codemap → /bin/sh`` resolves outside the root, and asking git about the resolved path said
|
|
83
|
+
"not ours". The resolved path is asked too (a link from outside into the repository).
|
|
84
|
+
"""
|
|
85
|
+
rels = []
|
|
86
|
+
lexical = _inside(root, path)
|
|
87
|
+
if lexical is not None:
|
|
88
|
+
parts = lexical.parts
|
|
89
|
+
rels += [Path(*parts[:i]).as_posix() for i in range(1, len(parts) + 1)]
|
|
90
|
+
try:
|
|
91
|
+
rels.append(Path(path).resolve().relative_to(root.resolve()).as_posix())
|
|
92
|
+
except ValueError:
|
|
93
|
+
pass
|
|
94
|
+
if not rels:
|
|
95
|
+
return None
|
|
96
|
+
r = subprocess.run(["git", "--literal-pathspecs", "-C", str(root), "ls-files", "-s", "-z", "--", *rels],
|
|
97
|
+
capture_output=True)
|
|
98
|
+
if r.returncode != 0:
|
|
99
|
+
return "it is inside a directory that is not a git repository, so who wrote it cannot be told"
|
|
100
|
+
listed = {entry.split(b"\t", 1)[1].decode("utf-8", "replace") for entry in r.stdout.split(b"\0") if b"\t" in entry}
|
|
101
|
+
hit = next((rel for rel in rels if rel in listed), None)
|
|
102
|
+
if hit is None:
|
|
103
|
+
return None
|
|
104
|
+
if lexical is not None and hit == lexical.as_posix():
|
|
105
|
+
return "it is a file of this repository"
|
|
106
|
+
return f"`{hit}` on its way is carried by this repository"
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
#: R1-C133: what an installed console script for codemap holds (pip, pipx, uv write `from codemap.cli import main`)
|
|
110
|
+
_CONSOLE_MARK = b"codemap.cli"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _console_script_problem(exe: Path) -> str | None:
|
|
114
|
+
"""Is ``exe`` (followed to its target) a console script that starts codemap? Asked of the content, not the name."""
|
|
115
|
+
try:
|
|
116
|
+
with open(exe, "rb") as fh:
|
|
117
|
+
head = fh.read(4096 if exe.suffix.lower() != ".exe" else 8 << 20)
|
|
118
|
+
except OSError as exc:
|
|
119
|
+
return f"it cannot be read ({exc.strerror})"
|
|
120
|
+
if exe.suffix.lower() == ".exe":
|
|
121
|
+
ok = _CONSOLE_MARK in head # the launcher carries its script as a stored zip
|
|
122
|
+
else:
|
|
123
|
+
ok = head.startswith(b"#!") and _CONSOLE_MARK in head
|
|
124
|
+
return None if ok else "it is not a console script that starts codemap"
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def pin_problem(root: Path, pin: list[str] | None) -> str | None:
|
|
128
|
+
"""Why ``pin`` is not a codemap the devkit may run or write into the hook, or None (R1-C121, R1-C133).
|
|
129
|
+
|
|
130
|
+
`.mcp.json` is a project file: the command in it is whatever the last push said. Accepted are only the
|
|
131
|
+
shapes the devkit itself writes — the absolute path of a `codemap` console script, or an absolute python
|
|
132
|
+
run as `-I -m codemap` — never a file the repository carries, nor one reached through a directory or link
|
|
133
|
+
it carries; and a console script is accepted by what it holds, not by its name.
|
|
134
|
+
"""
|
|
135
|
+
if not pin or not all(isinstance(a, str) and a for a in pin):
|
|
136
|
+
return "no command"
|
|
137
|
+
exe = Path(pin[0])
|
|
138
|
+
if not exe.is_absolute():
|
|
139
|
+
return f"{pin[0]!r} is not an absolute path"
|
|
140
|
+
if len(pin) == 1:
|
|
141
|
+
if exe.name not in ("codemap", "codemap.exe"):
|
|
142
|
+
return f"{exe.name!r} is not a codemap console script"
|
|
143
|
+
elif pin[1:] == ["-I", "-m", "codemap"]:
|
|
144
|
+
if not _PYTHON.fullmatch(exe.name):
|
|
145
|
+
return f"{exe.name!r} is not a python interpreter"
|
|
146
|
+
else:
|
|
147
|
+
return f"{shlex.join(pin)!r} is not `<codemap>` or `<python> -I -m codemap`"
|
|
148
|
+
if not exe.is_file():
|
|
149
|
+
return f"{pin[0]} does not exist"
|
|
150
|
+
carried = _carried(root, pin[0])
|
|
151
|
+
if carried:
|
|
152
|
+
return f"{pin[0]}: {carried}, not an installed codemap"
|
|
153
|
+
if len(pin) == 1:
|
|
154
|
+
script = _console_script_problem(exe)
|
|
155
|
+
if script:
|
|
156
|
+
return f"{pin[0]}: {script}"
|
|
157
|
+
return None
|
|
56
158
|
|
|
57
159
|
|
|
58
160
|
def pin_from_mcp(entry: dict | None) -> list[str] | None:
|
|
@@ -74,9 +176,12 @@ def pin_version(pin: list[str]) -> str | None:
|
|
|
74
176
|
|
|
75
177
|
|
|
76
178
|
def pin_has_mcp(pin: list[str]) -> bool | None:
|
|
77
|
-
"""Can the pinned interpreter import `mcp`? (`serve --mcp` needs the `codmap[mcp]` extra.)
|
|
179
|
+
"""Can the pinned interpreter import `mcp`? (`serve --mcp` needs the `codmap[mcp]` extra.)
|
|
180
|
+
|
|
181
|
+
Callers pass only a pin :func:`pin_problem` accepted (R1-C121): this runs an interpreter.
|
|
182
|
+
"""
|
|
78
183
|
py = None
|
|
79
|
-
if len(pin) >= 3 and pin[
|
|
184
|
+
if len(pin) >= 3 and pin[-2] == "-m":
|
|
80
185
|
py = pin[0]
|
|
81
186
|
else:
|
|
82
187
|
try:
|
|
@@ -88,7 +193,7 @@ def pin_has_mcp(pin: list[str]) -> bool | None:
|
|
|
88
193
|
if not py:
|
|
89
194
|
return None
|
|
90
195
|
try:
|
|
91
|
-
r = subprocess.run([py, "-c", "import mcp"], capture_output=True, timeout=30)
|
|
196
|
+
r = subprocess.run([py, "-I", "-c", "import mcp"], capture_output=True, timeout=30)
|
|
92
197
|
except (OSError, subprocess.SubprocessError):
|
|
93
198
|
return None
|
|
94
199
|
return r.returncode == 0
|
|
@@ -108,6 +213,11 @@ def context(st: dict, pin: list[str], codemap_version: str, root: Path | None =
|
|
|
108
213
|
"package_name": Path(pkg).name,
|
|
109
214
|
"graph": st.get("graph", GRAPH),
|
|
110
215
|
"graph_next": GRAPH_NEXT,
|
|
216
|
+
# R1-C121: what goes into shell (the hook) and into a YAML `run:` line is quoted as one argument —
|
|
217
|
+
# the state is checked against a plain alphabet too, this is the second wall, not the only one.
|
|
218
|
+
"package_sh": shlex.quote(pkg),
|
|
219
|
+
"graph_sh": shlex.quote(st.get("graph", GRAPH)),
|
|
220
|
+
"graph_next_sh": shlex.quote(GRAPH_NEXT),
|
|
111
221
|
"build_args": build_args(st),
|
|
112
222
|
"agents_file": st.get("agents_file", "AGENTS.md"),
|
|
113
223
|
"pin_shell": shlex.join(pin),
|
|
@@ -387,6 +497,9 @@ def init(root: Path, *, package: str, consumers: list[str], docs: list[str], age
|
|
|
387
497
|
claude_hooks: bool, codex: bool, ci: str | None, hook: bool, build: bool, ratchet: bool,
|
|
388
498
|
dry_run: bool, force: bool, agents_lang: str | None = None) -> int:
|
|
389
499
|
root = root.resolve()
|
|
500
|
+
_refuse_paths(root, [("--package", package), *(("--consumer", c) for c in consumers),
|
|
501
|
+
*(("--docs", d) for d in docs),
|
|
502
|
+
*((("--agents-file", agents_file),) if agents_file else ())])
|
|
390
503
|
st = load_state(root)
|
|
391
504
|
if st is not None:
|
|
392
505
|
print(f"The devkit is already installed here (v{st.get('devkit_version')}); running `update` with the "
|
|
@@ -430,10 +543,13 @@ def init(root: Path, *, package: str, consumers: list[str], docs: list[str], age
|
|
|
430
543
|
ok, err = _build_graph(root, st, pin)
|
|
431
544
|
if not ok:
|
|
432
545
|
notes.append(f"graph build FAILED — {err.splitlines()[-1] if err else 'no message'}")
|
|
433
|
-
elif graph.is_file() and unfit != "there is no graph":
|
|
434
|
-
notes.append(f"graph rebuilt ({unfit}; fast tier — the post-commit hook builds --deep)")
|
|
435
546
|
else:
|
|
436
|
-
|
|
547
|
+
# The hook's --deep rebuild is promised only where there is a hook (tgsh-26, 23.11).
|
|
548
|
+
deep = ("the post-commit hook builds --deep" if hook
|
|
549
|
+
else "no hook: `codemap build … --deep` or `codemap refresh` by hand")
|
|
550
|
+
notes.append(f"graph rebuilt ({unfit}; fast tier — {deep})"
|
|
551
|
+
if graph.is_file() and unfit != "there is no graph"
|
|
552
|
+
else f"graph built (fast tier; {deep})")
|
|
437
553
|
_contract(root, st, ratchet=ratchet, dry_run=dry_run, notes=notes)
|
|
438
554
|
if any(o.key == "mcp" and o.status == "created" for o in outcomes):
|
|
439
555
|
notes.append(".mcp.json names the codemap executable by its absolute path on this machine "
|
|
@@ -479,13 +595,15 @@ def _mcp_notes(root: Path, st: dict, pin: list[str], outcomes, notes: list[str])
|
|
|
479
595
|
def update(root: Path, *, force: bool, repin: bool, dry_run: bool, _state: dict | None = None,
|
|
480
596
|
agents_file: str | None = None, agents_lang: str | None = None) -> int:
|
|
481
597
|
root = root.resolve()
|
|
598
|
+
if agents_file:
|
|
599
|
+
_refuse_paths(root, [("--agents-file", agents_file)])
|
|
482
600
|
st = _state if _state is not None else load_state(root)
|
|
483
601
|
if st is None:
|
|
484
602
|
print(f"error: no devkit here ({STATE} not found) — run `codemap devkit init --package <path>`",
|
|
485
603
|
file=sys.stderr)
|
|
486
604
|
return 2
|
|
487
|
-
pin, version = _pin_and_version(root, st, repin)
|
|
488
605
|
notes: list[str] = []
|
|
606
|
+
pin, version = _pin_and_version(root, st, repin, notes)
|
|
489
607
|
if agents_lang:
|
|
490
608
|
if agents_lang == "en":
|
|
491
609
|
st.pop("agents_lang", None)
|
|
@@ -528,23 +646,40 @@ def _move_agents_block(root: Path, st: dict, new_file: str, *, write: bool, note
|
|
|
528
646
|
st.get("artifacts", {}).pop("agents", None)
|
|
529
647
|
|
|
530
648
|
|
|
531
|
-
def
|
|
532
|
-
"""
|
|
649
|
+
def _refuse_paths(root: Path, given: list[tuple[str, str]]) -> None:
|
|
650
|
+
"""R1-C121: a path given on the command line meets the same rule as one read from the state."""
|
|
651
|
+
problems = [path_problem(root, v.rstrip("/"), flag) for flag, v in given]
|
|
652
|
+
problems = [p for p in problems if p]
|
|
653
|
+
if problems:
|
|
654
|
+
raise StateError("; ".join(problems))
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
def _pin_and_version(root: Path, st: dict, repin: bool,
|
|
658
|
+
notes: list[str] | None = None) -> tuple[list[str], str]:
|
|
659
|
+
"""Keep the project's pin unless asked to move it (D2): from `.mcp.json`, else this codemap.
|
|
660
|
+
|
|
661
|
+
R1-C121: a pin is kept only when :func:`pin_problem` accepts it — `.mcp.json` is a project file, and the
|
|
662
|
+
kept pin is run here (`--version`) and written into the post-commit hook. A refused one is named in
|
|
663
|
+
``notes`` and replaced by this codemap.
|
|
664
|
+
"""
|
|
533
665
|
if not repin:
|
|
534
666
|
entry = JsonKey("mcp", root / ".mcp.json").entry()
|
|
535
667
|
recorded = (st.get("artifacts", {}).get("mcp") or {}).get("sha256")
|
|
536
668
|
pin = pin_from_mcp(entry) if entry is not None and recorded is not None else None
|
|
537
|
-
if pin
|
|
669
|
+
problem = pin_problem(root, pin) if pin else None
|
|
670
|
+
if pin and problem is None:
|
|
538
671
|
ci = root / ".github" / "workflows" / "codemap.yml"
|
|
539
672
|
gl = root / ".gitlab" / "codemap-ci.yml"
|
|
540
673
|
ver = None
|
|
541
674
|
for f in (ci, gl):
|
|
542
675
|
if f.is_file():
|
|
543
|
-
import re
|
|
544
676
|
m = re.search(r"codmap==([\w.\-+]+)", f.read_text(encoding="utf-8"))
|
|
545
677
|
if m:
|
|
546
678
|
ver = m.group(1)
|
|
547
679
|
return pin, ver or pin_version(pin) or _version()
|
|
680
|
+
if pin and notes is not None:
|
|
681
|
+
notes.append(f"the codemap command in .mcp.json was not run and is not kept — {problem}. The devkit "
|
|
682
|
+
f"runs only an installed codemap; it uses this one ({shlex.join(running_pin())})")
|
|
548
683
|
return running_pin(), _version()
|
|
549
684
|
|
|
550
685
|
|
|
@@ -558,8 +693,10 @@ def status(root: Path, fmt: str = "text") -> int:
|
|
|
558
693
|
else:
|
|
559
694
|
print(f"No devkit here ({STATE} not found) — `codemap devkit init --package <path>` installs it.")
|
|
560
695
|
return 1
|
|
561
|
-
|
|
696
|
+
pin_notes: list[str] = []
|
|
697
|
+
pin, version = _pin_and_version(root, st, repin=False, notes=pin_notes)
|
|
562
698
|
its, notes = items(root, st, pin, version)
|
|
699
|
+
notes = pin_notes + notes
|
|
563
700
|
outcomes = [process(root, st, it, write=False, force=False) for it in its]
|
|
564
701
|
installed = st.get("devkit_version")
|
|
565
702
|
behind = installed != DEVKIT_VERSION
|
|
@@ -236,7 +236,7 @@ def edit_cycles_region(root: Path, now: dict[str, list[frozenset[str]]], *, tigh
|
|
|
236
236
|
group = frozenset(re.findall(r'"([^"]+)"', g.group(1)))
|
|
237
237
|
tangles = now.get(key, [])
|
|
238
238
|
if tighten and not any(t <= group for t in tangles) and not any(
|
|
239
|
-
|
|
239
|
+
group < t for t in tangles): # absorbed whole: alive inside a larger one (R1-C123)
|
|
240
240
|
res.removed.setdefault(key, []).append(group)
|
|
241
241
|
continue
|
|
242
242
|
have[key].append(group)
|