From 077149011beb39e6ad5d76c85a6ac75e7e7b936a Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 22 Jun 2026 12:20:32 -0400 Subject: [PATCH] fix(audit): real line numbers + entry.get() field-access detection + Optional/dict/Union patterns Three real bugs fixed: 1. FunctionRef always used line=0. Now passes node.lineno from AST. 2. P3_pass results were discarded with bare pass. Now stored in ProducerConsumerGraph.field_accesses. 3. Field-access detector only saw entry['key']; missed entry.get('key') which is the dominant pattern in this codebase. Now handles both. Plus _extract_type_name() helper handles Optional[T], dict[str, T], list[T], Result[T], Union[T, ...], and T | None (PEP 604) so P1/P2 catch more annotation patterns. Real numbers (Metadata aggregate): - producers: 77 -> 117 - consumers: 35 -> 66 - field-access sites: 130 -> 173 - line numbers: all real (line 1281, 1746, etc.) AUDIT_REPORT.md grew 2009 -> 3140 lines with real evidence. Total audit output: 5176 lines / 50 files (was 2415 / 49). All 131 tests still passing. --- .../2026-06-22/AUDIT_REPORT.md | 1238 ++++++++++------- .../2026-06-22/aggregates/FileItems.dsl | 16 +- .../2026-06-22/aggregates/FileItems.md | 56 +- .../2026-06-22/aggregates/FileItems.tree | 7 +- .../2026-06-22/aggregates/HistoryMessage.dsl | 14 +- .../2026-06-22/aggregates/HistoryMessage.md | 45 +- .../2026-06-22/aggregates/HistoryMessage.tree | 7 +- .../2026-06-22/aggregates/Metadata.dsl | 408 ++++-- .../2026-06-22/aggregates/Metadata.md | 695 +++++---- .../2026-06-22/aggregates/Metadata.tree | 271 ++-- .../2026-06-22/aggregates/ToolCall.dsl | 4 +- .../2026-06-22/aggregates/ToolCall.md | 4 +- .../2026-06-22/aggregates/ToolDefinition.dsl | 11 +- .../2026-06-22/aggregates/ToolDefinition.md | 36 +- .../2026-06-22/aggregates/ToolDefinition.tree | 8 +- .../code_path_audit/2026-06-22/call_graph.md | 280 ++-- .../2026-06-22/cross_audit_summary.md | 2 +- .../code_path_audit/2026-06-22/dead_fields.md | 10 +- .../2026-06-22/decomposition_matrix.md | 8 +- .../code_path_audit/2026-06-22/field_usage.md | 5 +- .../code_path_audit/2026-06-22/hot_paths.md | 3 +- .../2026-06-22/organization_deductions.md | 20 +- .../2026-06-22/ssdl_analysis.md | 48 +- .../code_path_audit/2026-06-22/summary.md | 26 +- src/code_path_audit.py | 100 +- src/code_path_audit_analysis.py | 14 +- tests/test_code_path_audit.py | 14 +- 27 files changed, 2087 insertions(+), 1263 deletions(-) diff --git a/docs/reports/code_path_audit/2026-06-22/AUDIT_REPORT.md b/docs/reports/code_path_audit/2026-06-22/AUDIT_REPORT.md index f97ddf3d..6c1fb5d1 100644 --- a/docs/reports/code_path_audit/2026-06-22/AUDIT_REPORT.md +++ b/docs/reports/code_path_audit/2026-06-22/AUDIT_REPORT.md @@ -303,268 +303,404 @@ This section embeds the full per-aggregate audit output. Each aggregate has its ## Pipeline summary -- Producers: 77 -- Consumers: 35 -- Distinct producer fqnames: 77 -- Distinct consumer fqnames: 35 +- Producers: 117 +- Consumers: 66 +- Distinct producer fqnames: 96 +- Distinct consumer fqnames: 46 - Access pattern (aggregate): whole_struct - Frequency (aggregate): per_turn - Decomposition direction: hold - Struct field count (estimated): 10 -## Producers (77) +## Producers (117) -### `src\ai_client.py` (9 producers) +### `src\aggregate.py` (1 producer) -- `src.ai_client._send_cli_round_result` (line 0) -- `src.ai_client.ollama_chat` (line 0) -- `src.ai_client._add_bleed_derived` (line 0) -- `src.ai_client._parse_tool_args_result` (line 0) -- `src.ai_client._load_credentials` (line 0) -- `src.ai_client.get_token_stats` (line 0) -- `src.ai_client._dashscope_call` (line 0) -- `src.ai_client._content_block_to_dict` (line 0) -- `src.ai_client.get_gemini_cache_stats` (line 0) +- `src.aggregate.build_file_items` (line 158) -### `src\api_hook_client.py` (33 producers) +### `src\ai_client.py` (16 producers) -- `src.api_hook_client.get_performance` (line 0) -- `src.api_hook_client.post_session` (line 0) -- `src.api_hook_client.get_financial_metrics` (line 0) -- `src.api_hook_client.get_status` (line 0) -- `src.api_hook_client.get_context_state` (line 0) -- `src.api_hook_client.get_gui_health` (line 0) -- `src.api_hook_client.post_project` (line 0) -- `src.api_hook_client.select_list_item` (line 0) -- `src.api_hook_client.get_io_pool_status` (line 0) -- `src.api_hook_client.reject_patch` (line 0) -- `src.api_hook_client.get_system_telemetry` (line 0) -- `src.api_hook_client.push_event` (line 0) -- `src.api_hook_client.get_project_switch_status` (line 0) -- `src.api_hook_client.select_tab` (line 0) -- `src.api_hook_client.post_gui` (line 0) -- `src.api_hook_client.get_warmup_status` (line 0) -- `src.api_hook_client.get_warmup_wait` (line 0) -- `src.api_hook_client.wait_for_project_switch` (line 0) -- `src.api_hook_client.get_session` (line 0) -- `src.api_hook_client.get_startup_timeline` (line 0) -- `src.api_hook_client.get_mma_workers` (line 0) -- `src.api_hook_client.drag` (line 0) -- `src.api_hook_client.get_node_status` (line 0) -- `src.api_hook_client.apply_patch` (line 0) -- `src.api_hook_client.set_value` (line 0) -- `src.api_hook_client.get_mma_status` (line 0) -- `src.api_hook_client.get_gui_state` (line 0) -- `src.api_hook_client.right_click` (line 0) -- `src.api_hook_client.get_patch_status` (line 0) -- `src.api_hook_client.trigger_patch` (line 0) -- `src.api_hook_client.get_project` (line 0) -- `src.api_hook_client.get_gui_diagnostics` (line 0) -- `src.api_hook_client.click` (line 0) +- `src.ai_client._build_chunked_context_blocks` (line 1281) +- `src.ai_client._send_cli_round_result` (line 1746) +- `src.ai_client._get_anthropic_tools` (line 664) +- `src.ai_client.get_gemini_cache_stats` (line 1604) +- `src.ai_client._content_block_to_dict` (line 1200) +- `src.ai_client._strip_private_keys` (line 1464) +- `src.ai_client._add_bleed_derived` (line 3332) +- `src.ai_client._parse_tool_args_result` (line 741) +- `src.ai_client._extract_dashscope_tool_calls` (line 2754) +- `src.ai_client.get_comms_log` (line 273) +- `src.ai_client.get_token_stats` (line 3185) +- `src.ai_client._dashscope_call` (line 2716) +- `src.ai_client._load_credentials` (line 282) +- `src.ai_client._get_deepseek_tools` (line 1194) +- `src.ai_client._pre_dispatch` (line 2089) +- `src.ai_client.ollama_chat` (line 2938) -### `src\app_controller.py` (26 producers) +### `src\api_hook_client.py` (39 producers) -- `src.app_controller.get_performance` (line 0) -- `src.app_controller.wait` (line 0) -- `src.app_controller.get_diagnostics` (line 0) -- `src.app_controller.get_gui_state` (line 0) -- `src.app_controller._api_status` (line 0) -- `src.app_controller._api_token_stats` (line 0) -- `src.app_controller._api_get_api_session` (line 0) -- `src.app_controller._api_get_context` (line 0) -- `src.app_controller.get_api_project` (line 0) -- `src.app_controller._api_get_performance` (line 0) -- `src.app_controller.status` (line 0) -- `src.app_controller._api_get_gui_state` (line 0) -- `src.app_controller._api_get_session` (line 0) -- `src.app_controller.load_config` (line 0) -- `src.app_controller._api_get_mma_status` (line 0) -- `src.app_controller.token_stats` (line 0) -- `src.app_controller.get_mma_status` (line 0) -- `src.app_controller.get_session_insights` (line 0) -- `src.app_controller._api_get_api_project` (line 0) -- `src.app_controller._api_generate` (line 0) -- `src.app_controller.get_context` (line 0) -- `src.app_controller._api_get_diagnostics` (line 0) -- `src.app_controller._offload_entry_payload` (line 0) -- `src.app_controller.get_session` (line 0) -- `src.app_controller.get_api_session` (line 0) -- `src.app_controller.generate` (line 0) +- `src.api_hook_client.get_gui_diagnostics` (line 311) +- `src.api_hook_client.clear_events` (line 129) +- `src.api_hook_client.get_mma_workers` (line 546) +- `src.api_hook_client.get_startup_timeline` (line 353) +- `src.api_hook_client.get_session` (line 502) +- `src.api_hook_client.get_status` (line 105) +- `src.api_hook_client._make_request` (line 65) +- `src.api_hook_client.right_click` (line 237) +- `src.api_hook_client.trigger_patch` (line 274) +- `src.api_hook_client.select_tab` (line 263) +- `src.api_hook_client.click` (line 223) +- `src.api_hook_client.get_gui_state` (line 165) +- `src.api_hook_client.post_project` (line 473) +- `src.api_hook_client.get_patch_status` (line 295) +- `src.api_hook_client.push_event` (line 156) +- `src.api_hook_client.reject_patch` (line 288) +- `src.api_hook_client.get_project` (line 367) +- `src.api_hook_client.get_performance` (line 318) +- `src.api_hook_client.select_list_item` (line 256) +- `src.api_hook_client.get_warmup_status` (line 325) +- `src.api_hook_client.get_project_switch_status` (line 374) +- `src.api_hook_client.post_session` (line 117) +- `src.api_hook_client.get_system_telemetry` (line 524) +- `src.api_hook_client.wait_for_project_switch` (line 389) +- `src.api_hook_client.get_events` (line 124) +- `src.api_hook_client.get_gui_health` (line 434) +- `src.api_hook_client.apply_patch` (line 281) +- `src.api_hook_client.get_warmup_wait` (line 332) +- `src.api_hook_client.get_warmup_canaries` (line 342) +- `src.api_hook_client.get_financial_metrics` (line 520) +- `src.api_hook_client.post_gui` (line 149) +- `src.api_hook_client.drag` (line 230) +- `src.api_hook_client.post_project` (line 470) +- `src.api_hook_client.get_node_status` (line 532) +- `src.api_hook_client.get_io_pool_status` (line 420) +- `src.api_hook_client.wait_for_event` (line 136) +- `src.api_hook_client.get_context_state` (line 491) +- `src.api_hook_client.get_mma_status` (line 539) +- `src.api_hook_client.set_value` (line 212) -### `src\models.py` (2 producers) +### `src\app_controller.py` (30 producers) -- `src.models._load_config_from_disk` (line 0) -- `src.models.to_dict` (line 0) +- `src.app_controller._api_get_api_project` (line 188) +- `src.app_controller.get_api_project` (line 2853) +- `src.app_controller._offload_entry_payload` (line 4240) +- `src.app_controller.generate` (line 2868) +- `src.app_controller.token_stats` (line 2898) +- `src.app_controller._api_get_session` (line 374) +- `src.app_controller._api_get_gui_state` (line 123) +- `src.app_controller.load_config` (line 5142) +- `src.app_controller.pending_actions` (line 2874) +- `src.app_controller._api_get_performance` (line 195) +- `src.app_controller._api_get_context` (line 398) +- `src.app_controller.status` (line 2865) +- `src.app_controller._api_generate` (line 221) +- `src.app_controller._api_status` (line 209) +- `src.app_controller._api_token_stats` (line 417) +- `src.app_controller._api_get_api_session` (line 170) +- `src.app_controller.get_context` (line 2892) +- `src.app_controller.get_session_insights` (line 3049) +- `src.app_controller._pending_mma_approval` (line 2776) +- `src.app_controller.wait` (line 5205) +- `src.app_controller.get_session` (line 2883) +- `src.app_controller._api_get_mma_status` (line 144) +- `src.app_controller._api_pending_actions` (line 335) +- `src.app_controller.get_mma_status` (line 2835) +- `src.app_controller._pending_mma_spawn` (line 2772) +- `src.app_controller.get_performance` (line 2856) +- `src.app_controller.get_diagnostics` (line 2862) +- `src.app_controller._api_get_diagnostics` (line 202) +- `src.app_controller.get_api_session` (line 2847) +- `src.app_controller.get_gui_state` (line 2829) -### `src\project_manager.py` (7 producers) +### `src\models.py` (23 producers) -- `src.project_manager.load_history` (line 0) -- `src.project_manager.flat_config` (line 0) -- `src.project_manager.default_discussion` (line 0) -- `src.project_manager.str_to_entry` (line 0) -- `src.project_manager.migrate_from_legacy_config` (line 0) -- `src.project_manager.default_project` (line 0) -- `src.project_manager.load_project` (line 0) +- `src.models.to_dict` (line 441) +- `src.models.to_dict` (line 1024) +- `src.models.to_dict` (line 737) +- `src.models.to_dict` (line 618) +- `src.models.to_dict` (line 486) +- `src.models.to_dict` (line 886) +- `src.models.to_dict` (line 971) +- `src.models.parse_history_entries` (line 214) +- `src.models.to_dict` (line 646) +- `src.models.to_dict` (line 406) +- `src.models.to_dict` (line 701) +- `src.models.to_dict` (line 672) +- `src.models.to_dict` (line 355) +- `src.models.to_dict` (line 1059) +- `src.models.to_dict` (line 794) +- `src.models._load_config_from_disk` (line 186) +- `src.models.to_dict` (line 855) +- `src.models.to_dict` (line 1000) +- `src.models.to_dict` (line 938) +- `src.models.to_dict` (line 288) +- `src.models.to_dict` (line 913) +- `src.models.to_dict` (line 596) +- `src.models.to_dict` (line 558) -## Consumers (35) +### `src\project_manager.py` (8 producers) + +- `src.project_manager.flat_config` (line 267) +- `src.project_manager.str_to_entry` (line 75) +- `src.project_manager.default_discussion` (line 117) +- `src.project_manager.load_project` (line 186) +- `src.project_manager.get_all_tracks` (line 342) +- `src.project_manager.default_project` (line 123) +- `src.project_manager.migrate_from_legacy_config` (line 253) +- `src.project_manager.load_history` (line 209) + +## Consumers (66) ### `src\aggregate.py` (5 consumers) -- `src.aggregate._build_files_section_from_items` (line 0) -- `src.aggregate.build_tier3_context` (line 0) -- `src.aggregate.run` (line 0) -- `src.aggregate.build_markdown_from_items` (line 0) -- `src.aggregate.build_markdown_no_history` (line 0) +- `src.aggregate.build_markdown_from_items` (line 348) +- `src.aggregate.build_tier3_context` (line 382) +- `src.aggregate.build_markdown_no_history` (line 366) +- `src.aggregate.run` (line 479) +- `src.aggregate._build_files_section_from_items` (line 300) -### `src\ai_client.py` (18 consumers) +### `src\ai_client.py` (29 consumers) -- `src.ai_client._strip_stale_file_refreshes` (line 0) -- `src.ai_client._append_comms` (line 0) -- `src.ai_client._trim_anthropic_history` (line 0) -- `src.ai_client._execute_single_tool_call_async` (line 0) -- `src.ai_client._dashscope_call` (line 0) -- `src.ai_client.ollama_chat` (line 0) -- `src.ai_client._pre_dispatch` (line 0) -- `src.ai_client._strip_cache_controls` (line 0) -- `src.ai_client._estimate_prompt_tokens` (line 0) -- `src.ai_client._add_history_cache_breakpoint` (line 0) -- `src.ai_client._repair_minimax_history` (line 0) -- `src.ai_client._strip_private_keys` (line 0) -- `src.ai_client._repair_deepseek_history` (line 0) -- `src.ai_client._estimate_message_tokens` (line 0) -- `src.ai_client._add_bleed_derived` (line 0) -- `src.ai_client._invalidate_token_estimate` (line 0) -- `src.ai_client._repair_anthropic_history` (line 0) -- `src.ai_client._trim_minimax_history` (line 0) +- `src.ai_client._send_anthropic` (line 1405) +- `src.ai_client._add_history_cache_breakpoint` (line 1299) +- `src.ai_client._append_comms` (line 257) +- `src.ai_client._repair_deepseek_history` (line 2138) +- `src.ai_client._dashscope_call` (line 2716) +- `src.ai_client._send_grok` (line 2530) +- `src.ai_client._trim_minimax_history` (line 2482) +- `src.ai_client._send_gemini` (line 1802) +- `src.ai_client._repair_minimax_history` (line 2462) +- `src.ai_client._repair_anthropic_history` (line 1381) +- `src.ai_client._pre_dispatch` (line 2089) +- `src.ai_client._strip_stale_file_refreshes` (line 1253) +- `src.ai_client.send` (line 3208) +- `src.ai_client._send_minimax` (line 2616) +- `src.ai_client._send_llama_native` (line 2958) +- `src.ai_client._create_gemini_cache_result` (line 1706) +- `src.ai_client._send_qwen` (line 2773) +- `src.ai_client._trim_anthropic_history` (line 1353) +- `src.ai_client._strip_private_keys` (line 1464) +- `src.ai_client._estimate_prompt_tokens` (line 1243) +- `src.ai_client.ollama_chat` (line 2938) +- `src.ai_client._execute_single_tool_call_async` (line 945) +- `src.ai_client._send_deepseek` (line 2165) +- `src.ai_client._send_llama` (line 2858) +- `src.ai_client._add_bleed_derived` (line 3332) +- `src.ai_client._send_gemini_cli` (line 2019) +- `src.ai_client._invalidate_token_estimate` (line 1240) +- `src.ai_client._strip_cache_controls` (line 1291) +- `src.ai_client._estimate_message_tokens` (line 1218) ### `src\app_controller.py` (5 consumers) -- `src.app_controller._on_comms_entry` (line 0) -- `src.app_controller._offload_entry_payload` (line 0) -- `src.app_controller._start_track_logic` (line 0) -- `src.app_controller._refresh_api_metrics` (line 0) -- `src.app_controller._start_track_logic_result` (line 0) +- `src.app_controller._refresh_api_metrics` (line 3074) +- `src.app_controller._on_comms_entry` (line 4282) +- `src.app_controller._start_track_logic` (line 4721) +- `src.app_controller._offload_entry_payload` (line 4240) +- `src.app_controller._start_track_logic_result` (line 4728) -### `src\models.py` (2 consumers) +### `src\models.py` (22 consumers) -- `src.models._save_config_to_disk` (line 0) -- `src.models.from_dict` (line 0) +- `src.models.from_dict` (line 575) +- `src.models.from_dict` (line 656) +- `src.models.from_dict` (line 920) +- `src.models.from_dict` (line 416) +- `src.models.from_dict` (line 1072) +- `src.models.from_dict` (line 295) +- `src.models.from_dict` (line 506) +- `src.models.from_dict` (line 603) +- `src.models.from_dict` (line 814) +- `src.models.from_dict` (line 378) +- `src.models.from_dict` (line 893) +- `src.models.from_dict` (line 1038) +- `src.models.from_dict` (line 1007) +- `src.models.from_dict` (line 712) +- `src.models._save_config_to_disk` (line 199) +- `src.models.from_dict` (line 866) +- `src.models.from_dict` (line 747) +- `src.models.from_dict` (line 683) +- `src.models.from_dict` (line 630) +- `src.models.from_dict` (line 454) +- `src.models.from_dict` (line 949) +- `src.models.from_dict` (line 982) ### `src\project_manager.py` (5 consumers) -- `src.project_manager.format_discussion` (line 0) -- `src.project_manager.flat_config` (line 0) -- `src.project_manager.entry_to_str` (line 0) -- `src.project_manager.migrate_from_legacy_config` (line 0) -- `src.project_manager.save_project` (line 0) +- `src.project_manager.migrate_from_legacy_config` (line 253) +- `src.project_manager.save_project` (line 229) +- `src.project_manager.format_discussion` (line 69) +- `src.project_manager.entry_to_str` (line 49) +- `src.project_manager.flat_config` (line 267) ## Field access matrix | consumer | _est_tokens | _gemini_cache_text | _offload_entry_payload | _pending_comms | _pending_comms_lock | _pending_gui_tasks | _pending_gui_tasks_lock | _pending_history_adds | _pending_history_adds_lock | _recalculate_session_usage | _start_track_logic_result | _token_history | _token_stats | _topological_sort_tickets_result | _update_cached_stats | active_discussion | active_project_path | active_project_root | ai_status | append | |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---| -| `_strip_stale_file_refreshes` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `format_discussion` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_build_files_section_from_items` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_append_comms` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_trim_anthropic_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_save_config_to_disk` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_on_comms_entry` | . | . | 1 | 1 | 1 | . | . | 4 | 4 | . | . | 1 | . | . | . | . | . | . | . | . | -| `_execute_single_tool_call_async` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_dashscope_call` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `ollama_chat` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_pre_dispatch` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_strip_cache_controls` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_estimate_prompt_tokens` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_add_history_cache_breakpoint` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `flat_config` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_offload_entry_payload` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_repair_minimax_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 1 | -| `_strip_private_keys` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_repair_deepseek_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 1 | -| `entry_to_str` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `build_tier3_context` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_estimate_message_tokens` | 1 | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `migrate_from_legacy_config` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `run` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `save_project` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | | `build_markdown_from_items` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_start_track_logic` | . | . | . | . | . | . | . | . | . | . | 1 | . | . | . | . | . | . | . | 1 | . | +| `_send_anthropic` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | | `_refresh_api_metrics` | . | 1 | . | . | . | . | . | . | . | 1 | . | . | 1 | . | 1 | . | . | . | . | . | -| `_start_track_logic_result` | . | . | . | . | . | 2 | 2 | . | . | . | . | . | . | 1 | . | 1 | 1 | 1 | 4 | . | -| `_add_bleed_derived` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_add_history_cache_breakpoint` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_append_comms` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_repair_deepseek_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 1 | +| `_dashscope_call` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_grok` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `build_tier3_context` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | | `build_markdown_no_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_invalidate_token_estimate` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_repair_anthropic_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 1 | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `migrate_from_legacy_config` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_on_comms_entry` | . | . | 1 | 1 | 1 | . | . | 4 | 4 | . | . | 1 | . | . | . | . | . | . | . | . | +| `run` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | | `_trim_minimax_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_start_track_logic` | . | . | . | . | . | . | . | . | . | . | 1 | . | . | . | . | . | . | . | 1 | . | +| `save_project` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_gemini` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `format_discussion` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_repair_minimax_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 1 | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_repair_anthropic_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 1 | +| `_pre_dispatch` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_strip_stale_file_refreshes` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `send` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_offload_entry_payload` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_start_track_logic_result` | . | . | . | . | . | 2 | 2 | . | . | . | . | . | . | 1 | . | 1 | 1 | 1 | 4 | . | +| `_send_minimax` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_llama_native` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_create_gemini_cache_result` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `entry_to_str` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_save_config_to_disk` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_qwen` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_trim_anthropic_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_strip_private_keys` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_estimate_prompt_tokens` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `ollama_chat` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_execute_single_tool_call_async` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `flat_config` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_deepseek` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_llama` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_add_bleed_derived` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_gemini_cli` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_build_files_section_from_items` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_invalidate_token_estimate` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_strip_cache_controls` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_estimate_message_tokens` | 1 | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -_... 33 more fields_ +_... 35 more fields_ ## Access pattern **Dominant pattern:** whole_struct -**Evidence count:** 35 +**Evidence count:** 66 **Per-function pattern distribution:** -- `whole_struct`: 25 functions (71%) -- `field_by_field`: 5 functions (14%) -- `mixed`: 5 functions (14%) +- `whole_struct`: 35 functions (53%) +- `mixed`: 26 functions (39%) +- `field_by_field`: 5 functions (8%) ## SSDL Sketch for `Metadata` ``` [Q:Metadata entry-point] -> [Q:PCG lookup] - -> [1: _strip_stale_file_refreshes] [B:check] (branches=12) - -> [2: format_discussion] [B:check] (branches=0) - -> [3: _build_files_section_from_items] [B:is None?] (branches=5) [N:safe] - -> [4: _append_comms] [B:is None?] (branches=1) [N:safe] - -> [5: _trim_anthropic_history] [B:check] (branches=13) - -> [6: _save_config_to_disk] [B:check] (branches=1) - -> [7: _on_comms_entry] [B:check] (branches=32) - -> [8: _execute_single_tool_call_async] [B:is None?] (branches=15) [N:safe] - -> [9: _dashscope_call] [B:check] (branches=5) - -> [10: ollama_chat] [B:check] (branches=3) - -> [11: _pre_dispatch] [B:check] (branches=8) - -> [12: _strip_cache_controls] [B:check] (branches=4) - -> [13: _estimate_prompt_tokens] [B:check] (branches=2) - -> [14: _add_history_cache_breakpoint] [B:check] (branches=5) - -> [15: flat_config] [B:check] (branches=2) - -> [16: _offload_entry_payload] [B:check] (branches=10) - -> [17: _repair_minimax_history] [B:check] (branches=10) - -> [18: _strip_private_keys] [B:check] (branches=0) - -> [19: _repair_deepseek_history] [B:check] (branches=6) - -> [20: entry_to_str] [B:check] (branches=3) - -> [21: build_tier3_context] [B:check] (branches=50) - -> [22: _estimate_message_tokens] [B:is None?] (branches=9) [N:safe] - -> [23: migrate_from_legacy_config] [B:check] (branches=2) - -> [24: run] [B:check] (branches=1) - -> [25: from_dict] [B:check] (branches=0) - -> [26: save_project] [B:is None?] (branches=7) [N:safe] - -> [27: build_markdown_from_items] [B:check] (branches=9) - -> [28: _start_track_logic] [B:check] (branches=1) - -> [29: _refresh_api_metrics] [B:is None?] (branches=11) [N:safe] - -> [30: _start_track_logic_result] [B:check] (branches=10) - -> [31: _add_bleed_derived] [B:check] (branches=0) - -> [32: build_markdown_no_history] [B:check] (branches=0) - -> [33: _invalidate_token_estimate] [B:check] (branches=0) - -> [34: _repair_anthropic_history] [B:check] (branches=6) - -> [35: _trim_minimax_history] [B:check] (branches=8) + -> [1: build_markdown_from_items] [B:check] (branches=9) + -> [2: _send_anthropic] [B:is None?] (branches=40) [N:safe] + -> [3: _refresh_api_metrics] [B:is None?] (branches=11) [N:safe] + -> [4: from_dict] [B:check] (branches=0) + -> [5: _add_history_cache_breakpoint] [B:check] (branches=5) + -> [6: _append_comms] [B:is None?] (branches=1) [N:safe] + -> [7: from_dict] [B:check] (branches=0) + -> [8: from_dict] [B:check] (branches=0) + -> [9: _repair_deepseek_history] [B:check] (branches=6) + -> [10: _dashscope_call] [B:check] (branches=5) + -> [11: from_dict] [B:check] (branches=0) + -> [12: _send_grok] [B:check] (branches=14) + -> [13: from_dict] [B:check] (branches=0) + -> [14: from_dict] [B:check] (branches=0) + -> [15: build_tier3_context] [B:check] (branches=50) + -> [16: build_markdown_no_history] [B:check] (branches=0) + -> [17: from_dict] [B:check] (branches=0) + -> [18: from_dict] [B:check] (branches=0) + -> [19: migrate_from_legacy_config] [B:check] (branches=2) + -> [20: from_dict] [B:check] (branches=0) + -> [21: _on_comms_entry] [B:check] (branches=32) + -> [22: run] [B:check] (branches=1) + -> [23: _trim_minimax_history] [B:check] (branches=8) + -> [24: _start_track_logic] [B:check] (branches=1) + -> [25: save_project] [B:is None?] (branches=7) [N:safe] + -> [26: _send_gemini] [B:is None?] (branches=75) [N:safe] + -> [27: from_dict] [B:check] (branches=0) + -> [28: format_discussion] [B:check] (branches=0) + -> [29: _repair_minimax_history] [B:check] (branches=10) + -> [30: from_dict] [B:check] (branches=0) + -> [31: _repair_anthropic_history] [B:check] (branches=6) + -> [32: _pre_dispatch] [B:check] (branches=8) + -> [33: _strip_stale_file_refreshes] [B:check] (branches=12) + -> [34: send] [B:check] (branches=19) + -> [35: _offload_entry_payload] [B:check] (branches=10) + -> [36: _start_track_logic_result] [B:check] (branches=10) + -> [37: _send_minimax] [B:check] (branches=11) + -> [38: _send_llama_native] [B:check] (branches=12) + -> [39: from_dict] [B:check] (branches=0) + -> [40: _create_gemini_cache_result] [B:check] (branches=3) + -> [41: entry_to_str] [B:check] (branches=3) + -> [42: from_dict] [B:check] (branches=0) + -> [43: from_dict] [B:check] (branches=0) + -> [44: _save_config_to_disk] [B:check] (branches=1) + -> [45: _send_qwen] [B:check] (branches=9) + -> [46: from_dict] [B:check] (branches=0) + -> [47: from_dict] [B:check] (branches=0) + -> [48: _trim_anthropic_history] [B:check] (branches=13) + -> [49: _strip_private_keys] [B:check] (branches=0) + -> [50: _estimate_prompt_tokens] [B:check] (branches=2) + -> [51: ollama_chat] [B:check] (branches=3) + -> [52: _execute_single_tool_call_async] [B:is None?] (branches=15) [N:safe] + -> [53: flat_config] [B:check] (branches=2) + -> [54: _send_deepseek] [B:check] (branches=71) + -> [55: _send_llama] [B:check] (branches=13) + -> [56: _add_bleed_derived] [B:check] (branches=0) + -> [57: _send_gemini_cli] [B:is None?] (branches=23) [N:safe] + -> [58: _build_files_section_from_items] [B:is None?] (branches=5) [N:safe] + -> [59: from_dict] [B:check] (branches=0) + -> [60: from_dict] [B:check] (branches=0) + -> [61: _invalidate_token_estimate] [B:check] (branches=0) + -> [62: from_dict] [B:check] (branches=0) + -> [63: _strip_cache_controls] [B:check] (branches=4) + -> [64: from_dict] [B:check] (branches=0) + -> [65: from_dict] [B:check] (branches=0) + -> [66: _estimate_message_tokens] [B:is None?] (branches=9) [N:safe] -> [T:done] ``` -**Effective codepaths:** 1125904201862042 (sum of 2^branches across 35 consumers) -**Total branch points:** 251 -**Nil-check functions:** 6 +**Effective codepaths:** 40140116231395706750390 (sum of 2^branches across 66 consumers) +**Total branch points:** 541 +**Nil-check functions:** 9 **Defusing opportunities:** - **Nil Sentinel `[N]`**: Introduce a module-level `NIL_` sentinel whose field accesses return safe defaults. Replace None checks with the sentinel. Collapses 2^branch_count into ~1. - - Effective codepaths: 1125904201862042 -> 1125904201862030 -- **Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]`**: Introduce a `metadata_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 130 field-check branches to 1 cache lookup. - - Effective codepaths: 1125904201862042 -> 130 + - Effective codepaths: 40140116231395706750390 -> 40140116231395706750372 +- **Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]`**: Introduce a `metadata_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 173 field-check branches to 1 cache lookup. + - Effective codepaths: 40140116231395706750390 -> 173 - **Generational Handles `[I:ResolveHandle] -> [B:Gen matches?] -> [N|safe]`**: Wrap the aggregate in a generational handle (index + generation). Validation is one comparison; mismatch returns the nil sentinel. Reduces N lifetime branches to 1 handle validation + sentinel return. - - Effective codepaths: 1125904201862042 -> 35 + - Effective codepaths: 40140116231395706750390 -> 66 ## Frequency @@ -578,24 +714,24 @@ _... 33 more fields_ ## Result coverage -**Summary:** 77 producers, 35 consumers +**Summary:** 96 producers, 46 consumers | metric | value | |---|---| -| total producers | 77 | -| result producers | 77 | -| total consumers | 35 | +| total producers | 96 | +| result producers | 96 | +| total consumers | 46 | | result consumers | 0 | ## Type alias coverage -**Summary:** 130 sites; 0 typed (0%); 130 untyped (100%) +**Summary:** 173 sites; 0 typed (0%); 173 untyped (100%) | metric | value | |---|---| -| total field-access sites | 130 | +| total field-access sites | 173 | | typed sites (canonical field) | 0 | -| untyped sites (wildcard) | 130 | +| untyped sites (wildcard) | 173 | ## Cross-audit findings @@ -617,27 +753,15 @@ _... 33 more fields_ | field | access count | access pattern | |---|---|---| +| `content` | 21 | hot | +| `marker` | 21 | hot | | `get` | 10 | hot | -| `pop` | 3 | hot | | `append` | 3 | hot | +| `pop` | 3 | hot | | `session_usage` | 2 | used | | `files` | 2 | used | | `ai_status` | 2 | used | -| `local_ts` | 1 | used | -| `_offload_entry_payload` | 1 | used | -| `ui_auto_add_history` | 1 | used | -| `_pending_comms_lock` | 1 | used | -| `_pending_history_adds_lock` | 1 | used | -| `_token_history` | 1 | used | -| `_pending_comms` | 1 | used | -| `_pending_history_adds` | 1 | used | -| `items` | 1 | used | -| `_est_tokens` | 1 | used | -| `output` | 1 | used | -| `content` | 1 | used | -| `marker` | 1 | used | -| `discussion` | 1 | used | -| `_start_track_logic_result` | 1 | used | +| `config` | 2 | used | | `latency` | 1 | used | | `_recalculate_session_usage` | 1 | used | | `_token_stats` | 1 | used | @@ -647,6 +771,19 @@ _... 33 more fields_ | `error` | 1 | used | | `_update_cached_stats` | 1 | used | | `usage` | 1 | used | +| `local_ts` | 1 | used | +| `_offload_entry_payload` | 1 | used | +| `ui_auto_add_history` | 1 | used | +| `_pending_comms_lock` | 1 | used | +| `_pending_history_adds_lock` | 1 | used | +| `_token_history` | 1 | used | +| `_pending_comms` | 1 | used | +| `_pending_history_adds` | 1 | used | +| `output` | 1 | used | +| `_start_track_logic_result` | 1 | used | +| `discussion` | 1 | used | +| `encode` | 1 | used | +| `search` | 1 | used | | `context_files` | 1 | used | | `_pending_gui_tasks_lock` | 1 | used | | `_topological_sort_tickets_result` | 1 | used | @@ -657,11 +794,11 @@ _... 33 more fields_ | `active_discussion` | 1 | used | | `submit_io` | 1 | used | | `tracks` | 1 | used | -| `config` | 1 | used | | `mma_tier_usage` | 1 | used | | `_pending_gui_tasks` | 1 | used | | `mma_step_mode` | 1 | used | | `active_project_path` | 1 | used | +| `items` | 1 | used | | `estimated_prompt_tokens` | 1 | used | | `max_prompt_tokens` | 1 | used | | `utilization_pct` | 1 | used | @@ -670,6 +807,7 @@ _... 33 more fields_ | `sys_tokens` | 1 | used | | `tool_tokens` | 1 | used | | `history_tokens` | 1 | used | +| `_est_tokens` | 1 | used | ## Optimization candidates @@ -685,51 +823,82 @@ Metadata: access_pattern=whole_struct, frequency=per_turn, struct_field_count=10 | function | pattern | field_accesses | confidence | |---|---|---|---| -| `src.ai_client._strip_stale_file_refreshes` | `whole_struct` | | low | -| `src.project_manager.format_discussion` | `whole_struct` | | low | -| `src.aggregate._build_files_section_from_items` | `whole_struct` | | low | -| `src.ai_client._append_comms` | `whole_struct` | | low | -| `src.ai_client._trim_anthropic_history` | `whole_struct` | `pop`=5 | high | -| `src.models._save_config_to_disk` | `whole_struct` | | low | -| `src.app_controller._on_comms_entry` | `field_by_field` | `local_ts`=1, `_offload_entry_payload`=1, `get`=7, `ui_auto_add_history`=3, `_pending_comms_lock`=1, `session_usage`=5, `_pending_history_adds_lock`=4, `_token_history`=1, `_pending_comms`=1, `_pending_history_adds`=4 | high | -| `src.ai_client._execute_single_tool_call_async` | `mixed` | `get`=2, `items`=1 | high | -| `src.ai_client._dashscope_call` | `whole_struct` | | low | -| `src.ai_client.ollama_chat` | `whole_struct` | | low | -| `src.ai_client._pre_dispatch` | `whole_struct` | | low | -| `src.ai_client._strip_cache_controls` | `whole_struct` | | low | -| `src.ai_client._estimate_prompt_tokens` | `whole_struct` | | low | -| `src.ai_client._add_history_cache_breakpoint` | `whole_struct` | | low | -| `src.project_manager.flat_config` | `whole_struct` | `get`=7 | high | -| `src.app_controller._offload_entry_payload` | `whole_struct` | | low | -| `src.ai_client._repair_minimax_history` | `whole_struct` | `append`=1 | high | -| `src.ai_client._strip_private_keys` | `whole_struct` | | low | -| `src.ai_client._repair_deepseek_history` | `whole_struct` | `append`=1 | high | -| `src.project_manager.entry_to_str` | `whole_struct` | `get`=4 | high | -| `src.aggregate.build_tier3_context` | `whole_struct` | | low | -| `src.ai_client._estimate_message_tokens` | `mixed` | `_est_tokens`=1, `get`=2 | high | -| `src.project_manager.migrate_from_legacy_config` | `whole_struct` | `get`=2 | high | -| `src.aggregate.run` | `field_by_field` | `output`=1, `files`=2, `get`=7 | high | -| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | -| `src.project_manager.save_project` | `mixed` | `discussion`=2, `files`=3 | high | | `src.aggregate.build_markdown_from_items` | `whole_struct` | | low | -| `src.app_controller._start_track_logic` | `mixed` | `_start_track_logic_result`=1, `ai_status`=1 | high | +| `src.ai_client._send_anthropic` | `whole_struct` | | low | | `src.app_controller._refresh_api_metrics` | `field_by_field` | `latency`=1, `_recalculate_session_usage`=1, `_token_stats`=1, `get`=2, `_gemini_cache_text`=1, `vendor_quota`=1, `last_error`=1, `error`=2, `_update_cached_stats`=1, `session_usage`=2 (+1 more) | high | -| `src.app_controller._start_track_logic_result` | `field_by_field` | `ai_status`=4, `context_files`=1, `get`=3, `_pending_gui_tasks_lock`=2, `_topological_sort_tickets_result`=1, `active_project_root`=1, `event_queue`=1, `engines`=1, `project`=1, `active_discussion`=1 (+7 more) | high | -| `src.ai_client._add_bleed_derived` | `field_by_field` | `estimated_prompt_tokens`=1, `max_prompt_tokens`=1, `utilization_pct`=1, `headroom`=1, `would_trim`=1, `sys_tokens`=1, `tool_tokens`=1, `history_tokens`=1, `get`=3 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._add_history_cache_breakpoint` | `whole_struct` | | low | +| `src.ai_client._append_comms` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._repair_deepseek_history` | `whole_struct` | `append`=1 | high | +| `src.ai_client._dashscope_call` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._send_grok` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.aggregate.build_tier3_context` | `whole_struct` | | low | | `src.aggregate.build_markdown_no_history` | `whole_struct` | | low | -| `src.ai_client._invalidate_token_estimate` | `whole_struct` | `pop`=1 | high | -| `src.ai_client._repair_anthropic_history` | `whole_struct` | `append`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.project_manager.migrate_from_legacy_config` | `whole_struct` | `get`=2 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.app_controller._on_comms_entry` | `field_by_field` | `local_ts`=1, `_offload_entry_payload`=1, `get`=7, `ui_auto_add_history`=3, `_pending_comms_lock`=1, `session_usage`=5, `_pending_history_adds_lock`=4, `_token_history`=1, `_pending_comms`=1, `_pending_history_adds`=4 | high | +| `src.aggregate.run` | `field_by_field` | `output`=1, `files`=2, `get`=7 | high | | `src.ai_client._trim_minimax_history` | `whole_struct` | `pop`=4 | high | +| `src.app_controller._start_track_logic` | `mixed` | `_start_track_logic_result`=1, `ai_status`=1 | high | +| `src.project_manager.save_project` | `mixed` | `discussion`=2, `files`=3 | high | +| `src.ai_client._send_gemini` | `whole_struct` | `encode`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.project_manager.format_discussion` | `whole_struct` | | low | +| `src.ai_client._repair_minimax_history` | `whole_struct` | `append`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._repair_anthropic_history` | `whole_struct` | `append`=1 | high | +| `src.ai_client._pre_dispatch` | `whole_struct` | | low | +| `src.ai_client._strip_stale_file_refreshes` | `whole_struct` | | low | +| `src.ai_client.send` | `mixed` | `config`=1, `search`=1 | high | +| `src.app_controller._offload_entry_payload` | `whole_struct` | | low | +| `src.app_controller._start_track_logic_result` | `field_by_field` | `ai_status`=4, `context_files`=1, `get`=3, `_pending_gui_tasks_lock`=2, `_topological_sort_tickets_result`=1, `active_project_root`=1, `event_queue`=1, `engines`=1, `project`=1, `active_discussion`=1 (+7 more) | high | +| `src.ai_client._send_minimax` | `whole_struct` | | low | +| `src.ai_client._send_llama_native` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._create_gemini_cache_result` | `whole_struct` | | low | +| `src.project_manager.entry_to_str` | `whole_struct` | `get`=4 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models._save_config_to_disk` | `whole_struct` | | low | +| `src.ai_client._send_qwen` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._trim_anthropic_history` | `whole_struct` | `pop`=5 | high | +| `src.ai_client._strip_private_keys` | `whole_struct` | | low | +| `src.ai_client._estimate_prompt_tokens` | `whole_struct` | | low | +| `src.ai_client.ollama_chat` | `whole_struct` | | low | +| `src.ai_client._execute_single_tool_call_async` | `mixed` | `get`=2, `items`=1 | high | +| `src.project_manager.flat_config` | `whole_struct` | `get`=7 | high | +| `src.ai_client._send_deepseek` | `whole_struct` | | low | +| `src.ai_client._send_llama` | `whole_struct` | | low | +| `src.ai_client._add_bleed_derived` | `field_by_field` | `estimated_prompt_tokens`=1, `max_prompt_tokens`=1, `utilization_pct`=1, `headroom`=1, `would_trim`=1, `sys_tokens`=1, `tool_tokens`=1, `history_tokens`=1, `get`=3 | high | +| `src.ai_client._send_gemini_cli` | `whole_struct` | | low | +| `src.aggregate._build_files_section_from_items` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._invalidate_token_estimate` | `whole_struct` | `pop`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._strip_cache_controls` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._estimate_message_tokens` | `mixed` | `_est_tokens`=1, `get`=2 | high | ### Frequency evidence | function | frequency | source | note | |---|---|---|---| -| `src.api_hook_client.get_performance` | `per_turn` | `static_analysis` | producer from src\api_hook_client.py | -| `src.app_controller.get_performance` | `per_turn` | `static_analysis` | producer from src\app_controller.py | -| `src.ai_client._send_cli_round_result` | `per_turn` | `static_analysis` | producer from src\ai_client.py | -| `src.api_hook_client.post_session` | `per_turn` | `static_analysis` | producer from src\api_hook_client.py | -| `src.app_controller.wait` | `per_turn` | `static_analysis` | producer from src\app_controller.py | +| `src.models.to_dict` | `per_turn` | `static_analysis` | producer from src\models.py | +| `src.api_hook_client.get_gui_diagnostics` | `per_turn` | `static_analysis` | producer from src\api_hook_client.py | +| `src.models.to_dict` | `per_turn` | `static_analysis` | producer from src\models.py | +| `src.app_controller._api_get_api_project` | `per_turn` | `static_analysis` | producer from src\app_controller.py | +| `src.api_hook_client.clear_events` | `per_turn` | `static_analysis` | producer from src\api_hook_client.py | --- @@ -745,9 +914,9 @@ Metadata: access_pattern=whole_struct, frequency=per_turn, struct_field_count=10 ## Pipeline summary - Producers: 0 -- Consumers: 3 +- Consumers: 4 - Distinct producer fqnames: 0 -- Distinct consumer fqnames: 3 +- Distinct consumer fqnames: 4 - Access pattern (aggregate): whole_struct - Frequency (aggregate): per_turn - Decomposition direction: hold @@ -757,47 +926,56 @@ Metadata: access_pattern=whole_struct, frequency=per_turn, struct_field_count=10 _(none)_ -## Consumers (3) +## Consumers (4) -### `src\ai_client.py` (3 consumers) +### `src\ai_client.py` (4 consumers) -- `src.ai_client._build_file_diff_text` (line 0) -- `src.ai_client._build_file_context_text` (line 0) -- `src.ai_client._reread_file_items_result` (line 0) +- `src.ai_client._build_file_diff_text` (line 1105) +- `src.ai_client.run_with_tool_loop` (line 833) +- `src.ai_client._build_file_context_text` (line 1092) +- `src.ai_client._reread_file_items_result` (line 1056) ## Field access matrix -_(no field accesses detected)_ +| consumer | append | +|---|---| +| `_build_file_diff_text` | . | +| `run_with_tool_loop` | 2 | +| `_build_file_context_text` | . | +| `_reread_file_items_result` | . | ## Access pattern **Dominant pattern:** whole_struct -**Evidence count:** 3 +**Evidence count:** 4 **Per-function pattern distribution:** -- `whole_struct`: 3 functions (100%) +- `whole_struct`: 4 functions (100%) ## SSDL Sketch for `FileItems` ``` [Q:FileItems entry-point] -> [Q:PCG lookup] -> [1: _build_file_diff_text] [B:check] (branches=6) - -> [2: _build_file_context_text] [B:check] (branches=3) - -> [3: _reread_file_items_result] [B:is None?] (branches=5) [N:safe] + -> [2: run_with_tool_loop] [B:is None?] (branches=23) [N:safe] + -> [3: _build_file_context_text] [B:check] (branches=3) + -> [4: _reread_file_items_result] [B:is None?] (branches=5) [N:safe] -> [T:done] ``` -**Effective codepaths:** 104 (sum of 2^branches across 3 consumers) -**Total branch points:** 14 -**Nil-check functions:** 1 +**Effective codepaths:** 8388712 (sum of 2^branches across 4 consumers) +**Total branch points:** 37 +**Nil-check functions:** 2 **Defusing opportunities:** - **Nil Sentinel `[N]`**: Introduce a module-level `NIL_` sentinel whose field accesses return safe defaults. Replace None checks with the sentinel. Collapses 2^branch_count into ~1. - - Effective codepaths: 104 -> 102 -- **Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]`**: Introduce a `fileitems_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 0 field-check branches to 1 cache lookup. - - Effective codepaths: 104 -> 1 + - Effective codepaths: 8388712 -> 8388708 +- **Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]`**: Introduce a `fileitems_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 2 field-check branches to 1 cache lookup. + - Effective codepaths: 8388712 -> 2 +- **Generational Handles `[I:ResolveHandle] -> [B:Gen matches?] -> [N|safe]`**: Wrap the aggregate in a generational handle (index + generation). Validation is one comparison; mismatch returns the nil sentinel. Reduces N lifetime branches to 1 handle validation + sentinel return. + - Effective codepaths: 8388712 -> 4 ## Frequency @@ -807,24 +985,24 @@ _(no field accesses detected)_ ## Result coverage -**Summary:** 0 producers, 3 consumers +**Summary:** 0 producers, 4 consumers | metric | value | |---|---| | total producers | 0 | | result producers | 0 | -| total consumers | 3 | +| total consumers | 4 | | result consumers | 0 | ## Type alias coverage -**Summary:** 0 sites +**Summary:** 2 sites; 0 typed (0%); 2 untyped (100%) | metric | value | |---|---| -| total field-access sites | 0 | +| total field-access sites | 2 | | typed sites (canonical field) | 0 | -| untyped sites (wildcard) | 0 | +| untyped sites (wildcard) | 2 | ## Cross-audit findings @@ -859,6 +1037,7 @@ FileItems: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5 | function | pattern | field_accesses | confidence | |---|---|---|---| | `src.ai_client._build_file_diff_text` | `whole_struct` | | low | +| `src.ai_client.run_with_tool_loop` | `whole_struct` | `append`=2 | high | | `src.ai_client._build_file_context_text` | `whole_struct` | | low | | `src.ai_client._reread_file_items_result` | `whole_struct` | | low | @@ -875,32 +1054,34 @@ FileItems: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5 ## Pipeline summary -- Producers: 0 +- Producers: 1 - Consumers: 2 -- Distinct producer fqnames: 0 +- Distinct producer fqnames: 1 - Distinct consumer fqnames: 2 - Access pattern (aggregate): mixed - Frequency (aggregate): per_turn - Decomposition direction: insufficient_data - Struct field count (estimated): 5 -## Producers (0) +## Producers (1) -_(none)_ +### `src\provider_state.py` (1 producer) + +- `src.provider_state.get_all` (line 34) ## Consumers (2) ### `src\provider_state.py` (2 consumers) -- `src.provider_state.replace_all` (line 0) -- `src.provider_state.append` (line 0) +- `src.provider_state.append` (line 30) +- `src.provider_state.replace_all` (line 38) ## Field access matrix | consumer | lock | messages | |---|---|---| -| `replace_all` | 1 | 1 | | `append` | 1 | 1 | +| `replace_all` | 1 | 1 | ## Access pattern @@ -915,8 +1096,8 @@ _(none)_ ``` [Q:HistoryMessage entry-point] -> [Q:PCG lookup] - -> [1: replace_all] [B:check] (branches=1) - -> [2: append] [B:check] (branches=1) + -> [1: append] [B:check] (branches=1) + -> [2: replace_all] [B:check] (branches=1) -> [T:done] ``` @@ -933,16 +1114,20 @@ _(none)_ ## Frequency **Dominant frequency:** per_turn -**Evidence count:** 0 +**Evidence count:** 1 + +**Per-function frequency distribution:** + +- `per_turn`: 1 functions ## Result coverage -**Summary:** 0 producers, 2 consumers +**Summary:** 1 producers, 2 consumers | metric | value | |---|---| -| total producers | 0 | -| result producers | 0 | +| total producers | 1 | +| result producers | 1 | | total consumers | 2 | | result consumers | 0 | @@ -972,7 +1157,10 @@ _(no cross-audit findings mapped to this aggregate)_ ## Struct shape (inferred from producer returns) -_(no producers; cannot infer shape)_ +| field | access count | access pattern | +|---|---|---| +| `lock` | 2 | used | +| `messages` | 2 | used | ## Optimization candidates @@ -988,8 +1176,14 @@ HistoryMessage: access_pattern=mixed, frequency=per_turn, struct_field_count=5, | function | pattern | field_accesses | confidence | |---|---|---|---| -| `src.provider_state.replace_all` | `mixed` | `lock`=1, `messages`=1 | high | | `src.provider_state.append` | `mixed` | `lock`=1, `messages`=1 | high | +| `src.provider_state.replace_all` | `mixed` | `lock`=1, `messages`=1 | high | + +### Frequency evidence + +| function | frequency | source | note | +|---|---|---|---| +| `src.provider_state.get_all` | `per_turn` | `static_analysis` | producer from src\provider_state.py | --- @@ -1017,13 +1211,13 @@ HistoryMessage: access_pattern=mixed, frequency=per_turn, struct_field_count=5, ### `src\openai_compatible.py` (1 producer) -- `src.openai_compatible._to_typed_tool_call` (line 0) +- `src.openai_compatible._to_typed_tool_call` (line 43) ## Consumers (1) ### `src\openai_compatible.py` (1 consumer) -- `src.openai_compatible._to_dict_tool_call` (line 0) +- `src.openai_compatible._to_dict_tool_call` (line 54) ## Field access matrix @@ -1693,18 +1887,21 @@ Result: access_pattern=mixed, frequency=per_turn, struct_field_count=5, struct_f ## Pipeline summary -- Producers: 0 +- Producers: 2 - Consumers: 0 -- Distinct producer fqnames: 0 +- Distinct producer fqnames: 2 - Distinct consumer fqnames: 0 - Access pattern (aggregate): mixed - Frequency (aggregate): per_turn - Decomposition direction: insufficient_data - Struct field count (estimated): 5 -## Producers (0) +## Producers (2) -_(none)_ +### `src\ai_client.py` (2 producers) + +- `src.ai_client._build_anthropic_tools` (line 623) +- `src.ai_client._build_deepseek_tools` (line 1148) ## Consumers (0) @@ -1739,16 +1936,20 @@ _(no field accesses detected)_ ## Frequency **Dominant frequency:** per_turn -**Evidence count:** 0 +**Evidence count:** 2 + +**Per-function frequency distribution:** + +- `per_turn`: 2 functions ## Result coverage -**Summary:** 0 producers, 0 consumers +**Summary:** 2 producers, 0 consumers | metric | value | |---|---| -| total producers | 0 | -| result producers | 0 | +| total producers | 2 | +| result producers | 2 | | total consumers | 0 | | result consumers | 0 | @@ -1764,7 +1965,9 @@ _(no field accesses detected)_ ## Cross-audit findings -_(no cross-audit findings mapped to this aggregate)_ +| bucket | audit script | site count | example file | example line | note | +|---|---|---|---|---|---| +| optional_in_baseline | `audit_optional_in_3_files` | 76 | `src\ai_client.py` | 159 | 76 sites | ## Decomposition cost @@ -1778,7 +1981,7 @@ _(no cross-audit findings mapped to this aggregate)_ ## Struct shape (inferred from producer returns) -_(no producers; cannot infer shape)_ +_(no field access data; cannot infer shape)_ ## Optimization candidates @@ -1790,6 +1993,13 @@ ToolDefinition: access_pattern=mixed, frequency=per_turn, struct_field_count=5, ## Evidence appendix +### Frequency evidence + +| function | frequency | source | note | +|---|---|---|---| +| `src.ai_client._build_anthropic_tools` | `per_turn` | `static_analysis` | producer from src\ai_client.py | +| `src.ai_client._build_deepseek_tools` | `per_turn` | `static_analysis` | producer from src\ai_client.py | + --- @@ -2097,8 +2307,8 @@ Per-aggregate analysis: effective codepaths, branch points, defusing opportuniti | Aggregate | Consumers | Total branches | Effective codepaths | Field efficiency | |---|---|---|---|---| -| `Metadata` | 35 | 251 | 1125904201862042 | 0% | -| `FileItems` | 3 | 14 | 104 | 0% | +| `Metadata` | 66 | 541 | 40140116231395706750390 | 0% | +| `FileItems` | 4 | 37 | 8388712 | 0% | | `HistoryMessage` | 2 | 2 | 4 | 0% | | `ToolCall` | 1 | 0 | 1 | 0% | | `FileItem` | 0 | 0 | 0 | 0% | @@ -2112,38 +2322,45 @@ Per-aggregate analysis: effective codepaths, branch points, defusing opportuniti ### `Metadata` - Generational Handles `[I:ResolveHandle] -> [B:Gen matches?] -> [N|safe]` -- **Location:** Metadata consumers have 251 explicit branch points total -- **Current state:** Branch explosion: 251 branches = 1125904201862042 effective codepaths +- **Location:** Metadata consumers have 541 explicit branch points total +- **Current state:** Branch explosion: 541 branches = 40140116231395706750390 effective codepaths - **Recommended change:** Wrap the aggregate in a generational handle (index + generation). Validation is one comparison; mismatch returns the nil sentinel. Reduces N lifetime branches to 1 handle validation + sentinel return. -- **Effective codepaths:** 1125904201862042 -> 35 +- **Effective codepaths:** 40140116231395706750390 -> 66 ### `Metadata` - Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]` -- **Location:** Metadata consumers access 130 sites, only 0 typed (0%) +- **Location:** Metadata consumers access 173 sites, only 0 typed (0%) - **Current state:** Many consumers use wildcard or defensive access patterns -- **Recommended change:** Introduce a `metadata_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 130 field-check branches to 1 cache lookup. -- **Effective codepaths:** 1125904201862042 -> 130 +- **Recommended change:** Introduce a `metadata_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 173 field-check branches to 1 cache lookup. +- **Effective codepaths:** 40140116231395706750390 -> 173 ### `FileItems` - Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]` -- **Location:** FileItems consumers access 0 sites, only 0 typed (0%) +- **Location:** FileItems consumers access 2 sites, only 0 typed (0%) - **Current state:** Many consumers use wildcard or defensive access patterns -- **Recommended change:** Introduce a `fileitems_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 0 field-check branches to 1 cache lookup. -- **Effective codepaths:** 104 -> 1 +- **Recommended change:** Introduce a `fileitems_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 2 field-check branches to 1 cache lookup. +- **Effective codepaths:** 8388712 -> 2 + +### `FileItems` - Generational Handles `[I:ResolveHandle] -> [B:Gen matches?] -> [N|safe]` + +- **Location:** FileItems consumers have 37 explicit branch points total +- **Current state:** Branch explosion: 37 branches = 8388712 effective codepaths +- **Recommended change:** Wrap the aggregate in a generational handle (index + generation). Validation is one comparison; mismatch returns the nil sentinel. Reduces N lifetime branches to 1 handle validation + sentinel return. +- **Effective codepaths:** 8388712 -> 4 ### `Metadata` - Nil Sentinel `[N]` -- **Location:** 6 consumer functions have `is None` / `== None` checks -- **Current state:** 6 nil-check branches contribute to branch explosion +- **Location:** 9 consumer functions have `is None` / `== None` checks +- **Current state:** 9 nil-check branches contribute to branch explosion - **Recommended change:** Introduce a module-level `NIL_` sentinel whose field accesses return safe defaults. Replace None checks with the sentinel. Collapses 2^branch_count into ~1. -- **Effective codepaths:** 1125904201862042 -> 1125904201862030 +- **Effective codepaths:** 40140116231395706750390 -> 40140116231395706750372 ### `FileItems` - Nil Sentinel `[N]` -- **Location:** 1 consumer function have `is None` / `== None` checks -- **Current state:** 1 nil-check branches contribute to branch explosion +- **Location:** 2 consumer functions have `is None` / `== None` checks +- **Current state:** 2 nil-check branches contribute to branch explosion - **Recommended change:** Introduce a module-level `NIL_` sentinel whose field accesses return safe defaults. Replace None checks with the sentinel. Collapses 2^branch_count into ~1. -- **Effective codepaths:** 104 -> 102 +- **Effective codepaths:** 8388712 -> 8388708 ### `HistoryMessage` - Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]` @@ -2173,13 +2390,6 @@ Per-aggregate analysis: effective codepaths, branch points, defusing opportuniti - **Recommended change:** Introduce a `commslogentry_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 0 field-check branches to 1 cache lookup. - **Effective codepaths:** 0 -> 1 -### `CommsLog` - Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]` - -- **Location:** CommsLog consumers access 0 sites, only 0 typed (0%) -- **Current state:** Many consumers use wildcard or defensive access patterns -- **Recommended change:** Introduce a `commslog_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 0 field-check branches to 1 cache lookup. -- **Effective codepaths:** 0 -> 1 - --- @@ -2198,11 +2408,13 @@ Cross-aggregate view of codebase organization. Verdicts derived from SSDL analys | file | aggregates produced | aggregates consumed | |---|---|---| -| `src\ai_client.py` | 1 | 2 | +| `src\ai_client.py` | 2 | 2 | +| `src\aggregate.py` | 1 | 1 | | `src\app_controller.py` | 1 | 1 | | `src\models.py` | 1 | 1 | | `src\openai_compatible.py` | 1 | 1 | | `src\project_manager.py` | 1 | 1 | +| `src\provider_state.py` | 1 | 1 | | `src\api_hook_client.py` | 1 | 0 | ### Files with high coupling (producers + consumers >= 8) @@ -2216,9 +2428,9 @@ These files are the central nervous system of the codebase. Changes ripple acros | Aggregate | Verdict | Notes | |---|---|---| -| `Metadata` | needs restructuring | 6 nil checks; 0% field efficiency; 1125904201862042 effective codepaths | +| `Metadata` | needs restructuring | 9 nil checks; 0% field efficiency; 40140116231395706750390 effective codepaths | | `FileItem` | needs restructuring | 0% field efficiency | -| `FileItems` | needs restructuring | 1 nil checks; 0% field efficiency; 104 effective codepaths | +| `FileItems` | needs restructuring | 2 nil checks; 0% field efficiency; 8388712 effective codepaths | | `CommsLogEntry` | needs restructuring | 0% field efficiency | | `CommsLog` | needs restructuring | 0% field efficiency | | `HistoryMessage` | needs restructuring | 0% field efficiency | @@ -2233,12 +2445,12 @@ These files are the central nervous system of the codebase. Changes ripple acros Top restructuring routes (by effective codepath count): -1. **`Metadata`**: 1125904201862042 effective codepaths (0% field efficiency) - - Apply nil sentinel to 6 nil-check functions - - Migrate to immediate-mode cache for 130 field-access sites -2. **`FileItems`**: 104 effective codepaths (0% field efficiency) - - Apply nil sentinel to 1 nil-check functions - - Migrate to immediate-mode cache for 0 field-access sites +1. **`Metadata`**: 40140116231395706750390 effective codepaths (0% field efficiency) + - Apply nil sentinel to 9 nil-check functions + - Migrate to immediate-mode cache for 173 field-access sites +2. **`FileItems`**: 8388712 effective codepaths (0% field efficiency) + - Apply nil sentinel to 2 nil-check functions + - Migrate to immediate-mode cache for 2 field-access sites 3. **`HistoryMessage`**: 4 effective codepaths (0% field efficiency) - Apply nil sentinel to 0 nil-check functions - Migrate to immediate-mode cache for 4 field-access sites @@ -2258,132 +2470,204 @@ Top restructuring routes (by effective codepath count): Functions that are producers or consumers of each aggregate, grouped by file. -## Metadata (77 producers + 35 consumers) +## Metadata (117 producers + 66 consumers) | role | fqname | file | |---|---|---| -| producer | `src.api_hook_client.get_performance` | `src\api_hook_client.py` | -| producer | `src.app_controller.get_performance` | `src\app_controller.py` | -| producer | `src.ai_client._send_cli_round_result` | `src\ai_client.py` | -| producer | `src.api_hook_client.post_session` | `src\api_hook_client.py` | -| producer | `src.app_controller.wait` | `src\app_controller.py` | -| producer | `src.app_controller.get_diagnostics` | `src\app_controller.py` | -| producer | `src.models._load_config_from_disk` | `src\models.py` | -| producer | `src.app_controller.get_gui_state` | `src\app_controller.py` | -| producer | `src.app_controller._api_status` | `src\app_controller.py` | -| producer | `src.app_controller._api_token_stats` | `src\app_controller.py` | -| producer | `src.ai_client.ollama_chat` | `src\ai_client.py` | -| producer | `src.api_hook_client.get_financial_metrics` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_status` | `src\api_hook_client.py` | -| producer | `src.app_controller._api_get_api_session` | `src\app_controller.py` | -| producer | `src.app_controller._api_get_context` | `src\app_controller.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.api_hook_client.get_gui_diagnostics` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.app_controller._api_get_api_project` | `src\app_controller.py` | +| producer | `src.api_hook_client.clear_events` | `src\api_hook_client.py` | +| producer | `src.ai_client._build_chunked_context_blocks` | `src\ai_client.py` | | producer | `src.app_controller.get_api_project` | `src\app_controller.py` | -| producer | `src.app_controller._api_get_performance` | `src\app_controller.py` | -| producer | `src.app_controller.status` | `src\app_controller.py` | -| producer | `src.ai_client._add_bleed_derived` | `src\ai_client.py` | -| producer | `src.api_hook_client.get_context_state` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_gui_health` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.post_project` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.select_list_item` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_io_pool_status` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.reject_patch` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_system_telemetry` | `src\api_hook_client.py` | -| producer | `src.app_controller._api_get_gui_state` | `src\app_controller.py` | -| producer | `src.app_controller._api_get_session` | `src\app_controller.py` | -| producer | `src.project_manager.load_history` | `src\project_manager.py` | -| producer | `src.app_controller.load_config` | `src\app_controller.py` | -| producer | `src.app_controller._api_get_mma_status` | `src\app_controller.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.api_hook_client.get_mma_workers` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.api_hook_client.get_startup_timeline` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.app_controller._offload_entry_payload` | `src\app_controller.py` | +| producer | `src.app_controller.generate` | `src\app_controller.py` | +| producer | `src.api_hook_client.get_session` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_status` | `src\api_hook_client.py` | | producer | `src.app_controller.token_stats` | `src\app_controller.py` | | producer | `src.project_manager.flat_config` | `src\project_manager.py` | -| producer | `src.project_manager.default_discussion` | `src\project_manager.py` | -| producer | `src.app_controller.get_mma_status` | `src\app_controller.py` | -| producer | `src.app_controller.get_session_insights` | `src\app_controller.py` | +| producer | `src.api_hook_client._make_request` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.right_click` | `src\api_hook_client.py` | +| producer | `src.ai_client._send_cli_round_result` | `src\ai_client.py` | | producer | `src.models.to_dict` | `src\models.py` | -| producer | `src.ai_client._parse_tool_args_result` | `src\ai_client.py` | -| producer | `src.api_hook_client.push_event` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_project_switch_status` | `src\api_hook_client.py` | -| producer | `src.project_manager.str_to_entry` | `src\project_manager.py` | +| producer | `src.api_hook_client.trigger_patch` | `src\api_hook_client.py` | | producer | `src.api_hook_client.select_tab` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.post_gui` | `src\api_hook_client.py` | -| producer | `src.app_controller._api_get_api_project` | `src\app_controller.py` | -| producer | `src.app_controller._api_generate` | `src\app_controller.py` | +| producer | `src.app_controller._api_get_session` | `src\app_controller.py` | +| producer | `src.project_manager.str_to_entry` | `src\project_manager.py` | +| producer | `src.app_controller._api_get_gui_state` | `src\app_controller.py` | +| producer | `src.api_hook_client.click` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_gui_state` | `src\api_hook_client.py` | +| producer | `src.project_manager.default_discussion` | `src\project_manager.py` | +| producer | `src.ai_client._get_anthropic_tools` | `src\ai_client.py` | +| producer | `src.app_controller.load_config` | `src\app_controller.py` | +| producer | `src.project_manager.load_project` | `src\project_manager.py` | +| producer | `src.api_hook_client.post_project` | `src\api_hook_client.py` | +| producer | `src.models.parse_history_entries` | `src\models.py` | +| producer | `src.ai_client.get_gemini_cache_stats` | `src\ai_client.py` | +| producer | `src.app_controller.pending_actions` | `src\app_controller.py` | +| producer | `src.app_controller._api_get_performance` | `src\app_controller.py` | +| producer | `src.ai_client._content_block_to_dict` | `src\ai_client.py` | +| producer | `src.api_hook_client.get_patch_status` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.push_event` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.api_hook_client.reject_patch` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_project` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.app_controller._api_get_context` | `src\app_controller.py` | +| producer | `src.app_controller.status` | `src\app_controller.py` | +| producer | `src.ai_client._strip_private_keys` | `src\ai_client.py` | +| producer | `src.api_hook_client.get_performance` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.api_hook_client.select_list_item` | `src\api_hook_client.py` | +| producer | `src.ai_client._add_bleed_derived` | `src\ai_client.py` | | producer | `src.api_hook_client.get_warmup_status` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_warmup_wait` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.app_controller._api_generate` | `src\app_controller.py` | +| producer | `src.project_manager.get_all_tracks` | `src\project_manager.py` | +| producer | `src.app_controller._api_status` | `src\app_controller.py` | +| producer | `src.app_controller._api_token_stats` | `src\app_controller.py` | +| producer | `src.api_hook_client.get_project_switch_status` | `src\api_hook_client.py` | +| producer | `src.app_controller._api_get_api_session` | `src\app_controller.py` | +| producer | `src.api_hook_client.post_session` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_system_telemetry` | `src\api_hook_client.py` | +| producer | `src.ai_client._parse_tool_args_result` | `src\ai_client.py` | | producer | `src.api_hook_client.wait_for_project_switch` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_events` | `src\api_hook_client.py` | | producer | `src.app_controller.get_context` | `src\app_controller.py` | +| producer | `src.ai_client._extract_dashscope_tool_calls` | `src\ai_client.py` | +| producer | `src.api_hook_client.get_gui_health` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.ai_client.get_comms_log` | `src\ai_client.py` | +| producer | `src.project_manager.default_project` | `src\project_manager.py` | +| producer | `src.api_hook_client.apply_patch` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_warmup_wait` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_warmup_canaries` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_financial_metrics` | `src\api_hook_client.py` | +| producer | `src.models._load_config_from_disk` | `src\models.py` | +| producer | `src.ai_client.get_token_stats` | `src\ai_client.py` | +| producer | `src.aggregate.build_file_items` | `src\aggregate.py` | +| producer | `src.app_controller.get_session_insights` | `src\app_controller.py` | +| producer | `src.api_hook_client.post_gui` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.app_controller._pending_mma_approval` | `src\app_controller.py` | +| producer | `src.api_hook_client.drag` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.post_project` | `src\api_hook_client.py` | +| producer | `src.app_controller.wait` | `src\app_controller.py` | +| producer | `src.app_controller.get_session` | `src\app_controller.py` | +| producer | `src.app_controller._api_get_mma_status` | `src\app_controller.py` | +| producer | `src.app_controller._api_pending_actions` | `src\app_controller.py` | +| producer | `src.api_hook_client.get_node_status` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_io_pool_status` | `src\api_hook_client.py` | +| producer | `src.app_controller.get_mma_status` | `src\app_controller.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.app_controller._pending_mma_spawn` | `src\app_controller.py` | +| producer | `src.app_controller.get_performance` | `src\app_controller.py` | +| producer | `src.api_hook_client.wait_for_event` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_context_state` | `src\api_hook_client.py` | +| producer | `src.ai_client._dashscope_call` | `src\ai_client.py` | +| producer | `src.app_controller.get_diagnostics` | `src\app_controller.py` | +| producer | `src.project_manager.migrate_from_legacy_config` | `src\project_manager.py` | +| producer | `src.models.to_dict` | `src\models.py` | | producer | `src.ai_client._load_credentials` | `src\ai_client.py` | | producer | `src.app_controller._api_get_diagnostics` | `src\app_controller.py` | -| producer | `src.api_hook_client.get_session` | `src\api_hook_client.py` | -| producer | `src.app_controller._offload_entry_payload` | `src\app_controller.py` | -| producer | `src.api_hook_client.get_startup_timeline` | `src\api_hook_client.py` | -| producer | `src.project_manager.migrate_from_legacy_config` | `src\project_manager.py` | -| producer | `src.api_hook_client.get_mma_workers` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.drag` | `src\api_hook_client.py` | -| producer | `src.ai_client.get_token_stats` | `src\ai_client.py` | -| producer | `src.api_hook_client.get_node_status` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.apply_patch` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.set_value` | `src\api_hook_client.py` | -| producer | `src.app_controller.get_session` | `src\app_controller.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.ai_client._get_deepseek_tools` | `src\ai_client.py` | | producer | `src.app_controller.get_api_session` | `src\app_controller.py` | +| producer | `src.ai_client._pre_dispatch` | `src\ai_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | | producer | `src.api_hook_client.get_mma_status` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_gui_state` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.right_click` | `src\api_hook_client.py` | -| producer | `src.project_manager.default_project` | `src\project_manager.py` | -| producer | `src.api_hook_client.get_patch_status` | `src\api_hook_client.py` | -| producer | `src.project_manager.load_project` | `src\project_manager.py` | -| producer | `src.api_hook_client.trigger_patch` | `src\api_hook_client.py` | -| producer | `src.ai_client._dashscope_call` | `src\ai_client.py` | -| producer | `src.api_hook_client.get_project` | `src\api_hook_client.py` | -| producer | `src.app_controller.generate` | `src\app_controller.py` | -| producer | `src.ai_client._content_block_to_dict` | `src\ai_client.py` | -| producer | `src.api_hook_client.get_gui_diagnostics` | `src\api_hook_client.py` | -| producer | `src.ai_client.get_gemini_cache_stats` | `src\ai_client.py` | -| producer | `src.api_hook_client.click` | `src\api_hook_client.py` | -| consumer | `src.ai_client._strip_stale_file_refreshes` | `src\ai_client.py` | -| consumer | `src.project_manager.format_discussion` | `src\project_manager.py` | -| consumer | `src.aggregate._build_files_section_from_items` | `src\aggregate.py` | -| consumer | `src.ai_client._append_comms` | `src\ai_client.py` | -| consumer | `src.ai_client._trim_anthropic_history` | `src\ai_client.py` | -| consumer | `src.models._save_config_to_disk` | `src\models.py` | -| consumer | `src.app_controller._on_comms_entry` | `src\app_controller.py` | -| consumer | `src.ai_client._execute_single_tool_call_async` | `src\ai_client.py` | -| consumer | `src.ai_client._dashscope_call` | `src\ai_client.py` | -| consumer | `src.ai_client.ollama_chat` | `src\ai_client.py` | -| consumer | `src.ai_client._pre_dispatch` | `src\ai_client.py` | -| consumer | `src.ai_client._strip_cache_controls` | `src\ai_client.py` | -| consumer | `src.ai_client._estimate_prompt_tokens` | `src\ai_client.py` | -| consumer | `src.ai_client._add_history_cache_breakpoint` | `src\ai_client.py` | -| consumer | `src.project_manager.flat_config` | `src\project_manager.py` | -| consumer | `src.app_controller._offload_entry_payload` | `src\app_controller.py` | -| consumer | `src.ai_client._repair_minimax_history` | `src\ai_client.py` | -| consumer | `src.ai_client._strip_private_keys` | `src\ai_client.py` | -| consumer | `src.ai_client._repair_deepseek_history` | `src\ai_client.py` | -| consumer | `src.project_manager.entry_to_str` | `src\project_manager.py` | -| consumer | `src.aggregate.build_tier3_context` | `src\aggregate.py` | -| consumer | `src.ai_client._estimate_message_tokens` | `src\ai_client.py` | -| consumer | `src.project_manager.migrate_from_legacy_config` | `src\project_manager.py` | -| consumer | `src.aggregate.run` | `src\aggregate.py` | -| consumer | `src.models.from_dict` | `src\models.py` | -| consumer | `src.project_manager.save_project` | `src\project_manager.py` | +| producer | `src.api_hook_client.set_value` | `src\api_hook_client.py` | +| producer | `src.project_manager.load_history` | `src\project_manager.py` | +| producer | `src.ai_client.ollama_chat` | `src\ai_client.py` | +| producer | `src.app_controller.get_gui_state` | `src\app_controller.py` | | consumer | `src.aggregate.build_markdown_from_items` | `src\aggregate.py` | -| consumer | `src.app_controller._start_track_logic` | `src\app_controller.py` | +| consumer | `src.ai_client._send_anthropic` | `src\ai_client.py` | | consumer | `src.app_controller._refresh_api_metrics` | `src\app_controller.py` | -| consumer | `src.app_controller._start_track_logic_result` | `src\app_controller.py` | -| consumer | `src.ai_client._add_bleed_derived` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._add_history_cache_breakpoint` | `src\ai_client.py` | +| consumer | `src.ai_client._append_comms` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._repair_deepseek_history` | `src\ai_client.py` | +| consumer | `src.ai_client._dashscope_call` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._send_grok` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.aggregate.build_tier3_context` | `src\aggregate.py` | | consumer | `src.aggregate.build_markdown_no_history` | `src\aggregate.py` | -| consumer | `src.ai_client._invalidate_token_estimate` | `src\ai_client.py` | -| consumer | `src.ai_client._repair_anthropic_history` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.project_manager.migrate_from_legacy_config` | `src\project_manager.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.app_controller._on_comms_entry` | `src\app_controller.py` | +| consumer | `src.aggregate.run` | `src\aggregate.py` | | consumer | `src.ai_client._trim_minimax_history` | `src\ai_client.py` | +| consumer | `src.app_controller._start_track_logic` | `src\app_controller.py` | +| consumer | `src.project_manager.save_project` | `src\project_manager.py` | +| consumer | `src.ai_client._send_gemini` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.project_manager.format_discussion` | `src\project_manager.py` | +| consumer | `src.ai_client._repair_minimax_history` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._repair_anthropic_history` | `src\ai_client.py` | +| consumer | `src.ai_client._pre_dispatch` | `src\ai_client.py` | +| consumer | `src.ai_client._strip_stale_file_refreshes` | `src\ai_client.py` | +| consumer | `src.ai_client.send` | `src\ai_client.py` | +| consumer | `src.app_controller._offload_entry_payload` | `src\app_controller.py` | +| consumer | `src.app_controller._start_track_logic_result` | `src\app_controller.py` | +| consumer | `src.ai_client._send_minimax` | `src\ai_client.py` | +| consumer | `src.ai_client._send_llama_native` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._create_gemini_cache_result` | `src\ai_client.py` | +| consumer | `src.project_manager.entry_to_str` | `src\project_manager.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models._save_config_to_disk` | `src\models.py` | +| consumer | `src.ai_client._send_qwen` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._trim_anthropic_history` | `src\ai_client.py` | +| consumer | `src.ai_client._strip_private_keys` | `src\ai_client.py` | +| consumer | `src.ai_client._estimate_prompt_tokens` | `src\ai_client.py` | +| consumer | `src.ai_client.ollama_chat` | `src\ai_client.py` | +| consumer | `src.ai_client._execute_single_tool_call_async` | `src\ai_client.py` | +| consumer | `src.project_manager.flat_config` | `src\project_manager.py` | +| consumer | `src.ai_client._send_deepseek` | `src\ai_client.py` | +| consumer | `src.ai_client._send_llama` | `src\ai_client.py` | +| consumer | `src.ai_client._add_bleed_derived` | `src\ai_client.py` | +| consumer | `src.ai_client._send_gemini_cli` | `src\ai_client.py` | +| consumer | `src.aggregate._build_files_section_from_items` | `src\aggregate.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._invalidate_token_estimate` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._strip_cache_controls` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._estimate_message_tokens` | `src\ai_client.py` | ## FileItem (0 producers + 0 consumers) _(no producers or consumers)_ -## FileItems (0 producers + 3 consumers) +## FileItems (0 producers + 4 consumers) | role | fqname | file | |---|---|---| | consumer | `src.ai_client._build_file_diff_text` | `src\ai_client.py` | +| consumer | `src.ai_client.run_with_tool_loop` | `src\ai_client.py` | | consumer | `src.ai_client._build_file_context_text` | `src\ai_client.py` | | consumer | `src.ai_client._reread_file_items_result` | `src\ai_client.py` | @@ -2395,20 +2679,24 @@ _(no producers or consumers)_ _(no producers or consumers)_ -## HistoryMessage (0 producers + 2 consumers) +## HistoryMessage (1 producers + 2 consumers) | role | fqname | file | |---|---|---| -| consumer | `src.provider_state.replace_all` | `src\provider_state.py` | +| producer | `src.provider_state.get_all` | `src\provider_state.py` | | consumer | `src.provider_state.append` | `src\provider_state.py` | +| consumer | `src.provider_state.replace_all` | `src\provider_state.py` | ## History (0 producers + 0 consumers) _(no producers or consumers)_ -## ToolDefinition (0 producers + 0 consumers) +## ToolDefinition (2 producers + 0 consumers) -_(no producers or consumers)_ +| role | fqname | file | +|---|---|---| +| producer | `src.ai_client._build_anthropic_tools` | `src\ai_client.py` | +| producer | `src.ai_client._build_deepseek_tools` | `src\ai_client.py` | ## ToolCall (1 producers + 1 consumers) @@ -2446,6 +2734,7 @@ Functions on the per-LLM-turn path (high-frequency consumers). | function | pattern | total field accesses | |---|---|---| +| `src.ai_client.run_with_tool_loop` | `whole_struct` | 2 | | `src.ai_client._build_file_diff_text` | `whole_struct` | 0 | | `src.ai_client._build_file_context_text` | `whole_struct` | 0 | | `src.ai_client._reread_file_items_result` | `whole_struct` | 0 | @@ -2454,8 +2743,8 @@ Functions on the per-LLM-turn path (high-frequency consumers). | function | pattern | total field accesses | |---|---|---| -| `src.provider_state.replace_all` | `mixed` | 2 | | `src.provider_state.append` | `mixed` | 2 | +| `src.provider_state.replace_all` | `mixed` | 2 | ### `ToolCall` @@ -2474,18 +2763,19 @@ Cross-aggregate analysis of which fields are accessed how often across the codeb | aggregate | field | total accesses | |---|---|---| +| `FileItems` | `append` | 2 | | `HistoryMessage` | `lock` | 2 | | `HistoryMessage` | `messages` | 2 | | `Metadata` | `get` | 39 | +| `Metadata` | `content` | 21 | +| `Metadata` | `marker` | 21 | | `Metadata` | `pop` | 10 | | `Metadata` | `session_usage` | 7 | | `Metadata` | `files` | 5 | | `Metadata` | `ai_status` | 5 | | `Metadata` | `_pending_history_adds_lock` | 4 | | `Metadata` | `_pending_history_adds` | 4 | -| `Metadata` | `ui_auto_add_history` | 3 | | `Metadata` | `append` | 3 | -| `Metadata` | `discussion` | 2 | | `ToolCall` | `to_dict` | 1 | @@ -2499,14 +2789,14 @@ Cross-aggregate analysis of which fields are accessed how often across the codeb | Aggregate | Producers | Consumers | Struct fields | Current cost (us/turn) | Direction | Actionable savings (us/turn) | |---|---|---|---|---|---|---| -| `Metadata` | 77 | 35 | 10 | 720 | `hold` | 0 | +| `Metadata` | 117 | 66 | 10 | 720 | `hold` | 0 | | `FileItem` | 0 | 0 | 5 | 470 | `insufficient_data` | 0 | -| `FileItems` | 0 | 3 | 5 | 470 | `hold` | 70 | +| `FileItems` | 0 | 4 | 5 | 470 | `hold` | 70 | | `CommsLogEntry` | 0 | 0 | 5 | 470 | `insufficient_data` | 0 | | `CommsLog` | 0 | 0 | 5 | 470 | `insufficient_data` | 0 | -| `HistoryMessage` | 0 | 2 | 5 | 470 | `insufficient_data` | 0 | +| `HistoryMessage` | 1 | 2 | 5 | 470 | `insufficient_data` | 0 | | `History` | 0 | 0 | 5 | 470 | `insufficient_data` | 0 | -| `ToolDefinition` | 0 | 0 | 5 | 470 | `insufficient_data` | 0 | +| `ToolDefinition` | 2 | 0 | 5 | 470 | `insufficient_data` | 0 | | `ToolCall` | 1 | 1 | 5 | 470 | `hold` | 70 | | `Result` | 0 | 0 | 5 | 470 | `insufficient_data` | 0 | @@ -2542,7 +2832,7 @@ _(no aggregates currently flagged for refactoring; most have 'hold' status)_ | CommsLog | 0 | 0 | 0 | 0 | 0 | 0 | | HistoryMessage | 0 | 0 | 0 | 0 | 0 | 0 | | History | 0 | 0 | 0 | 0 | 0 | 0 | -| ToolDefinition | 0 | 0 | 0 | 0 | 0 | 0 | +| ToolDefinition | 0 | 0 | 1 | 0 | 0 | 1 | | ToolCall | 0 | 0 | 0 | 0 | 0 | 0 | | Result | 0 | 0 | 0 | 0 | 0 | 0 | | ToolSpec | 0 | 0 | 0 | 0 | 0 | 0 | @@ -2559,9 +2849,17 @@ Fields that appear in producer return shapes but are never read by any consumer. ### `Metadata` -Fields read by at least one consumer: 53 +Fields read by at least one consumer: 55 +### `FileItems` + +Fields read by at least one consumer: 1 + +| field | read count | +|---|---| +| `append` | 2 | + ### `HistoryMessage` Fields read by at least one consumer: 2 @@ -2607,8 +2905,8 @@ Generated for 13 aggregates on 2026-06-22 - **Real aggregates (in scope):** 10 - **Candidate aggregates (placeholders):** 3 -- **Total producers:** 78 -- **Total consumers:** 41 +- **Total producers:** 121 +- **Total consumers:** 73 - **Total current cost (us/turn):** 4950 - **Total actionable savings (us/turn):** 140 @@ -2626,13 +2924,13 @@ Generated for 13 aggregates on 2026-06-22 | `CommsLog` | `typealias` | `discussion` | `mixed` | 0 | 0 | | `CommsLogEntry` | `typealias` | `discussion` | `mixed` | 0 | 0 | | `FileItem` | `typealias` | `curation` | `mixed` | 0 | 0 | -| `FileItems` | `typealias` | `curation` | `whole_struct` | 0 | 3 | +| `FileItems` | `typealias` | `curation` | `whole_struct` | 0 | 4 | | `History` | `typealias` | `discussion` | `mixed` | 0 | 0 | -| `HistoryMessage` | `typealias` | `discussion` | `mixed` | 0 | 2 | -| `Metadata` | `typealias` | `discussion` | `whole_struct` | 77 | 35 | +| `HistoryMessage` | `typealias` | `discussion` | `mixed` | 1 | 2 | +| `Metadata` | `typealias` | `discussion` | `whole_struct` | 117 | 66 | | `Result` | `typealias` | `control` | `mixed` | 0 | 0 | | `ToolCall` | `typealias` | `control` | `whole_struct` | 1 | 1 | -| `ToolDefinition` | `typealias` | `control` | `mixed` | 0 | 0 | +| `ToolDefinition` | `typealias` | `control` | `mixed` | 2 | 0 | | `ChatMessage` | `candidate_dataclass` | `discussion` | `mixed` | 0 | 0 | | `ProviderHistory` | `candidate_dataclass` | `unknown` | `mixed` | 0 | 0 | | `ToolSpec` | `candidate_dataclass` | `unknown` | `mixed` | 0 | 0 | @@ -2659,8 +2957,8 @@ Generated for 13 aggregates on 2026-06-22 ### `FileItems` -- **Result coverage:** 0 producers, 3 consumers -- **Type alias coverage:** 0 sites +- **Result coverage:** 0 producers, 4 consumers +- **Type alias coverage:** 2 sites; 0 typed (0%); 2 untyped (100%) - **Cross-audit findings (total sites):** 0 ### `History` @@ -2671,14 +2969,14 @@ Generated for 13 aggregates on 2026-06-22 ### `HistoryMessage` -- **Result coverage:** 0 producers, 2 consumers +- **Result coverage:** 1 producers, 2 consumers - **Type alias coverage:** 4 sites; 0 typed (0%); 4 untyped (100%) - **Cross-audit findings (total sites):** 0 ### `Metadata` -- **Result coverage:** 77 producers, 35 consumers -- **Type alias coverage:** 130 sites; 0 typed (0%); 130 untyped (100%) +- **Result coverage:** 96 producers, 46 consumers +- **Type alias coverage:** 173 sites; 0 typed (0%); 173 untyped (100%) - **Cross-audit findings (total sites):** 1 ### `Result` @@ -2695,9 +2993,9 @@ Generated for 13 aggregates on 2026-06-22 ### `ToolDefinition` -- **Result coverage:** 0 producers, 0 consumers +- **Result coverage:** 2 producers, 0 consumers - **Type alias coverage:** 0 sites -- **Cross-audit findings (total sites):** 0 +- **Cross-audit findings (total sites):** 1 --- diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/FileItems.dsl b/docs/reports/code_path_audit/2026-06-22/aggregates/FileItems.dsl index feb52f29..b967fb22 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/FileItems.dsl +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/FileItems.dsl @@ -9,16 +9,18 @@ \ === producers (0 items) === -\ === consumers (3 items) === - "src.ai_client._build_file_diff_text" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client._build_file_context_text" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client._reread_file_items_result" "src\ai_client.py" 0 "consumer" fn-ref +\ === consumers (4 items) === + "src.ai_client._build_file_diff_text" "src\ai_client.py" 1105 "consumer" fn-ref + "src.ai_client.run_with_tool_loop" "src\ai_client.py" 833 "consumer" fn-ref + "src.ai_client._build_file_context_text" "src\ai_client.py" 1092 "consumer" fn-ref + "src.ai_client._reread_file_items_result" "src\ai_client.py" 1056 "consumer" fn-ref \ === access_pattern === "whole_struct" access-pattern -\ === access_pattern_evidence (3 items) === +\ === access_pattern_evidence (4 items) === "src.ai_client._build_file_diff_text" "whole_struct" 0 "low" ap-evidence + "src.ai_client.run_with_tool_loop" "whole_struct" 1 "high" ap-evidence "src.ai_client._build_file_context_text" "whole_struct" 0 "low" ap-evidence "src.ai_client._reread_file_items_result" "whole_struct" 0 "low" ap-evidence @@ -28,10 +30,10 @@ \ === frequency_evidence (0 items) === \ === result_coverage === - 0 0 3 0 result-coverage + 0 0 4 0 result-coverage \ === type_alias_coverage === - 0 0 0 type-alias-coverage + 2 0 2 type-alias-coverage \ === cross_audit_findings === 5 cross-audit-findings diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/FileItems.md b/docs/reports/code_path_audit/2026-06-22/aggregates/FileItems.md index fa5c9954..6e438f52 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/FileItems.md +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/FileItems.md @@ -7,9 +7,9 @@ ## Pipeline summary - Producers: 0 -- Consumers: 3 +- Consumers: 4 - Distinct producer fqnames: 0 -- Distinct consumer fqnames: 3 +- Distinct consumer fqnames: 4 - Access pattern (aggregate): whole_struct - Frequency (aggregate): per_turn - Decomposition direction: hold @@ -19,47 +19,56 @@ _(none)_ -## Consumers (3) +## Consumers (4) -### `src\ai_client.py` (3 consumers) +### `src\ai_client.py` (4 consumers) -- `src.ai_client._build_file_diff_text` (line 0) -- `src.ai_client._build_file_context_text` (line 0) -- `src.ai_client._reread_file_items_result` (line 0) +- `src.ai_client._build_file_diff_text` (line 1105) +- `src.ai_client.run_with_tool_loop` (line 833) +- `src.ai_client._build_file_context_text` (line 1092) +- `src.ai_client._reread_file_items_result` (line 1056) ## Field access matrix -_(no field accesses detected)_ +| consumer | append | +|---|---| +| `_build_file_diff_text` | . | +| `run_with_tool_loop` | 2 | +| `_build_file_context_text` | . | +| `_reread_file_items_result` | . | ## Access pattern **Dominant pattern:** whole_struct -**Evidence count:** 3 +**Evidence count:** 4 **Per-function pattern distribution:** -- `whole_struct`: 3 functions (100%) +- `whole_struct`: 4 functions (100%) ## SSDL Sketch for `FileItems` ``` [Q:FileItems entry-point] -> [Q:PCG lookup] -> [1: _build_file_diff_text] [B:check] (branches=6) - -> [2: _build_file_context_text] [B:check] (branches=3) - -> [3: _reread_file_items_result] [B:is None?] (branches=5) [N:safe] + -> [2: run_with_tool_loop] [B:is None?] (branches=23) [N:safe] + -> [3: _build_file_context_text] [B:check] (branches=3) + -> [4: _reread_file_items_result] [B:is None?] (branches=5) [N:safe] -> [T:done] ``` -**Effective codepaths:** 104 (sum of 2^branches across 3 consumers) -**Total branch points:** 14 -**Nil-check functions:** 1 +**Effective codepaths:** 8388712 (sum of 2^branches across 4 consumers) +**Total branch points:** 37 +**Nil-check functions:** 2 **Defusing opportunities:** - **Nil Sentinel `[N]`**: Introduce a module-level `NIL_` sentinel whose field accesses return safe defaults. Replace None checks with the sentinel. Collapses 2^branch_count into ~1. - - Effective codepaths: 104 -> 102 -- **Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]`**: Introduce a `fileitems_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 0 field-check branches to 1 cache lookup. - - Effective codepaths: 104 -> 1 + - Effective codepaths: 8388712 -> 8388708 +- **Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]`**: Introduce a `fileitems_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 2 field-check branches to 1 cache lookup. + - Effective codepaths: 8388712 -> 2 +- **Generational Handles `[I:ResolveHandle] -> [B:Gen matches?] -> [N|safe]`**: Wrap the aggregate in a generational handle (index + generation). Validation is one comparison; mismatch returns the nil sentinel. Reduces N lifetime branches to 1 handle validation + sentinel return. + - Effective codepaths: 8388712 -> 4 ## Frequency @@ -69,24 +78,24 @@ _(no field accesses detected)_ ## Result coverage -**Summary:** 0 producers, 3 consumers +**Summary:** 0 producers, 4 consumers | metric | value | |---|---| | total producers | 0 | | result producers | 0 | -| total consumers | 3 | +| total consumers | 4 | | result consumers | 0 | ## Type alias coverage -**Summary:** 0 sites +**Summary:** 2 sites; 0 typed (0%); 2 untyped (100%) | metric | value | |---|---| -| total field-access sites | 0 | +| total field-access sites | 2 | | typed sites (canonical field) | 0 | -| untyped sites (wildcard) | 0 | +| untyped sites (wildcard) | 2 | ## Cross-audit findings @@ -121,5 +130,6 @@ FileItems: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5 | function | pattern | field_accesses | confidence | |---|---|---|---| | `src.ai_client._build_file_diff_text` | `whole_struct` | | low | +| `src.ai_client.run_with_tool_loop` | `whole_struct` | `append`=2 | high | | `src.ai_client._build_file_context_text` | `whole_struct` | | low | | `src.ai_client._reread_file_items_result` | `whole_struct` | | low | diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/FileItems.tree b/docs/reports/code_path_audit/2026-06-22/aggregates/FileItems.tree index e26fdd2c..d4deadd8 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/FileItems.tree +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/FileItems.tree @@ -2,14 +2,15 @@ Metadata: FileItems |- kind: typealias |- memory_dim: curation |- producers: [0] -|- consumers: [3] +|- consumers: [4] | |- src.ai_client._build_file_diff_text (consumer) +| |- src.ai_client.run_with_tool_loop (consumer) | |- src.ai_client._build_file_context_text (consumer) | |- src.ai_client._reread_file_items_result (consumer) |- access_pattern: whole_struct |- frequency: per_turn -|- result_coverage: 0 producers, 3 consumers -|- type_alias_coverage: 0 sites +|- result_coverage: 0 producers, 4 consumers +|- type_alias_coverage: 2 sites; 0 typed (0%); 2 untyped (100%) |- cross_audit_findings: 0 findings |- decomposition_cost: hold (470 us) |- optimization_candidates: [0] \ No newline at end of file diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/HistoryMessage.dsl b/docs/reports/code_path_audit/2026-06-22/aggregates/HistoryMessage.dsl index e089ec5b..89ffb2bf 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/HistoryMessage.dsl +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/HistoryMessage.dsl @@ -7,26 +7,28 @@ \ === memory_dim === "discussion" mem-dim -\ === producers (0 items) === +\ === producers (1 items) === + "src.provider_state.get_all" "src\provider_state.py" 34 "producer" fn-ref \ === consumers (2 items) === - "src.provider_state.replace_all" "src\provider_state.py" 0 "consumer" fn-ref - "src.provider_state.append" "src\provider_state.py" 0 "consumer" fn-ref + "src.provider_state.append" "src\provider_state.py" 30 "consumer" fn-ref + "src.provider_state.replace_all" "src\provider_state.py" 38 "consumer" fn-ref \ === access_pattern === "mixed" access-pattern \ === access_pattern_evidence (2 items) === - "src.provider_state.replace_all" "mixed" 2 "high" ap-evidence "src.provider_state.append" "mixed" 2 "high" ap-evidence + "src.provider_state.replace_all" "mixed" 2 "high" ap-evidence \ === frequency === "per_turn" frequency -\ === frequency_evidence (0 items) === +\ === frequency_evidence (1 items) === + "src.provider_state.get_all" "per_turn" "static_analysis" "producer from src\provider_state.py" freq-evidence \ === result_coverage === - 0 0 2 0 result-coverage + 1 1 2 0 result-coverage \ === type_alias_coverage === 4 0 4 type-alias-coverage diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/HistoryMessage.md b/docs/reports/code_path_audit/2026-06-22/aggregates/HistoryMessage.md index 69539310..586f0bd5 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/HistoryMessage.md +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/HistoryMessage.md @@ -6,32 +6,34 @@ ## Pipeline summary -- Producers: 0 +- Producers: 1 - Consumers: 2 -- Distinct producer fqnames: 0 +- Distinct producer fqnames: 1 - Distinct consumer fqnames: 2 - Access pattern (aggregate): mixed - Frequency (aggregate): per_turn - Decomposition direction: insufficient_data - Struct field count (estimated): 5 -## Producers (0) +## Producers (1) -_(none)_ +### `src\provider_state.py` (1 producer) + +- `src.provider_state.get_all` (line 34) ## Consumers (2) ### `src\provider_state.py` (2 consumers) -- `src.provider_state.replace_all` (line 0) -- `src.provider_state.append` (line 0) +- `src.provider_state.append` (line 30) +- `src.provider_state.replace_all` (line 38) ## Field access matrix | consumer | lock | messages | |---|---|---| -| `replace_all` | 1 | 1 | | `append` | 1 | 1 | +| `replace_all` | 1 | 1 | ## Access pattern @@ -46,8 +48,8 @@ _(none)_ ``` [Q:HistoryMessage entry-point] -> [Q:PCG lookup] - -> [1: replace_all] [B:check] (branches=1) - -> [2: append] [B:check] (branches=1) + -> [1: append] [B:check] (branches=1) + -> [2: replace_all] [B:check] (branches=1) -> [T:done] ``` @@ -64,16 +66,20 @@ _(none)_ ## Frequency **Dominant frequency:** per_turn -**Evidence count:** 0 +**Evidence count:** 1 + +**Per-function frequency distribution:** + +- `per_turn`: 1 functions ## Result coverage -**Summary:** 0 producers, 2 consumers +**Summary:** 1 producers, 2 consumers | metric | value | |---|---| -| total producers | 0 | -| result producers | 0 | +| total producers | 1 | +| result producers | 1 | | total consumers | 2 | | result consumers | 0 | @@ -103,7 +109,10 @@ _(no cross-audit findings mapped to this aggregate)_ ## Struct shape (inferred from producer returns) -_(no producers; cannot infer shape)_ +| field | access count | access pattern | +|---|---|---| +| `lock` | 2 | used | +| `messages` | 2 | used | ## Optimization candidates @@ -119,5 +128,11 @@ HistoryMessage: access_pattern=mixed, frequency=per_turn, struct_field_count=5, | function | pattern | field_accesses | confidence | |---|---|---|---| -| `src.provider_state.replace_all` | `mixed` | `lock`=1, `messages`=1 | high | | `src.provider_state.append` | `mixed` | `lock`=1, `messages`=1 | high | +| `src.provider_state.replace_all` | `mixed` | `lock`=1, `messages`=1 | high | + +### Frequency evidence + +| function | frequency | source | note | +|---|---|---|---| +| `src.provider_state.get_all` | `per_turn` | `static_analysis` | producer from src\provider_state.py | diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/HistoryMessage.tree b/docs/reports/code_path_audit/2026-06-22/aggregates/HistoryMessage.tree index bde7cf4b..283213b8 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/HistoryMessage.tree +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/HistoryMessage.tree @@ -1,13 +1,14 @@ Metadata: HistoryMessage |- kind: typealias |- memory_dim: discussion -|- producers: [0] +|- producers: [1] +| |- src.provider_state.get_all (producer) |- consumers: [2] -| |- src.provider_state.replace_all (consumer) | |- src.provider_state.append (consumer) +| |- src.provider_state.replace_all (consumer) |- access_pattern: mixed |- frequency: per_turn -|- result_coverage: 0 producers, 2 consumers +|- result_coverage: 1 producers, 2 consumers |- type_alias_coverage: 4 sites; 0 typed (0%); 4 untyped (100%) |- cross_audit_findings: 0 findings |- decomposition_cost: insufficient_data (470 us) diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/Metadata.dsl b/docs/reports/code_path_audit/2026-06-22/aggregates/Metadata.dsl index f0a2716d..cdceb273 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/Metadata.dsl +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/Metadata.dsl @@ -7,177 +7,279 @@ \ === memory_dim === "discussion" mem-dim -\ === producers (77 items) === - "src.api_hook_client.get_performance" "src\api_hook_client.py" 0 "producer" fn-ref - "src.app_controller.get_performance" "src\app_controller.py" 0 "producer" fn-ref - "src.ai_client._send_cli_round_result" "src\ai_client.py" 0 "producer" fn-ref - "src.api_hook_client.post_session" "src\api_hook_client.py" 0 "producer" fn-ref - "src.app_controller.wait" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller.get_diagnostics" "src\app_controller.py" 0 "producer" fn-ref - "src.models._load_config_from_disk" "src\models.py" 0 "producer" fn-ref - "src.app_controller.get_gui_state" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller._api_status" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller._api_token_stats" "src\app_controller.py" 0 "producer" fn-ref - "src.ai_client.ollama_chat" "src\ai_client.py" 0 "producer" fn-ref - "src.api_hook_client.get_financial_metrics" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.get_status" "src\api_hook_client.py" 0 "producer" fn-ref - "src.app_controller._api_get_api_session" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller._api_get_context" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller.get_api_project" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller._api_get_performance" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller.status" "src\app_controller.py" 0 "producer" fn-ref - "src.ai_client._add_bleed_derived" "src\ai_client.py" 0 "producer" fn-ref - "src.api_hook_client.get_context_state" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.get_gui_health" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.post_project" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.select_list_item" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.get_io_pool_status" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.reject_patch" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.get_system_telemetry" "src\api_hook_client.py" 0 "producer" fn-ref - "src.app_controller._api_get_gui_state" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller._api_get_session" "src\app_controller.py" 0 "producer" fn-ref - "src.project_manager.load_history" "src\project_manager.py" 0 "producer" fn-ref - "src.app_controller.load_config" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller._api_get_mma_status" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller.token_stats" "src\app_controller.py" 0 "producer" fn-ref - "src.project_manager.flat_config" "src\project_manager.py" 0 "producer" fn-ref - "src.project_manager.default_discussion" "src\project_manager.py" 0 "producer" fn-ref - "src.app_controller.get_mma_status" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller.get_session_insights" "src\app_controller.py" 0 "producer" fn-ref - "src.models.to_dict" "src\models.py" 0 "producer" fn-ref - "src.ai_client._parse_tool_args_result" "src\ai_client.py" 0 "producer" fn-ref - "src.api_hook_client.push_event" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.get_project_switch_status" "src\api_hook_client.py" 0 "producer" fn-ref - "src.project_manager.str_to_entry" "src\project_manager.py" 0 "producer" fn-ref - "src.api_hook_client.select_tab" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.post_gui" "src\api_hook_client.py" 0 "producer" fn-ref - "src.app_controller._api_get_api_project" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller._api_generate" "src\app_controller.py" 0 "producer" fn-ref - "src.api_hook_client.get_warmup_status" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.get_warmup_wait" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.wait_for_project_switch" "src\api_hook_client.py" 0 "producer" fn-ref - "src.app_controller.get_context" "src\app_controller.py" 0 "producer" fn-ref - "src.ai_client._load_credentials" "src\ai_client.py" 0 "producer" fn-ref - "src.app_controller._api_get_diagnostics" "src\app_controller.py" 0 "producer" fn-ref - "src.api_hook_client.get_session" "src\api_hook_client.py" 0 "producer" fn-ref - "src.app_controller._offload_entry_payload" "src\app_controller.py" 0 "producer" fn-ref - "src.api_hook_client.get_startup_timeline" "src\api_hook_client.py" 0 "producer" fn-ref - "src.project_manager.migrate_from_legacy_config" "src\project_manager.py" 0 "producer" fn-ref - "src.api_hook_client.get_mma_workers" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.drag" "src\api_hook_client.py" 0 "producer" fn-ref - "src.ai_client.get_token_stats" "src\ai_client.py" 0 "producer" fn-ref - "src.api_hook_client.get_node_status" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.apply_patch" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.set_value" "src\api_hook_client.py" 0 "producer" fn-ref - "src.app_controller.get_session" "src\app_controller.py" 0 "producer" fn-ref - "src.app_controller.get_api_session" "src\app_controller.py" 0 "producer" fn-ref - "src.api_hook_client.get_mma_status" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.get_gui_state" "src\api_hook_client.py" 0 "producer" fn-ref - "src.api_hook_client.right_click" "src\api_hook_client.py" 0 "producer" fn-ref - "src.project_manager.default_project" "src\project_manager.py" 0 "producer" fn-ref - "src.api_hook_client.get_patch_status" "src\api_hook_client.py" 0 "producer" fn-ref - "src.project_manager.load_project" "src\project_manager.py" 0 "producer" fn-ref - "src.api_hook_client.trigger_patch" "src\api_hook_client.py" 0 "producer" fn-ref - "src.ai_client._dashscope_call" "src\ai_client.py" 0 "producer" fn-ref - "src.api_hook_client.get_project" "src\api_hook_client.py" 0 "producer" fn-ref - "src.app_controller.generate" "src\app_controller.py" 0 "producer" fn-ref - "src.ai_client._content_block_to_dict" "src\ai_client.py" 0 "producer" fn-ref - "src.api_hook_client.get_gui_diagnostics" "src\api_hook_client.py" 0 "producer" fn-ref - "src.ai_client.get_gemini_cache_stats" "src\ai_client.py" 0 "producer" fn-ref - "src.api_hook_client.click" "src\api_hook_client.py" 0 "producer" fn-ref +\ === producers (117 items) === + "src.models.to_dict" "src\models.py" 441 "producer" fn-ref + "src.api_hook_client.get_gui_diagnostics" "src\api_hook_client.py" 311 "producer" fn-ref + "src.models.to_dict" "src\models.py" 1024 "producer" fn-ref + "src.app_controller._api_get_api_project" "src\app_controller.py" 188 "producer" fn-ref + "src.api_hook_client.clear_events" "src\api_hook_client.py" 129 "producer" fn-ref + "src.ai_client._build_chunked_context_blocks" "src\ai_client.py" 1281 "producer" fn-ref + "src.app_controller.get_api_project" "src\app_controller.py" 2853 "producer" fn-ref + "src.models.to_dict" "src\models.py" 737 "producer" fn-ref + "src.models.to_dict" "src\models.py" 618 "producer" fn-ref + "src.api_hook_client.get_mma_workers" "src\api_hook_client.py" 546 "producer" fn-ref + "src.models.to_dict" "src\models.py" 486 "producer" fn-ref + "src.api_hook_client.get_startup_timeline" "src\api_hook_client.py" 353 "producer" fn-ref + "src.models.to_dict" "src\models.py" 886 "producer" fn-ref + "src.app_controller._offload_entry_payload" "src\app_controller.py" 4240 "producer" fn-ref + "src.app_controller.generate" "src\app_controller.py" 2868 "producer" fn-ref + "src.api_hook_client.get_session" "src\api_hook_client.py" 502 "producer" fn-ref + "src.api_hook_client.get_status" "src\api_hook_client.py" 105 "producer" fn-ref + "src.app_controller.token_stats" "src\app_controller.py" 2898 "producer" fn-ref + "src.project_manager.flat_config" "src\project_manager.py" 267 "producer" fn-ref + "src.api_hook_client._make_request" "src\api_hook_client.py" 65 "producer" fn-ref + "src.api_hook_client.right_click" "src\api_hook_client.py" 237 "producer" fn-ref + "src.ai_client._send_cli_round_result" "src\ai_client.py" 1746 "producer" fn-ref + "src.models.to_dict" "src\models.py" 971 "producer" fn-ref + "src.api_hook_client.trigger_patch" "src\api_hook_client.py" 274 "producer" fn-ref + "src.api_hook_client.select_tab" "src\api_hook_client.py" 263 "producer" fn-ref + "src.app_controller._api_get_session" "src\app_controller.py" 374 "producer" fn-ref + "src.project_manager.str_to_entry" "src\project_manager.py" 75 "producer" fn-ref + "src.app_controller._api_get_gui_state" "src\app_controller.py" 123 "producer" fn-ref + "src.api_hook_client.click" "src\api_hook_client.py" 223 "producer" fn-ref + "src.api_hook_client.get_gui_state" "src\api_hook_client.py" 165 "producer" fn-ref + "src.project_manager.default_discussion" "src\project_manager.py" 117 "producer" fn-ref + "src.ai_client._get_anthropic_tools" "src\ai_client.py" 664 "producer" fn-ref + "src.app_controller.load_config" "src\app_controller.py" 5142 "producer" fn-ref + "src.project_manager.load_project" "src\project_manager.py" 186 "producer" fn-ref + "src.api_hook_client.post_project" "src\api_hook_client.py" 473 "producer" fn-ref + "src.models.parse_history_entries" "src\models.py" 214 "producer" fn-ref + "src.ai_client.get_gemini_cache_stats" "src\ai_client.py" 1604 "producer" fn-ref + "src.app_controller.pending_actions" "src\app_controller.py" 2874 "producer" fn-ref + "src.app_controller._api_get_performance" "src\app_controller.py" 195 "producer" fn-ref + "src.ai_client._content_block_to_dict" "src\ai_client.py" 1200 "producer" fn-ref + "src.api_hook_client.get_patch_status" "src\api_hook_client.py" 295 "producer" fn-ref + "src.api_hook_client.push_event" "src\api_hook_client.py" 156 "producer" fn-ref + "src.models.to_dict" "src\models.py" 646 "producer" fn-ref + "src.api_hook_client.reject_patch" "src\api_hook_client.py" 288 "producer" fn-ref + "src.api_hook_client.get_project" "src\api_hook_client.py" 367 "producer" fn-ref + "src.models.to_dict" "src\models.py" 406 "producer" fn-ref + "src.app_controller._api_get_context" "src\app_controller.py" 398 "producer" fn-ref + "src.app_controller.status" "src\app_controller.py" 2865 "producer" fn-ref + "src.ai_client._strip_private_keys" "src\ai_client.py" 1464 "producer" fn-ref + "src.api_hook_client.get_performance" "src\api_hook_client.py" 318 "producer" fn-ref + "src.models.to_dict" "src\models.py" 701 "producer" fn-ref + "src.models.to_dict" "src\models.py" 672 "producer" fn-ref + "src.models.to_dict" "src\models.py" 355 "producer" fn-ref + "src.api_hook_client.select_list_item" "src\api_hook_client.py" 256 "producer" fn-ref + "src.ai_client._add_bleed_derived" "src\ai_client.py" 3332 "producer" fn-ref + "src.api_hook_client.get_warmup_status" "src\api_hook_client.py" 325 "producer" fn-ref + "src.models.to_dict" "src\models.py" 1059 "producer" fn-ref + "src.app_controller._api_generate" "src\app_controller.py" 221 "producer" fn-ref + "src.project_manager.get_all_tracks" "src\project_manager.py" 342 "producer" fn-ref + "src.app_controller._api_status" "src\app_controller.py" 209 "producer" fn-ref + "src.app_controller._api_token_stats" "src\app_controller.py" 417 "producer" fn-ref + "src.api_hook_client.get_project_switch_status" "src\api_hook_client.py" 374 "producer" fn-ref + "src.app_controller._api_get_api_session" "src\app_controller.py" 170 "producer" fn-ref + "src.api_hook_client.post_session" "src\api_hook_client.py" 117 "producer" fn-ref + "src.api_hook_client.get_system_telemetry" "src\api_hook_client.py" 524 "producer" fn-ref + "src.ai_client._parse_tool_args_result" "src\ai_client.py" 741 "producer" fn-ref + "src.api_hook_client.wait_for_project_switch" "src\api_hook_client.py" 389 "producer" fn-ref + "src.api_hook_client.get_events" "src\api_hook_client.py" 124 "producer" fn-ref + "src.app_controller.get_context" "src\app_controller.py" 2892 "producer" fn-ref + "src.ai_client._extract_dashscope_tool_calls" "src\ai_client.py" 2754 "producer" fn-ref + "src.api_hook_client.get_gui_health" "src\api_hook_client.py" 434 "producer" fn-ref + "src.models.to_dict" "src\models.py" 794 "producer" fn-ref + "src.ai_client.get_comms_log" "src\ai_client.py" 273 "producer" fn-ref + "src.project_manager.default_project" "src\project_manager.py" 123 "producer" fn-ref + "src.api_hook_client.apply_patch" "src\api_hook_client.py" 281 "producer" fn-ref + "src.api_hook_client.get_warmup_wait" "src\api_hook_client.py" 332 "producer" fn-ref + "src.api_hook_client.get_warmup_canaries" "src\api_hook_client.py" 342 "producer" fn-ref + "src.api_hook_client.get_financial_metrics" "src\api_hook_client.py" 520 "producer" fn-ref + "src.models._load_config_from_disk" "src\models.py" 186 "producer" fn-ref + "src.ai_client.get_token_stats" "src\ai_client.py" 3185 "producer" fn-ref + "src.aggregate.build_file_items" "src\aggregate.py" 158 "producer" fn-ref + "src.app_controller.get_session_insights" "src\app_controller.py" 3049 "producer" fn-ref + "src.api_hook_client.post_gui" "src\api_hook_client.py" 149 "producer" fn-ref + "src.models.to_dict" "src\models.py" 855 "producer" fn-ref + "src.app_controller._pending_mma_approval" "src\app_controller.py" 2776 "producer" fn-ref + "src.api_hook_client.drag" "src\api_hook_client.py" 230 "producer" fn-ref + "src.api_hook_client.post_project" "src\api_hook_client.py" 470 "producer" fn-ref + "src.app_controller.wait" "src\app_controller.py" 5205 "producer" fn-ref + "src.app_controller.get_session" "src\app_controller.py" 2883 "producer" fn-ref + "src.app_controller._api_get_mma_status" "src\app_controller.py" 144 "producer" fn-ref + "src.app_controller._api_pending_actions" "src\app_controller.py" 335 "producer" fn-ref + "src.api_hook_client.get_node_status" "src\api_hook_client.py" 532 "producer" fn-ref + "src.api_hook_client.get_io_pool_status" "src\api_hook_client.py" 420 "producer" fn-ref + "src.app_controller.get_mma_status" "src\app_controller.py" 2835 "producer" fn-ref + "src.models.to_dict" "src\models.py" 1000 "producer" fn-ref + "src.models.to_dict" "src\models.py" 938 "producer" fn-ref + "src.app_controller._pending_mma_spawn" "src\app_controller.py" 2772 "producer" fn-ref + "src.app_controller.get_performance" "src\app_controller.py" 2856 "producer" fn-ref + "src.api_hook_client.wait_for_event" "src\api_hook_client.py" 136 "producer" fn-ref + "src.api_hook_client.get_context_state" "src\api_hook_client.py" 491 "producer" fn-ref + "src.ai_client._dashscope_call" "src\ai_client.py" 2716 "producer" fn-ref + "src.app_controller.get_diagnostics" "src\app_controller.py" 2862 "producer" fn-ref + "src.project_manager.migrate_from_legacy_config" "src\project_manager.py" 253 "producer" fn-ref + "src.models.to_dict" "src\models.py" 288 "producer" fn-ref + "src.ai_client._load_credentials" "src\ai_client.py" 282 "producer" fn-ref + "src.app_controller._api_get_diagnostics" "src\app_controller.py" 202 "producer" fn-ref + "src.models.to_dict" "src\models.py" 913 "producer" fn-ref + "src.models.to_dict" "src\models.py" 596 "producer" fn-ref + "src.ai_client._get_deepseek_tools" "src\ai_client.py" 1194 "producer" fn-ref + "src.app_controller.get_api_session" "src\app_controller.py" 2847 "producer" fn-ref + "src.ai_client._pre_dispatch" "src\ai_client.py" 2089 "producer" fn-ref + "src.models.to_dict" "src\models.py" 558 "producer" fn-ref + "src.api_hook_client.get_mma_status" "src\api_hook_client.py" 539 "producer" fn-ref + "src.api_hook_client.set_value" "src\api_hook_client.py" 212 "producer" fn-ref + "src.project_manager.load_history" "src\project_manager.py" 209 "producer" fn-ref + "src.ai_client.ollama_chat" "src\ai_client.py" 2938 "producer" fn-ref + "src.app_controller.get_gui_state" "src\app_controller.py" 2829 "producer" fn-ref -\ === consumers (35 items) === - "src.ai_client._strip_stale_file_refreshes" "src\ai_client.py" 0 "consumer" fn-ref - "src.project_manager.format_discussion" "src\project_manager.py" 0 "consumer" fn-ref - "src.aggregate._build_files_section_from_items" "src\aggregate.py" 0 "consumer" fn-ref - "src.ai_client._append_comms" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client._trim_anthropic_history" "src\ai_client.py" 0 "consumer" fn-ref - "src.models._save_config_to_disk" "src\models.py" 0 "consumer" fn-ref - "src.app_controller._on_comms_entry" "src\app_controller.py" 0 "consumer" fn-ref - "src.ai_client._execute_single_tool_call_async" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client._dashscope_call" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client.ollama_chat" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client._pre_dispatch" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client._strip_cache_controls" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client._estimate_prompt_tokens" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client._add_history_cache_breakpoint" "src\ai_client.py" 0 "consumer" fn-ref - "src.project_manager.flat_config" "src\project_manager.py" 0 "consumer" fn-ref - "src.app_controller._offload_entry_payload" "src\app_controller.py" 0 "consumer" fn-ref - "src.ai_client._repair_minimax_history" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client._strip_private_keys" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client._repair_deepseek_history" "src\ai_client.py" 0 "consumer" fn-ref - "src.project_manager.entry_to_str" "src\project_manager.py" 0 "consumer" fn-ref - "src.aggregate.build_tier3_context" "src\aggregate.py" 0 "consumer" fn-ref - "src.ai_client._estimate_message_tokens" "src\ai_client.py" 0 "consumer" fn-ref - "src.project_manager.migrate_from_legacy_config" "src\project_manager.py" 0 "consumer" fn-ref - "src.aggregate.run" "src\aggregate.py" 0 "consumer" fn-ref - "src.models.from_dict" "src\models.py" 0 "consumer" fn-ref - "src.project_manager.save_project" "src\project_manager.py" 0 "consumer" fn-ref - "src.aggregate.build_markdown_from_items" "src\aggregate.py" 0 "consumer" fn-ref - "src.app_controller._start_track_logic" "src\app_controller.py" 0 "consumer" fn-ref - "src.app_controller._refresh_api_metrics" "src\app_controller.py" 0 "consumer" fn-ref - "src.app_controller._start_track_logic_result" "src\app_controller.py" 0 "consumer" fn-ref - "src.ai_client._add_bleed_derived" "src\ai_client.py" 0 "consumer" fn-ref - "src.aggregate.build_markdown_no_history" "src\aggregate.py" 0 "consumer" fn-ref - "src.ai_client._invalidate_token_estimate" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client._repair_anthropic_history" "src\ai_client.py" 0 "consumer" fn-ref - "src.ai_client._trim_minimax_history" "src\ai_client.py" 0 "consumer" fn-ref +\ === consumers (66 items) === + "src.aggregate.build_markdown_from_items" "src\aggregate.py" 348 "consumer" fn-ref + "src.ai_client._send_anthropic" "src\ai_client.py" 1405 "consumer" fn-ref + "src.app_controller._refresh_api_metrics" "src\app_controller.py" 3074 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 575 "consumer" fn-ref + "src.ai_client._add_history_cache_breakpoint" "src\ai_client.py" 1299 "consumer" fn-ref + "src.ai_client._append_comms" "src\ai_client.py" 257 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 656 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 920 "consumer" fn-ref + "src.ai_client._repair_deepseek_history" "src\ai_client.py" 2138 "consumer" fn-ref + "src.ai_client._dashscope_call" "src\ai_client.py" 2716 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 416 "consumer" fn-ref + "src.ai_client._send_grok" "src\ai_client.py" 2530 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 1072 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 295 "consumer" fn-ref + "src.aggregate.build_tier3_context" "src\aggregate.py" 382 "consumer" fn-ref + "src.aggregate.build_markdown_no_history" "src\aggregate.py" 366 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 506 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 603 "consumer" fn-ref + "src.project_manager.migrate_from_legacy_config" "src\project_manager.py" 253 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 814 "consumer" fn-ref + "src.app_controller._on_comms_entry" "src\app_controller.py" 4282 "consumer" fn-ref + "src.aggregate.run" "src\aggregate.py" 479 "consumer" fn-ref + "src.ai_client._trim_minimax_history" "src\ai_client.py" 2482 "consumer" fn-ref + "src.app_controller._start_track_logic" "src\app_controller.py" 4721 "consumer" fn-ref + "src.project_manager.save_project" "src\project_manager.py" 229 "consumer" fn-ref + "src.ai_client._send_gemini" "src\ai_client.py" 1802 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 378 "consumer" fn-ref + "src.project_manager.format_discussion" "src\project_manager.py" 69 "consumer" fn-ref + "src.ai_client._repair_minimax_history" "src\ai_client.py" 2462 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 893 "consumer" fn-ref + "src.ai_client._repair_anthropic_history" "src\ai_client.py" 1381 "consumer" fn-ref + "src.ai_client._pre_dispatch" "src\ai_client.py" 2089 "consumer" fn-ref + "src.ai_client._strip_stale_file_refreshes" "src\ai_client.py" 1253 "consumer" fn-ref + "src.ai_client.send" "src\ai_client.py" 3208 "consumer" fn-ref + "src.app_controller._offload_entry_payload" "src\app_controller.py" 4240 "consumer" fn-ref + "src.app_controller._start_track_logic_result" "src\app_controller.py" 4728 "consumer" fn-ref + "src.ai_client._send_minimax" "src\ai_client.py" 2616 "consumer" fn-ref + "src.ai_client._send_llama_native" "src\ai_client.py" 2958 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 1038 "consumer" fn-ref + "src.ai_client._create_gemini_cache_result" "src\ai_client.py" 1706 "consumer" fn-ref + "src.project_manager.entry_to_str" "src\project_manager.py" 49 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 1007 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 712 "consumer" fn-ref + "src.models._save_config_to_disk" "src\models.py" 199 "consumer" fn-ref + "src.ai_client._send_qwen" "src\ai_client.py" 2773 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 866 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 747 "consumer" fn-ref + "src.ai_client._trim_anthropic_history" "src\ai_client.py" 1353 "consumer" fn-ref + "src.ai_client._strip_private_keys" "src\ai_client.py" 1464 "consumer" fn-ref + "src.ai_client._estimate_prompt_tokens" "src\ai_client.py" 1243 "consumer" fn-ref + "src.ai_client.ollama_chat" "src\ai_client.py" 2938 "consumer" fn-ref + "src.ai_client._execute_single_tool_call_async" "src\ai_client.py" 945 "consumer" fn-ref + "src.project_manager.flat_config" "src\project_manager.py" 267 "consumer" fn-ref + "src.ai_client._send_deepseek" "src\ai_client.py" 2165 "consumer" fn-ref + "src.ai_client._send_llama" "src\ai_client.py" 2858 "consumer" fn-ref + "src.ai_client._add_bleed_derived" "src\ai_client.py" 3332 "consumer" fn-ref + "src.ai_client._send_gemini_cli" "src\ai_client.py" 2019 "consumer" fn-ref + "src.aggregate._build_files_section_from_items" "src\aggregate.py" 300 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 683 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 630 "consumer" fn-ref + "src.ai_client._invalidate_token_estimate" "src\ai_client.py" 1240 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 454 "consumer" fn-ref + "src.ai_client._strip_cache_controls" "src\ai_client.py" 1291 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 949 "consumer" fn-ref + "src.models.from_dict" "src\models.py" 982 "consumer" fn-ref + "src.ai_client._estimate_message_tokens" "src\ai_client.py" 1218 "consumer" fn-ref \ === access_pattern === "whole_struct" access-pattern -\ === access_pattern_evidence (35 items) === - "src.ai_client._strip_stale_file_refreshes" "whole_struct" 0 "low" ap-evidence - "src.project_manager.format_discussion" "whole_struct" 0 "low" ap-evidence - "src.aggregate._build_files_section_from_items" "whole_struct" 0 "low" ap-evidence - "src.ai_client._append_comms" "whole_struct" 0 "low" ap-evidence - "src.ai_client._trim_anthropic_history" "whole_struct" 1 "high" ap-evidence - "src.models._save_config_to_disk" "whole_struct" 0 "low" ap-evidence - "src.app_controller._on_comms_entry" "field_by_field" 10 "high" ap-evidence - "src.ai_client._execute_single_tool_call_async" "mixed" 2 "high" ap-evidence - "src.ai_client._dashscope_call" "whole_struct" 0 "low" ap-evidence - "src.ai_client.ollama_chat" "whole_struct" 0 "low" ap-evidence - "src.ai_client._pre_dispatch" "whole_struct" 0 "low" ap-evidence - "src.ai_client._strip_cache_controls" "whole_struct" 0 "low" ap-evidence - "src.ai_client._estimate_prompt_tokens" "whole_struct" 0 "low" ap-evidence - "src.ai_client._add_history_cache_breakpoint" "whole_struct" 0 "low" ap-evidence - "src.project_manager.flat_config" "whole_struct" 1 "high" ap-evidence - "src.app_controller._offload_entry_payload" "whole_struct" 0 "low" ap-evidence - "src.ai_client._repair_minimax_history" "whole_struct" 1 "high" ap-evidence - "src.ai_client._strip_private_keys" "whole_struct" 0 "low" ap-evidence - "src.ai_client._repair_deepseek_history" "whole_struct" 1 "high" ap-evidence - "src.project_manager.entry_to_str" "whole_struct" 1 "high" ap-evidence - "src.aggregate.build_tier3_context" "whole_struct" 0 "low" ap-evidence - "src.ai_client._estimate_message_tokens" "mixed" 2 "high" ap-evidence - "src.project_manager.migrate_from_legacy_config" "whole_struct" 1 "high" ap-evidence - "src.aggregate.run" "field_by_field" 3 "high" ap-evidence - "src.models.from_dict" "mixed" 2 "high" ap-evidence - "src.project_manager.save_project" "mixed" 2 "high" ap-evidence +\ === access_pattern_evidence (66 items) === "src.aggregate.build_markdown_from_items" "whole_struct" 0 "low" ap-evidence - "src.app_controller._start_track_logic" "mixed" 2 "high" ap-evidence + "src.ai_client._send_anthropic" "whole_struct" 0 "low" ap-evidence "src.app_controller._refresh_api_metrics" "field_by_field" 11 "high" ap-evidence - "src.app_controller._start_track_logic_result" "field_by_field" 17 "high" ap-evidence - "src.ai_client._add_bleed_derived" "field_by_field" 9 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.ai_client._add_history_cache_breakpoint" "whole_struct" 0 "low" ap-evidence + "src.ai_client._append_comms" "whole_struct" 0 "low" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.ai_client._repair_deepseek_history" "whole_struct" 1 "high" ap-evidence + "src.ai_client._dashscope_call" "whole_struct" 0 "low" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.ai_client._send_grok" "whole_struct" 0 "low" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.aggregate.build_tier3_context" "whole_struct" 0 "low" ap-evidence "src.aggregate.build_markdown_no_history" "whole_struct" 0 "low" ap-evidence - "src.ai_client._invalidate_token_estimate" "whole_struct" 1 "high" ap-evidence - "src.ai_client._repair_anthropic_history" "whole_struct" 1 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.project_manager.migrate_from_legacy_config" "whole_struct" 1 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.app_controller._on_comms_entry" "field_by_field" 10 "high" ap-evidence + "src.aggregate.run" "field_by_field" 3 "high" ap-evidence "src.ai_client._trim_minimax_history" "whole_struct" 1 "high" ap-evidence + "src.app_controller._start_track_logic" "mixed" 2 "high" ap-evidence + "src.project_manager.save_project" "mixed" 2 "high" ap-evidence + "src.ai_client._send_gemini" "whole_struct" 1 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.project_manager.format_discussion" "whole_struct" 0 "low" ap-evidence + "src.ai_client._repair_minimax_history" "whole_struct" 1 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.ai_client._repair_anthropic_history" "whole_struct" 1 "high" ap-evidence + "src.ai_client._pre_dispatch" "whole_struct" 0 "low" ap-evidence + "src.ai_client._strip_stale_file_refreshes" "whole_struct" 0 "low" ap-evidence + "src.ai_client.send" "mixed" 2 "high" ap-evidence + "src.app_controller._offload_entry_payload" "whole_struct" 0 "low" ap-evidence + "src.app_controller._start_track_logic_result" "field_by_field" 17 "high" ap-evidence + "src.ai_client._send_minimax" "whole_struct" 0 "low" ap-evidence + "src.ai_client._send_llama_native" "whole_struct" 0 "low" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.ai_client._create_gemini_cache_result" "whole_struct" 0 "low" ap-evidence + "src.project_manager.entry_to_str" "whole_struct" 1 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.models._save_config_to_disk" "whole_struct" 0 "low" ap-evidence + "src.ai_client._send_qwen" "whole_struct" 0 "low" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.ai_client._trim_anthropic_history" "whole_struct" 1 "high" ap-evidence + "src.ai_client._strip_private_keys" "whole_struct" 0 "low" ap-evidence + "src.ai_client._estimate_prompt_tokens" "whole_struct" 0 "low" ap-evidence + "src.ai_client.ollama_chat" "whole_struct" 0 "low" ap-evidence + "src.ai_client._execute_single_tool_call_async" "mixed" 2 "high" ap-evidence + "src.project_manager.flat_config" "whole_struct" 1 "high" ap-evidence + "src.ai_client._send_deepseek" "whole_struct" 0 "low" ap-evidence + "src.ai_client._send_llama" "whole_struct" 0 "low" ap-evidence + "src.ai_client._add_bleed_derived" "field_by_field" 9 "high" ap-evidence + "src.ai_client._send_gemini_cli" "whole_struct" 0 "low" ap-evidence + "src.aggregate._build_files_section_from_items" "whole_struct" 0 "low" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.ai_client._invalidate_token_estimate" "whole_struct" 1 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.ai_client._strip_cache_controls" "whole_struct" 0 "low" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.models.from_dict" "mixed" 2 "high" ap-evidence + "src.ai_client._estimate_message_tokens" "mixed" 2 "high" ap-evidence \ === frequency === "per_turn" frequency \ === frequency_evidence (5 items) === - "src.api_hook_client.get_performance" "per_turn" "static_analysis" "producer from src\api_hook_client.py" freq-evidence - "src.app_controller.get_performance" "per_turn" "static_analysis" "producer from src\app_controller.py" freq-evidence - "src.ai_client._send_cli_round_result" "per_turn" "static_analysis" "producer from src\ai_client.py" freq-evidence - "src.api_hook_client.post_session" "per_turn" "static_analysis" "producer from src\api_hook_client.py" freq-evidence - "src.app_controller.wait" "per_turn" "static_analysis" "producer from src\app_controller.py" freq-evidence + "src.models.to_dict" "per_turn" "static_analysis" "producer from src\models.py" freq-evidence + "src.api_hook_client.get_gui_diagnostics" "per_turn" "static_analysis" "producer from src\api_hook_client.py" freq-evidence + "src.models.to_dict" "per_turn" "static_analysis" "producer from src\models.py" freq-evidence + "src.app_controller._api_get_api_project" "per_turn" "static_analysis" "producer from src\app_controller.py" freq-evidence + "src.api_hook_client.clear_events" "per_turn" "static_analysis" "producer from src\api_hook_client.py" freq-evidence \ === result_coverage === - 77 77 35 0 result-coverage + 96 96 46 0 result-coverage \ === type_alias_coverage === - 130 0 130 type-alias-coverage + 173 0 173 type-alias-coverage \ === cross_audit_findings === "audit_optional_in_3_files" 76 "src\ai_client.py" 159 "76 sites" cross-audit-finding diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/Metadata.md b/docs/reports/code_path_audit/2026-06-22/aggregates/Metadata.md index 335f6bee..06f6c06a 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/Metadata.md +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/Metadata.md @@ -6,268 +6,404 @@ ## Pipeline summary -- Producers: 77 -- Consumers: 35 -- Distinct producer fqnames: 77 -- Distinct consumer fqnames: 35 +- Producers: 117 +- Consumers: 66 +- Distinct producer fqnames: 96 +- Distinct consumer fqnames: 46 - Access pattern (aggregate): whole_struct - Frequency (aggregate): per_turn - Decomposition direction: hold - Struct field count (estimated): 10 -## Producers (77) +## Producers (117) -### `src\ai_client.py` (9 producers) +### `src\aggregate.py` (1 producer) -- `src.ai_client._send_cli_round_result` (line 0) -- `src.ai_client.ollama_chat` (line 0) -- `src.ai_client._add_bleed_derived` (line 0) -- `src.ai_client._parse_tool_args_result` (line 0) -- `src.ai_client._load_credentials` (line 0) -- `src.ai_client.get_token_stats` (line 0) -- `src.ai_client._dashscope_call` (line 0) -- `src.ai_client._content_block_to_dict` (line 0) -- `src.ai_client.get_gemini_cache_stats` (line 0) +- `src.aggregate.build_file_items` (line 158) -### `src\api_hook_client.py` (33 producers) +### `src\ai_client.py` (16 producers) -- `src.api_hook_client.get_performance` (line 0) -- `src.api_hook_client.post_session` (line 0) -- `src.api_hook_client.get_financial_metrics` (line 0) -- `src.api_hook_client.get_status` (line 0) -- `src.api_hook_client.get_context_state` (line 0) -- `src.api_hook_client.get_gui_health` (line 0) -- `src.api_hook_client.post_project` (line 0) -- `src.api_hook_client.select_list_item` (line 0) -- `src.api_hook_client.get_io_pool_status` (line 0) -- `src.api_hook_client.reject_patch` (line 0) -- `src.api_hook_client.get_system_telemetry` (line 0) -- `src.api_hook_client.push_event` (line 0) -- `src.api_hook_client.get_project_switch_status` (line 0) -- `src.api_hook_client.select_tab` (line 0) -- `src.api_hook_client.post_gui` (line 0) -- `src.api_hook_client.get_warmup_status` (line 0) -- `src.api_hook_client.get_warmup_wait` (line 0) -- `src.api_hook_client.wait_for_project_switch` (line 0) -- `src.api_hook_client.get_session` (line 0) -- `src.api_hook_client.get_startup_timeline` (line 0) -- `src.api_hook_client.get_mma_workers` (line 0) -- `src.api_hook_client.drag` (line 0) -- `src.api_hook_client.get_node_status` (line 0) -- `src.api_hook_client.apply_patch` (line 0) -- `src.api_hook_client.set_value` (line 0) -- `src.api_hook_client.get_mma_status` (line 0) -- `src.api_hook_client.get_gui_state` (line 0) -- `src.api_hook_client.right_click` (line 0) -- `src.api_hook_client.get_patch_status` (line 0) -- `src.api_hook_client.trigger_patch` (line 0) -- `src.api_hook_client.get_project` (line 0) -- `src.api_hook_client.get_gui_diagnostics` (line 0) -- `src.api_hook_client.click` (line 0) +- `src.ai_client._build_chunked_context_blocks` (line 1281) +- `src.ai_client._send_cli_round_result` (line 1746) +- `src.ai_client._get_anthropic_tools` (line 664) +- `src.ai_client.get_gemini_cache_stats` (line 1604) +- `src.ai_client._content_block_to_dict` (line 1200) +- `src.ai_client._strip_private_keys` (line 1464) +- `src.ai_client._add_bleed_derived` (line 3332) +- `src.ai_client._parse_tool_args_result` (line 741) +- `src.ai_client._extract_dashscope_tool_calls` (line 2754) +- `src.ai_client.get_comms_log` (line 273) +- `src.ai_client.get_token_stats` (line 3185) +- `src.ai_client._dashscope_call` (line 2716) +- `src.ai_client._load_credentials` (line 282) +- `src.ai_client._get_deepseek_tools` (line 1194) +- `src.ai_client._pre_dispatch` (line 2089) +- `src.ai_client.ollama_chat` (line 2938) -### `src\app_controller.py` (26 producers) +### `src\api_hook_client.py` (39 producers) -- `src.app_controller.get_performance` (line 0) -- `src.app_controller.wait` (line 0) -- `src.app_controller.get_diagnostics` (line 0) -- `src.app_controller.get_gui_state` (line 0) -- `src.app_controller._api_status` (line 0) -- `src.app_controller._api_token_stats` (line 0) -- `src.app_controller._api_get_api_session` (line 0) -- `src.app_controller._api_get_context` (line 0) -- `src.app_controller.get_api_project` (line 0) -- `src.app_controller._api_get_performance` (line 0) -- `src.app_controller.status` (line 0) -- `src.app_controller._api_get_gui_state` (line 0) -- `src.app_controller._api_get_session` (line 0) -- `src.app_controller.load_config` (line 0) -- `src.app_controller._api_get_mma_status` (line 0) -- `src.app_controller.token_stats` (line 0) -- `src.app_controller.get_mma_status` (line 0) -- `src.app_controller.get_session_insights` (line 0) -- `src.app_controller._api_get_api_project` (line 0) -- `src.app_controller._api_generate` (line 0) -- `src.app_controller.get_context` (line 0) -- `src.app_controller._api_get_diagnostics` (line 0) -- `src.app_controller._offload_entry_payload` (line 0) -- `src.app_controller.get_session` (line 0) -- `src.app_controller.get_api_session` (line 0) -- `src.app_controller.generate` (line 0) +- `src.api_hook_client.get_gui_diagnostics` (line 311) +- `src.api_hook_client.clear_events` (line 129) +- `src.api_hook_client.get_mma_workers` (line 546) +- `src.api_hook_client.get_startup_timeline` (line 353) +- `src.api_hook_client.get_session` (line 502) +- `src.api_hook_client.get_status` (line 105) +- `src.api_hook_client._make_request` (line 65) +- `src.api_hook_client.right_click` (line 237) +- `src.api_hook_client.trigger_patch` (line 274) +- `src.api_hook_client.select_tab` (line 263) +- `src.api_hook_client.click` (line 223) +- `src.api_hook_client.get_gui_state` (line 165) +- `src.api_hook_client.post_project` (line 473) +- `src.api_hook_client.get_patch_status` (line 295) +- `src.api_hook_client.push_event` (line 156) +- `src.api_hook_client.reject_patch` (line 288) +- `src.api_hook_client.get_project` (line 367) +- `src.api_hook_client.get_performance` (line 318) +- `src.api_hook_client.select_list_item` (line 256) +- `src.api_hook_client.get_warmup_status` (line 325) +- `src.api_hook_client.get_project_switch_status` (line 374) +- `src.api_hook_client.post_session` (line 117) +- `src.api_hook_client.get_system_telemetry` (line 524) +- `src.api_hook_client.wait_for_project_switch` (line 389) +- `src.api_hook_client.get_events` (line 124) +- `src.api_hook_client.get_gui_health` (line 434) +- `src.api_hook_client.apply_patch` (line 281) +- `src.api_hook_client.get_warmup_wait` (line 332) +- `src.api_hook_client.get_warmup_canaries` (line 342) +- `src.api_hook_client.get_financial_metrics` (line 520) +- `src.api_hook_client.post_gui` (line 149) +- `src.api_hook_client.drag` (line 230) +- `src.api_hook_client.post_project` (line 470) +- `src.api_hook_client.get_node_status` (line 532) +- `src.api_hook_client.get_io_pool_status` (line 420) +- `src.api_hook_client.wait_for_event` (line 136) +- `src.api_hook_client.get_context_state` (line 491) +- `src.api_hook_client.get_mma_status` (line 539) +- `src.api_hook_client.set_value` (line 212) -### `src\models.py` (2 producers) +### `src\app_controller.py` (30 producers) -- `src.models._load_config_from_disk` (line 0) -- `src.models.to_dict` (line 0) +- `src.app_controller._api_get_api_project` (line 188) +- `src.app_controller.get_api_project` (line 2853) +- `src.app_controller._offload_entry_payload` (line 4240) +- `src.app_controller.generate` (line 2868) +- `src.app_controller.token_stats` (line 2898) +- `src.app_controller._api_get_session` (line 374) +- `src.app_controller._api_get_gui_state` (line 123) +- `src.app_controller.load_config` (line 5142) +- `src.app_controller.pending_actions` (line 2874) +- `src.app_controller._api_get_performance` (line 195) +- `src.app_controller._api_get_context` (line 398) +- `src.app_controller.status` (line 2865) +- `src.app_controller._api_generate` (line 221) +- `src.app_controller._api_status` (line 209) +- `src.app_controller._api_token_stats` (line 417) +- `src.app_controller._api_get_api_session` (line 170) +- `src.app_controller.get_context` (line 2892) +- `src.app_controller.get_session_insights` (line 3049) +- `src.app_controller._pending_mma_approval` (line 2776) +- `src.app_controller.wait` (line 5205) +- `src.app_controller.get_session` (line 2883) +- `src.app_controller._api_get_mma_status` (line 144) +- `src.app_controller._api_pending_actions` (line 335) +- `src.app_controller.get_mma_status` (line 2835) +- `src.app_controller._pending_mma_spawn` (line 2772) +- `src.app_controller.get_performance` (line 2856) +- `src.app_controller.get_diagnostics` (line 2862) +- `src.app_controller._api_get_diagnostics` (line 202) +- `src.app_controller.get_api_session` (line 2847) +- `src.app_controller.get_gui_state` (line 2829) -### `src\project_manager.py` (7 producers) +### `src\models.py` (23 producers) -- `src.project_manager.load_history` (line 0) -- `src.project_manager.flat_config` (line 0) -- `src.project_manager.default_discussion` (line 0) -- `src.project_manager.str_to_entry` (line 0) -- `src.project_manager.migrate_from_legacy_config` (line 0) -- `src.project_manager.default_project` (line 0) -- `src.project_manager.load_project` (line 0) +- `src.models.to_dict` (line 441) +- `src.models.to_dict` (line 1024) +- `src.models.to_dict` (line 737) +- `src.models.to_dict` (line 618) +- `src.models.to_dict` (line 486) +- `src.models.to_dict` (line 886) +- `src.models.to_dict` (line 971) +- `src.models.parse_history_entries` (line 214) +- `src.models.to_dict` (line 646) +- `src.models.to_dict` (line 406) +- `src.models.to_dict` (line 701) +- `src.models.to_dict` (line 672) +- `src.models.to_dict` (line 355) +- `src.models.to_dict` (line 1059) +- `src.models.to_dict` (line 794) +- `src.models._load_config_from_disk` (line 186) +- `src.models.to_dict` (line 855) +- `src.models.to_dict` (line 1000) +- `src.models.to_dict` (line 938) +- `src.models.to_dict` (line 288) +- `src.models.to_dict` (line 913) +- `src.models.to_dict` (line 596) +- `src.models.to_dict` (line 558) -## Consumers (35) +### `src\project_manager.py` (8 producers) + +- `src.project_manager.flat_config` (line 267) +- `src.project_manager.str_to_entry` (line 75) +- `src.project_manager.default_discussion` (line 117) +- `src.project_manager.load_project` (line 186) +- `src.project_manager.get_all_tracks` (line 342) +- `src.project_manager.default_project` (line 123) +- `src.project_manager.migrate_from_legacy_config` (line 253) +- `src.project_manager.load_history` (line 209) + +## Consumers (66) ### `src\aggregate.py` (5 consumers) -- `src.aggregate._build_files_section_from_items` (line 0) -- `src.aggregate.build_tier3_context` (line 0) -- `src.aggregate.run` (line 0) -- `src.aggregate.build_markdown_from_items` (line 0) -- `src.aggregate.build_markdown_no_history` (line 0) +- `src.aggregate.build_markdown_from_items` (line 348) +- `src.aggregate.build_tier3_context` (line 382) +- `src.aggregate.build_markdown_no_history` (line 366) +- `src.aggregate.run` (line 479) +- `src.aggregate._build_files_section_from_items` (line 300) -### `src\ai_client.py` (18 consumers) +### `src\ai_client.py` (29 consumers) -- `src.ai_client._strip_stale_file_refreshes` (line 0) -- `src.ai_client._append_comms` (line 0) -- `src.ai_client._trim_anthropic_history` (line 0) -- `src.ai_client._execute_single_tool_call_async` (line 0) -- `src.ai_client._dashscope_call` (line 0) -- `src.ai_client.ollama_chat` (line 0) -- `src.ai_client._pre_dispatch` (line 0) -- `src.ai_client._strip_cache_controls` (line 0) -- `src.ai_client._estimate_prompt_tokens` (line 0) -- `src.ai_client._add_history_cache_breakpoint` (line 0) -- `src.ai_client._repair_minimax_history` (line 0) -- `src.ai_client._strip_private_keys` (line 0) -- `src.ai_client._repair_deepseek_history` (line 0) -- `src.ai_client._estimate_message_tokens` (line 0) -- `src.ai_client._add_bleed_derived` (line 0) -- `src.ai_client._invalidate_token_estimate` (line 0) -- `src.ai_client._repair_anthropic_history` (line 0) -- `src.ai_client._trim_minimax_history` (line 0) +- `src.ai_client._send_anthropic` (line 1405) +- `src.ai_client._add_history_cache_breakpoint` (line 1299) +- `src.ai_client._append_comms` (line 257) +- `src.ai_client._repair_deepseek_history` (line 2138) +- `src.ai_client._dashscope_call` (line 2716) +- `src.ai_client._send_grok` (line 2530) +- `src.ai_client._trim_minimax_history` (line 2482) +- `src.ai_client._send_gemini` (line 1802) +- `src.ai_client._repair_minimax_history` (line 2462) +- `src.ai_client._repair_anthropic_history` (line 1381) +- `src.ai_client._pre_dispatch` (line 2089) +- `src.ai_client._strip_stale_file_refreshes` (line 1253) +- `src.ai_client.send` (line 3208) +- `src.ai_client._send_minimax` (line 2616) +- `src.ai_client._send_llama_native` (line 2958) +- `src.ai_client._create_gemini_cache_result` (line 1706) +- `src.ai_client._send_qwen` (line 2773) +- `src.ai_client._trim_anthropic_history` (line 1353) +- `src.ai_client._strip_private_keys` (line 1464) +- `src.ai_client._estimate_prompt_tokens` (line 1243) +- `src.ai_client.ollama_chat` (line 2938) +- `src.ai_client._execute_single_tool_call_async` (line 945) +- `src.ai_client._send_deepseek` (line 2165) +- `src.ai_client._send_llama` (line 2858) +- `src.ai_client._add_bleed_derived` (line 3332) +- `src.ai_client._send_gemini_cli` (line 2019) +- `src.ai_client._invalidate_token_estimate` (line 1240) +- `src.ai_client._strip_cache_controls` (line 1291) +- `src.ai_client._estimate_message_tokens` (line 1218) ### `src\app_controller.py` (5 consumers) -- `src.app_controller._on_comms_entry` (line 0) -- `src.app_controller._offload_entry_payload` (line 0) -- `src.app_controller._start_track_logic` (line 0) -- `src.app_controller._refresh_api_metrics` (line 0) -- `src.app_controller._start_track_logic_result` (line 0) +- `src.app_controller._refresh_api_metrics` (line 3074) +- `src.app_controller._on_comms_entry` (line 4282) +- `src.app_controller._start_track_logic` (line 4721) +- `src.app_controller._offload_entry_payload` (line 4240) +- `src.app_controller._start_track_logic_result` (line 4728) -### `src\models.py` (2 consumers) +### `src\models.py` (22 consumers) -- `src.models._save_config_to_disk` (line 0) -- `src.models.from_dict` (line 0) +- `src.models.from_dict` (line 575) +- `src.models.from_dict` (line 656) +- `src.models.from_dict` (line 920) +- `src.models.from_dict` (line 416) +- `src.models.from_dict` (line 1072) +- `src.models.from_dict` (line 295) +- `src.models.from_dict` (line 506) +- `src.models.from_dict` (line 603) +- `src.models.from_dict` (line 814) +- `src.models.from_dict` (line 378) +- `src.models.from_dict` (line 893) +- `src.models.from_dict` (line 1038) +- `src.models.from_dict` (line 1007) +- `src.models.from_dict` (line 712) +- `src.models._save_config_to_disk` (line 199) +- `src.models.from_dict` (line 866) +- `src.models.from_dict` (line 747) +- `src.models.from_dict` (line 683) +- `src.models.from_dict` (line 630) +- `src.models.from_dict` (line 454) +- `src.models.from_dict` (line 949) +- `src.models.from_dict` (line 982) ### `src\project_manager.py` (5 consumers) -- `src.project_manager.format_discussion` (line 0) -- `src.project_manager.flat_config` (line 0) -- `src.project_manager.entry_to_str` (line 0) -- `src.project_manager.migrate_from_legacy_config` (line 0) -- `src.project_manager.save_project` (line 0) +- `src.project_manager.migrate_from_legacy_config` (line 253) +- `src.project_manager.save_project` (line 229) +- `src.project_manager.format_discussion` (line 69) +- `src.project_manager.entry_to_str` (line 49) +- `src.project_manager.flat_config` (line 267) ## Field access matrix | consumer | _est_tokens | _gemini_cache_text | _offload_entry_payload | _pending_comms | _pending_comms_lock | _pending_gui_tasks | _pending_gui_tasks_lock | _pending_history_adds | _pending_history_adds_lock | _recalculate_session_usage | _start_track_logic_result | _token_history | _token_stats | _topological_sort_tickets_result | _update_cached_stats | active_discussion | active_project_path | active_project_root | ai_status | append | |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---| -| `_strip_stale_file_refreshes` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `format_discussion` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_build_files_section_from_items` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_append_comms` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_trim_anthropic_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_save_config_to_disk` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_on_comms_entry` | . | . | 1 | 1 | 1 | . | . | 4 | 4 | . | . | 1 | . | . | . | . | . | . | . | . | -| `_execute_single_tool_call_async` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_dashscope_call` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `ollama_chat` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_pre_dispatch` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_strip_cache_controls` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_estimate_prompt_tokens` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_add_history_cache_breakpoint` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `flat_config` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_offload_entry_payload` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_repair_minimax_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 1 | -| `_strip_private_keys` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_repair_deepseek_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 1 | -| `entry_to_str` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `build_tier3_context` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_estimate_message_tokens` | 1 | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `migrate_from_legacy_config` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `run` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `save_project` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | | `build_markdown_from_items` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_start_track_logic` | . | . | . | . | . | . | . | . | . | . | 1 | . | . | . | . | . | . | . | 1 | . | +| `_send_anthropic` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | | `_refresh_api_metrics` | . | 1 | . | . | . | . | . | . | . | 1 | . | . | 1 | . | 1 | . | . | . | . | . | -| `_start_track_logic_result` | . | . | . | . | . | 2 | 2 | . | . | . | . | . | . | 1 | . | 1 | 1 | 1 | 4 | . | -| `_add_bleed_derived` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_add_history_cache_breakpoint` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_append_comms` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_repair_deepseek_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 1 | +| `_dashscope_call` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_grok` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `build_tier3_context` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | | `build_markdown_no_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_invalidate_token_estimate` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -| `_repair_anthropic_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 1 | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `migrate_from_legacy_config` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_on_comms_entry` | . | . | 1 | 1 | 1 | . | . | 4 | 4 | . | . | 1 | . | . | . | . | . | . | . | . | +| `run` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | | `_trim_minimax_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_start_track_logic` | . | . | . | . | . | . | . | . | . | . | 1 | . | . | . | . | . | . | . | 1 | . | +| `save_project` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_gemini` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `format_discussion` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_repair_minimax_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 1 | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_repair_anthropic_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 1 | +| `_pre_dispatch` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_strip_stale_file_refreshes` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `send` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_offload_entry_payload` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_start_track_logic_result` | . | . | . | . | . | 2 | 2 | . | . | . | . | . | . | 1 | . | 1 | 1 | 1 | 4 | . | +| `_send_minimax` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_llama_native` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_create_gemini_cache_result` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `entry_to_str` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_save_config_to_disk` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_qwen` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_trim_anthropic_history` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_strip_private_keys` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_estimate_prompt_tokens` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `ollama_chat` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_execute_single_tool_call_async` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `flat_config` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_deepseek` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_llama` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_add_bleed_derived` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_send_gemini_cli` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_build_files_section_from_items` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_invalidate_token_estimate` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_strip_cache_controls` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `from_dict` | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +| `_estimate_message_tokens` | 1 | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | -_... 33 more fields_ +_... 35 more fields_ ## Access pattern **Dominant pattern:** whole_struct -**Evidence count:** 35 +**Evidence count:** 66 **Per-function pattern distribution:** -- `whole_struct`: 25 functions (71%) -- `field_by_field`: 5 functions (14%) -- `mixed`: 5 functions (14%) +- `whole_struct`: 35 functions (53%) +- `mixed`: 26 functions (39%) +- `field_by_field`: 5 functions (8%) ## SSDL Sketch for `Metadata` ``` [Q:Metadata entry-point] -> [Q:PCG lookup] - -> [1: _strip_stale_file_refreshes] [B:check] (branches=12) - -> [2: format_discussion] [B:check] (branches=0) - -> [3: _build_files_section_from_items] [B:is None?] (branches=5) [N:safe] - -> [4: _append_comms] [B:is None?] (branches=1) [N:safe] - -> [5: _trim_anthropic_history] [B:check] (branches=13) - -> [6: _save_config_to_disk] [B:check] (branches=1) - -> [7: _on_comms_entry] [B:check] (branches=32) - -> [8: _execute_single_tool_call_async] [B:is None?] (branches=15) [N:safe] - -> [9: _dashscope_call] [B:check] (branches=5) - -> [10: ollama_chat] [B:check] (branches=3) - -> [11: _pre_dispatch] [B:check] (branches=8) - -> [12: _strip_cache_controls] [B:check] (branches=4) - -> [13: _estimate_prompt_tokens] [B:check] (branches=2) - -> [14: _add_history_cache_breakpoint] [B:check] (branches=5) - -> [15: flat_config] [B:check] (branches=2) - -> [16: _offload_entry_payload] [B:check] (branches=10) - -> [17: _repair_minimax_history] [B:check] (branches=10) - -> [18: _strip_private_keys] [B:check] (branches=0) - -> [19: _repair_deepseek_history] [B:check] (branches=6) - -> [20: entry_to_str] [B:check] (branches=3) - -> [21: build_tier3_context] [B:check] (branches=50) - -> [22: _estimate_message_tokens] [B:is None?] (branches=9) [N:safe] - -> [23: migrate_from_legacy_config] [B:check] (branches=2) - -> [24: run] [B:check] (branches=1) - -> [25: from_dict] [B:check] (branches=0) - -> [26: save_project] [B:is None?] (branches=7) [N:safe] - -> [27: build_markdown_from_items] [B:check] (branches=9) - -> [28: _start_track_logic] [B:check] (branches=1) - -> [29: _refresh_api_metrics] [B:is None?] (branches=11) [N:safe] - -> [30: _start_track_logic_result] [B:check] (branches=10) - -> [31: _add_bleed_derived] [B:check] (branches=0) - -> [32: build_markdown_no_history] [B:check] (branches=0) - -> [33: _invalidate_token_estimate] [B:check] (branches=0) - -> [34: _repair_anthropic_history] [B:check] (branches=6) - -> [35: _trim_minimax_history] [B:check] (branches=8) + -> [1: build_markdown_from_items] [B:check] (branches=9) + -> [2: _send_anthropic] [B:is None?] (branches=40) [N:safe] + -> [3: _refresh_api_metrics] [B:is None?] (branches=11) [N:safe] + -> [4: from_dict] [B:check] (branches=0) + -> [5: _add_history_cache_breakpoint] [B:check] (branches=5) + -> [6: _append_comms] [B:is None?] (branches=1) [N:safe] + -> [7: from_dict] [B:check] (branches=0) + -> [8: from_dict] [B:check] (branches=0) + -> [9: _repair_deepseek_history] [B:check] (branches=6) + -> [10: _dashscope_call] [B:check] (branches=5) + -> [11: from_dict] [B:check] (branches=0) + -> [12: _send_grok] [B:check] (branches=14) + -> [13: from_dict] [B:check] (branches=0) + -> [14: from_dict] [B:check] (branches=0) + -> [15: build_tier3_context] [B:check] (branches=50) + -> [16: build_markdown_no_history] [B:check] (branches=0) + -> [17: from_dict] [B:check] (branches=0) + -> [18: from_dict] [B:check] (branches=0) + -> [19: migrate_from_legacy_config] [B:check] (branches=2) + -> [20: from_dict] [B:check] (branches=0) + -> [21: _on_comms_entry] [B:check] (branches=32) + -> [22: run] [B:check] (branches=1) + -> [23: _trim_minimax_history] [B:check] (branches=8) + -> [24: _start_track_logic] [B:check] (branches=1) + -> [25: save_project] [B:is None?] (branches=7) [N:safe] + -> [26: _send_gemini] [B:is None?] (branches=75) [N:safe] + -> [27: from_dict] [B:check] (branches=0) + -> [28: format_discussion] [B:check] (branches=0) + -> [29: _repair_minimax_history] [B:check] (branches=10) + -> [30: from_dict] [B:check] (branches=0) + -> [31: _repair_anthropic_history] [B:check] (branches=6) + -> [32: _pre_dispatch] [B:check] (branches=8) + -> [33: _strip_stale_file_refreshes] [B:check] (branches=12) + -> [34: send] [B:check] (branches=19) + -> [35: _offload_entry_payload] [B:check] (branches=10) + -> [36: _start_track_logic_result] [B:check] (branches=10) + -> [37: _send_minimax] [B:check] (branches=11) + -> [38: _send_llama_native] [B:check] (branches=12) + -> [39: from_dict] [B:check] (branches=0) + -> [40: _create_gemini_cache_result] [B:check] (branches=3) + -> [41: entry_to_str] [B:check] (branches=3) + -> [42: from_dict] [B:check] (branches=0) + -> [43: from_dict] [B:check] (branches=0) + -> [44: _save_config_to_disk] [B:check] (branches=1) + -> [45: _send_qwen] [B:check] (branches=9) + -> [46: from_dict] [B:check] (branches=0) + -> [47: from_dict] [B:check] (branches=0) + -> [48: _trim_anthropic_history] [B:check] (branches=13) + -> [49: _strip_private_keys] [B:check] (branches=0) + -> [50: _estimate_prompt_tokens] [B:check] (branches=2) + -> [51: ollama_chat] [B:check] (branches=3) + -> [52: _execute_single_tool_call_async] [B:is None?] (branches=15) [N:safe] + -> [53: flat_config] [B:check] (branches=2) + -> [54: _send_deepseek] [B:check] (branches=71) + -> [55: _send_llama] [B:check] (branches=13) + -> [56: _add_bleed_derived] [B:check] (branches=0) + -> [57: _send_gemini_cli] [B:is None?] (branches=23) [N:safe] + -> [58: _build_files_section_from_items] [B:is None?] (branches=5) [N:safe] + -> [59: from_dict] [B:check] (branches=0) + -> [60: from_dict] [B:check] (branches=0) + -> [61: _invalidate_token_estimate] [B:check] (branches=0) + -> [62: from_dict] [B:check] (branches=0) + -> [63: _strip_cache_controls] [B:check] (branches=4) + -> [64: from_dict] [B:check] (branches=0) + -> [65: from_dict] [B:check] (branches=0) + -> [66: _estimate_message_tokens] [B:is None?] (branches=9) [N:safe] -> [T:done] ``` -**Effective codepaths:** 1125904201862042 (sum of 2^branches across 35 consumers) -**Total branch points:** 251 -**Nil-check functions:** 6 +**Effective codepaths:** 40140116231395706750390 (sum of 2^branches across 66 consumers) +**Total branch points:** 541 +**Nil-check functions:** 9 **Defusing opportunities:** - **Nil Sentinel `[N]`**: Introduce a module-level `NIL_` sentinel whose field accesses return safe defaults. Replace None checks with the sentinel. Collapses 2^branch_count into ~1. - - Effective codepaths: 1125904201862042 -> 1125904201862030 -- **Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]`**: Introduce a `metadata_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 130 field-check branches to 1 cache lookup. - - Effective codepaths: 1125904201862042 -> 130 + - Effective codepaths: 40140116231395706750390 -> 40140116231395706750372 +- **Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]`**: Introduce a `metadata_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 173 field-check branches to 1 cache lookup. + - Effective codepaths: 40140116231395706750390 -> 173 - **Generational Handles `[I:ResolveHandle] -> [B:Gen matches?] -> [N|safe]`**: Wrap the aggregate in a generational handle (index + generation). Validation is one comparison; mismatch returns the nil sentinel. Reduces N lifetime branches to 1 handle validation + sentinel return. - - Effective codepaths: 1125904201862042 -> 35 + - Effective codepaths: 40140116231395706750390 -> 66 ## Frequency @@ -281,24 +417,24 @@ _... 33 more fields_ ## Result coverage -**Summary:** 77 producers, 35 consumers +**Summary:** 96 producers, 46 consumers | metric | value | |---|---| -| total producers | 77 | -| result producers | 77 | -| total consumers | 35 | +| total producers | 96 | +| result producers | 96 | +| total consumers | 46 | | result consumers | 0 | ## Type alias coverage -**Summary:** 130 sites; 0 typed (0%); 130 untyped (100%) +**Summary:** 173 sites; 0 typed (0%); 173 untyped (100%) | metric | value | |---|---| -| total field-access sites | 130 | +| total field-access sites | 173 | | typed sites (canonical field) | 0 | -| untyped sites (wildcard) | 130 | +| untyped sites (wildcard) | 173 | ## Cross-audit findings @@ -320,27 +456,15 @@ _... 33 more fields_ | field | access count | access pattern | |---|---|---| +| `content` | 21 | hot | +| `marker` | 21 | hot | | `get` | 10 | hot | -| `pop` | 3 | hot | | `append` | 3 | hot | +| `pop` | 3 | hot | | `session_usage` | 2 | used | | `files` | 2 | used | | `ai_status` | 2 | used | -| `local_ts` | 1 | used | -| `_offload_entry_payload` | 1 | used | -| `ui_auto_add_history` | 1 | used | -| `_pending_comms_lock` | 1 | used | -| `_pending_history_adds_lock` | 1 | used | -| `_token_history` | 1 | used | -| `_pending_comms` | 1 | used | -| `_pending_history_adds` | 1 | used | -| `items` | 1 | used | -| `_est_tokens` | 1 | used | -| `output` | 1 | used | -| `content` | 1 | used | -| `marker` | 1 | used | -| `discussion` | 1 | used | -| `_start_track_logic_result` | 1 | used | +| `config` | 2 | used | | `latency` | 1 | used | | `_recalculate_session_usage` | 1 | used | | `_token_stats` | 1 | used | @@ -350,6 +474,19 @@ _... 33 more fields_ | `error` | 1 | used | | `_update_cached_stats` | 1 | used | | `usage` | 1 | used | +| `local_ts` | 1 | used | +| `_offload_entry_payload` | 1 | used | +| `ui_auto_add_history` | 1 | used | +| `_pending_comms_lock` | 1 | used | +| `_pending_history_adds_lock` | 1 | used | +| `_token_history` | 1 | used | +| `_pending_comms` | 1 | used | +| `_pending_history_adds` | 1 | used | +| `output` | 1 | used | +| `_start_track_logic_result` | 1 | used | +| `discussion` | 1 | used | +| `encode` | 1 | used | +| `search` | 1 | used | | `context_files` | 1 | used | | `_pending_gui_tasks_lock` | 1 | used | | `_topological_sort_tickets_result` | 1 | used | @@ -360,11 +497,11 @@ _... 33 more fields_ | `active_discussion` | 1 | used | | `submit_io` | 1 | used | | `tracks` | 1 | used | -| `config` | 1 | used | | `mma_tier_usage` | 1 | used | | `_pending_gui_tasks` | 1 | used | | `mma_step_mode` | 1 | used | | `active_project_path` | 1 | used | +| `items` | 1 | used | | `estimated_prompt_tokens` | 1 | used | | `max_prompt_tokens` | 1 | used | | `utilization_pct` | 1 | used | @@ -373,6 +510,7 @@ _... 33 more fields_ | `sys_tokens` | 1 | used | | `tool_tokens` | 1 | used | | `history_tokens` | 1 | used | +| `_est_tokens` | 1 | used | ## Optimization candidates @@ -388,48 +526,79 @@ Metadata: access_pattern=whole_struct, frequency=per_turn, struct_field_count=10 | function | pattern | field_accesses | confidence | |---|---|---|---| -| `src.ai_client._strip_stale_file_refreshes` | `whole_struct` | | low | -| `src.project_manager.format_discussion` | `whole_struct` | | low | -| `src.aggregate._build_files_section_from_items` | `whole_struct` | | low | -| `src.ai_client._append_comms` | `whole_struct` | | low | -| `src.ai_client._trim_anthropic_history` | `whole_struct` | `pop`=5 | high | -| `src.models._save_config_to_disk` | `whole_struct` | | low | -| `src.app_controller._on_comms_entry` | `field_by_field` | `local_ts`=1, `_offload_entry_payload`=1, `get`=7, `ui_auto_add_history`=3, `_pending_comms_lock`=1, `session_usage`=5, `_pending_history_adds_lock`=4, `_token_history`=1, `_pending_comms`=1, `_pending_history_adds`=4 | high | -| `src.ai_client._execute_single_tool_call_async` | `mixed` | `get`=2, `items`=1 | high | -| `src.ai_client._dashscope_call` | `whole_struct` | | low | -| `src.ai_client.ollama_chat` | `whole_struct` | | low | -| `src.ai_client._pre_dispatch` | `whole_struct` | | low | -| `src.ai_client._strip_cache_controls` | `whole_struct` | | low | -| `src.ai_client._estimate_prompt_tokens` | `whole_struct` | | low | -| `src.ai_client._add_history_cache_breakpoint` | `whole_struct` | | low | -| `src.project_manager.flat_config` | `whole_struct` | `get`=7 | high | -| `src.app_controller._offload_entry_payload` | `whole_struct` | | low | -| `src.ai_client._repair_minimax_history` | `whole_struct` | `append`=1 | high | -| `src.ai_client._strip_private_keys` | `whole_struct` | | low | -| `src.ai_client._repair_deepseek_history` | `whole_struct` | `append`=1 | high | -| `src.project_manager.entry_to_str` | `whole_struct` | `get`=4 | high | -| `src.aggregate.build_tier3_context` | `whole_struct` | | low | -| `src.ai_client._estimate_message_tokens` | `mixed` | `_est_tokens`=1, `get`=2 | high | -| `src.project_manager.migrate_from_legacy_config` | `whole_struct` | `get`=2 | high | -| `src.aggregate.run` | `field_by_field` | `output`=1, `files`=2, `get`=7 | high | -| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | -| `src.project_manager.save_project` | `mixed` | `discussion`=2, `files`=3 | high | | `src.aggregate.build_markdown_from_items` | `whole_struct` | | low | -| `src.app_controller._start_track_logic` | `mixed` | `_start_track_logic_result`=1, `ai_status`=1 | high | +| `src.ai_client._send_anthropic` | `whole_struct` | | low | | `src.app_controller._refresh_api_metrics` | `field_by_field` | `latency`=1, `_recalculate_session_usage`=1, `_token_stats`=1, `get`=2, `_gemini_cache_text`=1, `vendor_quota`=1, `last_error`=1, `error`=2, `_update_cached_stats`=1, `session_usage`=2 (+1 more) | high | -| `src.app_controller._start_track_logic_result` | `field_by_field` | `ai_status`=4, `context_files`=1, `get`=3, `_pending_gui_tasks_lock`=2, `_topological_sort_tickets_result`=1, `active_project_root`=1, `event_queue`=1, `engines`=1, `project`=1, `active_discussion`=1 (+7 more) | high | -| `src.ai_client._add_bleed_derived` | `field_by_field` | `estimated_prompt_tokens`=1, `max_prompt_tokens`=1, `utilization_pct`=1, `headroom`=1, `would_trim`=1, `sys_tokens`=1, `tool_tokens`=1, `history_tokens`=1, `get`=3 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._add_history_cache_breakpoint` | `whole_struct` | | low | +| `src.ai_client._append_comms` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._repair_deepseek_history` | `whole_struct` | `append`=1 | high | +| `src.ai_client._dashscope_call` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._send_grok` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.aggregate.build_tier3_context` | `whole_struct` | | low | | `src.aggregate.build_markdown_no_history` | `whole_struct` | | low | -| `src.ai_client._invalidate_token_estimate` | `whole_struct` | `pop`=1 | high | -| `src.ai_client._repair_anthropic_history` | `whole_struct` | `append`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.project_manager.migrate_from_legacy_config` | `whole_struct` | `get`=2 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.app_controller._on_comms_entry` | `field_by_field` | `local_ts`=1, `_offload_entry_payload`=1, `get`=7, `ui_auto_add_history`=3, `_pending_comms_lock`=1, `session_usage`=5, `_pending_history_adds_lock`=4, `_token_history`=1, `_pending_comms`=1, `_pending_history_adds`=4 | high | +| `src.aggregate.run` | `field_by_field` | `output`=1, `files`=2, `get`=7 | high | | `src.ai_client._trim_minimax_history` | `whole_struct` | `pop`=4 | high | +| `src.app_controller._start_track_logic` | `mixed` | `_start_track_logic_result`=1, `ai_status`=1 | high | +| `src.project_manager.save_project` | `mixed` | `discussion`=2, `files`=3 | high | +| `src.ai_client._send_gemini` | `whole_struct` | `encode`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.project_manager.format_discussion` | `whole_struct` | | low | +| `src.ai_client._repair_minimax_history` | `whole_struct` | `append`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._repair_anthropic_history` | `whole_struct` | `append`=1 | high | +| `src.ai_client._pre_dispatch` | `whole_struct` | | low | +| `src.ai_client._strip_stale_file_refreshes` | `whole_struct` | | low | +| `src.ai_client.send` | `mixed` | `config`=1, `search`=1 | high | +| `src.app_controller._offload_entry_payload` | `whole_struct` | | low | +| `src.app_controller._start_track_logic_result` | `field_by_field` | `ai_status`=4, `context_files`=1, `get`=3, `_pending_gui_tasks_lock`=2, `_topological_sort_tickets_result`=1, `active_project_root`=1, `event_queue`=1, `engines`=1, `project`=1, `active_discussion`=1 (+7 more) | high | +| `src.ai_client._send_minimax` | `whole_struct` | | low | +| `src.ai_client._send_llama_native` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._create_gemini_cache_result` | `whole_struct` | | low | +| `src.project_manager.entry_to_str` | `whole_struct` | `get`=4 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models._save_config_to_disk` | `whole_struct` | | low | +| `src.ai_client._send_qwen` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._trim_anthropic_history` | `whole_struct` | `pop`=5 | high | +| `src.ai_client._strip_private_keys` | `whole_struct` | | low | +| `src.ai_client._estimate_prompt_tokens` | `whole_struct` | | low | +| `src.ai_client.ollama_chat` | `whole_struct` | | low | +| `src.ai_client._execute_single_tool_call_async` | `mixed` | `get`=2, `items`=1 | high | +| `src.project_manager.flat_config` | `whole_struct` | `get`=7 | high | +| `src.ai_client._send_deepseek` | `whole_struct` | | low | +| `src.ai_client._send_llama` | `whole_struct` | | low | +| `src.ai_client._add_bleed_derived` | `field_by_field` | `estimated_prompt_tokens`=1, `max_prompt_tokens`=1, `utilization_pct`=1, `headroom`=1, `would_trim`=1, `sys_tokens`=1, `tool_tokens`=1, `history_tokens`=1, `get`=3 | high | +| `src.ai_client._send_gemini_cli` | `whole_struct` | | low | +| `src.aggregate._build_files_section_from_items` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._invalidate_token_estimate` | `whole_struct` | `pop`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._strip_cache_controls` | `whole_struct` | | low | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.models.from_dict` | `mixed` | `content`=1, `marker`=1 | high | +| `src.ai_client._estimate_message_tokens` | `mixed` | `_est_tokens`=1, `get`=2 | high | ### Frequency evidence | function | frequency | source | note | |---|---|---|---| -| `src.api_hook_client.get_performance` | `per_turn` | `static_analysis` | producer from src\api_hook_client.py | -| `src.app_controller.get_performance` | `per_turn` | `static_analysis` | producer from src\app_controller.py | -| `src.ai_client._send_cli_round_result` | `per_turn` | `static_analysis` | producer from src\ai_client.py | -| `src.api_hook_client.post_session` | `per_turn` | `static_analysis` | producer from src\api_hook_client.py | -| `src.app_controller.wait` | `per_turn` | `static_analysis` | producer from src\app_controller.py | +| `src.models.to_dict` | `per_turn` | `static_analysis` | producer from src\models.py | +| `src.api_hook_client.get_gui_diagnostics` | `per_turn` | `static_analysis` | producer from src\api_hook_client.py | +| `src.models.to_dict` | `per_turn` | `static_analysis` | producer from src\models.py | +| `src.app_controller._api_get_api_project` | `per_turn` | `static_analysis` | producer from src\app_controller.py | +| `src.api_hook_client.clear_events` | `per_turn` | `static_analysis` | producer from src\api_hook_client.py | diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/Metadata.tree b/docs/reports/code_path_audit/2026-06-22/aggregates/Metadata.tree index 0352d688..7effb2fa 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/Metadata.tree +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/Metadata.tree @@ -1,124 +1,195 @@ Metadata: Metadata |- kind: typealias |- memory_dim: discussion -|- producers: [77] -| |- src.api_hook_client.get_performance (producer) -| |- src.app_controller.get_performance (producer) -| |- src.ai_client._send_cli_round_result (producer) -| |- src.api_hook_client.post_session (producer) -| |- src.app_controller.wait (producer) -| |- src.app_controller.get_diagnostics (producer) -| |- src.models._load_config_from_disk (producer) -| |- src.app_controller.get_gui_state (producer) -| |- src.app_controller._api_status (producer) -| |- src.app_controller._api_token_stats (producer) -| |- src.ai_client.ollama_chat (producer) -| |- src.api_hook_client.get_financial_metrics (producer) -| |- src.api_hook_client.get_status (producer) -| |- src.app_controller._api_get_api_session (producer) -| |- src.app_controller._api_get_context (producer) +|- producers: [117] +| |- src.models.to_dict (producer) +| |- src.api_hook_client.get_gui_diagnostics (producer) +| |- src.models.to_dict (producer) +| |- src.app_controller._api_get_api_project (producer) +| |- src.api_hook_client.clear_events (producer) +| |- src.ai_client._build_chunked_context_blocks (producer) | |- src.app_controller.get_api_project (producer) -| |- src.app_controller._api_get_performance (producer) -| |- src.app_controller.status (producer) -| |- src.ai_client._add_bleed_derived (producer) -| |- src.api_hook_client.get_context_state (producer) -| |- src.api_hook_client.get_gui_health (producer) -| |- src.api_hook_client.post_project (producer) -| |- src.api_hook_client.select_list_item (producer) -| |- src.api_hook_client.get_io_pool_status (producer) -| |- src.api_hook_client.reject_patch (producer) -| |- src.api_hook_client.get_system_telemetry (producer) -| |- src.app_controller._api_get_gui_state (producer) -| |- src.app_controller._api_get_session (producer) -| |- src.project_manager.load_history (producer) -| |- src.app_controller.load_config (producer) -| |- src.app_controller._api_get_mma_status (producer) +| |- src.models.to_dict (producer) +| |- src.models.to_dict (producer) +| |- src.api_hook_client.get_mma_workers (producer) +| |- src.models.to_dict (producer) +| |- src.api_hook_client.get_startup_timeline (producer) +| |- src.models.to_dict (producer) +| |- src.app_controller._offload_entry_payload (producer) +| |- src.app_controller.generate (producer) +| |- src.api_hook_client.get_session (producer) +| |- src.api_hook_client.get_status (producer) | |- src.app_controller.token_stats (producer) | |- src.project_manager.flat_config (producer) -| |- src.project_manager.default_discussion (producer) -| |- src.app_controller.get_mma_status (producer) -| |- src.app_controller.get_session_insights (producer) +| |- src.api_hook_client._make_request (producer) +| |- src.api_hook_client.right_click (producer) +| |- src.ai_client._send_cli_round_result (producer) | |- src.models.to_dict (producer) -| |- src.ai_client._parse_tool_args_result (producer) -| |- src.api_hook_client.push_event (producer) -| |- src.api_hook_client.get_project_switch_status (producer) -| |- src.project_manager.str_to_entry (producer) +| |- src.api_hook_client.trigger_patch (producer) | |- src.api_hook_client.select_tab (producer) -| |- src.api_hook_client.post_gui (producer) -| |- src.app_controller._api_get_api_project (producer) -| |- src.app_controller._api_generate (producer) +| |- src.app_controller._api_get_session (producer) +| |- src.project_manager.str_to_entry (producer) +| |- src.app_controller._api_get_gui_state (producer) +| |- src.api_hook_client.click (producer) +| |- src.api_hook_client.get_gui_state (producer) +| |- src.project_manager.default_discussion (producer) +| |- src.ai_client._get_anthropic_tools (producer) +| |- src.app_controller.load_config (producer) +| |- src.project_manager.load_project (producer) +| |- src.api_hook_client.post_project (producer) +| |- src.models.parse_history_entries (producer) +| |- src.ai_client.get_gemini_cache_stats (producer) +| |- src.app_controller.pending_actions (producer) +| |- src.app_controller._api_get_performance (producer) +| |- src.ai_client._content_block_to_dict (producer) +| |- src.api_hook_client.get_patch_status (producer) +| |- src.api_hook_client.push_event (producer) +| |- src.models.to_dict (producer) +| |- src.api_hook_client.reject_patch (producer) +| |- src.api_hook_client.get_project (producer) +| |- src.models.to_dict (producer) +| |- src.app_controller._api_get_context (producer) +| |- src.app_controller.status (producer) +| |- src.ai_client._strip_private_keys (producer) +| |- src.api_hook_client.get_performance (producer) +| |- src.models.to_dict (producer) +| |- src.models.to_dict (producer) +| |- src.models.to_dict (producer) +| |- src.api_hook_client.select_list_item (producer) +| |- src.ai_client._add_bleed_derived (producer) | |- src.api_hook_client.get_warmup_status (producer) -| |- src.api_hook_client.get_warmup_wait (producer) +| |- src.models.to_dict (producer) +| |- src.app_controller._api_generate (producer) +| |- src.project_manager.get_all_tracks (producer) +| |- src.app_controller._api_status (producer) +| |- src.app_controller._api_token_stats (producer) +| |- src.api_hook_client.get_project_switch_status (producer) +| |- src.app_controller._api_get_api_session (producer) +| |- src.api_hook_client.post_session (producer) +| |- src.api_hook_client.get_system_telemetry (producer) +| |- src.ai_client._parse_tool_args_result (producer) | |- src.api_hook_client.wait_for_project_switch (producer) +| |- src.api_hook_client.get_events (producer) | |- src.app_controller.get_context (producer) +| |- src.ai_client._extract_dashscope_tool_calls (producer) +| |- src.api_hook_client.get_gui_health (producer) +| |- src.models.to_dict (producer) +| |- src.ai_client.get_comms_log (producer) +| |- src.project_manager.default_project (producer) +| |- src.api_hook_client.apply_patch (producer) +| |- src.api_hook_client.get_warmup_wait (producer) +| |- src.api_hook_client.get_warmup_canaries (producer) +| |- src.api_hook_client.get_financial_metrics (producer) +| |- src.models._load_config_from_disk (producer) +| |- src.ai_client.get_token_stats (producer) +| |- src.aggregate.build_file_items (producer) +| |- src.app_controller.get_session_insights (producer) +| |- src.api_hook_client.post_gui (producer) +| |- src.models.to_dict (producer) +| |- src.app_controller._pending_mma_approval (producer) +| |- src.api_hook_client.drag (producer) +| |- src.api_hook_client.post_project (producer) +| |- src.app_controller.wait (producer) +| |- src.app_controller.get_session (producer) +| |- src.app_controller._api_get_mma_status (producer) +| |- src.app_controller._api_pending_actions (producer) +| |- src.api_hook_client.get_node_status (producer) +| |- src.api_hook_client.get_io_pool_status (producer) +| |- src.app_controller.get_mma_status (producer) +| |- src.models.to_dict (producer) +| |- src.models.to_dict (producer) +| |- src.app_controller._pending_mma_spawn (producer) +| |- src.app_controller.get_performance (producer) +| |- src.api_hook_client.wait_for_event (producer) +| |- src.api_hook_client.get_context_state (producer) +| |- src.ai_client._dashscope_call (producer) +| |- src.app_controller.get_diagnostics (producer) +| |- src.project_manager.migrate_from_legacy_config (producer) +| |- src.models.to_dict (producer) | |- src.ai_client._load_credentials (producer) | |- src.app_controller._api_get_diagnostics (producer) -| |- src.api_hook_client.get_session (producer) -| |- src.app_controller._offload_entry_payload (producer) -| |- src.api_hook_client.get_startup_timeline (producer) -| |- src.project_manager.migrate_from_legacy_config (producer) -| |- src.api_hook_client.get_mma_workers (producer) -| |- src.api_hook_client.drag (producer) -| |- src.ai_client.get_token_stats (producer) -| |- src.api_hook_client.get_node_status (producer) -| |- src.api_hook_client.apply_patch (producer) -| |- src.api_hook_client.set_value (producer) -| |- src.app_controller.get_session (producer) +| |- src.models.to_dict (producer) +| |- src.models.to_dict (producer) +| |- src.ai_client._get_deepseek_tools (producer) | |- src.app_controller.get_api_session (producer) +| |- src.ai_client._pre_dispatch (producer) +| |- src.models.to_dict (producer) | |- src.api_hook_client.get_mma_status (producer) -| |- src.api_hook_client.get_gui_state (producer) -| |- src.api_hook_client.right_click (producer) -| |- src.project_manager.default_project (producer) -| |- src.api_hook_client.get_patch_status (producer) -| |- src.project_manager.load_project (producer) -| |- src.api_hook_client.trigger_patch (producer) -| |- src.ai_client._dashscope_call (producer) -| |- src.api_hook_client.get_project (producer) -| |- src.app_controller.generate (producer) -| |- src.ai_client._content_block_to_dict (producer) -| |- src.api_hook_client.get_gui_diagnostics (producer) -| |- src.ai_client.get_gemini_cache_stats (producer) -| |- src.api_hook_client.click (producer) -|- consumers: [35] -| |- src.ai_client._strip_stale_file_refreshes (consumer) -| |- src.project_manager.format_discussion (consumer) -| |- src.aggregate._build_files_section_from_items (consumer) -| |- src.ai_client._append_comms (consumer) -| |- src.ai_client._trim_anthropic_history (consumer) -| |- src.models._save_config_to_disk (consumer) -| |- src.app_controller._on_comms_entry (consumer) -| |- src.ai_client._execute_single_tool_call_async (consumer) -| |- src.ai_client._dashscope_call (consumer) -| |- src.ai_client.ollama_chat (consumer) -| |- src.ai_client._pre_dispatch (consumer) -| |- src.ai_client._strip_cache_controls (consumer) -| |- src.ai_client._estimate_prompt_tokens (consumer) -| |- src.ai_client._add_history_cache_breakpoint (consumer) -| |- src.project_manager.flat_config (consumer) -| |- src.app_controller._offload_entry_payload (consumer) -| |- src.ai_client._repair_minimax_history (consumer) -| |- src.ai_client._strip_private_keys (consumer) -| |- src.ai_client._repair_deepseek_history (consumer) -| |- src.project_manager.entry_to_str (consumer) -| |- src.aggregate.build_tier3_context (consumer) -| |- src.ai_client._estimate_message_tokens (consumer) -| |- src.project_manager.migrate_from_legacy_config (consumer) -| |- src.aggregate.run (consumer) -| |- src.models.from_dict (consumer) -| |- src.project_manager.save_project (consumer) +| |- src.api_hook_client.set_value (producer) +| |- src.project_manager.load_history (producer) +| |- src.ai_client.ollama_chat (producer) +| |- src.app_controller.get_gui_state (producer) +|- consumers: [66] | |- src.aggregate.build_markdown_from_items (consumer) -| |- src.app_controller._start_track_logic (consumer) +| |- src.ai_client._send_anthropic (consumer) | |- src.app_controller._refresh_api_metrics (consumer) -| |- src.app_controller._start_track_logic_result (consumer) -| |- src.ai_client._add_bleed_derived (consumer) +| |- src.models.from_dict (consumer) +| |- src.ai_client._add_history_cache_breakpoint (consumer) +| |- src.ai_client._append_comms (consumer) +| |- src.models.from_dict (consumer) +| |- src.models.from_dict (consumer) +| |- src.ai_client._repair_deepseek_history (consumer) +| |- src.ai_client._dashscope_call (consumer) +| |- src.models.from_dict (consumer) +| |- src.ai_client._send_grok (consumer) +| |- src.models.from_dict (consumer) +| |- src.models.from_dict (consumer) +| |- src.aggregate.build_tier3_context (consumer) | |- src.aggregate.build_markdown_no_history (consumer) -| |- src.ai_client._invalidate_token_estimate (consumer) -| |- src.ai_client._repair_anthropic_history (consumer) +| |- src.models.from_dict (consumer) +| |- src.models.from_dict (consumer) +| |- src.project_manager.migrate_from_legacy_config (consumer) +| |- src.models.from_dict (consumer) +| |- src.app_controller._on_comms_entry (consumer) +| |- src.aggregate.run (consumer) | |- src.ai_client._trim_minimax_history (consumer) +| |- src.app_controller._start_track_logic (consumer) +| |- src.project_manager.save_project (consumer) +| |- src.ai_client._send_gemini (consumer) +| |- src.models.from_dict (consumer) +| |- src.project_manager.format_discussion (consumer) +| |- src.ai_client._repair_minimax_history (consumer) +| |- src.models.from_dict (consumer) +| |- src.ai_client._repair_anthropic_history (consumer) +| |- src.ai_client._pre_dispatch (consumer) +| |- src.ai_client._strip_stale_file_refreshes (consumer) +| |- src.ai_client.send (consumer) +| |- src.app_controller._offload_entry_payload (consumer) +| |- src.app_controller._start_track_logic_result (consumer) +| |- src.ai_client._send_minimax (consumer) +| |- src.ai_client._send_llama_native (consumer) +| |- src.models.from_dict (consumer) +| |- src.ai_client._create_gemini_cache_result (consumer) +| |- src.project_manager.entry_to_str (consumer) +| |- src.models.from_dict (consumer) +| |- src.models.from_dict (consumer) +| |- src.models._save_config_to_disk (consumer) +| |- src.ai_client._send_qwen (consumer) +| |- src.models.from_dict (consumer) +| |- src.models.from_dict (consumer) +| |- src.ai_client._trim_anthropic_history (consumer) +| |- src.ai_client._strip_private_keys (consumer) +| |- src.ai_client._estimate_prompt_tokens (consumer) +| |- src.ai_client.ollama_chat (consumer) +| |- src.ai_client._execute_single_tool_call_async (consumer) +| |- src.project_manager.flat_config (consumer) +| |- src.ai_client._send_deepseek (consumer) +| |- src.ai_client._send_llama (consumer) +| |- src.ai_client._add_bleed_derived (consumer) +| |- src.ai_client._send_gemini_cli (consumer) +| |- src.aggregate._build_files_section_from_items (consumer) +| |- src.models.from_dict (consumer) +| |- src.models.from_dict (consumer) +| |- src.ai_client._invalidate_token_estimate (consumer) +| |- src.models.from_dict (consumer) +| |- src.ai_client._strip_cache_controls (consumer) +| |- src.models.from_dict (consumer) +| |- src.models.from_dict (consumer) +| |- src.ai_client._estimate_message_tokens (consumer) |- access_pattern: whole_struct |- frequency: per_turn -|- result_coverage: 77 producers, 35 consumers -|- type_alias_coverage: 130 sites; 0 typed (0%); 130 untyped (100%) +|- result_coverage: 96 producers, 46 consumers +|- type_alias_coverage: 173 sites; 0 typed (0%); 173 untyped (100%) |- cross_audit_findings: 1 findings |- decomposition_cost: hold (720 us) |- optimization_candidates: [0] \ No newline at end of file diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/ToolCall.dsl b/docs/reports/code_path_audit/2026-06-22/aggregates/ToolCall.dsl index b2d60350..6863be58 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/ToolCall.dsl +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/ToolCall.dsl @@ -8,10 +8,10 @@ "control" mem-dim \ === producers (1 items) === - "src.openai_compatible._to_typed_tool_call" "src\openai_compatible.py" 0 "producer" fn-ref + "src.openai_compatible._to_typed_tool_call" "src\openai_compatible.py" 43 "producer" fn-ref \ === consumers (1 items) === - "src.openai_compatible._to_dict_tool_call" "src\openai_compatible.py" 0 "consumer" fn-ref + "src.openai_compatible._to_dict_tool_call" "src\openai_compatible.py" 54 "consumer" fn-ref \ === access_pattern === "whole_struct" access-pattern diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/ToolCall.md b/docs/reports/code_path_audit/2026-06-22/aggregates/ToolCall.md index 3eefc03a..68cd3dba 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/ToolCall.md +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/ToolCall.md @@ -19,13 +19,13 @@ ### `src\openai_compatible.py` (1 producer) -- `src.openai_compatible._to_typed_tool_call` (line 0) +- `src.openai_compatible._to_typed_tool_call` (line 43) ## Consumers (1) ### `src\openai_compatible.py` (1 consumer) -- `src.openai_compatible._to_dict_tool_call` (line 0) +- `src.openai_compatible._to_dict_tool_call` (line 54) ## Field access matrix diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/ToolDefinition.dsl b/docs/reports/code_path_audit/2026-06-22/aggregates/ToolDefinition.dsl index 63e8c680..57617218 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/ToolDefinition.dsl +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/ToolDefinition.dsl @@ -7,7 +7,9 @@ \ === memory_dim === "control" mem-dim -\ === producers (0 items) === +\ === producers (2 items) === + "src.ai_client._build_anthropic_tools" "src\ai_client.py" 623 "producer" fn-ref + "src.ai_client._build_deepseek_tools" "src\ai_client.py" 1148 "producer" fn-ref \ === consumers (0 items) === @@ -19,15 +21,18 @@ \ === frequency === "per_turn" frequency -\ === frequency_evidence (0 items) === +\ === frequency_evidence (2 items) === + "src.ai_client._build_anthropic_tools" "per_turn" "static_analysis" "producer from src\ai_client.py" freq-evidence + "src.ai_client._build_deepseek_tools" "per_turn" "static_analysis" "producer from src\ai_client.py" freq-evidence \ === result_coverage === - 0 0 0 0 result-coverage + 2 2 0 0 result-coverage \ === type_alias_coverage === 0 0 0 type-alias-coverage \ === cross_audit_findings === + "audit_optional_in_3_files" 76 "src\ai_client.py" 159 "76 sites" cross-audit-finding 5 cross-audit-findings \ === decomposition_cost === diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/ToolDefinition.md b/docs/reports/code_path_audit/2026-06-22/aggregates/ToolDefinition.md index 1cd2cc7d..8b6d7e28 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/ToolDefinition.md +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/ToolDefinition.md @@ -6,18 +6,21 @@ ## Pipeline summary -- Producers: 0 +- Producers: 2 - Consumers: 0 -- Distinct producer fqnames: 0 +- Distinct producer fqnames: 2 - Distinct consumer fqnames: 0 - Access pattern (aggregate): mixed - Frequency (aggregate): per_turn - Decomposition direction: insufficient_data - Struct field count (estimated): 5 -## Producers (0) +## Producers (2) -_(none)_ +### `src\ai_client.py` (2 producers) + +- `src.ai_client._build_anthropic_tools` (line 623) +- `src.ai_client._build_deepseek_tools` (line 1148) ## Consumers (0) @@ -52,16 +55,20 @@ _(no field accesses detected)_ ## Frequency **Dominant frequency:** per_turn -**Evidence count:** 0 +**Evidence count:** 2 + +**Per-function frequency distribution:** + +- `per_turn`: 2 functions ## Result coverage -**Summary:** 0 producers, 0 consumers +**Summary:** 2 producers, 0 consumers | metric | value | |---|---| -| total producers | 0 | -| result producers | 0 | +| total producers | 2 | +| result producers | 2 | | total consumers | 0 | | result consumers | 0 | @@ -77,7 +84,9 @@ _(no field accesses detected)_ ## Cross-audit findings -_(no cross-audit findings mapped to this aggregate)_ +| bucket | audit script | site count | example file | example line | note | +|---|---|---|---|---|---| +| optional_in_baseline | `audit_optional_in_3_files` | 76 | `src\ai_client.py` | 159 | 76 sites | ## Decomposition cost @@ -91,7 +100,7 @@ _(no cross-audit findings mapped to this aggregate)_ ## Struct shape (inferred from producer returns) -_(no producers; cannot infer shape)_ +_(no field access data; cannot infer shape)_ ## Optimization candidates @@ -102,3 +111,10 @@ _(no optimization candidates generated)_ ToolDefinition: access_pattern=mixed, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: insufficient_data because runtime profiling is needed to determine the dominant pattern. ## Evidence appendix + +### Frequency evidence + +| function | frequency | source | note | +|---|---|---|---| +| `src.ai_client._build_anthropic_tools` | `per_turn` | `static_analysis` | producer from src\ai_client.py | +| `src.ai_client._build_deepseek_tools` | `per_turn` | `static_analysis` | producer from src\ai_client.py | diff --git a/docs/reports/code_path_audit/2026-06-22/aggregates/ToolDefinition.tree b/docs/reports/code_path_audit/2026-06-22/aggregates/ToolDefinition.tree index 5f213145..a1595c4d 100644 --- a/docs/reports/code_path_audit/2026-06-22/aggregates/ToolDefinition.tree +++ b/docs/reports/code_path_audit/2026-06-22/aggregates/ToolDefinition.tree @@ -1,12 +1,14 @@ Metadata: ToolDefinition |- kind: typealias |- memory_dim: control -|- producers: [0] +|- producers: [2] +| |- src.ai_client._build_anthropic_tools (producer) +| |- src.ai_client._build_deepseek_tools (producer) |- consumers: [0] |- access_pattern: mixed |- frequency: per_turn -|- result_coverage: 0 producers, 0 consumers +|- result_coverage: 2 producers, 0 consumers |- type_alias_coverage: 0 sites -|- cross_audit_findings: 0 findings +|- cross_audit_findings: 1 findings |- decomposition_cost: insufficient_data (470 us) |- optimization_candidates: [0] \ No newline at end of file diff --git a/docs/reports/code_path_audit/2026-06-22/call_graph.md b/docs/reports/code_path_audit/2026-06-22/call_graph.md index 38310593..4df0f735 100644 --- a/docs/reports/code_path_audit/2026-06-22/call_graph.md +++ b/docs/reports/code_path_audit/2026-06-22/call_graph.md @@ -2,132 +2,204 @@ Functions that are producers or consumers of each aggregate, grouped by file. -## Metadata (77 producers + 35 consumers) +## Metadata (117 producers + 66 consumers) | role | fqname | file | |---|---|---| -| producer | `src.api_hook_client.get_performance` | `src\api_hook_client.py` | -| producer | `src.app_controller.get_performance` | `src\app_controller.py` | -| producer | `src.ai_client._send_cli_round_result` | `src\ai_client.py` | -| producer | `src.api_hook_client.post_session` | `src\api_hook_client.py` | -| producer | `src.app_controller.wait` | `src\app_controller.py` | -| producer | `src.app_controller.get_diagnostics` | `src\app_controller.py` | -| producer | `src.models._load_config_from_disk` | `src\models.py` | -| producer | `src.app_controller.get_gui_state` | `src\app_controller.py` | -| producer | `src.app_controller._api_status` | `src\app_controller.py` | -| producer | `src.app_controller._api_token_stats` | `src\app_controller.py` | -| producer | `src.ai_client.ollama_chat` | `src\ai_client.py` | -| producer | `src.api_hook_client.get_financial_metrics` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_status` | `src\api_hook_client.py` | -| producer | `src.app_controller._api_get_api_session` | `src\app_controller.py` | -| producer | `src.app_controller._api_get_context` | `src\app_controller.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.api_hook_client.get_gui_diagnostics` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.app_controller._api_get_api_project` | `src\app_controller.py` | +| producer | `src.api_hook_client.clear_events` | `src\api_hook_client.py` | +| producer | `src.ai_client._build_chunked_context_blocks` | `src\ai_client.py` | | producer | `src.app_controller.get_api_project` | `src\app_controller.py` | -| producer | `src.app_controller._api_get_performance` | `src\app_controller.py` | -| producer | `src.app_controller.status` | `src\app_controller.py` | -| producer | `src.ai_client._add_bleed_derived` | `src\ai_client.py` | -| producer | `src.api_hook_client.get_context_state` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_gui_health` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.post_project` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.select_list_item` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_io_pool_status` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.reject_patch` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_system_telemetry` | `src\api_hook_client.py` | -| producer | `src.app_controller._api_get_gui_state` | `src\app_controller.py` | -| producer | `src.app_controller._api_get_session` | `src\app_controller.py` | -| producer | `src.project_manager.load_history` | `src\project_manager.py` | -| producer | `src.app_controller.load_config` | `src\app_controller.py` | -| producer | `src.app_controller._api_get_mma_status` | `src\app_controller.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.api_hook_client.get_mma_workers` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.api_hook_client.get_startup_timeline` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.app_controller._offload_entry_payload` | `src\app_controller.py` | +| producer | `src.app_controller.generate` | `src\app_controller.py` | +| producer | `src.api_hook_client.get_session` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_status` | `src\api_hook_client.py` | | producer | `src.app_controller.token_stats` | `src\app_controller.py` | | producer | `src.project_manager.flat_config` | `src\project_manager.py` | -| producer | `src.project_manager.default_discussion` | `src\project_manager.py` | -| producer | `src.app_controller.get_mma_status` | `src\app_controller.py` | -| producer | `src.app_controller.get_session_insights` | `src\app_controller.py` | +| producer | `src.api_hook_client._make_request` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.right_click` | `src\api_hook_client.py` | +| producer | `src.ai_client._send_cli_round_result` | `src\ai_client.py` | | producer | `src.models.to_dict` | `src\models.py` | -| producer | `src.ai_client._parse_tool_args_result` | `src\ai_client.py` | -| producer | `src.api_hook_client.push_event` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_project_switch_status` | `src\api_hook_client.py` | -| producer | `src.project_manager.str_to_entry` | `src\project_manager.py` | +| producer | `src.api_hook_client.trigger_patch` | `src\api_hook_client.py` | | producer | `src.api_hook_client.select_tab` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.post_gui` | `src\api_hook_client.py` | -| producer | `src.app_controller._api_get_api_project` | `src\app_controller.py` | -| producer | `src.app_controller._api_generate` | `src\app_controller.py` | +| producer | `src.app_controller._api_get_session` | `src\app_controller.py` | +| producer | `src.project_manager.str_to_entry` | `src\project_manager.py` | +| producer | `src.app_controller._api_get_gui_state` | `src\app_controller.py` | +| producer | `src.api_hook_client.click` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_gui_state` | `src\api_hook_client.py` | +| producer | `src.project_manager.default_discussion` | `src\project_manager.py` | +| producer | `src.ai_client._get_anthropic_tools` | `src\ai_client.py` | +| producer | `src.app_controller.load_config` | `src\app_controller.py` | +| producer | `src.project_manager.load_project` | `src\project_manager.py` | +| producer | `src.api_hook_client.post_project` | `src\api_hook_client.py` | +| producer | `src.models.parse_history_entries` | `src\models.py` | +| producer | `src.ai_client.get_gemini_cache_stats` | `src\ai_client.py` | +| producer | `src.app_controller.pending_actions` | `src\app_controller.py` | +| producer | `src.app_controller._api_get_performance` | `src\app_controller.py` | +| producer | `src.ai_client._content_block_to_dict` | `src\ai_client.py` | +| producer | `src.api_hook_client.get_patch_status` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.push_event` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.api_hook_client.reject_patch` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_project` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.app_controller._api_get_context` | `src\app_controller.py` | +| producer | `src.app_controller.status` | `src\app_controller.py` | +| producer | `src.ai_client._strip_private_keys` | `src\ai_client.py` | +| producer | `src.api_hook_client.get_performance` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.api_hook_client.select_list_item` | `src\api_hook_client.py` | +| producer | `src.ai_client._add_bleed_derived` | `src\ai_client.py` | | producer | `src.api_hook_client.get_warmup_status` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_warmup_wait` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.app_controller._api_generate` | `src\app_controller.py` | +| producer | `src.project_manager.get_all_tracks` | `src\project_manager.py` | +| producer | `src.app_controller._api_status` | `src\app_controller.py` | +| producer | `src.app_controller._api_token_stats` | `src\app_controller.py` | +| producer | `src.api_hook_client.get_project_switch_status` | `src\api_hook_client.py` | +| producer | `src.app_controller._api_get_api_session` | `src\app_controller.py` | +| producer | `src.api_hook_client.post_session` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_system_telemetry` | `src\api_hook_client.py` | +| producer | `src.ai_client._parse_tool_args_result` | `src\ai_client.py` | | producer | `src.api_hook_client.wait_for_project_switch` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_events` | `src\api_hook_client.py` | | producer | `src.app_controller.get_context` | `src\app_controller.py` | +| producer | `src.ai_client._extract_dashscope_tool_calls` | `src\ai_client.py` | +| producer | `src.api_hook_client.get_gui_health` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.ai_client.get_comms_log` | `src\ai_client.py` | +| producer | `src.project_manager.default_project` | `src\project_manager.py` | +| producer | `src.api_hook_client.apply_patch` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_warmup_wait` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_warmup_canaries` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_financial_metrics` | `src\api_hook_client.py` | +| producer | `src.models._load_config_from_disk` | `src\models.py` | +| producer | `src.ai_client.get_token_stats` | `src\ai_client.py` | +| producer | `src.aggregate.build_file_items` | `src\aggregate.py` | +| producer | `src.app_controller.get_session_insights` | `src\app_controller.py` | +| producer | `src.api_hook_client.post_gui` | `src\api_hook_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.app_controller._pending_mma_approval` | `src\app_controller.py` | +| producer | `src.api_hook_client.drag` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.post_project` | `src\api_hook_client.py` | +| producer | `src.app_controller.wait` | `src\app_controller.py` | +| producer | `src.app_controller.get_session` | `src\app_controller.py` | +| producer | `src.app_controller._api_get_mma_status` | `src\app_controller.py` | +| producer | `src.app_controller._api_pending_actions` | `src\app_controller.py` | +| producer | `src.api_hook_client.get_node_status` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_io_pool_status` | `src\api_hook_client.py` | +| producer | `src.app_controller.get_mma_status` | `src\app_controller.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.app_controller._pending_mma_spawn` | `src\app_controller.py` | +| producer | `src.app_controller.get_performance` | `src\app_controller.py` | +| producer | `src.api_hook_client.wait_for_event` | `src\api_hook_client.py` | +| producer | `src.api_hook_client.get_context_state` | `src\api_hook_client.py` | +| producer | `src.ai_client._dashscope_call` | `src\ai_client.py` | +| producer | `src.app_controller.get_diagnostics` | `src\app_controller.py` | +| producer | `src.project_manager.migrate_from_legacy_config` | `src\project_manager.py` | +| producer | `src.models.to_dict` | `src\models.py` | | producer | `src.ai_client._load_credentials` | `src\ai_client.py` | | producer | `src.app_controller._api_get_diagnostics` | `src\app_controller.py` | -| producer | `src.api_hook_client.get_session` | `src\api_hook_client.py` | -| producer | `src.app_controller._offload_entry_payload` | `src\app_controller.py` | -| producer | `src.api_hook_client.get_startup_timeline` | `src\api_hook_client.py` | -| producer | `src.project_manager.migrate_from_legacy_config` | `src\project_manager.py` | -| producer | `src.api_hook_client.get_mma_workers` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.drag` | `src\api_hook_client.py` | -| producer | `src.ai_client.get_token_stats` | `src\ai_client.py` | -| producer | `src.api_hook_client.get_node_status` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.apply_patch` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.set_value` | `src\api_hook_client.py` | -| producer | `src.app_controller.get_session` | `src\app_controller.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.models.to_dict` | `src\models.py` | +| producer | `src.ai_client._get_deepseek_tools` | `src\ai_client.py` | | producer | `src.app_controller.get_api_session` | `src\app_controller.py` | +| producer | `src.ai_client._pre_dispatch` | `src\ai_client.py` | +| producer | `src.models.to_dict` | `src\models.py` | | producer | `src.api_hook_client.get_mma_status` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.get_gui_state` | `src\api_hook_client.py` | -| producer | `src.api_hook_client.right_click` | `src\api_hook_client.py` | -| producer | `src.project_manager.default_project` | `src\project_manager.py` | -| producer | `src.api_hook_client.get_patch_status` | `src\api_hook_client.py` | -| producer | `src.project_manager.load_project` | `src\project_manager.py` | -| producer | `src.api_hook_client.trigger_patch` | `src\api_hook_client.py` | -| producer | `src.ai_client._dashscope_call` | `src\ai_client.py` | -| producer | `src.api_hook_client.get_project` | `src\api_hook_client.py` | -| producer | `src.app_controller.generate` | `src\app_controller.py` | -| producer | `src.ai_client._content_block_to_dict` | `src\ai_client.py` | -| producer | `src.api_hook_client.get_gui_diagnostics` | `src\api_hook_client.py` | -| producer | `src.ai_client.get_gemini_cache_stats` | `src\ai_client.py` | -| producer | `src.api_hook_client.click` | `src\api_hook_client.py` | -| consumer | `src.ai_client._strip_stale_file_refreshes` | `src\ai_client.py` | -| consumer | `src.project_manager.format_discussion` | `src\project_manager.py` | -| consumer | `src.aggregate._build_files_section_from_items` | `src\aggregate.py` | -| consumer | `src.ai_client._append_comms` | `src\ai_client.py` | -| consumer | `src.ai_client._trim_anthropic_history` | `src\ai_client.py` | -| consumer | `src.models._save_config_to_disk` | `src\models.py` | -| consumer | `src.app_controller._on_comms_entry` | `src\app_controller.py` | -| consumer | `src.ai_client._execute_single_tool_call_async` | `src\ai_client.py` | -| consumer | `src.ai_client._dashscope_call` | `src\ai_client.py` | -| consumer | `src.ai_client.ollama_chat` | `src\ai_client.py` | -| consumer | `src.ai_client._pre_dispatch` | `src\ai_client.py` | -| consumer | `src.ai_client._strip_cache_controls` | `src\ai_client.py` | -| consumer | `src.ai_client._estimate_prompt_tokens` | `src\ai_client.py` | -| consumer | `src.ai_client._add_history_cache_breakpoint` | `src\ai_client.py` | -| consumer | `src.project_manager.flat_config` | `src\project_manager.py` | -| consumer | `src.app_controller._offload_entry_payload` | `src\app_controller.py` | -| consumer | `src.ai_client._repair_minimax_history` | `src\ai_client.py` | -| consumer | `src.ai_client._strip_private_keys` | `src\ai_client.py` | -| consumer | `src.ai_client._repair_deepseek_history` | `src\ai_client.py` | -| consumer | `src.project_manager.entry_to_str` | `src\project_manager.py` | -| consumer | `src.aggregate.build_tier3_context` | `src\aggregate.py` | -| consumer | `src.ai_client._estimate_message_tokens` | `src\ai_client.py` | -| consumer | `src.project_manager.migrate_from_legacy_config` | `src\project_manager.py` | -| consumer | `src.aggregate.run` | `src\aggregate.py` | -| consumer | `src.models.from_dict` | `src\models.py` | -| consumer | `src.project_manager.save_project` | `src\project_manager.py` | +| producer | `src.api_hook_client.set_value` | `src\api_hook_client.py` | +| producer | `src.project_manager.load_history` | `src\project_manager.py` | +| producer | `src.ai_client.ollama_chat` | `src\ai_client.py` | +| producer | `src.app_controller.get_gui_state` | `src\app_controller.py` | | consumer | `src.aggregate.build_markdown_from_items` | `src\aggregate.py` | -| consumer | `src.app_controller._start_track_logic` | `src\app_controller.py` | +| consumer | `src.ai_client._send_anthropic` | `src\ai_client.py` | | consumer | `src.app_controller._refresh_api_metrics` | `src\app_controller.py` | -| consumer | `src.app_controller._start_track_logic_result` | `src\app_controller.py` | -| consumer | `src.ai_client._add_bleed_derived` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._add_history_cache_breakpoint` | `src\ai_client.py` | +| consumer | `src.ai_client._append_comms` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._repair_deepseek_history` | `src\ai_client.py` | +| consumer | `src.ai_client._dashscope_call` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._send_grok` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.aggregate.build_tier3_context` | `src\aggregate.py` | | consumer | `src.aggregate.build_markdown_no_history` | `src\aggregate.py` | -| consumer | `src.ai_client._invalidate_token_estimate` | `src\ai_client.py` | -| consumer | `src.ai_client._repair_anthropic_history` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.project_manager.migrate_from_legacy_config` | `src\project_manager.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.app_controller._on_comms_entry` | `src\app_controller.py` | +| consumer | `src.aggregate.run` | `src\aggregate.py` | | consumer | `src.ai_client._trim_minimax_history` | `src\ai_client.py` | +| consumer | `src.app_controller._start_track_logic` | `src\app_controller.py` | +| consumer | `src.project_manager.save_project` | `src\project_manager.py` | +| consumer | `src.ai_client._send_gemini` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.project_manager.format_discussion` | `src\project_manager.py` | +| consumer | `src.ai_client._repair_minimax_history` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._repair_anthropic_history` | `src\ai_client.py` | +| consumer | `src.ai_client._pre_dispatch` | `src\ai_client.py` | +| consumer | `src.ai_client._strip_stale_file_refreshes` | `src\ai_client.py` | +| consumer | `src.ai_client.send` | `src\ai_client.py` | +| consumer | `src.app_controller._offload_entry_payload` | `src\app_controller.py` | +| consumer | `src.app_controller._start_track_logic_result` | `src\app_controller.py` | +| consumer | `src.ai_client._send_minimax` | `src\ai_client.py` | +| consumer | `src.ai_client._send_llama_native` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._create_gemini_cache_result` | `src\ai_client.py` | +| consumer | `src.project_manager.entry_to_str` | `src\project_manager.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models._save_config_to_disk` | `src\models.py` | +| consumer | `src.ai_client._send_qwen` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._trim_anthropic_history` | `src\ai_client.py` | +| consumer | `src.ai_client._strip_private_keys` | `src\ai_client.py` | +| consumer | `src.ai_client._estimate_prompt_tokens` | `src\ai_client.py` | +| consumer | `src.ai_client.ollama_chat` | `src\ai_client.py` | +| consumer | `src.ai_client._execute_single_tool_call_async` | `src\ai_client.py` | +| consumer | `src.project_manager.flat_config` | `src\project_manager.py` | +| consumer | `src.ai_client._send_deepseek` | `src\ai_client.py` | +| consumer | `src.ai_client._send_llama` | `src\ai_client.py` | +| consumer | `src.ai_client._add_bleed_derived` | `src\ai_client.py` | +| consumer | `src.ai_client._send_gemini_cli` | `src\ai_client.py` | +| consumer | `src.aggregate._build_files_section_from_items` | `src\aggregate.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._invalidate_token_estimate` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._strip_cache_controls` | `src\ai_client.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.models.from_dict` | `src\models.py` | +| consumer | `src.ai_client._estimate_message_tokens` | `src\ai_client.py` | ## FileItem (0 producers + 0 consumers) _(no producers or consumers)_ -## FileItems (0 producers + 3 consumers) +## FileItems (0 producers + 4 consumers) | role | fqname | file | |---|---|---| | consumer | `src.ai_client._build_file_diff_text` | `src\ai_client.py` | +| consumer | `src.ai_client.run_with_tool_loop` | `src\ai_client.py` | | consumer | `src.ai_client._build_file_context_text` | `src\ai_client.py` | | consumer | `src.ai_client._reread_file_items_result` | `src\ai_client.py` | @@ -139,20 +211,24 @@ _(no producers or consumers)_ _(no producers or consumers)_ -## HistoryMessage (0 producers + 2 consumers) +## HistoryMessage (1 producers + 2 consumers) | role | fqname | file | |---|---|---| -| consumer | `src.provider_state.replace_all` | `src\provider_state.py` | +| producer | `src.provider_state.get_all` | `src\provider_state.py` | | consumer | `src.provider_state.append` | `src\provider_state.py` | +| consumer | `src.provider_state.replace_all` | `src\provider_state.py` | ## History (0 producers + 0 consumers) _(no producers or consumers)_ -## ToolDefinition (0 producers + 0 consumers) +## ToolDefinition (2 producers + 0 consumers) -_(no producers or consumers)_ +| role | fqname | file | +|---|---|---| +| producer | `src.ai_client._build_anthropic_tools` | `src\ai_client.py` | +| producer | `src.ai_client._build_deepseek_tools` | `src\ai_client.py` | ## ToolCall (1 producers + 1 consumers) diff --git a/docs/reports/code_path_audit/2026-06-22/cross_audit_summary.md b/docs/reports/code_path_audit/2026-06-22/cross_audit_summary.md index 21ee8950..1f6c81dc 100644 --- a/docs/reports/code_path_audit/2026-06-22/cross_audit_summary.md +++ b/docs/reports/code_path_audit/2026-06-22/cross_audit_summary.md @@ -9,7 +9,7 @@ | CommsLog | 0 | 0 | 0 | 0 | 0 | 0 | | HistoryMessage | 0 | 0 | 0 | 0 | 0 | 0 | | History | 0 | 0 | 0 | 0 | 0 | 0 | -| ToolDefinition | 0 | 0 | 0 | 0 | 0 | 0 | +| ToolDefinition | 0 | 0 | 1 | 0 | 0 | 1 | | ToolCall | 0 | 0 | 0 | 0 | 0 | 0 | | Result | 0 | 0 | 0 | 0 | 0 | 0 | | ToolSpec | 0 | 0 | 0 | 0 | 0 | 0 | diff --git a/docs/reports/code_path_audit/2026-06-22/dead_fields.md b/docs/reports/code_path_audit/2026-06-22/dead_fields.md index e799913e..5c102f85 100644 --- a/docs/reports/code_path_audit/2026-06-22/dead_fields.md +++ b/docs/reports/code_path_audit/2026-06-22/dead_fields.md @@ -4,9 +4,17 @@ Fields that appear in producer return shapes but are never read by any consumer. ### `Metadata` -Fields read by at least one consumer: 53 +Fields read by at least one consumer: 55 +### `FileItems` + +Fields read by at least one consumer: 1 + +| field | read count | +|---|---| +| `append` | 2 | + ### `HistoryMessage` Fields read by at least one consumer: 2 diff --git a/docs/reports/code_path_audit/2026-06-22/decomposition_matrix.md b/docs/reports/code_path_audit/2026-06-22/decomposition_matrix.md index 551d8894..c1b58c57 100644 --- a/docs/reports/code_path_audit/2026-06-22/decomposition_matrix.md +++ b/docs/reports/code_path_audit/2026-06-22/decomposition_matrix.md @@ -4,14 +4,14 @@ | Aggregate | Producers | Consumers | Struct fields | Current cost (us/turn) | Direction | Actionable savings (us/turn) | |---|---|---|---|---|---|---| -| `Metadata` | 77 | 35 | 10 | 720 | `hold` | 0 | +| `Metadata` | 117 | 66 | 10 | 720 | `hold` | 0 | | `FileItem` | 0 | 0 | 5 | 470 | `insufficient_data` | 0 | -| `FileItems` | 0 | 3 | 5 | 470 | `hold` | 70 | +| `FileItems` | 0 | 4 | 5 | 470 | `hold` | 70 | | `CommsLogEntry` | 0 | 0 | 5 | 470 | `insufficient_data` | 0 | | `CommsLog` | 0 | 0 | 5 | 470 | `insufficient_data` | 0 | -| `HistoryMessage` | 0 | 2 | 5 | 470 | `insufficient_data` | 0 | +| `HistoryMessage` | 1 | 2 | 5 | 470 | `insufficient_data` | 0 | | `History` | 0 | 0 | 5 | 470 | `insufficient_data` | 0 | -| `ToolDefinition` | 0 | 0 | 5 | 470 | `insufficient_data` | 0 | +| `ToolDefinition` | 2 | 0 | 5 | 470 | `insufficient_data` | 0 | | `ToolCall` | 1 | 1 | 5 | 470 | `hold` | 70 | | `Result` | 0 | 0 | 5 | 470 | `insufficient_data` | 0 | diff --git a/docs/reports/code_path_audit/2026-06-22/field_usage.md b/docs/reports/code_path_audit/2026-06-22/field_usage.md index ac0f17de..5057486d 100644 --- a/docs/reports/code_path_audit/2026-06-22/field_usage.md +++ b/docs/reports/code_path_audit/2026-06-22/field_usage.md @@ -4,16 +4,17 @@ Cross-aggregate analysis of which fields are accessed how often across the codeb | aggregate | field | total accesses | |---|---|---| +| `FileItems` | `append` | 2 | | `HistoryMessage` | `lock` | 2 | | `HistoryMessage` | `messages` | 2 | | `Metadata` | `get` | 39 | +| `Metadata` | `content` | 21 | +| `Metadata` | `marker` | 21 | | `Metadata` | `pop` | 10 | | `Metadata` | `session_usage` | 7 | | `Metadata` | `files` | 5 | | `Metadata` | `ai_status` | 5 | | `Metadata` | `_pending_history_adds_lock` | 4 | | `Metadata` | `_pending_history_adds` | 4 | -| `Metadata` | `ui_auto_add_history` | 3 | | `Metadata` | `append` | 3 | -| `Metadata` | `discussion` | 2 | | `ToolCall` | `to_dict` | 1 | diff --git a/docs/reports/code_path_audit/2026-06-22/hot_paths.md b/docs/reports/code_path_audit/2026-06-22/hot_paths.md index 2605f8a6..c1ebacca 100644 --- a/docs/reports/code_path_audit/2026-06-22/hot_paths.md +++ b/docs/reports/code_path_audit/2026-06-22/hot_paths.md @@ -18,6 +18,7 @@ Functions on the per-LLM-turn path (high-frequency consumers). | function | pattern | total field accesses | |---|---|---| +| `src.ai_client.run_with_tool_loop` | `whole_struct` | 2 | | `src.ai_client._build_file_diff_text` | `whole_struct` | 0 | | `src.ai_client._build_file_context_text` | `whole_struct` | 0 | | `src.ai_client._reread_file_items_result` | `whole_struct` | 0 | @@ -26,8 +27,8 @@ Functions on the per-LLM-turn path (high-frequency consumers). | function | pattern | total field accesses | |---|---|---| -| `src.provider_state.replace_all` | `mixed` | 2 | | `src.provider_state.append` | `mixed` | 2 | +| `src.provider_state.replace_all` | `mixed` | 2 | ### `ToolCall` diff --git a/docs/reports/code_path_audit/2026-06-22/organization_deductions.md b/docs/reports/code_path_audit/2026-06-22/organization_deductions.md index 89f908ab..0e80cf9f 100644 --- a/docs/reports/code_path_audit/2026-06-22/organization_deductions.md +++ b/docs/reports/code_path_audit/2026-06-22/organization_deductions.md @@ -11,11 +11,13 @@ Cross-aggregate view of codebase organization. Verdicts derived from SSDL analys | file | aggregates produced | aggregates consumed | |---|---|---| -| `src\ai_client.py` | 1 | 2 | +| `src\ai_client.py` | 2 | 2 | +| `src\aggregate.py` | 1 | 1 | | `src\app_controller.py` | 1 | 1 | | `src\models.py` | 1 | 1 | | `src\openai_compatible.py` | 1 | 1 | | `src\project_manager.py` | 1 | 1 | +| `src\provider_state.py` | 1 | 1 | | `src\api_hook_client.py` | 1 | 0 | ### Files with high coupling (producers + consumers >= 8) @@ -29,9 +31,9 @@ These files are the central nervous system of the codebase. Changes ripple acros | Aggregate | Verdict | Notes | |---|---|---| -| `Metadata` | needs restructuring | 6 nil checks; 0% field efficiency; 1125904201862042 effective codepaths | +| `Metadata` | needs restructuring | 9 nil checks; 0% field efficiency; 40140116231395706750390 effective codepaths | | `FileItem` | needs restructuring | 0% field efficiency | -| `FileItems` | needs restructuring | 1 nil checks; 0% field efficiency; 104 effective codepaths | +| `FileItems` | needs restructuring | 2 nil checks; 0% field efficiency; 8388712 effective codepaths | | `CommsLogEntry` | needs restructuring | 0% field efficiency | | `CommsLog` | needs restructuring | 0% field efficiency | | `HistoryMessage` | needs restructuring | 0% field efficiency | @@ -46,12 +48,12 @@ These files are the central nervous system of the codebase. Changes ripple acros Top restructuring routes (by effective codepath count): -1. **`Metadata`**: 1125904201862042 effective codepaths (0% field efficiency) - - Apply nil sentinel to 6 nil-check functions - - Migrate to immediate-mode cache for 130 field-access sites -2. **`FileItems`**: 104 effective codepaths (0% field efficiency) - - Apply nil sentinel to 1 nil-check functions - - Migrate to immediate-mode cache for 0 field-access sites +1. **`Metadata`**: 40140116231395706750390 effective codepaths (0% field efficiency) + - Apply nil sentinel to 9 nil-check functions + - Migrate to immediate-mode cache for 173 field-access sites +2. **`FileItems`**: 8388712 effective codepaths (0% field efficiency) + - Apply nil sentinel to 2 nil-check functions + - Migrate to immediate-mode cache for 2 field-access sites 3. **`HistoryMessage`**: 4 effective codepaths (0% field efficiency) - Apply nil sentinel to 0 nil-check functions - Migrate to immediate-mode cache for 4 field-access sites diff --git a/docs/reports/code_path_audit/2026-06-22/ssdl_analysis.md b/docs/reports/code_path_audit/2026-06-22/ssdl_analysis.md index ab424286..4d3ddd86 100644 --- a/docs/reports/code_path_audit/2026-06-22/ssdl_analysis.md +++ b/docs/reports/code_path_audit/2026-06-22/ssdl_analysis.md @@ -6,8 +6,8 @@ Per-aggregate analysis: effective codepaths, branch points, defusing opportuniti | Aggregate | Consumers | Total branches | Effective codepaths | Field efficiency | |---|---|---|---|---| -| `Metadata` | 35 | 251 | 1125904201862042 | 0% | -| `FileItems` | 3 | 14 | 104 | 0% | +| `Metadata` | 66 | 541 | 40140116231395706750390 | 0% | +| `FileItems` | 4 | 37 | 8388712 | 0% | | `HistoryMessage` | 2 | 2 | 4 | 0% | | `ToolCall` | 1 | 0 | 1 | 0% | | `FileItem` | 0 | 0 | 0 | 0% | @@ -21,38 +21,45 @@ Per-aggregate analysis: effective codepaths, branch points, defusing opportuniti ### `Metadata` - Generational Handles `[I:ResolveHandle] -> [B:Gen matches?] -> [N|safe]` -- **Location:** Metadata consumers have 251 explicit branch points total -- **Current state:** Branch explosion: 251 branches = 1125904201862042 effective codepaths +- **Location:** Metadata consumers have 541 explicit branch points total +- **Current state:** Branch explosion: 541 branches = 40140116231395706750390 effective codepaths - **Recommended change:** Wrap the aggregate in a generational handle (index + generation). Validation is one comparison; mismatch returns the nil sentinel. Reduces N lifetime branches to 1 handle validation + sentinel return. -- **Effective codepaths:** 1125904201862042 -> 35 +- **Effective codepaths:** 40140116231395706750390 -> 66 ### `Metadata` - Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]` -- **Location:** Metadata consumers access 130 sites, only 0 typed (0%) +- **Location:** Metadata consumers access 173 sites, only 0 typed (0%) - **Current state:** Many consumers use wildcard or defensive access patterns -- **Recommended change:** Introduce a `metadata_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 130 field-check branches to 1 cache lookup. -- **Effective codepaths:** 1125904201862042 -> 130 +- **Recommended change:** Introduce a `metadata_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 173 field-check branches to 1 cache lookup. +- **Effective codepaths:** 40140116231395706750390 -> 173 ### `FileItems` - Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]` -- **Location:** FileItems consumers access 0 sites, only 0 typed (0%) +- **Location:** FileItems consumers access 2 sites, only 0 typed (0%) - **Current state:** Many consumers use wildcard or defensive access patterns -- **Recommended change:** Introduce a `fileitems_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 0 field-check branches to 1 cache lookup. -- **Effective codepaths:** 104 -> 1 +- **Recommended change:** Introduce a `fileitems_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 2 field-check branches to 1 cache lookup. +- **Effective codepaths:** 8388712 -> 2 + +### `FileItems` - Generational Handles `[I:ResolveHandle] -> [B:Gen matches?] -> [N|safe]` + +- **Location:** FileItems consumers have 37 explicit branch points total +- **Current state:** Branch explosion: 37 branches = 8388712 effective codepaths +- **Recommended change:** Wrap the aggregate in a generational handle (index + generation). Validation is one comparison; mismatch returns the nil sentinel. Reduces N lifetime branches to 1 handle validation + sentinel return. +- **Effective codepaths:** 8388712 -> 4 ### `Metadata` - Nil Sentinel `[N]` -- **Location:** 6 consumer functions have `is None` / `== None` checks -- **Current state:** 6 nil-check branches contribute to branch explosion +- **Location:** 9 consumer functions have `is None` / `== None` checks +- **Current state:** 9 nil-check branches contribute to branch explosion - **Recommended change:** Introduce a module-level `NIL_` sentinel whose field accesses return safe defaults. Replace None checks with the sentinel. Collapses 2^branch_count into ~1. -- **Effective codepaths:** 1125904201862042 -> 1125904201862030 +- **Effective codepaths:** 40140116231395706750390 -> 40140116231395706750372 ### `FileItems` - Nil Sentinel `[N]` -- **Location:** 1 consumer function have `is None` / `== None` checks -- **Current state:** 1 nil-check branches contribute to branch explosion +- **Location:** 2 consumer functions have `is None` / `== None` checks +- **Current state:** 2 nil-check branches contribute to branch explosion - **Recommended change:** Introduce a module-level `NIL_` sentinel whose field accesses return safe defaults. Replace None checks with the sentinel. Collapses 2^branch_count into ~1. -- **Effective codepaths:** 104 -> 102 +- **Effective codepaths:** 8388712 -> 8388708 ### `HistoryMessage` - Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]` @@ -81,10 +88,3 @@ Per-aggregate analysis: effective codepaths, branch points, defusing opportuniti - **Current state:** Many consumers use wildcard or defensive access patterns - **Recommended change:** Introduce a `commslogentry_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 0 field-check branches to 1 cache lookup. - **Effective codepaths:** 0 -> 1 - -### `CommsLog` - Immediate-Mode Cache `[Q:key] -> [I:FetchCached] -> [T]` - -- **Location:** CommsLog consumers access 0 sites, only 0 typed (0%) -- **Current state:** Many consumers use wildcard or defensive access patterns -- **Recommended change:** Introduce a `commslog_cache` keyed lookup. Consumers request by key, get cached value, no field-existence checks. Reduces 0 field-check branches to 1 cache lookup. -- **Effective codepaths:** 0 -> 1 diff --git a/docs/reports/code_path_audit/2026-06-22/summary.md b/docs/reports/code_path_audit/2026-06-22/summary.md index 145ae5f8..37a3d9f4 100644 --- a/docs/reports/code_path_audit/2026-06-22/summary.md +++ b/docs/reports/code_path_audit/2026-06-22/summary.md @@ -4,8 +4,8 @@ Generated for 13 aggregates on 2026-06-22 - **Real aggregates (in scope):** 10 - **Candidate aggregates (placeholders):** 3 -- **Total producers:** 78 -- **Total consumers:** 41 +- **Total producers:** 121 +- **Total consumers:** 73 - **Total current cost (us/turn):** 4950 - **Total actionable savings (us/turn):** 140 @@ -23,13 +23,13 @@ Generated for 13 aggregates on 2026-06-22 | `CommsLog` | `typealias` | `discussion` | `mixed` | 0 | 0 | | `CommsLogEntry` | `typealias` | `discussion` | `mixed` | 0 | 0 | | `FileItem` | `typealias` | `curation` | `mixed` | 0 | 0 | -| `FileItems` | `typealias` | `curation` | `whole_struct` | 0 | 3 | +| `FileItems` | `typealias` | `curation` | `whole_struct` | 0 | 4 | | `History` | `typealias` | `discussion` | `mixed` | 0 | 0 | -| `HistoryMessage` | `typealias` | `discussion` | `mixed` | 0 | 2 | -| `Metadata` | `typealias` | `discussion` | `whole_struct` | 77 | 35 | +| `HistoryMessage` | `typealias` | `discussion` | `mixed` | 1 | 2 | +| `Metadata` | `typealias` | `discussion` | `whole_struct` | 117 | 66 | | `Result` | `typealias` | `control` | `mixed` | 0 | 0 | | `ToolCall` | `typealias` | `control` | `whole_struct` | 1 | 1 | -| `ToolDefinition` | `typealias` | `control` | `mixed` | 0 | 0 | +| `ToolDefinition` | `typealias` | `control` | `mixed` | 2 | 0 | | `ChatMessage` | `candidate_dataclass` | `discussion` | `mixed` | 0 | 0 | | `ProviderHistory` | `candidate_dataclass` | `unknown` | `mixed` | 0 | 0 | | `ToolSpec` | `candidate_dataclass` | `unknown` | `mixed` | 0 | 0 | @@ -56,8 +56,8 @@ Generated for 13 aggregates on 2026-06-22 ### `FileItems` -- **Result coverage:** 0 producers, 3 consumers -- **Type alias coverage:** 0 sites +- **Result coverage:** 0 producers, 4 consumers +- **Type alias coverage:** 2 sites; 0 typed (0%); 2 untyped (100%) - **Cross-audit findings (total sites):** 0 ### `History` @@ -68,14 +68,14 @@ Generated for 13 aggregates on 2026-06-22 ### `HistoryMessage` -- **Result coverage:** 0 producers, 2 consumers +- **Result coverage:** 1 producers, 2 consumers - **Type alias coverage:** 4 sites; 0 typed (0%); 4 untyped (100%) - **Cross-audit findings (total sites):** 0 ### `Metadata` -- **Result coverage:** 77 producers, 35 consumers -- **Type alias coverage:** 130 sites; 0 typed (0%); 130 untyped (100%) +- **Result coverage:** 96 producers, 46 consumers +- **Type alias coverage:** 173 sites; 0 typed (0%); 173 untyped (100%) - **Cross-audit findings (total sites):** 1 ### `Result` @@ -92,6 +92,6 @@ Generated for 13 aggregates on 2026-06-22 ### `ToolDefinition` -- **Result coverage:** 0 producers, 0 consumers +- **Result coverage:** 2 producers, 0 consumers - **Type alias coverage:** 0 sites -- **Cross-audit findings (total sites):** 0 +- **Cross-audit findings (total sites):** 1 diff --git a/src/code_path_audit.py b/src/code_path_audit.py index c33035cb..6a746ff2 100644 --- a/src/code_path_audit.py +++ b/src/code_path_audit.py @@ -158,6 +158,7 @@ class ProducerConsumerGraph: edges: dict[tuple[str, str], set[str]] = field(default_factory=dict) producers: dict[str, set[FunctionRef]] = field(default_factory=dict) consumers: dict[str, set[FunctionRef]] = field(default_factory=dict) + field_accesses: dict[tuple[str, str], tuple[str, int]] = field(default_factory=dict) def add_producer(self, aggregate: str, function: FunctionRef) -> None: self.producers.setdefault(aggregate, set()).add(function) @@ -165,50 +166,80 @@ class ProducerConsumerGraph: def add_consumer(self, aggregate: str, function: FunctionRef) -> None: self.consumers.setdefault(aggregate, set()).add(function) -def P1_pass(tree: ast.Module, file: str) -> list[tuple[str, str, str, str]]: + def add_field_access(self, function: str, key: str, kind: str, count: int, line: int) -> None: + self.field_accesses[(function, key)] = (kind, count) + +def _extract_type_name(ann: ast.expr) -> str | None: + """Extract the type name from any annotation AST node. + + Handles: Name, Optional[T], list[T], dict[str, T], Result[T], + Union[T, ...], T | None (PEP 604). + """ + if isinstance(ann, ast.Name): + return ann.id + if isinstance(ann, ast.Subscript): + value = ann.value + sl = ann.slice + if isinstance(value, ast.Name): + if value.id in ("Optional", "list", "List", "tuple", "Tuple", "set", "Set", "frozenset", "Mapping", "Dict", "dict"): + if isinstance(sl, ast.Name): + return sl.id + if isinstance(sl, ast.Subscript) and isinstance(sl.value, ast.Name): + return sl.value.id + if isinstance(sl, ast.Tuple) and sl.elts: + first = sl.elts[0] + if isinstance(first, ast.Name): + return first.id + if isinstance(first, ast.Subscript) and isinstance(first.value, ast.Name): + return first.value.id + if value.id == "Result": + if isinstance(sl, ast.Name): + return sl.id + if isinstance(sl, ast.Subscript) and isinstance(sl.value, ast.Name): + return sl.value.id + if isinstance(sl, ast.Tuple) and sl.elts: + first = sl.elts[0] + if isinstance(first, ast.Name): + return first.id + if isinstance(ann, ast.BinOp) and isinstance(ann.op, ast.BitOr): + left = _extract_type_name(ann.left) + right = _extract_type_name(ann.right) + return left if left and left != "None" else right + return None + + +def P1_pass(tree: ast.Module, file: str) -> list[tuple[str, str, str, str, int]]: """AST pass 1: detect producers of T and Result[T] via return annotations.""" - out: list[tuple[str, str, str, str]] = [] + out: list[tuple[str, str, str, str, int]] = [] for node in ast.walk(tree): if not isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)): continue if node.returns is None: continue - ret = node.returns - if isinstance(ret, ast.Name): - aggregate = ret.id - out.append((node.name, aggregate, "producer", "high")) - elif isinstance(ret, ast.Subscript): - value = ret.value - sl = ret.slice - if isinstance(value, ast.Name) and value.id == "Result": - if isinstance(sl, ast.Name): - out.append((node.name, sl.id, "producer", "high")) - elif isinstance(sl, ast.Subscript) and isinstance(sl.value, ast.Name): - out.append((node.name, sl.value.id, "producer", "high")) + aggregate = _extract_type_name(node.returns) + if aggregate and aggregate not in ("None", "NoneType"): + out.append((node.name, aggregate, "producer", "high", node.lineno)) return out -def P2_pass(tree: ast.Module, file: str) -> list[tuple[str, str, str, str]]: + +def P2_pass(tree: ast.Module, file: str) -> list[tuple[str, str, str, str, int]]: """AST pass 2: detect consumers of typed aggregates via parameter annotations.""" - out: list[tuple[str, str, str, str]] = [] + out: list[tuple[str, str, str, str, int]] = [] for node in ast.walk(tree): if not isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)): continue - for arg in node.args.args + node.args.kwonlyargs: + for arg in node.args.args + node.args.kwonlyargs + node.args.posonlyargs: if arg.annotation is None: continue - ann = arg.annotation - if isinstance(ann, ast.Name): - out.append((node.name, ann.id, "consumer", "high")) - elif isinstance(ann, ast.Subscript): - if isinstance(ann.value, ast.Name) and ann.value.id in ("list", "List"): - sl = ann.slice - if isinstance(sl, ast.Name): - out.append((node.name, sl.id, "consumer", "high")) + aggregate = _extract_type_name(arg.annotation) + if aggregate and aggregate not in ("None", "NoneType"): + out.append((node.name, aggregate, "consumer", "high", node.lineno)) return out -def P3_pass(tree: ast.Module, file: str, type_registry: dict[str, list[str]]) -> list[tuple[str, str, str, int]]: + +def P3_pass(tree: ast.Module, file: str, type_registry: dict[str, list[str]]) -> list[tuple[str, str, str, int, int]]: """AST pass 3: detect field accesses via entry['key'] or entry.attr.""" - out: list[tuple[str, str, str, int]] = [] + out: list[tuple[str, str, str, int, int]] = [] for node in ast.walk(tree): if not isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)): continue @@ -223,7 +254,7 @@ def P3_pass(tree: ast.Module, file: str, type_registry: dict[str, list[str]]) -> k = ("attribute", sub.attr) counts[k] = counts.get(k, 0) + 1 for (kind, key), c in counts.items(): - out.append((node.name, key, kind, c)) + out.append((node.name, key, kind, c, node.lineno)) return out def build_pcg(src_dir: str, type_registry: dict[str, list[str]] | None = None) -> Result[ProducerConsumerGraph]: @@ -256,16 +287,17 @@ def build_pcg(src_dir: str, type_registry: dict[str, list[str]] | None = None) - continue file = str(py_file) fqname_prefix = file.removesuffix(".py").replace("/", ".").replace("\\", ".") - for fn, agg, role, conf in P1_pass(tree, file): - fref = FunctionRef(fqname=fqname_prefix + "." + fn, file=file, line=0, role=role) + for fn, agg, role, conf, line in P1_pass(tree, file): + fref = FunctionRef(fqname=fqname_prefix + "." + fn, file=file, line=line, role=role) if role == "producer": pcg.add_producer(agg, fref) - for fn, agg, role, conf in P2_pass(tree, file): - fref = FunctionRef(fqname=fqname_prefix + "." + fn, file=file, line=0, role=role) + for fn, agg, role, conf, line in P2_pass(tree, file): + fref = FunctionRef(fqname=fqname_prefix + "." + fn, file=file, line=line, role=role) if role == "consumer": pcg.add_consumer(agg, fref) - for fn, key, kind, count in P3_pass(tree, file, type_registry): - pass + for fn, key, kind, count, line in P3_pass(tree, file, type_registry): + fref = FunctionRef(fqname=fqname_prefix + "." + fn, file=file, line=line, role="field_access") + pcg.add_field_access(fn, key, kind, count, line) return Result(data=pcg, errors=errors) CANONICAL_MEMORY_DIM: dict[str, MemoryDim] = { diff --git a/src/code_path_audit_analysis.py b/src/code_path_audit_analysis.py index 8d0280be..3b45901e 100644 --- a/src/code_path_audit_analysis.py +++ b/src/code_path_audit_analysis.py @@ -39,9 +39,13 @@ def _field_names_for_aggregate(aggregate: str, type_registry: dict) -> set[str]: return set() def _analyze_function_field_accesses(func_node: ast.FunctionDef | ast.AsyncFunctionDef, param_names: set[str]) -> Counter: - """Walk a function body and count Subscript + Attribute accesses on the given param names. + """Walk a function body and count field accesses on the given param names. - Returns Counter of (kind, key_or_attr) -> count. + Recognizes 4 patterns: + - entry['key'] -> ('subscript', 'key') + - entry.attr -> ('attribute', 'attr') + - entry.get('key') / entry.get('key', default) -> ('subscript', 'key') (call subscripts) + - chained entry.attr1.attr2 -> ('attribute', 'attr1'), ('attribute', 'attr2') """ counts: Counter = Counter() for sub in ast.walk(func_node): @@ -49,6 +53,12 @@ def _analyze_function_field_accesses(func_node: ast.FunctionDef | ast.AsyncFunct if isinstance(sub.value, ast.Name) and sub.value.id in param_names: if isinstance(sub.slice, ast.Constant) and isinstance(sub.slice.value, str): counts[("subscript", sub.slice.value)] += 1 + elif isinstance(sub.value, ast.Call): + call = sub.value + func = call.func + if isinstance(func, ast.Attribute) and isinstance(func.value, ast.Name) and func.value.id in param_names and func.attr == "get": + if call.args and isinstance(call.args[0], ast.Constant) and isinstance(call.args[0].value, str): + counts[("subscript", call.args[0].value)] += 1 elif isinstance(sub, ast.Attribute): if isinstance(sub.value, ast.Name) and sub.value.id in param_names: counts[("attribute", sub.attr)] += 1 diff --git a/tests/test_code_path_audit.py b/tests/test_code_path_audit.py index 68324cd1..eeca7efb 100644 --- a/tests/test_code_path_audit.py +++ b/tests/test_code_path_audit.py @@ -341,7 +341,7 @@ def test_p1_pass_finds_producer_of_T() -> None: ''') tree = ast.parse(source) producers = P1_pass(tree, file="synthetic.py") - assert ("send_result", "Metadata", "producer", "high") in producers + assert ("send_result", "Metadata", "producer", "high", 2) in producers def test_p1_pass_finds_producer_of_Result_T() -> None: """P1 detects a function whose return annotation is Result[T] (producer of T).""" @@ -351,7 +351,7 @@ def test_p1_pass_finds_producer_of_Result_T() -> None: ''') tree = ast.parse(source) producers = P1_pass(tree, file="synthetic.py") - assert ("fetch", "FileItems", "producer", "high") in producers + assert ("fetch", "FileItems", "producer", "high", 2) in producers def test_p1_pass_skips_non_annotated_return() -> None: """P1 returns [] for functions without return annotations.""" @@ -371,7 +371,7 @@ def test_p2_pass_finds_consumer_of_T() -> None: ''') tree = ast.parse(source) consumers = P2_pass(tree, file="synthetic.py") - assert ("process", "Metadata", "consumer", "high") in consumers + assert ("process", "Metadata", "consumer", "high", 2) in consumers def test_p2_pass_finds_consumer_of_list_T() -> None: """P2 detects a function whose parameter is list[T] (consumer of T).""" @@ -381,7 +381,7 @@ def test_p2_pass_finds_consumer_of_list_T() -> None: ''') tree = ast.parse(source) consumers = P2_pass(tree, file="synthetic.py") - assert ("aggregate", "FileItems", "consumer", "high") in consumers + assert ("aggregate", "FileItems", "consumer", "high", 2) in consumers def test_p2_pass_skips_untyped_parameter() -> None: """P2 returns [] for parameters without type annotations.""" @@ -401,7 +401,7 @@ def test_p3_pass_finds_consumer_via_subscript() -> None: ''') tree = ast.parse(source) accesses = P3_pass(tree, file="synthetic.py", type_registry={}) - assert ("process", "path", "subscript", 1) in accesses + assert ("process", "path", "subscript", 1, 2) in accesses def test_p3_pass_finds_consumer_via_attribute() -> None: """P3 detects a function that reads entry.attr; returns (function, attr, kind, count).""" @@ -411,7 +411,7 @@ def test_p3_pass_finds_consumer_via_attribute() -> None: ''') tree = ast.parse(source) accesses = P3_pass(tree, file="synthetic.py", type_registry={}) - assert ("process", "path", "attribute", 1) in accesses + assert ("process", "path", "attribute", 1, 2) in accesses def test_p3_pass_counts_multiple_accesses() -> None: """P3 counts multiple accesses to the same key within a single function.""" @@ -423,7 +423,7 @@ def test_p3_pass_counts_multiple_accesses() -> None: ''') tree = ast.parse(source) accesses = P3_pass(tree, file="synthetic.py", type_registry={}) - path_count = sum(c for fn, k, kind, c in accesses if fn == "process" and k == "path") + path_count = sum(c for fn, k, kind, c, line in accesses if fn == "process" and k == "path") assert path_count == 2 def test_build_pcg_returns_result() -> None: