codmap 0.0.44__tar.gz → 0.0.46__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.44/codmap.egg-info → codmap-0.0.46}/PKG-INFO +2 -2
- {codmap-0.0.44 → codmap-0.0.46}/README.md +1 -1
- {codmap-0.0.44 → codmap-0.0.46}/codemap/advise/__init__.py +15 -1
- {codmap-0.0.44 → codmap-0.0.46}/codemap/advise/refresh.py +29 -4
- {codmap-0.0.44 → codmap-0.0.46}/codemap/arch.py +8 -3
- codmap-0.0.46/codemap/atomic.py +33 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/cli.py +55 -6
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/__init__.py +2 -2
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/hooks.py +7 -2
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/install.py +90 -12
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/ratchet.py +1 -1
- codmap-0.0.46/codemap/devkit/state.py +81 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/templates/github-workflow.yml +4 -4
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/templates/gitlab-ci.yml +2 -2
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/templates/post-commit.sh +7 -7
- {codmap-0.0.44 → codmap-0.0.46}/codemap/extract/behavior.py +8 -2
- {codmap-0.0.44 → codmap-0.0.46}/codemap/freshness.py +2 -2
- {codmap-0.0.44 → codmap-0.0.46}/codemap/model.py +73 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/scope.py +25 -1
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/currency.py +4 -4
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/mcp_server.py +2 -1
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/session.py +29 -2
- {codmap-0.0.44 → codmap-0.0.46}/codemap/store.py +5 -4
- {codmap-0.0.44 → codmap-0.0.46/codmap.egg-info}/PKG-INFO +2 -2
- {codmap-0.0.44 → codmap-0.0.46}/codmap.egg-info/SOURCES.txt +7 -0
- {codmap-0.0.44 → codmap-0.0.46}/pyproject.toml +1 -1
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m32_watch.py +1 -1
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c108_devkit.py +15 -5
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c114_devkit_graph.py +14 -5
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c120_dispatch_absorbed.py +29 -1
- codmap-0.0.46/tests/test_r1c121_devkit_trust.py +168 -0
- codmap-0.0.46/tests/test_r1c122_serve_robust.py +85 -0
- codmap-0.0.46/tests/test_r1c124_atomic_writes.py +86 -0
- codmap-0.0.46/tests/test_r1c125_graph_trust.py +99 -0
- codmap-0.0.46/tests/test_r1c126_scope_roles.py +57 -0
- codmap-0.0.46/tests/test_r1c127_require_current.py +48 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c37_rule_mutation.py +1 -1
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_scope.py +1 -1
- codmap-0.0.44/codemap/devkit/state.py +0 -28
- {codmap-0.0.44 → codmap-0.0.46}/LICENSE +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/__init__.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/__main__.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/advise/data/feed.json +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/advise/data/matrix.toml +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/advise/render.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/apidiff.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/artifacts.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/templates/agents_block.md +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/templates/agents_block.ru.md +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/templates/brief.txt +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/templates/claude_hooks.json +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/templates/codex_region.toml +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/templates/contract_head.toml +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/templates/cycles_region.toml +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/templates/mcp_claude.args +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/templates/ratchet_region.toml +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/devkit/usage.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/diagnostics.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/extract/__init__.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/extract/attrflow.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/extract/dataflow.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/extract/dispatch.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/extract/griffe_extractor.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/extract/gsource.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/extract/probe.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/extract/roots.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/extract/union.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/incremental.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/integrations/__init__.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/integrations/base.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/integrations/cocoindex.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/integrations/gate.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/integrations/gitnexus.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/integrations/registry.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/integrations/transport.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/provenance.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/query.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/__init__.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/_scip_pb2.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/api_surface.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/apidiff.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/architecture.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/audit.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/check.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/ctags.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/impact.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/limits.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/livingdocs.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/mermaid.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/pack.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/rag.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/review.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/scip.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/semantic.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/server.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/subsystems.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/serve/vault.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/tomlio.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codemap/watch.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codmap.egg-info/dependency_links.txt +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codmap.egg-info/entry_points.txt +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codmap.egg-info/requires.txt +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/codmap.egg-info/top_level.txt +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/setup.cfg +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_epistemic.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_gitnexus_router.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_impact_depth.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_integrations.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_issue3_serve_freshness.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_livingdocs.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m0_api_surface.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m11_argcontract.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m12_dataflow.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m15_review.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m16_architecture.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m17_mcp.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m18_freshness.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m1_5_semantics.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m1_query.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m2_views.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m3_serve.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m4_behavior.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m5_deep.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m6_repo_scope.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m7_dispatch.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_m9_family.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_pack_honesty.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c109_namespace_source.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c110_advise.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c111_recipe.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c115_agents_block.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c116_known_cycles.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c118_dead_code.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c119_first_build.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c13_callgraph_accuracy.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c13_grep_vs_graph.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c16_semantic.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c20_attribute_edges.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c21_flat_layout.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c22_source_visible_refs.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c23_hard_python.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c24_test_mapping.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c25_provenance.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c26_deep_union.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c27_config_honesty.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c28_limit_envelope.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c29_lazy_imports.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c2_ctags.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c30_local_import_calls.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c30f1_reexport_calls.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c30f2_check_scope.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c31_path_origin.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c32_report_json.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c33_query_signature.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c34_signature_kinds.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c35_contract_location.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c36_target_resolution.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c38_tool_drift.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c39_edge_resolution.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c3_arch_contract.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c3_dogfood.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c40_flow_reach.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c41_scope_membership.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c42_deep_tier_stability.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c43_incremental_splice.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c44_absent_answers.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c45_repeat_union.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c46_shadowed_definitions.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c47_incremental_resample.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c48_type_checking_imports.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c49_type_only_cycles.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c4_complexity.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c50_flow_entry_points.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c53_narrowing_declared.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c54_deterministic_rendering.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c55_override_grade.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c56_stub_files.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c57_facade_package.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c58_cycle_tangles.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c59_completeness_drop.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c5_apidiff.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c60_nested_definitions.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c62_phantom_rules.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c63_answer_format.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c64_dependency_probe.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c66_pack_direction.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c68_dotted_imports.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c69_contract_validation.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c6_pack.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c70_check_graph_currency.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c71_attribute_chain_calls.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c72_flat_inference_in_packages.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c73_cli_version.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c74_call_site_conservation.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c75_reexported_class_calls.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c76_contract_table_typo.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c77_gate_probe_battery.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c78_forbidden_chains.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c7_edge_vocab.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c80_tests_through_helpers.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c81_protocol_dispatch.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c82_review_changed_lines.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c83_foreign_graph_paths.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c84_missing_roots.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c85_mcp_graph_currency.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c86_incremental_repo_scope.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c87_review_path_base.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c89_review_docs.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c8_deadcode.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c90_currency_without_recipe.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c91_route_vocabulary.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c92_sidecar_pair.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c94_root_builds.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c95_r1c96_foreign_trees.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_r1c9_incremental.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/tests/test_scip_export.py +0 -0
- {codmap-0.0.44 → codmap-0.0.46}/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.46
|
|
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, **1476 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, **1476 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,20 @@ 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) -> Path:
|
|
108
|
+
"""The generation ``current`` names, or the cache itself for a pair written before generations existed."""
|
|
109
|
+
try:
|
|
110
|
+
name = (cdir / CURRENT).read_text(encoding="utf-8").strip()
|
|
111
|
+
except OSError:
|
|
112
|
+
return cdir
|
|
113
|
+
gen = cdir / name
|
|
114
|
+
return gen if name.startswith("gen-") and "/" not in name and gen.is_dir() else cdir
|
|
115
|
+
|
|
116
|
+
|
|
103
117
|
def cache_dir() -> Path:
|
|
104
118
|
base = os.environ.get("XDG_CACHE_HOME") or str(Path.home() / ".cache")
|
|
105
119
|
return Path(base) / "codemap" / "advise"
|
|
@@ -132,7 +146,7 @@ def load(cache: Path | None = None, packaged: Path | None = None) -> Catalog:
|
|
|
132
146
|
cdir = cache if cache is not None else cache_dir()
|
|
133
147
|
if not cdir.is_dir():
|
|
134
148
|
return cat
|
|
135
|
-
cm, cf, cerrs = _read_pair(cdir)
|
|
149
|
+
cm, cf, cerrs = _read_pair(_served_dir(cdir))
|
|
136
150
|
cat.notes.extend(f"cache ignored: {e}" for e in cerrs)
|
|
137
151
|
m, f, src = pm, pf, {"matrix": "packaged", "feed": "packaged"}
|
|
138
152
|
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,34 @@ 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
|
+
def publish_pair(cdir: Path, mraw: bytes, fraw: bytes) -> None:
|
|
61
|
+
"""Publish matrix + feed as one generation (R1-C124): both files go to a new directory, then the pointer
|
|
62
|
+
file ``current`` is replaced atomically. A failure before that leaves the previous pair served whole; a reader
|
|
63
|
+
never sees one file of one generation beside the other file of another."""
|
|
64
|
+
import shutil
|
|
65
|
+
import tempfile
|
|
66
|
+
|
|
67
|
+
from codemap import atomic
|
|
68
|
+
cdir.mkdir(parents=True, exist_ok=True)
|
|
69
|
+
gen = Path(tempfile.mkdtemp(prefix="gen-", dir=cdir))
|
|
70
|
+
try:
|
|
71
|
+
atomic.write_bytes(gen / "matrix.toml", mraw)
|
|
72
|
+
atomic.write_bytes(gen / "feed.json", fraw)
|
|
73
|
+
atomic.write_text(cdir / CURRENT, gen.name + "\n")
|
|
74
|
+
except BaseException:
|
|
75
|
+
shutil.rmtree(gen, ignore_errors=True)
|
|
76
|
+
raise
|
|
77
|
+
for old in cdir.glob("gen-*"): # previous generations, and any torn leftovers
|
|
78
|
+
if old.is_dir() and old.name != gen.name:
|
|
79
|
+
shutil.rmtree(old, ignore_errors=True)
|
|
80
|
+
for legacy in ("matrix.toml", "feed.json"): # a pre-0.0.46 pair at the top level
|
|
81
|
+
try:
|
|
82
|
+
(cdir / legacy).unlink()
|
|
83
|
+
except FileNotFoundError:
|
|
84
|
+
pass
|
|
@@ -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,6 +897,10 @@ 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
905
|
if cwd and os.path.isdir(cwd):
|
|
902
906
|
os.chdir(cwd) # recorded argv may use paths relative to the build cwd
|
|
@@ -904,6 +908,24 @@ def _cmd_refresh(args) -> int:
|
|
|
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): `refresh` repeats it as a command, and
|
|
913
|
+
the sidecar is a file anyone can edit. Only `build`, writing back to this same graph, is repeated."""
|
|
914
|
+
argv = meta.get("argv")
|
|
915
|
+
if not isinstance(argv, list) or not argv or not all(isinstance(a, str) for a in argv):
|
|
916
|
+
return "it is not a list of arguments"
|
|
917
|
+
if argv[0] != "build":
|
|
918
|
+
return f"it runs `{argv[0]}`, not `build`"
|
|
919
|
+
out = next((argv[i + 1] for i, a in enumerate(argv[:-1]) if a in ("-o", "--out")), None)
|
|
920
|
+
out = out or next((a.split("=", 1)[1] for a in argv if a.startswith("--out=")), None)
|
|
921
|
+
if out is None:
|
|
922
|
+
return "it writes no graph file"
|
|
923
|
+
cwd = meta.get("cwd") if isinstance(meta.get("cwd"), str) else os.getcwd()
|
|
924
|
+
if (Path(cwd) / out).resolve() != Path(graph).resolve():
|
|
925
|
+
return f"it writes {out!r}, not this graph"
|
|
926
|
+
return None
|
|
927
|
+
|
|
928
|
+
|
|
907
929
|
def _cmd_route(args) -> int:
|
|
908
930
|
"""Route a capability question to an opt-in external tool (DESIGN §13.1).
|
|
909
931
|
|
|
@@ -1030,7 +1052,14 @@ def _cmd_check(args) -> int:
|
|
|
1030
1052
|
raise SystemExit("error: no [architecture] contract found (--require-contract)")
|
|
1031
1053
|
violations = check_contract(q, contract)
|
|
1032
1054
|
_emit_answer(render_check(q, contract, violations, **kw))
|
|
1033
|
-
|
|
1055
|
+
rc = _check_exit(violations, currency, allow_stale)
|
|
1056
|
+
# R1-C127: `unknown` passes by design (R1-C70: "I cannot tell" is not "behind"); a strict gate can refuse it.
|
|
1057
|
+
if getattr(args, "require_current", False) and currency is not None and currency.get("status") != "current":
|
|
1058
|
+
why = currency.get("reason") or f"{currency.get('status')}"
|
|
1059
|
+
print(f"error: the graph is not known to match its source tree ({why}) — --require-current accepts "
|
|
1060
|
+
"only a graph checked current, or one built in this run (--build)", file=sys.stderr)
|
|
1061
|
+
return 2
|
|
1062
|
+
return rc
|
|
1034
1063
|
|
|
1035
1064
|
|
|
1036
1065
|
def _cmd_advise(args) -> int:
|
|
@@ -1081,7 +1110,19 @@ def _cmd_advise(args) -> int:
|
|
|
1081
1110
|
|
|
1082
1111
|
|
|
1083
1112
|
def _cmd_devkit(args) -> int:
|
|
1084
|
-
"""R1-C108: `codemap devkit …` — design ``docs/design/devkit.md``.
|
|
1113
|
+
"""R1-C108: `codemap devkit …` — design ``docs/design/devkit.md``.
|
|
1114
|
+
|
|
1115
|
+
R1-C121: a refused state or path argument is exit 2 with the reason, before anything is written or run.
|
|
1116
|
+
"""
|
|
1117
|
+
from codemap.devkit.state import StateError
|
|
1118
|
+
try:
|
|
1119
|
+
return _devkit_dispatch(args)
|
|
1120
|
+
except StateError as exc:
|
|
1121
|
+
print(f"error: {exc}", file=sys.stderr)
|
|
1122
|
+
return 2
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
def _devkit_dispatch(args) -> int:
|
|
1085
1126
|
from pathlib import Path as _P
|
|
1086
1127
|
root = _P(args.root)
|
|
1087
1128
|
cmd = args.devkit_cmd
|
|
@@ -1273,7 +1314,11 @@ def _emit(text: str, out: str | None) -> None:
|
|
|
1273
1314
|
|
|
1274
1315
|
|
|
1275
1316
|
def _write_vault(files: dict[str, str], out_dir: str) -> None:
|
|
1276
|
-
|
|
1317
|
+
"""R1-C125: note names come from node ids; none may land outside the vault directory."""
|
|
1318
|
+
base = Path(out_dir).resolve()
|
|
1319
|
+
for rel in files:
|
|
1320
|
+
if not (base / rel).resolve().is_relative_to(base):
|
|
1321
|
+
raise SystemExit(f"error: vault note {rel!r} would be written outside {base}; nothing written")
|
|
1277
1322
|
for rel, content in files.items():
|
|
1278
1323
|
path = base / rel
|
|
1279
1324
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -1558,9 +1603,13 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
1558
1603
|
help="Dir with codemap.toml holding [architecture] (default: cwd).")
|
|
1559
1604
|
ck.add_argument("--require-contract", action="store_true",
|
|
1560
1605
|
help="Fail if no [architecture] contract is present (default: no-op success).")
|
|
1561
|
-
ck.
|
|
1562
|
-
|
|
1563
|
-
|
|
1606
|
+
ck_stale = ck.add_mutually_exclusive_group()
|
|
1607
|
+
ck_stale.add_argument("--allow-stale", action="store_true",
|
|
1608
|
+
help="With --graph: do not fail when the graph is behind its source tree "
|
|
1609
|
+
"(R1-C70); the 'behind' line is still printed.")
|
|
1610
|
+
ck_stale.add_argument("--require-current", action="store_true",
|
|
1611
|
+
help="With --graph: fail unless the graph is checked current — an unknown currency "
|
|
1612
|
+
"(no provenance, roots not found) fails too (R1-C127).")
|
|
1564
1613
|
ck.set_defaults(func=_cmd_check)
|
|
1565
1614
|
|
|
1566
1615
|
# 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:
|
|
@@ -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,57 @@ 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
|
if argv0 is not None and argv0.name == "codemap" and argv0.exists():
|
|
53
58
|
# abspath, not resolve: `..` is folded, a venv's symlinked bin is kept as the user named it
|
|
54
59
|
return [os.path.abspath(argv0)]
|
|
55
|
-
return [sys.executable, "-m", "codemap"]
|
|
60
|
+
return [sys.executable, "-I", "-m", "codemap"]
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
_PYTHON = re.compile(r"python(\d+(\.\d+)*)?(\.exe)?")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _tracked(root: Path, path: Path) -> bool:
|
|
67
|
+
"""Is ``path`` a file the repository carries (so whoever pushed chose its content)?"""
|
|
68
|
+
try:
|
|
69
|
+
rel = path.resolve().relative_to(root.resolve())
|
|
70
|
+
except ValueError:
|
|
71
|
+
return False
|
|
72
|
+
r = subprocess.run(["git", "-C", str(root), "ls-files", "--error-unmatch", "--", str(rel)],
|
|
73
|
+
capture_output=True)
|
|
74
|
+
return r.returncode == 0
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def pin_problem(root: Path, pin: list[str] | None) -> str | None:
|
|
78
|
+
"""Why ``pin`` is not a codemap the devkit may run or write into the hook, or None (R1-C121).
|
|
79
|
+
|
|
80
|
+
`.mcp.json` is a project file: the command in it is whatever the last push said. Accepted are only the
|
|
81
|
+
shapes the devkit itself writes — the absolute path of a `codemap` console script, or an absolute python
|
|
82
|
+
run as `-I -m codemap` — and never a file the repository carries.
|
|
83
|
+
"""
|
|
84
|
+
if not pin or not all(isinstance(a, str) and a for a in pin):
|
|
85
|
+
return "no command"
|
|
86
|
+
exe = Path(pin[0])
|
|
87
|
+
if not exe.is_absolute():
|
|
88
|
+
return f"{pin[0]!r} is not an absolute path"
|
|
89
|
+
if len(pin) == 1:
|
|
90
|
+
if exe.name not in ("codemap", "codemap.exe"):
|
|
91
|
+
return f"{exe.name!r} is not a codemap console script"
|
|
92
|
+
elif pin[1:] == ["-I", "-m", "codemap"]:
|
|
93
|
+
if not _PYTHON.fullmatch(exe.name):
|
|
94
|
+
return f"{exe.name!r} is not a python interpreter"
|
|
95
|
+
else:
|
|
96
|
+
return f"{shlex.join(pin)!r} is not `<codemap>` or `<python> -I -m codemap`"
|
|
97
|
+
if not exe.is_file():
|
|
98
|
+
return f"{pin[0]} does not exist"
|
|
99
|
+
if _tracked(root, exe):
|
|
100
|
+
return f"{pin[0]} is a file of this repository, not an installed codemap"
|
|
101
|
+
return None
|
|
56
102
|
|
|
57
103
|
|
|
58
104
|
def pin_from_mcp(entry: dict | None) -> list[str] | None:
|
|
@@ -74,9 +120,12 @@ def pin_version(pin: list[str]) -> str | None:
|
|
|
74
120
|
|
|
75
121
|
|
|
76
122
|
def pin_has_mcp(pin: list[str]) -> bool | None:
|
|
77
|
-
"""Can the pinned interpreter import `mcp`? (`serve --mcp` needs the `codmap[mcp]` extra.)
|
|
123
|
+
"""Can the pinned interpreter import `mcp`? (`serve --mcp` needs the `codmap[mcp]` extra.)
|
|
124
|
+
|
|
125
|
+
Callers pass only a pin :func:`pin_problem` accepted (R1-C121): this runs an interpreter.
|
|
126
|
+
"""
|
|
78
127
|
py = None
|
|
79
|
-
if len(pin) >= 3 and pin[
|
|
128
|
+
if len(pin) >= 3 and pin[-2] == "-m":
|
|
80
129
|
py = pin[0]
|
|
81
130
|
else:
|
|
82
131
|
try:
|
|
@@ -88,7 +137,7 @@ def pin_has_mcp(pin: list[str]) -> bool | None:
|
|
|
88
137
|
if not py:
|
|
89
138
|
return None
|
|
90
139
|
try:
|
|
91
|
-
r = subprocess.run([py, "-c", "import mcp"], capture_output=True, timeout=30)
|
|
140
|
+
r = subprocess.run([py, "-I", "-c", "import mcp"], capture_output=True, timeout=30)
|
|
92
141
|
except (OSError, subprocess.SubprocessError):
|
|
93
142
|
return None
|
|
94
143
|
return r.returncode == 0
|
|
@@ -108,6 +157,11 @@ def context(st: dict, pin: list[str], codemap_version: str, root: Path | None =
|
|
|
108
157
|
"package_name": Path(pkg).name,
|
|
109
158
|
"graph": st.get("graph", GRAPH),
|
|
110
159
|
"graph_next": GRAPH_NEXT,
|
|
160
|
+
# R1-C121: what goes into shell (the hook) and into a YAML `run:` line is quoted as one argument —
|
|
161
|
+
# the state is checked against a plain alphabet too, this is the second wall, not the only one.
|
|
162
|
+
"package_sh": shlex.quote(pkg),
|
|
163
|
+
"graph_sh": shlex.quote(st.get("graph", GRAPH)),
|
|
164
|
+
"graph_next_sh": shlex.quote(GRAPH_NEXT),
|
|
111
165
|
"build_args": build_args(st),
|
|
112
166
|
"agents_file": st.get("agents_file", "AGENTS.md"),
|
|
113
167
|
"pin_shell": shlex.join(pin),
|
|
@@ -387,6 +441,9 @@ def init(root: Path, *, package: str, consumers: list[str], docs: list[str], age
|
|
|
387
441
|
claude_hooks: bool, codex: bool, ci: str | None, hook: bool, build: bool, ratchet: bool,
|
|
388
442
|
dry_run: bool, force: bool, agents_lang: str | None = None) -> int:
|
|
389
443
|
root = root.resolve()
|
|
444
|
+
_refuse_paths(root, [("--package", package), *(("--consumer", c) for c in consumers),
|
|
445
|
+
*(("--docs", d) for d in docs),
|
|
446
|
+
*((("--agents-file", agents_file),) if agents_file else ())])
|
|
390
447
|
st = load_state(root)
|
|
391
448
|
if st is not None:
|
|
392
449
|
print(f"The devkit is already installed here (v{st.get('devkit_version')}); running `update` with the "
|
|
@@ -479,13 +536,15 @@ def _mcp_notes(root: Path, st: dict, pin: list[str], outcomes, notes: list[str])
|
|
|
479
536
|
def update(root: Path, *, force: bool, repin: bool, dry_run: bool, _state: dict | None = None,
|
|
480
537
|
agents_file: str | None = None, agents_lang: str | None = None) -> int:
|
|
481
538
|
root = root.resolve()
|
|
539
|
+
if agents_file:
|
|
540
|
+
_refuse_paths(root, [("--agents-file", agents_file)])
|
|
482
541
|
st = _state if _state is not None else load_state(root)
|
|
483
542
|
if st is None:
|
|
484
543
|
print(f"error: no devkit here ({STATE} not found) — run `codemap devkit init --package <path>`",
|
|
485
544
|
file=sys.stderr)
|
|
486
545
|
return 2
|
|
487
|
-
pin, version = _pin_and_version(root, st, repin)
|
|
488
546
|
notes: list[str] = []
|
|
547
|
+
pin, version = _pin_and_version(root, st, repin, notes)
|
|
489
548
|
if agents_lang:
|
|
490
549
|
if agents_lang == "en":
|
|
491
550
|
st.pop("agents_lang", None)
|
|
@@ -528,23 +587,40 @@ def _move_agents_block(root: Path, st: dict, new_file: str, *, write: bool, note
|
|
|
528
587
|
st.get("artifacts", {}).pop("agents", None)
|
|
529
588
|
|
|
530
589
|
|
|
531
|
-
def
|
|
532
|
-
"""
|
|
590
|
+
def _refuse_paths(root: Path, given: list[tuple[str, str]]) -> None:
|
|
591
|
+
"""R1-C121: a path given on the command line meets the same rule as one read from the state."""
|
|
592
|
+
problems = [path_problem(root, v.rstrip("/"), flag) for flag, v in given]
|
|
593
|
+
problems = [p for p in problems if p]
|
|
594
|
+
if problems:
|
|
595
|
+
raise StateError("; ".join(problems))
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
def _pin_and_version(root: Path, st: dict, repin: bool,
|
|
599
|
+
notes: list[str] | None = None) -> tuple[list[str], str]:
|
|
600
|
+
"""Keep the project's pin unless asked to move it (D2): from `.mcp.json`, else this codemap.
|
|
601
|
+
|
|
602
|
+
R1-C121: a pin is kept only when :func:`pin_problem` accepts it — `.mcp.json` is a project file, and the
|
|
603
|
+
kept pin is run here (`--version`) and written into the post-commit hook. A refused one is named in
|
|
604
|
+
``notes`` and replaced by this codemap.
|
|
605
|
+
"""
|
|
533
606
|
if not repin:
|
|
534
607
|
entry = JsonKey("mcp", root / ".mcp.json").entry()
|
|
535
608
|
recorded = (st.get("artifacts", {}).get("mcp") or {}).get("sha256")
|
|
536
609
|
pin = pin_from_mcp(entry) if entry is not None and recorded is not None else None
|
|
537
|
-
if pin
|
|
610
|
+
problem = pin_problem(root, pin) if pin else None
|
|
611
|
+
if pin and problem is None:
|
|
538
612
|
ci = root / ".github" / "workflows" / "codemap.yml"
|
|
539
613
|
gl = root / ".gitlab" / "codemap-ci.yml"
|
|
540
614
|
ver = None
|
|
541
615
|
for f in (ci, gl):
|
|
542
616
|
if f.is_file():
|
|
543
|
-
import re
|
|
544
617
|
m = re.search(r"codmap==([\w.\-+]+)", f.read_text(encoding="utf-8"))
|
|
545
618
|
if m:
|
|
546
619
|
ver = m.group(1)
|
|
547
620
|
return pin, ver or pin_version(pin) or _version()
|
|
621
|
+
if pin and notes is not None:
|
|
622
|
+
notes.append(f"the codemap command in .mcp.json was not run and is not kept — {problem}. The devkit "
|
|
623
|
+
f"runs only an installed codemap; it uses this one ({shlex.join(running_pin())})")
|
|
548
624
|
return running_pin(), _version()
|
|
549
625
|
|
|
550
626
|
|
|
@@ -558,8 +634,10 @@ def status(root: Path, fmt: str = "text") -> int:
|
|
|
558
634
|
else:
|
|
559
635
|
print(f"No devkit here ({STATE} not found) — `codemap devkit init --package <path>` installs it.")
|
|
560
636
|
return 1
|
|
561
|
-
|
|
637
|
+
pin_notes: list[str] = []
|
|
638
|
+
pin, version = _pin_and_version(root, st, repin=False, notes=pin_notes)
|
|
562
639
|
its, notes = items(root, st, pin, version)
|
|
640
|
+
notes = pin_notes + notes
|
|
563
641
|
outcomes = [process(root, st, it, write=False, force=False) for it in its]
|
|
564
642
|
installed = st.get("devkit_version")
|
|
565
643
|
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)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""`.codemap-devkit.json` — which devkit version the repository is on, and what the devkit last wrote.
|
|
2
|
+
|
|
3
|
+
Committed with the repository, so every machine sees the same version and the same hashes. It holds no
|
|
4
|
+
machine-specific path: the pin lives in `.mcp.json` and the git hook, which are local by default (D2).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import re
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
STATE = ".codemap-devkit.json"
|
|
14
|
+
|
|
15
|
+
#: A path the devkit stores and later renders into shell, YAML and Markdown (R1-C121): relative, inside the
|
|
16
|
+
#: repository, from a plain alphabet. Anything else in the committed state is refused, not escaped later.
|
|
17
|
+
SAFE_PATH = re.compile(r"[A-Za-z0-9._@+-][A-Za-z0-9._/@+-]*")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class StateError(Exception):
|
|
21
|
+
"""`.codemap-devkit.json` (or a path given on the command line) is not one the devkit will act on."""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def path_problem(root: Path, value, field: str) -> str | None:
|
|
25
|
+
"""Why ``value`` may not name a file of this repository, or None (R1-C121).
|
|
26
|
+
|
|
27
|
+
The state file is committed, so it is input from whoever last pushed: a `../` or an absolute path, a
|
|
28
|
+
symbolic link that leaves the root, or a shell metacharacter would make the devkit write outside the
|
|
29
|
+
repository or run what a template renders.
|
|
30
|
+
"""
|
|
31
|
+
if not isinstance(value, str) or not value:
|
|
32
|
+
return f"`{field}` must be a non-empty string"
|
|
33
|
+
if not SAFE_PATH.fullmatch(value):
|
|
34
|
+
return (f"`{field}` = {value!r}: only letters, digits and `._/@+-` are allowed in a path the devkit "
|
|
35
|
+
"stores (it is rendered into shell and YAML)")
|
|
36
|
+
if value.startswith("/") or ".." in Path(value).parts:
|
|
37
|
+
return f"`{field}` = {value!r} leaves the repository (absolute, or `..`)"
|
|
38
|
+
base = Path(root).resolve()
|
|
39
|
+
if not (base / value).resolve().is_relative_to(base):
|
|
40
|
+
return f"`{field}` = {value!r} resolves outside the repository (a symbolic link?)"
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def state_problems(root: Path, st: dict) -> list[str]:
|
|
45
|
+
out = []
|
|
46
|
+
for field in ("package", "graph", "agents_file"):
|
|
47
|
+
if field in st:
|
|
48
|
+
out.append(path_problem(root, st[field], field))
|
|
49
|
+
for field in ("consumers", "docs"):
|
|
50
|
+
vals = st.get(field, [])
|
|
51
|
+
if not isinstance(vals, list):
|
|
52
|
+
out.append(f"`{field}` must be a list")
|
|
53
|
+
continue
|
|
54
|
+
out += [path_problem(root, v, f"{field}[{i}]") for i, v in enumerate(vals)]
|
|
55
|
+
if "agents_lang" in st and st["agents_lang"] not in ("en", "ru"):
|
|
56
|
+
out.append(f"`agents_lang` = {st['agents_lang']!r}: en or ru")
|
|
57
|
+
return [p for p in out if p]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def load_state(root: Path) -> dict | None:
|
|
61
|
+
"""The state, or None when there is none. Raises :class:`StateError` when it names a path the devkit must
|
|
62
|
+
not act on (R1-C121): a committed file is no more trusted than any other input."""
|
|
63
|
+
p = Path(root) / STATE
|
|
64
|
+
if not p.is_file():
|
|
65
|
+
return None
|
|
66
|
+
try:
|
|
67
|
+
data = json.loads(p.read_text(encoding="utf-8"))
|
|
68
|
+
except ValueError:
|
|
69
|
+
return None
|
|
70
|
+
if not isinstance(data, dict):
|
|
71
|
+
return None
|
|
72
|
+
problems = state_problems(root, data)
|
|
73
|
+
if problems:
|
|
74
|
+
raise StateError(f"{STATE} refused — " + "; ".join(problems))
|
|
75
|
+
return data
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def save_state(root: Path, state: dict) -> None:
|
|
79
|
+
p = Path(root) / STATE
|
|
80
|
+
from codemap import atomic
|
|
81
|
+
atomic.write_text(p, json.dumps(state, indent=2, sort_keys=True, ensure_ascii=False) + "\n")
|
|
@@ -5,10 +5,10 @@ jobs:
|
|
|
5
5
|
architecture:
|
|
6
6
|
runs-on: ubuntu-latest
|
|
7
7
|
steps:
|
|
8
|
-
- uses: actions/checkout@v4
|
|
9
|
-
- uses: actions/setup-python@v5
|
|
8
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
9
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
10
10
|
with:
|
|
11
11
|
python-version: "3.12"
|
|
12
12
|
- run: pip install "codmap=={{codemap_version}}"
|
|
13
|
-
- run: codemap build {{
|
|
14
|
-
- run: codemap check --graph {{
|
|
13
|
+
- run: codemap build {{package_sh}} -o {{graph_sh}}
|
|
14
|
+
- run: codemap check --graph {{graph_sh}} --root . --require-contract
|
|
@@ -5,5 +5,5 @@ codemap-architecture:
|
|
|
5
5
|
image: python:3.12-slim
|
|
6
6
|
script:
|
|
7
7
|
- pip install "codmap=={{codemap_version}}"
|
|
8
|
-
- codemap build {{
|
|
9
|
-
- codemap check --graph {{
|
|
8
|
+
- codemap build {{package_sh}} -o {{graph_sh}}
|
|
9
|
+
- codemap check --graph {{graph_sh}} --root . --require-contract
|
|
@@ -17,20 +17,20 @@ LOG="$ROOT/.codemap/rebuild.log"
|
|
|
17
17
|
while :; do
|
|
18
18
|
rm -f "$ROOT/.codemap/rebuild.again"
|
|
19
19
|
cd "$ROOT" && start=$(date +%s)
|
|
20
|
-
if [ -z "${CODEMAP_FULL:-}" ] && [ -s {{
|
|
20
|
+
if [ -z "${CODEMAP_FULL:-}" ] && [ -s {{graph_sh}} ] && [ -n "$(find .codemap/last_full -mmin -1440 2>/dev/null)" ]; then
|
|
21
21
|
kind=incremental
|
|
22
|
-
cp {{
|
|
23
|
-
cp {{
|
|
24
|
-
nice -n 19 $C build {{
|
|
22
|
+
cp {{graph_sh}} {{graph_next_sh}}
|
|
23
|
+
cp {{graph_sh}}.meta.json {{graph_next_sh}}.meta.json
|
|
24
|
+
nice -n 19 $C build {{package_sh}} --deep --repeat 2 {{build_args}} --incremental -o {{graph_next_sh}} >/dev/null 2>"$LOG.err" &
|
|
25
25
|
else
|
|
26
26
|
kind=full
|
|
27
|
-
nice -n 19 $C build {{
|
|
27
|
+
nice -n 19 $C build {{package_sh}} --deep --repeat 2 {{build_args}} -o {{graph_next_sh}} >/dev/null 2>"$LOG.err" &
|
|
28
28
|
fi
|
|
29
29
|
bpid=$!
|
|
30
30
|
wait "$bpid"; brc=$?
|
|
31
31
|
if [ "$brc" -eq 0 ]; then
|
|
32
|
-
mv {{
|
|
33
|
-
mv {{
|
|
32
|
+
mv {{graph_next_sh}}.meta.json {{graph_sh}}.meta.json
|
|
33
|
+
mv {{graph_next_sh}} {{graph_sh}}
|
|
34
34
|
[ "$kind" = full ] && touch .codemap/last_full
|
|
35
35
|
$C devkit index --root "$ROOT" >/dev/null 2>>"$LOG.err"
|
|
36
36
|
echo "$(date -Is) $(git log --oneline -1 | cut -c1-60) $kind ok $(( $(date +%s)-start ))s" >> "$LOG"
|