graphite-code 1.4.0__tar.gz → 1.4.1__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.
- {graphite_code-1.4.0 → graphite_code-1.4.1}/CHANGELOG.md +90 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/PKG-INFO +2 -2
- {graphite_code-1.4.0 → graphite_code-1.4.1}/README.md +1 -1
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/__init__.py +1 -1
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/agent_hooks.py +44 -3
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/extract/ast.py +153 -10
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/resolve.py +19 -11
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_agent_hooks.py +15 -0
- graphite_code-1.4.1/tests/test_agent_hooks_session_books.py +145 -0
- graphite_code-1.4.1/tests/test_ast_name_a_module_only_imports.py +274 -0
- graphite_code-1.4.1/tests/test_ast_super_over_a_builtin_base.py +277 -0
- graphite_code-1.4.1/tests/test_resolve_python_reexports_of.py +58 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/.gitignore +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/ARCHITECTURE.md +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/CONTRIBUTING.md +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/LICENSE +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/RELEASING.md +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/pyproject.toml +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/__main__.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/_cleanup_worker.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/_win32_ctypes.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/activation.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/agent_settings.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/analyze.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/answer_contract.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/bootstrap.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/buildlock.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/cache.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/channel.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/cli.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/cluster.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/config.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/context.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/daemon.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/daemon_health.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/daemon_launch.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/debt.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/dependency_install.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/detach.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/doctor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/doctor_probes.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/engine_identity.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/export/__init__.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/export/html.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/export/json.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/export/md.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/extract/__init__.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/extract/pyscope.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/freshness.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/git.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/graph.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/graph_io.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/health.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/hook_entry.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/hookinstall.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/hookshim.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/incident_ledger.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/ingest.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/init.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/io.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/launchd_agent.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/listing.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/llm.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/llm_probe.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/mcp.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/mcp_server.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/natural_query.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/overlays.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/ownership.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/probe_process.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/probe_workspace.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/process_contracts.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/programs.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/provider_observer.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/py.typed +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/query.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/query_plan.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/replacement_audit.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/review.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/__init__.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/approval.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/classifier.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/claude_executor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/claude_probe.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/cli_identity.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/codex_executor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/codex_probe.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/context_builder.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/contracts.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/diff_policy.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/edit_apply.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/effort.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/lifecycle.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/lifecycle_operator.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/lifecycle_service.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/lifecycle_storage.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/ollama_executor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/ollama_probe.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/openrouter_executor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/openrouter_probe.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/policy.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/probe_runner.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/process_runner.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/profiles.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/prompt.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/registry.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/route_pool.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/route_pool_execution.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/schema_validation.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/service.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/settings.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/shadow.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/storage.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/telemetry.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/worktree.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/zai_edit.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/zai_executor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/routing/zai_probe.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/savings.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/systemd_unit.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/ts_bridge.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/ts_resolver.mjs +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/typescript_activation.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/usage_ledger.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/validation.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/watch.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/windows_job.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/windows_startup.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/src/graphite/windows_task.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/conftest.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/data/sqloracle/blindspots.py.txt +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/data/sqloracle/round69.py.txt +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/fake_clis/fake_cli.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/fixtures/provider_lifecycle_schema_v1.sql +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/fixtures/routing_schema_v2_ca77600.sql +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/fixtures/routing_schema_v3_94eb333.sql +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/fixtures/routing_schema_v4_lifecycle_migration.sql +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test__win32_ctypes.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_activation.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_activation_backstop.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_agent_hook_activation.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_agent_settings.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_answer_contract.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_arrow_and_constructor_binding.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_ast_make_id_length.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_ast_source_lines.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_atomic_write.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_bootstrap.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_build_detach.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_buildlock.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cache_engine_identity.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cache_entry_pruning.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cache_file_identity.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cache_file_set.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cache_pruning.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_call_graph.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_case_ambiguous_answer.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_channel_attribution.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_channel_cli.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_channel_core.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_channel_kind.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_channel_lock.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_channel_log_integrity.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_channel_mcp.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_channel_register.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_channel_report.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_channel_status.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_class_field_arrow_binding.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cli_below_repository_root.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cli_build_missing_path.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cli_channel.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cli_channel_attribution.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cli_doctor_below_root.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cli_reference.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cli_usage.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cli_version.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cluster.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_compare_dist.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_configuration_reference.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_context.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_context_builder.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cwd_relative_config.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_cycle_search.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_daemon.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_daemon_activation.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_daemon_build_lock.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_daemon_child_lock.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_daemon_engine_staleness.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_daemon_health.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_daemon_health_activation.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_daemon_launch.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_daemon_service_cli.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_debt.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_dependency_install.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_destructured_binding.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_determinism.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_dispatch_evidence.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_doctor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_doctor_agent_hooks.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_doctor_hooks.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_doctor_managed_docs.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_doctor_probes.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_documentation.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_edit_apply.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_engine_identity.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_exit_codes_reference.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_external_calls.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_file_node_id_collision.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_git_security.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_go_rust.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_graph_io.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_graph_provider_isolation.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_hardening.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_health.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_hook_entry.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_hook_template.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_hookinstall.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_hookshim.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_html_security.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_incident_ledger.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_init.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_init_activation_doctrine.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_init_hooks.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_init_validation_exit.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_launchd_agent.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_lifecycle_operator.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_listing.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_listing_surfaces.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_llm.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_llm_probe.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_mcp.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_mcp_server.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_mcp_server_channel_attribution.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_member_call_receiver.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_method_dispatch_scope.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_monorepo.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_mutation_tests.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_natural_query.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_no_path_is_graded.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_node_identity.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_ollama_executor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_overlays.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_path_leak_fixture.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_probe_diagnostics.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_probe_process.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_probe_workspace.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_process_contracts.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_programs.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_provider_claude_probe.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_provider_codex_probe.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_provider_lifecycle.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_provider_lifecycle_service.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_provider_lifecycle_storage.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_provider_observer.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_provider_ollama_probe.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_provider_openrouter_probe.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_provider_probe_runner.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_public_surface.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_published_schemas.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_pyscope.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_pyscopeoracle.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_python_builtin_named_symbols.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_python_import_bindings.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_python_inherits_edge.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_python_local_alias_call.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_python_reexport_follow.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_python_resolver.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_python_scope_identity.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_query_plan.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_reliability.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_replacement_audit.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_repository_root_ownership.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_resolve.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_review.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_route_pool.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_route_pool_execution.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_approval.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_benchmark.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_classifier.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_claude_executor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_cli.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_cli_contracts.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_cli_recovery.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_codex_executor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_context.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_contracts.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_diff_policy.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_executor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_openrouter_executor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_policy.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_process_runner.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_profiles.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_registry.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_schema_validation.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_security.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_service.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_shadow.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_storage.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_telemetry.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_worktree.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_zai_executor.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_routing_zai_probe.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_savings.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_search.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_self_super_dispatch.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_smoke.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_sqloracle.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_synthetic_repo.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_systemd_unit.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_ts_bridge.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_typescript_activation.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_typescript_resolver.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_usage_ledger.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_verify_artifact.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_verify_published_release.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_watch.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_windows_startup.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_windows_task.py +0 -0
- {graphite_code-1.4.0 → graphite_code-1.4.1}/tests/test_zai_edit.py +0 -0
|
@@ -15,6 +15,96 @@ machine-checkable identity; the version is for humans.
|
|
|
15
15
|
|
|
16
16
|
## [Unreleased]
|
|
17
17
|
|
|
18
|
+
## [1.4.1] — 2026-10-25
|
|
19
|
+
|
|
20
|
+
A patch release: three fixes, two to the Python graph (#106, #107) and one
|
|
21
|
+
to the agent hooks' savings line (#108). No field, command or option is
|
|
22
|
+
added, removed or renamed, and `Requires-Dist` and the entry points are
|
|
23
|
+
those of 1.4.0.
|
|
24
|
+
|
|
25
|
+
The graph changes in this release. On this repository, measured against the
|
|
26
|
+
deployed 1.4.0 engine, with the same interpreter, from one tree:
|
|
27
|
+
|
|
28
|
+
- every definition and file node id survives (6,691 and 429), each naming
|
|
29
|
+
the same definition or file, and none is new; 10 placeholder nodes are
|
|
30
|
+
gone, so 9,231 nodes become 9,221;
|
|
31
|
+
- 59 call sites that ended at a placeholder for a name a module only
|
|
32
|
+
imports now end at the function or class that name is (#107);
|
|
33
|
+
- 14 calls edges at 10 sites are gone: each was a `super().__init__` in an
|
|
34
|
+
error class over a builtin exception, bound by name to an unrelated
|
|
35
|
+
constructor (#106). `calls` goes from 16,265 to 16,251 edges, and the
|
|
36
|
+
Python `calls` ratio from 0.978 to 0.983: 12,236 of 12,452 call sites
|
|
37
|
+
are bound, where 12,191 of 12,466 were;
|
|
38
|
+
- `contains` (6,689), `imports` (2,457) and `inherits` (120) are
|
|
39
|
+
unchanged;
|
|
40
|
+
- `analysis` lists 18 cycles where it listed 20: the two it no longer lists
|
|
41
|
+
ran through those edges. Entry points, god nodes, orphans, surprising
|
|
42
|
+
connections and top files are identical; the community count goes from
|
|
43
|
+
174 to 179.
|
|
44
|
+
|
|
45
|
+
Two builds of this tree with either engine are byte-identical (`graph.json`,
|
|
46
|
+
`GRAPH_REPORT.md`, `graph.html`).
|
|
47
|
+
|
|
48
|
+
The entries below quote figures measured when each change was made, on
|
|
49
|
+
earlier commits of this tree, so they differ from the ones above.
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- Python: a name a module only imports is followed to the file that defines
|
|
54
|
+
it (#107). Where `front.py` binds `target` by `from pkg.impl import target`
|
|
55
|
+
and nothing else, `front.target(x)` from another file, the local alias
|
|
56
|
+
`t = front.target; t(x)` (#90) and `from pkg.front import target` each
|
|
57
|
+
ended at a placeholder `pkg_front_py_target` that no file defines, so
|
|
58
|
+
`callers target` left the caller out while `callees` of the caller
|
|
59
|
+
answered `decision_grade` with that placeholder. #87 followed such a name
|
|
60
|
+
through a package's `__init__.py` only, and only for `from pkg import
|
|
61
|
+
name`: `import pkg; pkg.name()` stayed at the package. Each Python module
|
|
62
|
+
now records the names it binds only by one top-level `from X import name`,
|
|
63
|
+
by the rule #87 applies, and the dispatch post-pass follows them across
|
|
64
|
+
files for as many hops as the source states: a call or `inherits` target,
|
|
65
|
+
a stated receiver (`Base().step()`) and the bases a `self.m()` or
|
|
66
|
+
`super().m()` is looked up along all end at the definition. A name the
|
|
67
|
+
module binds any other way too is not followed, and neither is a
|
|
68
|
+
submodule (`from pkg import sub`); a name a function of the module
|
|
69
|
+
rebinds under `global` is no longer followed either, through
|
|
70
|
+
`__init__.py` as elsewhere. A star import is not read: a name it could
|
|
71
|
+
rebind is followed all the same. What a module records is on its own
|
|
72
|
+
cached extraction, so a change to it reaches an unchanged caller with no
|
|
73
|
+
new cache key. On this repository, the #106 engine against this one with
|
|
74
|
+
one interpreter, from one tree: 59 calls edges, at 59 sites, move from
|
|
75
|
+
10 placeholders to the functions and classes they name, and nothing else
|
|
76
|
+
changes. Those placeholder nodes are gone, every definition id is the same,
|
|
77
|
+
and the Python `calls` ratio goes from 0.978 to 0.983.
|
|
78
|
+
- Python: `super().m()` has no edge where the method it finds is a builtin's
|
|
79
|
+
(#106). In `class StepError(AppError)` with `AppError(RuntimeError)`,
|
|
80
|
+
`super().__init__(message)` runs `RuntimeError.__init__`, but the binding by
|
|
81
|
+
class read the builtin base as one it cannot read, found no class of the
|
|
82
|
+
repository with an `__init__`, and left the call to the name: it was a call
|
|
83
|
+
to every `__init__` in reach, up to three, at `decision_grade`. On this
|
|
84
|
+
repository 14 such edges went to constructors of unrelated classes, and two
|
|
85
|
+
entries of `analysis.cycles` ran through them. Where no class the source
|
|
86
|
+
states binds the name, every other base on the way is a builtin class the
|
|
87
|
+
file does not bind, and a builtin (or `object`) has the name, the call now
|
|
88
|
+
has no edge, as a call of a builtin has none. A name no builtin of the chain
|
|
89
|
+
has, a base that cannot be read beside the builtin, a class with no base,
|
|
90
|
+
and `self.m()` are bound as before.
|
|
91
|
+
- Agent hooks: a session's savings line no longer counts what other
|
|
92
|
+
sessions ran before it started or while it was away (#108). The usage
|
|
93
|
+
ledger holds every session's entries, and a session the stop cursor had
|
|
94
|
+
not seen started reading it at byte 0, so its first Stop reported all
|
|
95
|
+
earlier sessions' use as saved "this turn" and its session total carried
|
|
96
|
+
that history from then on, and
|
|
97
|
+
a resumed session counted everything other sessions had run since its
|
|
98
|
+
last turn. SessionStart now opens a new session's books where the ledger
|
|
99
|
+
ends, and on a resume moves a known session's books there, keeping its
|
|
100
|
+
totals; a compact falls inside a turn and leaves them where they are. A
|
|
101
|
+
Stop for a session with no books (its start was not seen, or it was
|
|
102
|
+
pruned from the cursor) starts at the ledger's end too: that turn's own
|
|
103
|
+
use is not counted, and no other session's is; neither is the use of a
|
|
104
|
+
turn whose Stop never fired before a resume. Two sessions open in one
|
|
105
|
+
repository at once still each count what the other ran between two of
|
|
106
|
+
their turns: a ledger entry does not say which session made it.
|
|
107
|
+
|
|
18
108
|
## [1.4.0] — 2026-10-25
|
|
19
109
|
|
|
20
110
|
A minor release: eight fixes, to the Python graph, the build, the CLI and the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: graphite-code
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: Local-first, zero-LLM knowledge graph extraction for codebases.
|
|
5
5
|
Project-URL: Homepage, https://github.com/jared0565/graphite
|
|
6
6
|
Project-URL: Repository, https://github.com/jared0565/graphite
|
|
@@ -48,7 +48,7 @@ Description-Content-Type: text/markdown
|
|
|
48
48
|
|
|
49
49
|
Local-first, deterministic knowledge graph extraction for codebases — zero-LLM, daemon-maintained, agent-agnostic.
|
|
50
50
|
|
|
51
|
-
**Status: 1.4.
|
|
51
|
+
**Status: 1.4.1, production/stable.** Published on PyPI as
|
|
52
52
|
[`graphite-code`](https://pypi.org/project/graphite-code/) with PEP 740
|
|
53
53
|
attestations; supported on Windows, Linux and macOS with Python 3.11–3.14
|
|
54
54
|
(every cell gates CI). What 1.x promises — CLI, JSON outputs, `graph.json`,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Local-first, deterministic knowledge graph extraction for codebases — zero-LLM, daemon-maintained, agent-agnostic.
|
|
4
4
|
|
|
5
|
-
**Status: 1.4.
|
|
5
|
+
**Status: 1.4.1, production/stable.** Published on PyPI as
|
|
6
6
|
[`graphite-code`](https://pypi.org/project/graphite-code/) with PEP 740
|
|
7
7
|
attestations; supported on Windows, Linux and macOS with Python 3.11–3.14
|
|
8
8
|
(every cell gates CI). What 1.x promises — CLI, JSON outputs, `graph.json`,
|
|
@@ -38,4 +38,4 @@ __all__ = ["__version__"]
|
|
|
38
38
|
#: Coarse and hand-maintained by construction. It is a release label, not
|
|
39
39
|
#: evidence that a given fix is present -- to answer that, survey for the marker
|
|
40
40
|
#: the fix introduced, or compare `graphite --version` fingerprints.
|
|
41
|
-
__version__ = "1.4.
|
|
41
|
+
__version__ = "1.4.1"
|
|
@@ -136,6 +136,7 @@ def handle_session_start(payload: dict[str, Any]) -> dict[str, Any] | None:
|
|
|
136
136
|
cwd = _payload_cwd(payload)
|
|
137
137
|
root = _repo_root(cwd)
|
|
138
138
|
_activate(root)
|
|
139
|
+
_open_session_books(root, str(payload.get("session_id") or ""), str(payload.get("source") or ""))
|
|
139
140
|
if (root / "graph-out" / "graph.json").is_file():
|
|
140
141
|
state, reason = _freshness_within_budget(root)
|
|
141
142
|
if state == "stale":
|
|
@@ -1295,6 +1296,43 @@ def _strict_denial(payload: dict[str, Any], root: Path, cwd: Path | None = None)
|
|
|
1295
1296
|
MAX_CURSOR_SESSIONS = 20
|
|
1296
1297
|
|
|
1297
1298
|
|
|
1299
|
+
def _keep_newest_sessions(sessions: dict[str, Any]) -> None:
|
|
1300
|
+
while len(sessions) > MAX_CURSOR_SESSIONS:
|
|
1301
|
+
sessions.pop(next(iter(sessions)))
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
def _open_session_books(root: Path, session_id: str, source: str) -> None:
|
|
1305
|
+
"""Start a new session's savings books where the usage ledger ends now.
|
|
1306
|
+
|
|
1307
|
+
The ledger holds every session's entries, so a session that counted from
|
|
1308
|
+
byte 0 took all of them as its own (#108). A session the cursor already
|
|
1309
|
+
knows keeps its totals: SessionStart fires again on a resume or a compact.
|
|
1310
|
+
On a resume its books move to the ledger's end as well: what the ledger
|
|
1311
|
+
gained while it was away is other sessions' use, and a turn of its own
|
|
1312
|
+
whose Stop never fired is not counted. A compact falls inside a turn, so
|
|
1313
|
+
the books stay where they are.
|
|
1314
|
+
"""
|
|
1315
|
+
try:
|
|
1316
|
+
if not session_id:
|
|
1317
|
+
return
|
|
1318
|
+
sessions = usage_ledger.read_cursor(root).get("sessions")
|
|
1319
|
+
if not isinstance(sessions, dict):
|
|
1320
|
+
sessions = {}
|
|
1321
|
+
known = sessions.pop(session_id, None)
|
|
1322
|
+
if isinstance(known, dict) and source != "resume":
|
|
1323
|
+
return
|
|
1324
|
+
ledger = usage_ledger.ledger_path(root)
|
|
1325
|
+
ledger_stat = ledger.stat() if ledger.is_file() else None
|
|
1326
|
+
books = known if isinstance(known, dict) else {"tokens": 0, "seconds": 0.0}
|
|
1327
|
+
books["offset"] = ledger_stat.st_size if ledger_stat is not None else 0
|
|
1328
|
+
books["ino"] = ledger_stat.st_ino if ledger_stat is not None else None
|
|
1329
|
+
sessions[session_id] = books
|
|
1330
|
+
_keep_newest_sessions(sessions)
|
|
1331
|
+
usage_ledger.write_cursor(root, {"sessions": sessions})
|
|
1332
|
+
except Exception:
|
|
1333
|
+
return
|
|
1334
|
+
|
|
1335
|
+
|
|
1298
1336
|
def _entries_between(path: Path, start: int, end: int) -> list[dict[str, Any]]:
|
|
1299
1337
|
entries: list[dict[str, Any]] = []
|
|
1300
1338
|
with open(path, "rb") as handle:
|
|
@@ -1348,7 +1386,11 @@ def handle_stop(payload: dict[str, Any]) -> dict[str, Any] | None:
|
|
|
1348
1386
|
sessions = {}
|
|
1349
1387
|
state = sessions.pop(session_id, None)
|
|
1350
1388
|
if not isinstance(state, dict):
|
|
1351
|
-
|
|
1389
|
+
# No books were opened for this session: its SessionStart was not
|
|
1390
|
+
# seen, or the session was pruned from the cursor. What the ledger
|
|
1391
|
+
# holds now is other sessions' history (#108), so the books start
|
|
1392
|
+
# at its end. This turn's own entries are lost; none are invented.
|
|
1393
|
+
state = {"offset": size, "tokens": 0, "seconds": 0.0, "ino": current_ino}
|
|
1352
1394
|
offset = state.get("offset", 0)
|
|
1353
1395
|
stored_ino = state.get("ino")
|
|
1354
1396
|
# A stored `ino` that isn't an int (missing key on the older 3-key cursor
|
|
@@ -1378,8 +1420,7 @@ def handle_stop(payload: dict[str, Any]) -> dict[str, Any] | None:
|
|
|
1378
1420
|
state["tokens"] = _cursor_number(state.get("tokens", 0), int) + turn_tokens
|
|
1379
1421
|
state["seconds"] = _cursor_number(state.get("seconds", 0.0), float) + turn_seconds
|
|
1380
1422
|
sessions[session_id] = state # re-insert -> newest position
|
|
1381
|
-
|
|
1382
|
-
sessions.pop(next(iter(sessions)))
|
|
1423
|
+
_keep_newest_sessions(sessions)
|
|
1383
1424
|
usage_ledger.write_cursor(root, {"sessions": sessions})
|
|
1384
1425
|
if not new_entries or not usage_ledger.savings_display_enabled(root):
|
|
1385
1426
|
return None
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Deterministic structural extraction via tree-sitter."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
|
+
import builtins
|
|
4
5
|
import hashlib
|
|
5
6
|
import importlib
|
|
6
7
|
import re
|
|
@@ -15,7 +16,7 @@ from ..cache import Cache
|
|
|
15
16
|
from ..config import Config
|
|
16
17
|
from ..graph import normalize_id
|
|
17
18
|
from ..ingest import LANGUAGE_BY_EXT, FileEntry
|
|
18
|
-
from ..resolve import SourceIndex, should_keep_call_target
|
|
19
|
+
from ..resolve import MAX_REEXPORT_HOPS, SourceIndex, python_reexports_of, should_keep_call_target
|
|
19
20
|
from .pyscope import (
|
|
20
21
|
PyScope,
|
|
21
22
|
Resolution,
|
|
@@ -1420,6 +1421,30 @@ def _python_import_bindings(
|
|
|
1420
1421
|
return out
|
|
1421
1422
|
|
|
1422
1423
|
|
|
1424
|
+
def _python_module_reexports(
|
|
1425
|
+
file_id: str, rel_path: str, source: bytes, source_index: SourceIndex
|
|
1426
|
+
) -> dict[str, str]:
|
|
1427
|
+
"""`<module>.<name>` -> where the module's own `from X import name` says it is (#107).
|
|
1428
|
+
|
|
1429
|
+
The key is the id a call of `module.name` gets, `_make_id(<file id>,
|
|
1430
|
+
<name>)`; the value is the id of `name` in the file `X` resolves to. Only
|
|
1431
|
+
a name the module binds by that one statement is recorded (the rule #87
|
|
1432
|
+
applies to a package's `__init__.py`), and one that names a submodule
|
|
1433
|
+
(`from pkg import sub`) is not: `pkg.sub` is the module, not a name of
|
|
1434
|
+
`pkg`. The dispatch post-pass follows these across files, so a value
|
|
1435
|
+
depends on the module's own bytes and the file set alone, as its cache
|
|
1436
|
+
key does.
|
|
1437
|
+
"""
|
|
1438
|
+
out: dict[str, str] = {}
|
|
1439
|
+
for (_, local), (module, level, original) in python_reexports_of(rel_path, source).items():
|
|
1440
|
+
if source_index.resolve_python_module(rel_path, f"{module}.{original}", level):
|
|
1441
|
+
continue
|
|
1442
|
+
defining = source_index.resolve_python_module(rel_path, module, level)
|
|
1443
|
+
if defining:
|
|
1444
|
+
out[_make_id(file_id, local)] = _make_id(_file_node_id(defining, source_index), original)
|
|
1445
|
+
return out
|
|
1446
|
+
|
|
1447
|
+
|
|
1423
1448
|
def _python_definition_name(node: Any) -> str | None:
|
|
1424
1449
|
"""A def/class node's name exactly as its graph node records it."""
|
|
1425
1450
|
name_node = node.child_by_field_name("name")
|
|
@@ -1559,14 +1584,21 @@ def _python_attribute_root(node: Any) -> str | None:
|
|
|
1559
1584
|
return None
|
|
1560
1585
|
|
|
1561
1586
|
|
|
1562
|
-
def _extract_python(file_id: str, rel_path: str,
|
|
1587
|
+
def _extract_python(file_id: str, rel_path: str, source: bytes, tree: Any, source_index: SourceIndex | None = None) -> ExtractionResult:
|
|
1563
1588
|
result = ExtractionResult()
|
|
1564
1589
|
root = tree.root_node
|
|
1565
1590
|
|
|
1566
1591
|
def _line(node: Any) -> int:
|
|
1567
1592
|
return node.start_point[0] + 1
|
|
1568
1593
|
|
|
1569
|
-
|
|
1594
|
+
file_node = _node(file_id, "file", Path(rel_path).name, rel_path)
|
|
1595
|
+
if source_index is not None:
|
|
1596
|
+
# For the dispatch post-pass, which takes it off again: what a call of
|
|
1597
|
+
# `<this module>.<name>` reaches where the module only imports the name.
|
|
1598
|
+
reexports = _python_module_reexports(file_id, rel_path, source, source_index)
|
|
1599
|
+
if reexports:
|
|
1600
|
+
file_node["_reexports"] = reexports
|
|
1601
|
+
result.nodes.append(file_node)
|
|
1570
1602
|
|
|
1571
1603
|
# One pass builds every Python scope and what each binds (#70, #71). The walk
|
|
1572
1604
|
# below reads it: each def/class gets its scope-qualified identity, and each
|
|
@@ -1604,8 +1636,9 @@ def _extract_python(file_id: str, rel_path: str, _source: bytes, tree: Any, sour
|
|
|
1604
1636
|
class_node = _node(did, "class", name, rel_path, _line(node), {"qualname": qualname})
|
|
1605
1637
|
body_scope = table.class_scope.get(node.id)
|
|
1606
1638
|
if body_scope is not None and body_scope.parent is not None:
|
|
1607
|
-
# For the dispatch post-pass (#73), which takes all
|
|
1608
|
-
# again: the bases in order,
|
|
1639
|
+
# For the dispatch post-pass (#73), which takes all six off
|
|
1640
|
+
# again: the bases in order, which of them are builtin classes
|
|
1641
|
+
# (#106), the names the body binds in some
|
|
1609
1642
|
# other way than one `def` written straight in it (a `def`
|
|
1610
1643
|
# under an `if` is there only if the `if` ran it, and one
|
|
1611
1644
|
# under `global` or `nonlocal` binds the name somewhere
|
|
@@ -1614,7 +1647,9 @@ def _extract_python(file_id: str, rel_path: str, _source: bytes, tree: Any, sour
|
|
|
1614
1647
|
# is made beyond its body and bases. With them `self.m()` and
|
|
1615
1648
|
# `super().m()` are bound to the method Python finds, not to
|
|
1616
1649
|
# every method called `m`.
|
|
1617
|
-
class_node["_bases"] = _python_class_bases(
|
|
1650
|
+
class_node["_bases"], class_node["_builtin_bases"] = _python_class_bases(
|
|
1651
|
+
node, body_scope.parent, table, ids
|
|
1652
|
+
)
|
|
1618
1653
|
class_node["_stops"] = sorted(
|
|
1619
1654
|
{
|
|
1620
1655
|
bound for bound, binders in body_scope.binders.items()
|
|
@@ -2254,7 +2289,7 @@ _MAX_METHOD_DISPATCH_CANDIDATES = 3
|
|
|
2254
2289
|
|
|
2255
2290
|
def _python_class_bases(
|
|
2256
2291
|
node: Any, scope: PyScope, table: ScopeTable, ids: dict[tuple[str, bool], str]
|
|
2257
|
-
) -> list[str | None]:
|
|
2292
|
+
) -> tuple[list[str | None], list[str | None]]:
|
|
2258
2293
|
"""Each base of a class statement, in order: the id of the class it names, or None.
|
|
2259
2294
|
|
|
2260
2295
|
A base is resolved where the source states it: a bare name that denotes a
|
|
@@ -2264,15 +2299,26 @@ def _python_class_bases(
|
|
|
2264
2299
|
It may bind any name, and it may derive from a class that was read.
|
|
2265
2300
|
`object` is left out: it is last in every linearisation and defines no
|
|
2266
2301
|
method of the repository. Class keywords (`metaclass=...`) are not bases.
|
|
2302
|
+
|
|
2303
|
+
The second list is as long as the first: the name of the builtin class a
|
|
2304
|
+
base is, where it is one (a bare name the file does not bind), and None
|
|
2305
|
+
elsewhere. Only `super()` reads it (#106): no class of the repository
|
|
2306
|
+
stands behind a builtin, so where the method `super()` finds is a
|
|
2307
|
+
builtin's, it is none of the repository's. A star import may bind the
|
|
2308
|
+
name; `super()` itself is not read beside one (`_is_bare_super`), so the
|
|
2309
|
+
list needs no check of its own for it.
|
|
2267
2310
|
"""
|
|
2268
2311
|
bases: list[str | None] = []
|
|
2312
|
+
builtin_bases: list[str | None] = []
|
|
2269
2313
|
arguments = node.child_by_field_name("superclasses")
|
|
2270
2314
|
for arg in arguments.named_children if arguments is not None else ():
|
|
2271
2315
|
if arg.type in ("comment", "keyword_argument", "dictionary_splat"):
|
|
2272
2316
|
continue
|
|
2273
|
-
|
|
2317
|
+
written = arg.text.decode("utf-8", errors="ignore")
|
|
2318
|
+
found = resolve(scope, written) if arg.type == "identifier" else None
|
|
2274
2319
|
if found is not None and found.kind in ("def", "symbol"):
|
|
2275
2320
|
bases.append(_python_definition_id(found, ids))
|
|
2321
|
+
builtin_bases.append(None)
|
|
2276
2322
|
elif (
|
|
2277
2323
|
found is not None and found.kind == "none"
|
|
2278
2324
|
and arg.text == b"object" and not table.module.star_import
|
|
@@ -2280,7 +2326,28 @@ def _python_class_bases(
|
|
|
2280
2326
|
continue
|
|
2281
2327
|
else:
|
|
2282
2328
|
bases.append(None)
|
|
2283
|
-
|
|
2329
|
+
builtin = (
|
|
2330
|
+
found is not None and found.kind == "none"
|
|
2331
|
+
and isinstance(getattr(builtins, written, None), type)
|
|
2332
|
+
)
|
|
2333
|
+
builtin_bases.append(written if builtin else None)
|
|
2334
|
+
return bases, builtin_bases
|
|
2335
|
+
|
|
2336
|
+
|
|
2337
|
+
#: What `class_method` answers where the method `super()` finds is a builtin's (#106).
|
|
2338
|
+
_A_BUILTIN_S_METHOD = "<builtin>"
|
|
2339
|
+
|
|
2340
|
+
|
|
2341
|
+
def _a_builtin_has(builtin_names: Collection[str], method: str) -> bool:
|
|
2342
|
+
"""Whether a method lookup that reaches these builtin classes finds `method`
|
|
2343
|
+
in one of them or in a class they derive from (`object` among them).
|
|
2344
|
+
|
|
2345
|
+
Each class's own namespace is read, not `hasattr`: `hasattr(dict, "mro")`
|
|
2346
|
+
is true because `type` defines `mro`, and `super()` never looks there.
|
|
2347
|
+
"""
|
|
2348
|
+
return any(
|
|
2349
|
+
method in vars(cls) for name in builtin_names for cls in getattr(builtins, name).__mro__
|
|
2350
|
+
)
|
|
2284
2351
|
|
|
2285
2352
|
|
|
2286
2353
|
def _python_class_making(node: Any, scope: PyScope, table: ScopeTable) -> list[str]:
|
|
@@ -2527,6 +2594,46 @@ def _dispatch_is_gated(source_file: str | None) -> bool:
|
|
|
2527
2594
|
return language in _DISPATCH_GATED_LANGUAGES
|
|
2528
2595
|
|
|
2529
2596
|
|
|
2597
|
+
def _follow_python_reexports(nodes: list[dict[str, Any]], edges: list[dict[str, Any]]) -> None:
|
|
2598
|
+
"""Re-point each id of a name a Python module only imports to its definition (#107).
|
|
2599
|
+
|
|
2600
|
+
`front.target(x)`, where `front.py` binds `target` only by `from pkg.impl
|
|
2601
|
+
import target`, was extracted as a call of `pkg_front_py_target`, which no
|
|
2602
|
+
file defines; so were `t = front.target; t(x)`, `from pkg.front import
|
|
2603
|
+
target` and a base class or receiver named that way. Each module's own
|
|
2604
|
+
imports are on its file node (`_reexports`); here they are followed across
|
|
2605
|
+
files, for as many hops as the source states, to the id the last module
|
|
2606
|
+
names. A definition is never moved: a module that defines a name binds it
|
|
2607
|
+
twice, and such a name is not recorded. A cycle stops at
|
|
2608
|
+
`MAX_REEXPORT_HOPS`, on an id no file defines.
|
|
2609
|
+
|
|
2610
|
+
Edge targets of every relation are re-pointed, and so are ``_receiver``
|
|
2611
|
+
on an edge and ``_bases`` on a class node, the other two places a
|
|
2612
|
+
definition id is read; ``_reexports`` is taken off every node.
|
|
2613
|
+
"""
|
|
2614
|
+
hops: dict[str, str] = {}
|
|
2615
|
+
for n in nodes:
|
|
2616
|
+
hops.update(n.pop("_reexports", None) or {})
|
|
2617
|
+
if not hops:
|
|
2618
|
+
return
|
|
2619
|
+
|
|
2620
|
+
def follow(target: str) -> str:
|
|
2621
|
+
for _ in range(MAX_REEXPORT_HOPS):
|
|
2622
|
+
hop = hops.get(target)
|
|
2623
|
+
if hop is None:
|
|
2624
|
+
break
|
|
2625
|
+
target = hop
|
|
2626
|
+
return target
|
|
2627
|
+
|
|
2628
|
+
for e in edges:
|
|
2629
|
+
e["target"] = follow(e["target"])
|
|
2630
|
+
if e.get("_receiver") is not None:
|
|
2631
|
+
e["_receiver"] = follow(e["_receiver"])
|
|
2632
|
+
for n in nodes:
|
|
2633
|
+
if n.get("_bases") is not None:
|
|
2634
|
+
n["_bases"] = [None if base is None else follow(base) for base in n["_bases"]]
|
|
2635
|
+
|
|
2636
|
+
|
|
2530
2637
|
def _resolve_method_dispatch(
|
|
2531
2638
|
nodes: list[dict[str, Any]], edges: list[dict[str, Any]]
|
|
2532
2639
|
) -> list[dict[str, Any]]:
|
|
@@ -2590,9 +2697,23 @@ def _resolve_method_dispatch(
|
|
|
2590
2697
|
`__init_subclass__` there can set a name on the class itself, over its own
|
|
2591
2698
|
`def`. So "bound" says what the classes that were read state, and not more.
|
|
2592
2699
|
|
|
2700
|
+
One case of a base that was not read is read for `super()` alone (#106):
|
|
2701
|
+
a builtin class, named in ``_builtin_bases``. No class of the repository
|
|
2702
|
+
stands behind a builtin. So where no class that was read binds the name,
|
|
2703
|
+
every base that was not read is a builtin, and a builtin (or `object`)
|
|
2704
|
+
has the name, what `super()` finds is the builtin's, and the call gets no
|
|
2705
|
+
edge, as a call of a builtin gets none. Bound by name, it was a call to
|
|
2706
|
+
every method of the name in reach.
|
|
2707
|
+
|
|
2708
|
+
Before any of it, a name a Python module only imports is followed to its
|
|
2709
|
+
definition (`_follow_python_reexports`, #107), so the ids read below are
|
|
2710
|
+
the definitions' own.
|
|
2711
|
+
|
|
2593
2712
|
``_member``, ``_receiver`` and ``_walk`` are stripped from every returned
|
|
2594
|
-
edge, and the
|
|
2713
|
+
edge, and the six class tags and ``_reexports`` from every node, so none
|
|
2714
|
+
leaks into the graph.
|
|
2595
2715
|
"""
|
|
2716
|
+
_follow_python_reexports(nodes, edges)
|
|
2596
2717
|
# method name (casefolded) -> set of definition node ids. A set collapses the
|
|
2597
2718
|
# same method appearing twice in the pre-dedup node list, so the cap counts
|
|
2598
2719
|
# distinct definitions.
|
|
@@ -2617,14 +2738,17 @@ def _resolve_method_dispatch(
|
|
|
2617
2738
|
instance_binds_of: dict[str, frozenset[str]] = {}
|
|
2618
2739
|
class_binds_of: dict[str, frozenset[str]] = {}
|
|
2619
2740
|
made_of: dict[str, frozenset[str]] = {}
|
|
2741
|
+
builtin_bases_of: dict[str, list[str | None]] = {}
|
|
2620
2742
|
for n in nodes:
|
|
2621
2743
|
bases = n.pop("_bases", None)
|
|
2744
|
+
builtin_bases = n.pop("_builtin_bases", None)
|
|
2622
2745
|
stops = n.pop("_stops", None)
|
|
2623
2746
|
instance_binds = n.pop("_self_binds", None)
|
|
2624
2747
|
class_binds = n.pop("_class_binds", None)
|
|
2625
2748
|
made = n.pop("_made", None)
|
|
2626
2749
|
if bases is not None:
|
|
2627
2750
|
bases_of[n["id"]] = bases
|
|
2751
|
+
builtin_bases_of[n["id"]] = list(builtin_bases or ())
|
|
2628
2752
|
stops_of[n["id"]] = frozenset(stops or ())
|
|
2629
2753
|
instance_binds_of[n["id"]] = frozenset(instance_binds or ())
|
|
2630
2754
|
class_binds_of[n["id"]] = frozenset(class_binds or ())
|
|
@@ -2687,6 +2811,21 @@ def _resolve_method_dispatch(
|
|
|
2687
2811
|
if (walk == "self" if current == cls else not private)
|
|
2688
2812
|
and ("decorator" in made_of[current] or body_binds(current, method))
|
|
2689
2813
|
]
|
|
2814
|
+
if walk == "super" and not binders and unread:
|
|
2815
|
+
# No class that was read binds the name. Where every base that
|
|
2816
|
+
# was not read is a builtin, no class of the repository stands
|
|
2817
|
+
# behind any of them, and one of them has the name, `super()`
|
|
2818
|
+
# finds a builtin's method (#106).
|
|
2819
|
+
builtin_names: list[str] = []
|
|
2820
|
+
for current, position in unread:
|
|
2821
|
+
named = builtin_bases_of.get(current, [])
|
|
2822
|
+
builtin = named[position] if position < len(named) else None
|
|
2823
|
+
if builtin is None:
|
|
2824
|
+
break
|
|
2825
|
+
builtin_names.append(builtin)
|
|
2826
|
+
else:
|
|
2827
|
+
if _a_builtin_has(builtin_names, method):
|
|
2828
|
+
return _A_BUILTIN_S_METHOD
|
|
2690
2829
|
if not unread:
|
|
2691
2830
|
# Every base was read, so the order is Python's own.
|
|
2692
2831
|
line = _c3_linearisation(cls, bases_of, linearisations) or ()
|
|
@@ -2768,6 +2907,10 @@ def _resolve_method_dispatch(
|
|
|
2768
2907
|
# `self.m()` / `super().m()`: the first `m` along the bases of the
|
|
2769
2908
|
# class the call is written in (#73).
|
|
2770
2909
|
own = class_method(receiver, method, walk)
|
|
2910
|
+
if own == _A_BUILTIN_S_METHOD:
|
|
2911
|
+
# What runs is a builtin's method: no edge, as a call of a
|
|
2912
|
+
# builtin has none (#106).
|
|
2913
|
+
continue
|
|
2771
2914
|
else:
|
|
2772
2915
|
own = own_methods.get(receiver, {}).get(method) if receiver else None
|
|
2773
2916
|
if own is not None:
|
|
@@ -34,9 +34,9 @@ def _rel_path_set_digest(rel_paths: frozenset[str]) -> str:
|
|
|
34
34
|
|
|
35
35
|
#: How many re-exports one name is followed through. A real package chain is a
|
|
36
36
|
#: hop or two; the bound only has to be finite beside the cycle guard.
|
|
37
|
-
|
|
37
|
+
MAX_REEXPORT_HOPS: Final = 8
|
|
38
38
|
|
|
39
|
-
#: `(
|
|
39
|
+
#: `(module path, name it binds) -> (module, leading dots, name there)`
|
|
40
40
|
ReexportTable = dict[tuple[str, str], tuple[str, int, str]]
|
|
41
41
|
|
|
42
42
|
|
|
@@ -46,7 +46,9 @@ def _module_level_bindings(body: list[ast.stmt]) -> dict[str, list[ast.stmt]]:
|
|
|
46
46
|
A name bound under `if` or `try` counts as bound there, and so does a
|
|
47
47
|
name an `import` or `def` binds: the statement list is what lets the caller
|
|
48
48
|
tell a name bound exactly once, by one `from X import name`, from a name
|
|
49
|
-
the
|
|
49
|
+
the module binds some other way too. So does a `global` declaration of the
|
|
50
|
+
name in any function or class of the module, which binds it from there
|
|
51
|
+
(#107).
|
|
50
52
|
"""
|
|
51
53
|
bound: dict[str, list[ast.stmt]] = {}
|
|
52
54
|
|
|
@@ -76,16 +78,22 @@ def _module_level_bindings(body: list[ast.stmt]) -> dict[str, list[ast.stmt]]:
|
|
|
76
78
|
add(node.name, stmt)
|
|
77
79
|
|
|
78
80
|
visit(body)
|
|
81
|
+
for stmt in body:
|
|
82
|
+
for node in ast.walk(stmt):
|
|
83
|
+
if isinstance(node, ast.Global):
|
|
84
|
+
for name in node.names:
|
|
85
|
+
add(name, node)
|
|
79
86
|
return bound
|
|
80
87
|
|
|
81
88
|
|
|
82
|
-
def
|
|
83
|
-
"""The names one
|
|
89
|
+
def python_reexports_of(rel_path: str, source: bytes) -> ReexportTable:
|
|
90
|
+
"""The names one module binds only by a top-level `from X import name`.
|
|
84
91
|
|
|
85
92
|
A name the file binds any other way too (assigned, defined, imported a
|
|
86
|
-
second time, imported under a condition
|
|
87
|
-
does not parse:
|
|
88
|
-
it was before re-exports were followed.
|
|
93
|
+
second time, imported under a condition, rebound under `global`) is left
|
|
94
|
+
out, and so is a file that does not parse: the name then stays bound to
|
|
95
|
+
the module, as it was before re-exports were followed. A star import is
|
|
96
|
+
not read.
|
|
89
97
|
"""
|
|
90
98
|
try:
|
|
91
99
|
tree = ast.parse(source)
|
|
@@ -116,7 +124,7 @@ def _python_reexports(entries: Iterable[FileEntry]) -> ReexportTable:
|
|
|
116
124
|
source = Path(entry.abs_path).read_bytes()
|
|
117
125
|
except OSError:
|
|
118
126
|
continue
|
|
119
|
-
table.update(
|
|
127
|
+
table.update(python_reexports_of(rel_path, source))
|
|
120
128
|
return table
|
|
121
129
|
|
|
122
130
|
|
|
@@ -233,11 +241,11 @@ class SourceIndex:
|
|
|
233
241
|
Follows `from X import name` statements the package `__init__.py`
|
|
234
242
|
makes, for as many steps as the source states. It stops where a hop does
|
|
235
243
|
not resolve to a file of the tree, where a name is bound some other way,
|
|
236
|
-
at a cycle, and at `
|
|
244
|
+
at a cycle, and at `MAX_REEXPORT_HOPS`; each returns the last place
|
|
237
245
|
reached, which is `(rel_path, name)` itself when nothing is followed.
|
|
238
246
|
"""
|
|
239
247
|
seen = {(rel_path, name)}
|
|
240
|
-
for _ in range(
|
|
248
|
+
for _ in range(MAX_REEXPORT_HOPS):
|
|
241
249
|
hop = self.python_reexports.get((rel_path, name))
|
|
242
250
|
if hop is None:
|
|
243
251
|
break
|
|
@@ -274,7 +274,14 @@ def _use_graphite(root: Path, cmd: str = "context") -> None:
|
|
|
274
274
|
record_usage(root, cmd=cmd, wall_ms=50, result={"files": [{"path": "alpha.py"}]})
|
|
275
275
|
|
|
276
276
|
|
|
277
|
+
def _open_session(root: Path, session: str = "s1") -> None:
|
|
278
|
+
"""The session's SessionStart, which opens its savings books (#108). A Stop
|
|
279
|
+
for a session with no books counts nothing already in the ledger."""
|
|
280
|
+
handle_session_start({"session_id": session, "cwd": str(root), "hook_event_name": "SessionStart"})
|
|
281
|
+
|
|
282
|
+
|
|
277
283
|
def test_stop_emits_summary_after_usage(built_repo: Path) -> None:
|
|
284
|
+
_open_session(built_repo)
|
|
278
285
|
_use_graphite(built_repo)
|
|
279
286
|
out = handle_stop(_stop_payload(built_repo))
|
|
280
287
|
message = out["systemMessage"]
|
|
@@ -284,12 +291,14 @@ def test_stop_emits_summary_after_usage(built_repo: Path) -> None:
|
|
|
284
291
|
|
|
285
292
|
|
|
286
293
|
def test_stop_silent_with_no_new_usage(built_repo: Path) -> None:
|
|
294
|
+
_open_session(built_repo)
|
|
287
295
|
_use_graphite(built_repo)
|
|
288
296
|
assert handle_stop(_stop_payload(built_repo)) is not None # consumes entries
|
|
289
297
|
assert handle_stop(_stop_payload(built_repo)) is None # nothing new this turn
|
|
290
298
|
|
|
291
299
|
|
|
292
300
|
def test_stop_session_totals_accumulate(built_repo: Path) -> None:
|
|
301
|
+
_open_session(built_repo)
|
|
293
302
|
_use_graphite(built_repo)
|
|
294
303
|
first = handle_stop(_stop_payload(built_repo))["systemMessage"]
|
|
295
304
|
_use_graphite(built_repo)
|
|
@@ -299,6 +308,7 @@ def test_stop_session_totals_accumulate(built_repo: Path) -> None:
|
|
|
299
308
|
|
|
300
309
|
|
|
301
310
|
def test_stop_respects_toggle_but_cursor_still_advances(built_repo: Path) -> None:
|
|
311
|
+
_open_session(built_repo)
|
|
302
312
|
set_savings_display(built_repo, False)
|
|
303
313
|
_use_graphite(built_repo)
|
|
304
314
|
assert handle_stop(_stop_payload(built_repo)) is None
|
|
@@ -314,6 +324,7 @@ def test_stop_without_session_id_is_silent(built_repo: Path) -> None:
|
|
|
314
324
|
def test_stop_survives_ledger_rotation_between_turns(built_repo: Path, monkeypatch) -> None:
|
|
315
325
|
from graphite import usage_ledger as ul
|
|
316
326
|
|
|
327
|
+
_open_session(built_repo)
|
|
317
328
|
_use_graphite(built_repo)
|
|
318
329
|
assert handle_stop(_stop_payload(built_repo)) is not None
|
|
319
330
|
monkeypatch.setattr(ul, "MAX_LEDGER_BYTES", 1) # force rotation on the next record
|
|
@@ -337,6 +348,7 @@ def test_stop_prunes_cursor_to_max_sessions(built_repo: Path) -> None:
|
|
|
337
348
|
def test_stop_self_heals_corrupted_cursor_tokens(built_repo: Path) -> None:
|
|
338
349
|
from graphite.usage_ledger import read_cursor, write_cursor
|
|
339
350
|
|
|
351
|
+
_open_session(built_repo)
|
|
340
352
|
_use_graphite(built_repo)
|
|
341
353
|
assert handle_stop(_stop_payload(built_repo)) is not None
|
|
342
354
|
cursor = read_cursor(built_repo)
|
|
@@ -359,6 +371,7 @@ def test_stop_self_heals_corrupted_cursor_tokens(built_repo: Path) -> None:
|
|
|
359
371
|
def test_stop_missing_ino_key_falls_back_to_offset_check(built_repo: Path) -> None:
|
|
360
372
|
from graphite.usage_ledger import read_cursor, write_cursor
|
|
361
373
|
|
|
374
|
+
_open_session(built_repo)
|
|
362
375
|
_use_graphite(built_repo)
|
|
363
376
|
assert handle_stop(_stop_payload(built_repo)) is not None
|
|
364
377
|
cursor = read_cursor(built_repo)
|
|
@@ -371,6 +384,7 @@ def test_stop_missing_ino_key_falls_back_to_offset_check(built_repo: Path) -> No
|
|
|
371
384
|
|
|
372
385
|
|
|
373
386
|
def test_cli_stop_event_emits_summary(built_repo, monkeypatch, capsys) -> None:
|
|
387
|
+
_open_session(built_repo)
|
|
374
388
|
_use_graphite(built_repo)
|
|
375
389
|
code, out = _run_cli_hook(
|
|
376
390
|
monkeypatch, capsys, ["agent-hook", "stop"], _stop_payload(built_repo)
|
|
@@ -1542,6 +1556,7 @@ def test_a_session_below_the_root_renews_the_repository(checkout: Path, tmp_path
|
|
|
1542
1556
|
def test_stop_below_the_root_keeps_its_books_at_the_root(checkout: Path, tmp_path: Path) -> None:
|
|
1543
1557
|
repo = tmp_path / "repo"
|
|
1544
1558
|
shutil.copytree(checkout, repo)
|
|
1559
|
+
_open_session(repo / "docs")
|
|
1545
1560
|
record_usage(repo, cmd="context", wall_ms=50, result={"files": [{"path": "src/pkg/core.py"}]})
|
|
1546
1561
|
|
|
1547
1562
|
out = handle_stop(_stop_payload(repo / "docs"))
|