Private
Public Access
0
0

feat(audit): real analysis - consumer fields, struct size, decomp

This commit is contained in:
2026-06-22 09:08:41 -04:00
parent 258d044f6b
commit 85f5808ae3
33 changed files with 782 additions and 361 deletions
@@ -12,7 +12,7 @@
\ === consumers (0 items) ===
\ === access_pattern ===
"whole_struct" access-pattern
"mixed" access-pattern
\ === access_pattern_evidence (0 items) ===
@@ -31,7 +31,7 @@
5 cross-audit-findings
\ === decomposition_cost ===
0 0 0 "hold" "no data" nil 0 false decomp-cost
470 0 0 "insufficient_data" "CommsLog: 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." nil 5 true decomp-cost
\ === optimization_candidates (0 items) ===
@@ -11,7 +11,7 @@
## Access pattern
**Dominant pattern:** whole_struct
**Dominant pattern:** mixed
**Evidence count:** 0
## Frequency
@@ -21,11 +21,11 @@
## Result coverage
**Summary:**
**Summary:** 0 producers, 0 consumers
## Type alias coverage
**Summary:**
**Summary:** 0 sites
## Cross-audit findings
@@ -34,11 +34,11 @@
## Decomposition cost
**Current cost estimate:** 0 us
**Current cost estimate:** 470 us
**Componentize savings:** 0 us
**Unify savings:** 0 us
**Recommended direction:** hold
**Rationale:** no data
**Recommended direction:** insufficient_data
**Rationale:** CommsLog: 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.
## Optimization candidates
@@ -46,4 +46,4 @@ _(none)_
## Verdict
no data
CommsLog: 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.
@@ -3,10 +3,10 @@ Metadata: CommsLog
|- memory_dim: discussion
|- producers: [0]
|- consumers: [0]
|- access_pattern: whole_struct
|- access_pattern: mixed
|- frequency: per_turn
|- result_coverage:
|- type_alias_coverage:
|- result_coverage: 0 producers, 0 consumers
|- type_alias_coverage: 0 sites
|- cross_audit_findings: 0 findings
|- decomposition_cost: hold (0 us)
|- decomposition_cost: insufficient_data (470 us)
|- optimization_candidates: [0]
@@ -12,7 +12,7 @@
\ === consumers (0 items) ===
\ === access_pattern ===
"whole_struct" access-pattern
"mixed" access-pattern
\ === access_pattern_evidence (0 items) ===
@@ -31,7 +31,7 @@
5 cross-audit-findings
\ === decomposition_cost ===
0 0 0 "hold" "no data" nil 0 false decomp-cost
470 0 0 "insufficient_data" "CommsLogEntry: 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." nil 5 true decomp-cost
\ === optimization_candidates (0 items) ===
@@ -11,7 +11,7 @@
## Access pattern
**Dominant pattern:** whole_struct
**Dominant pattern:** mixed
**Evidence count:** 0
## Frequency
@@ -21,11 +21,11 @@
## Result coverage
**Summary:**
**Summary:** 0 producers, 0 consumers
## Type alias coverage
**Summary:**
**Summary:** 0 sites
## Cross-audit findings
@@ -34,11 +34,11 @@
## Decomposition cost
**Current cost estimate:** 0 us
**Current cost estimate:** 470 us
**Componentize savings:** 0 us
**Unify savings:** 0 us
**Recommended direction:** hold
**Rationale:** no data
**Recommended direction:** insufficient_data
**Rationale:** CommsLogEntry: 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.
## Optimization candidates
@@ -46,4 +46,4 @@ _(none)_
## Verdict
no data
CommsLogEntry: 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.
@@ -3,10 +3,10 @@ Metadata: CommsLogEntry
|- memory_dim: discussion
|- producers: [0]
|- consumers: [0]
|- access_pattern: whole_struct
|- access_pattern: mixed
|- frequency: per_turn
|- result_coverage:
|- type_alias_coverage:
|- result_coverage: 0 producers, 0 consumers
|- type_alias_coverage: 0 sites
|- cross_audit_findings: 0 findings
|- decomposition_cost: hold (0 us)
|- decomposition_cost: insufficient_data (470 us)
|- optimization_candidates: [0]
@@ -12,7 +12,7 @@
\ === consumers (0 items) ===
\ === access_pattern ===
"whole_struct" access-pattern
"mixed" access-pattern
\ === access_pattern_evidence (0 items) ===
@@ -31,7 +31,7 @@
5 cross-audit-findings
\ === decomposition_cost ===
0 0 0 "hold" "no data" nil 0 false decomp-cost
470 0 0 "insufficient_data" "FileItem: 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." nil 5 true decomp-cost
\ === optimization_candidates (0 items) ===
@@ -11,7 +11,7 @@
## Access pattern
**Dominant pattern:** whole_struct
**Dominant pattern:** mixed
**Evidence count:** 0
## Frequency
@@ -21,11 +21,11 @@
## Result coverage
**Summary:**
**Summary:** 0 producers, 0 consumers
## Type alias coverage
**Summary:**
**Summary:** 0 sites
## Cross-audit findings
@@ -34,11 +34,11 @@
## Decomposition cost
**Current cost estimate:** 0 us
**Current cost estimate:** 470 us
**Componentize savings:** 0 us
**Unify savings:** 0 us
**Recommended direction:** hold
**Rationale:** no data
**Recommended direction:** insufficient_data
**Rationale:** FileItem: 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.
## Optimization candidates
@@ -46,4 +46,4 @@ _(none)_
## Verdict
no data
FileItem: 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.
@@ -3,10 +3,10 @@ Metadata: FileItem
|- memory_dim: curation
|- producers: [0]
|- consumers: [0]
|- access_pattern: whole_struct
|- access_pattern: mixed
|- frequency: per_turn
|- result_coverage:
|- type_alias_coverage:
|- result_coverage: 0 producers, 0 consumers
|- type_alias_coverage: 0 sites
|- cross_audit_findings: 0 findings
|- decomposition_cost: hold (0 us)
|- decomposition_cost: insufficient_data (470 us)
|- optimization_candidates: [0]
@@ -10,14 +10,17 @@
\ === producers (0 items) ===
\ === consumers (3 items) ===
"src.ai_client._build_file_context_text" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client._build_file_diff_text" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client._reread_file_items_result" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client._build_file_context_text" "src\ai_client.py" 0 "consumer" fn-ref
\ === access_pattern ===
"whole_struct" access-pattern
\ === access_pattern_evidence (0 items) ===
\ === access_pattern_evidence (3 items) ===
"src.ai_client._build_file_context_text" "whole_struct" 0 "low" ap-evidence
"src.ai_client._build_file_diff_text" "whole_struct" 0 "low" ap-evidence
"src.ai_client._reread_file_items_result" "whole_struct" 0 "low" ap-evidence
\ === frequency ===
"per_turn" frequency
@@ -34,7 +37,7 @@
5 cross-audit-findings
\ === decomposition_cost ===
0 0 0 "hold" "no data" nil 0 false decomp-cost
470 0 70 "hold" "FileItems: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: hold because the current shape matches the access pattern." nil 5 true decomp-cost
\ === optimization_candidates (0 items) ===
@@ -12,7 +12,7 @@
## Access pattern
**Dominant pattern:** whole_struct
**Evidence count:** 0
**Evidence count:** 3
## Frequency
@@ -21,11 +21,11 @@
## Result coverage
**Summary:**
**Summary:** 0 producers, 3 consumers
## Type alias coverage
**Summary:**
**Summary:** 0 sites
## Cross-audit findings
@@ -34,11 +34,11 @@
## Decomposition cost
**Current cost estimate:** 0 us
**Current cost estimate:** 470 us
**Componentize savings:** 0 us
**Unify savings:** 0 us
**Unify savings:** 70 us
**Recommended direction:** hold
**Rationale:** no data
**Rationale:** FileItems: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: hold because the current shape matches the access pattern.
## Optimization candidates
@@ -46,4 +46,4 @@ _(none)_
## Verdict
no data
FileItems: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: hold because the current shape matches the access pattern.
@@ -3,13 +3,13 @@ Metadata: FileItems
|- memory_dim: curation
|- producers: [0]
|- consumers: [3]
| |- src.ai_client._build_file_context_text (consumer)
| |- src.ai_client._build_file_diff_text (consumer)
| |- src.ai_client._reread_file_items_result (consumer)
| |- src.ai_client._build_file_context_text (consumer)
|- access_pattern: whole_struct
|- frequency: per_turn
|- result_coverage:
|- type_alias_coverage:
|- result_coverage: 0 producers, 3 consumers
|- type_alias_coverage: 0 sites
|- cross_audit_findings: 0 findings
|- decomposition_cost: hold (0 us)
|- decomposition_cost: hold (470 us)
|- optimization_candidates: [0]
@@ -12,7 +12,7 @@
\ === consumers (0 items) ===
\ === access_pattern ===
"whole_struct" access-pattern
"mixed" access-pattern
\ === access_pattern_evidence (0 items) ===
@@ -31,7 +31,7 @@
5 cross-audit-findings
\ === decomposition_cost ===
0 0 0 "hold" "no data" nil 0 false decomp-cost
470 0 0 "insufficient_data" "History: 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." nil 5 true decomp-cost
\ === optimization_candidates (0 items) ===
@@ -11,7 +11,7 @@
## Access pattern
**Dominant pattern:** whole_struct
**Dominant pattern:** mixed
**Evidence count:** 0
## Frequency
@@ -21,11 +21,11 @@
## Result coverage
**Summary:**
**Summary:** 0 producers, 0 consumers
## Type alias coverage
**Summary:**
**Summary:** 0 sites
## Cross-audit findings
@@ -34,11 +34,11 @@
## Decomposition cost
**Current cost estimate:** 0 us
**Current cost estimate:** 470 us
**Componentize savings:** 0 us
**Unify savings:** 0 us
**Recommended direction:** hold
**Rationale:** no data
**Recommended direction:** insufficient_data
**Rationale:** History: 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.
## Optimization candidates
@@ -46,4 +46,4 @@ _(none)_
## Verdict
no data
History: 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.
@@ -3,10 +3,10 @@ Metadata: History
|- memory_dim: discussion
|- producers: [0]
|- consumers: [0]
|- access_pattern: whole_struct
|- access_pattern: mixed
|- frequency: per_turn
|- result_coverage:
|- type_alias_coverage:
|- result_coverage: 0 producers, 0 consumers
|- type_alias_coverage: 0 sites
|- cross_audit_findings: 0 findings
|- decomposition_cost: hold (0 us)
|- decomposition_cost: insufficient_data (470 us)
|- optimization_candidates: [0]
@@ -10,13 +10,15 @@
\ === producers (0 items) ===
\ === consumers (2 items) ===
"src.provider_state.append" "src\provider_state.py" 0 "consumer" fn-ref
"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
\ === access_pattern ===
"whole_struct" access-pattern
\ === access_pattern_evidence (0 items) ===
\ === access_pattern_evidence (2 items) ===
"src.provider_state.replace_all" "whole_struct" 0 "low" ap-evidence
"src.provider_state.append" "whole_struct" 0 "low" ap-evidence
\ === frequency ===
"per_turn" frequency
@@ -33,7 +35,7 @@
5 cross-audit-findings
\ === decomposition_cost ===
0 0 0 "hold" "no data" nil 0 false decomp-cost
470 0 70 "hold" "HistoryMessage: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: hold because the current shape matches the access pattern." nil 5 true decomp-cost
\ === optimization_candidates (0 items) ===
@@ -12,7 +12,7 @@
## Access pattern
**Dominant pattern:** whole_struct
**Evidence count:** 0
**Evidence count:** 2
## Frequency
@@ -21,11 +21,11 @@
## Result coverage
**Summary:**
**Summary:** 0 producers, 2 consumers
## Type alias coverage
**Summary:**
**Summary:** 0 sites
## Cross-audit findings
@@ -34,11 +34,11 @@
## Decomposition cost
**Current cost estimate:** 0 us
**Current cost estimate:** 470 us
**Componentize savings:** 0 us
**Unify savings:** 0 us
**Unify savings:** 70 us
**Recommended direction:** hold
**Rationale:** no data
**Rationale:** HistoryMessage: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: hold because the current shape matches the access pattern.
## Optimization candidates
@@ -46,4 +46,4 @@ _(none)_
## Verdict
no data
HistoryMessage: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: hold because the current shape matches the access pattern.
@@ -3,12 +3,12 @@ Metadata: HistoryMessage
|- memory_dim: discussion
|- producers: [0]
|- consumers: [2]
| |- src.provider_state.append (consumer)
| |- src.provider_state.replace_all (consumer)
| |- src.provider_state.append (consumer)
|- access_pattern: whole_struct
|- frequency: per_turn
|- result_coverage:
|- type_alias_coverage:
|- result_coverage: 0 producers, 2 consumers
|- type_alias_coverage: 0 sites
|- cross_audit_findings: 0 findings
|- decomposition_cost: hold (0 us)
|- decomposition_cost: hold (470 us)
|- optimization_candidates: [0]
@@ -8,130 +8,170 @@
"discussion" mem-dim
\ === producers (77 items) ===
"src.project_manager.load_history" "src\project_manager.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_state" "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_io_pool_status" "src\api_hook_client.py" 0 "producer" fn-ref
"src.ai_client._add_bleed_derived" "src\ai_client.py" 0 "producer" fn-ref
"src.app_controller.get_performance" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.set_value" "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.ai_client._parse_tool_args_result" "src\ai_client.py" 0 "producer" fn-ref
"src.project_manager.load_project" "src\project_manager.py" 0 "producer" fn-ref
"src.app_controller._api_get_performance" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.right_click" "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.api_hook_client.get_project_switch_status" "src\api_hook_client.py" 0 "producer" fn-ref
"src.api_hook_client.post_session" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller.get_context" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.get_project" "src\api_hook_client.py" 0 "producer" fn-ref
"src.api_hook_client.push_event" "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_session" "src\app_controller.py" 0 "producer" fn-ref
"src.app_controller.token_stats" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.post_gui" "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_session" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.get_mma_workers" "src\api_hook_client.py" 0 "producer" fn-ref
"src.project_manager.default_project" "src\project_manager.py" 0 "producer" fn-ref
"src.project_manager.flat_config" "src\project_manager.py" 0 "producer" fn-ref
"src.api_hook_client.get_performance" "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.select_list_item" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller.get_gui_state" "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.ai_client._load_credentials" "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.app_controller._api_get_mma_status" "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._offload_entry_payload" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.drag" "src\api_hook_client.py" 0 "producer" fn-ref
"src.ai_client._send_cli_round_result" "src\ai_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_startup_timeline" "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.click" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller.get_api_session" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.trigger_patch" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller.get_diagnostics" "src\app_controller.py" 0 "producer" fn-ref
"src.app_controller.get_context" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.select_tab" "src\api_hook_client.py" 0 "producer" fn-ref
"src.api_hook_client.get_warmup_status" "src\api_hook_client.py" 0 "producer" fn-ref
"src.models._load_config_from_disk" "src\models.py" 0 "producer" fn-ref
"src.project_manager.default_discussion" "src\project_manager.py" 0 "producer" fn-ref
"src.ai_client._dashscope_call" "src\ai_client.py" 0 "producer" fn-ref
"src.api_hook_client.get_patch_status" "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.api_hook_client.post_project" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller.get_mma_status" "src\app_controller.py" 0 "producer" fn-ref
"src.app_controller.generate" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.get_gui_diagnostics" "src\api_hook_client.py" 0 "producer" fn-ref
"src.ai_client._content_block_to_dict" "src\ai_client.py" 0 "producer" fn-ref
"src.ai_client.ollama_chat" "src\ai_client.py" 0 "producer" fn-ref
"src.app_controller.get_session_insights" "src\app_controller.py" 0 "producer" fn-ref
"src.app_controller.load_config" "src\app_controller.py" 0 "producer" fn-ref
"src.app_controller._api_token_stats" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.reject_patch" "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._api_get_gui_state" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.get_node_status" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller.status" "src\app_controller.py" 0 "producer" fn-ref
"src.app_controller._api_status" "src\app_controller.py" 0 "producer" fn-ref
"src.project_manager.flat_config" "src\project_manager.py" 0 "producer" fn-ref
"src.api_hook_client.get_warmup_wait" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller._api_generate" "src\app_controller.py" 0 "producer" fn-ref
"src.app_controller._api_get_context" "src\app_controller.py" 0 "producer" fn-ref
"src.models.to_dict" "src\models.py" 0 "producer" fn-ref
"src.api_hook_client.get_session" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller.token_stats" "src\app_controller.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.apply_patch" "src\api_hook_client.py" 0 "producer" fn-ref
"src.project_manager.load_history" "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.app_controller._api_get_diagnostics" "src\app_controller.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.get_system_telemetry" "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_api_session" "src\app_controller.py" 0 "producer" fn-ref
"src.app_controller.get_gui_state" "src\app_controller.py" 0 "producer" fn-ref
"src.app_controller.get_mma_status" "src\app_controller.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.wait_for_project_switch" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller.generate" "src\app_controller.py" 0 "producer" fn-ref
"src.app_controller._api_get_mma_status" "src\app_controller.py" 0 "producer" fn-ref
"src.ai_client.get_token_stats" "src\ai_client.py" 0 "producer" fn-ref
"src.api_hook_client.click" "src\api_hook_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.post_project" "src\api_hook_client.py" 0 "producer" fn-ref
"src.api_hook_client.trigger_patch" "src\api_hook_client.py" 0 "producer" fn-ref
"src.api_hook_client.get_patch_status" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller._api_get_session" "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.app_controller.get_api_project" "src\app_controller.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_gui_state" "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.ai_client._load_credentials" "src\ai_client.py" 0 "producer" fn-ref
"src.app_controller._api_get_performance" "src\app_controller.py" 0 "producer" fn-ref
"src.ai_client._content_block_to_dict" "src\ai_client.py" 0 "producer" fn-ref
"src.ai_client._add_bleed_derived" "src\ai_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_gui_state" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.post_gui" "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.api_hook_client.reject_patch" "src\api_hook_client.py" 0 "producer" fn-ref
"src.api_hook_client.get_mma_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.get_session" "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.get_session" "src\app_controller.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.get_warmup_status" "src\api_hook_client.py" 0 "producer" fn-ref
"src.project_manager.default_project" "src\project_manager.py" 0 "producer" fn-ref
"src.project_manager.default_discussion" "src\project_manager.py" 0 "producer" fn-ref
"src.api_hook_client.get_project" "src\api_hook_client.py" 0 "producer" fn-ref
"src.api_hook_client.get_gui_diagnostics" "src\api_hook_client.py" 0 "producer" fn-ref
"src.project_manager.load_project" "src\project_manager.py" 0 "producer" fn-ref
"src.ai_client._dashscope_call" "src\ai_client.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.app_controller._api_status" "src\app_controller.py" 0 "producer" fn-ref
"src.app_controller.status" "src\app_controller.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_performance" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller._offload_entry_payload" "src\app_controller.py" 0 "producer" fn-ref
"src.models._load_config_from_disk" "src\models.py" 0 "producer" fn-ref
"src.project_manager.migrate_from_legacy_config" "src\project_manager.py" 0 "producer" fn-ref
"src.models.to_dict" "src\models.py" 0 "producer" fn-ref
"src.api_hook_client.get_system_telemetry" "src\api_hook_client.py" 0 "producer" fn-ref
"src.ai_client._parse_tool_args_result" "src\ai_client.py" 0 "producer" fn-ref
"src.ai_client._send_cli_round_result" "src\ai_client.py" 0 "producer" fn-ref
"src.app_controller.load_config" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.set_value" "src\api_hook_client.py" 0 "producer" fn-ref
"src.api_hook_client.drag" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller._api_get_context" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.post_session" "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.app_controller.get_session_insights" "src\app_controller.py" 0 "producer" fn-ref
"src.app_controller.get_performance" "src\app_controller.py" 0 "producer" fn-ref
"src.api_hook_client.push_event" "src\api_hook_client.py" 0 "producer" fn-ref
"src.app_controller.get_diagnostics" "src\app_controller.py" 0 "producer" fn-ref
\ === consumers (35 items) ===
"src.ai_client._dashscope_call" "src\ai_client.py" 0 "consumer" fn-ref
"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_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.app_controller._offload_entry_payload" "src\app_controller.py" 0 "consumer" fn-ref
"src.project_manager.save_project" "src\project_manager.py" 0 "consumer" fn-ref
"src.aggregate.run" "src\aggregate.py" 0 "consumer" fn-ref
"src.app_controller._on_comms_entry" "src\app_controller.py" 0 "consumer" fn-ref
"src.ai_client._pre_dispatch" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client._add_history_cache_breakpoint" "src\ai_client.py" 0 "consumer" fn-ref
"src.models.from_dict" "src\models.py" 0 "consumer" fn-ref
"src.project_manager.migrate_from_legacy_config" "src\project_manager.py" 0 "consumer" fn-ref
"src.models._save_config_to_disk" "src\models.py" 0 "consumer" fn-ref
"src.ai_client._execute_single_tool_call_async" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client.ollama_chat" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client._add_bleed_derived" "src\ai_client.py" 0 "consumer" fn-ref
"src.app_controller._start_track_logic" "src\app_controller.py" 0 "consumer" fn-ref
"src.ai_client._estimate_prompt_tokens" "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._append_comms" "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._repair_deepseek_history" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client._estimate_message_tokens" "src\ai_client.py" 0 "consumer" fn-ref
"src.aggregate.build_tier3_context" "src\aggregate.py" 0 "consumer" fn-ref
"src.project_manager.entry_to_str" "src\project_manager.py" 0 "consumer" fn-ref
"src.project_manager.flat_config" "src\project_manager.py" 0 "consumer" fn-ref
"src.ai_client._trim_anthropic_history" "src\ai_client.py" 0 "consumer" fn-ref
"src.app_controller._refresh_api_metrics" "src\app_controller.py" 0 "consumer" fn-ref
"src.ai_client._repair_minimax_history" "src\ai_client.py" 0 "consumer" fn-ref
"src.aggregate.build_markdown_from_items" "src\aggregate.py" 0 "consumer" fn-ref
"src.app_controller._start_track_logic_result" "src\app_controller.py" 0 "consumer" fn-ref
"src.ai_client._strip_private_keys" "src\ai_client.py" 0 "consumer" fn-ref
"src.aggregate._build_files_section_from_items" "src\aggregate.py" 0 "consumer" fn-ref
"src.ai_client._add_history_cache_breakpoint" "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._dashscope_call" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client._invalidate_token_estimate" "src\ai_client.py" 0 "consumer" fn-ref
"src.app_controller._start_track_logic_result" "src\app_controller.py" 0 "consumer" fn-ref
"src.ai_client._estimate_message_tokens" "src\ai_client.py" 0 "consumer" fn-ref
"src.app_controller._on_comms_entry" "src\app_controller.py" 0 "consumer" fn-ref
"src.project_manager.flat_config" "src\project_manager.py" 0 "consumer" fn-ref
"src.ai_client._estimate_prompt_tokens" "src\ai_client.py" 0 "consumer" fn-ref
"src.aggregate.build_markdown_from_items" "src\aggregate.py" 0 "consumer" fn-ref
"src.ai_client._append_comms" "src\ai_client.py" 0 "consumer" fn-ref
"src.models._save_config_to_disk" "src\models.py" 0 "consumer" fn-ref
"src.project_manager.entry_to_str" "src\project_manager.py" 0 "consumer" fn-ref
"src.ai_client._trim_anthropic_history" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client.ollama_chat" "src\ai_client.py" 0 "consumer" fn-ref
"src.app_controller._offload_entry_payload" "src\app_controller.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.project_manager.migrate_from_legacy_config" "src\project_manager.py" 0 "consumer" fn-ref
"src.ai_client._strip_stale_file_refreshes" "src\ai_client.py" 0 "consumer" fn-ref
"src.app_controller._refresh_api_metrics" "src\app_controller.py" 0 "consumer" fn-ref
"src.project_manager.format_discussion" "src\project_manager.py" 0 "consumer" fn-ref
"src.aggregate.run" "src\aggregate.py" 0 "consumer" fn-ref
"src.app_controller._start_track_logic" "src\app_controller.py" 0 "consumer" fn-ref
"src.ai_client._strip_cache_controls" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client._repair_minimax_history" "src\ai_client.py" 0 "consumer" fn-ref
"src.aggregate.build_markdown_no_history" "src\aggregate.py" 0 "consumer" fn-ref
"src.aggregate.build_tier3_context" "src\aggregate.py" 0 "consumer" fn-ref
"src.ai_client._repair_deepseek_history" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client._add_bleed_derived" "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._execute_single_tool_call_async" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client._pre_dispatch" "src\ai_client.py" 0 "consumer" fn-ref
"src.ai_client._trim_minimax_history" "src\ai_client.py" 0 "consumer" fn-ref
\ === access_pattern ===
"whole_struct" access-pattern
\ === access_pattern_evidence (0 items) ===
\ === access_pattern_evidence (35 items) ===
"src.aggregate._build_files_section_from_items" "whole_struct" 0 "low" ap-evidence
"src.ai_client._add_history_cache_breakpoint" "whole_struct" 0 "low" ap-evidence
"src.ai_client._strip_private_keys" "whole_struct" 0 "low" ap-evidence
"src.ai_client._dashscope_call" "whole_struct" 0 "low" ap-evidence
"src.ai_client._invalidate_token_estimate" "whole_struct" 0 "low" ap-evidence
"src.app_controller._start_track_logic_result" "whole_struct" 0 "low" ap-evidence
"src.ai_client._estimate_message_tokens" "whole_struct" 0 "low" ap-evidence
"src.app_controller._on_comms_entry" "whole_struct" 0 "low" ap-evidence
"src.project_manager.flat_config" "whole_struct" 0 "low" ap-evidence
"src.ai_client._estimate_prompt_tokens" "whole_struct" 0 "low" ap-evidence
"src.aggregate.build_markdown_from_items" "whole_struct" 0 "low" ap-evidence
"src.ai_client._append_comms" "whole_struct" 0 "low" ap-evidence
"src.models._save_config_to_disk" "whole_struct" 0 "low" ap-evidence
"src.project_manager.entry_to_str" "whole_struct" 0 "low" ap-evidence
"src.ai_client._trim_anthropic_history" "whole_struct" 0 "low" ap-evidence
"src.ai_client.ollama_chat" "whole_struct" 0 "low" ap-evidence
"src.app_controller._offload_entry_payload" "whole_struct" 0 "low" ap-evidence
"src.models.from_dict" "whole_struct" 0 "low" ap-evidence
"src.project_manager.save_project" "whole_struct" 0 "low" ap-evidence
"src.project_manager.migrate_from_legacy_config" "whole_struct" 0 "low" ap-evidence
"src.ai_client._strip_stale_file_refreshes" "whole_struct" 0 "low" ap-evidence
"src.app_controller._refresh_api_metrics" "whole_struct" 0 "low" ap-evidence
"src.project_manager.format_discussion" "whole_struct" 0 "low" ap-evidence
"src.aggregate.run" "whole_struct" 0 "low" ap-evidence
"src.app_controller._start_track_logic" "whole_struct" 0 "low" ap-evidence
"src.ai_client._strip_cache_controls" "whole_struct" 0 "low" ap-evidence
"src.ai_client._repair_minimax_history" "whole_struct" 0 "low" ap-evidence
"src.aggregate.build_markdown_no_history" "whole_struct" 0 "low" ap-evidence
"src.aggregate.build_tier3_context" "whole_struct" 0 "low" ap-evidence
"src.ai_client._repair_deepseek_history" "whole_struct" 0 "low" ap-evidence
"src.ai_client._add_bleed_derived" "whole_struct" 0 "low" ap-evidence
"src.ai_client._repair_anthropic_history" "whole_struct" 0 "low" ap-evidence
"src.ai_client._execute_single_tool_call_async" "whole_struct" 0 "low" ap-evidence
"src.ai_client._pre_dispatch" "whole_struct" 0 "low" ap-evidence
"src.ai_client._trim_minimax_history" "whole_struct" 0 "low" ap-evidence
\ === frequency ===
"per_turn" frequency
\ === frequency_evidence (0 items) ===
\ === frequency_evidence (5 items) ===
"src.api_hook_client.get_status" "per_turn" "static_analysis" "producer from src\api_hook_client.py" freq-evidence
"src.app_controller.get_context" "per_turn" "static_analysis" "producer from src\app_controller.py" freq-evidence
"src.api_hook_client.select_tab" "per_turn" "static_analysis" "producer from src\api_hook_client.py" freq-evidence
"src.project_manager.flat_config" "per_turn" "static_analysis" "producer from src\project_manager.py" freq-evidence
"src.api_hook_client.get_warmup_wait" "per_turn" "static_analysis" "producer from src\api_hook_client.py" freq-evidence
\ === result_coverage ===
77 77 35 0 result-coverage
@@ -143,7 +183,7 @@
5 cross-audit-findings
\ === decomposition_cost ===
0 0 0 "hold" "no data" nil 0 false decomp-cost
470 0 70 "hold" "Metadata: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: hold because the current shape matches the access pattern." nil 5 true decomp-cost
\ === optimization_candidates (0 items) ===
@@ -12,20 +12,20 @@
## Access pattern
**Dominant pattern:** whole_struct
**Evidence count:** 0
**Evidence count:** 35
## Frequency
**Dominant frequency:** per_turn
**Evidence count:** 0
**Evidence count:** 5
## Result coverage
**Summary:**
**Summary:** 77 producers, 35 consumers
## Type alias coverage
**Summary:**
**Summary:** 0 sites
## Cross-audit findings
@@ -34,11 +34,11 @@
## Decomposition cost
**Current cost estimate:** 0 us
**Current cost estimate:** 470 us
**Componentize savings:** 0 us
**Unify savings:** 0 us
**Unify savings:** 70 us
**Recommended direction:** hold
**Rationale:** no data
**Rationale:** Metadata: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: hold because the current shape matches the access pattern.
## Optimization candidates
@@ -46,4 +46,4 @@ _(none)_
## Verdict
no data
Metadata: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: hold because the current shape matches the access pattern.
@@ -2,123 +2,123 @@ Metadata: Metadata
|- kind: typealias
|- memory_dim: discussion
|- producers: [77]
| |- src.project_manager.load_history (producer)
| |- src.api_hook_client.get_context_state (producer)
| |- src.api_hook_client.get_gui_state (producer)
| |- src.ai_client.get_token_stats (producer)
| |- src.api_hook_client.get_io_pool_status (producer)
| |- src.ai_client._add_bleed_derived (producer)
| |- src.app_controller.get_performance (producer)
| |- src.api_hook_client.set_value (producer)
| |- src.api_hook_client.get_warmup_wait (producer)
| |- src.ai_client._parse_tool_args_result (producer)
| |- src.project_manager.load_project (producer)
| |- src.app_controller._api_get_performance (producer)
| |- src.api_hook_client.right_click (producer)
| |- src.app_controller._api_get_api_session (producer)
| |- src.api_hook_client.get_project_switch_status (producer)
| |- src.api_hook_client.post_session (producer)
| |- src.app_controller.get_context (producer)
| |- src.api_hook_client.get_project (producer)
| |- src.api_hook_client.push_event (producer)
| |- src.app_controller.wait (producer)
| |- src.app_controller.get_session (producer)
| |- src.app_controller.token_stats (producer)
| |- src.api_hook_client.post_gui (producer)
| |- src.api_hook_client.get_status (producer)
| |- src.app_controller._api_get_session (producer)
| |- src.api_hook_client.get_mma_workers (producer)
| |- src.project_manager.default_project (producer)
| |- src.project_manager.flat_config (producer)
| |- src.api_hook_client.get_performance (producer)
| |- src.api_hook_client.apply_patch (producer)
| |- src.api_hook_client.select_list_item (producer)
| |- src.app_controller.get_gui_state (producer)
| |- src.api_hook_client.get_mma_status (producer)
| |- src.ai_client._load_credentials (producer)
| |- src.api_hook_client.get_financial_metrics (producer)
| |- src.app_controller._api_get_mma_status (producer)
| |- src.app_controller.get_api_project (producer)
| |- src.app_controller._offload_entry_payload (producer)
| |- src.api_hook_client.drag (producer)
| |- src.ai_client._send_cli_round_result (producer)
| |- src.project_manager.migrate_from_legacy_config (producer)
| |- src.api_hook_client.get_startup_timeline (producer)
| |- src.project_manager.str_to_entry (producer)
| |- src.api_hook_client.click (producer)
| |- src.app_controller.get_api_session (producer)
| |- src.api_hook_client.trigger_patch (producer)
| |- src.app_controller.get_diagnostics (producer)
| |- src.app_controller.get_context (producer)
| |- src.api_hook_client.select_tab (producer)
| |- src.api_hook_client.get_warmup_status (producer)
| |- src.models._load_config_from_disk (producer)
| |- src.project_manager.default_discussion (producer)
| |- src.ai_client._dashscope_call (producer)
| |- src.api_hook_client.get_patch_status (producer)
| |- src.app_controller._api_get_api_project (producer)
| |- src.api_hook_client.post_project (producer)
| |- src.app_controller.get_mma_status (producer)
| |- src.app_controller.generate (producer)
| |- src.api_hook_client.get_gui_diagnostics (producer)
| |- src.ai_client._content_block_to_dict (producer)
| |- src.ai_client.ollama_chat (producer)
| |- src.app_controller.get_session_insights (producer)
| |- src.app_controller.load_config (producer)
| |- src.app_controller._api_token_stats (producer)
| |- src.api_hook_client.reject_patch (producer)
| |- src.api_hook_client.wait_for_project_switch (producer)
| |- src.app_controller._api_get_gui_state (producer)
| |- src.api_hook_client.get_node_status (producer)
| |- src.app_controller.status (producer)
| |- src.app_controller._api_status (producer)
| |- src.project_manager.flat_config (producer)
| |- src.api_hook_client.get_warmup_wait (producer)
| |- src.app_controller._api_generate (producer)
| |- src.app_controller._api_get_context (producer)
| |- src.models.to_dict (producer)
| |- src.api_hook_client.get_session (producer)
| |- src.app_controller.token_stats (producer)
| |- src.api_hook_client.get_io_pool_status (producer)
| |- src.api_hook_client.apply_patch (producer)
| |- src.project_manager.load_history (producer)
| |- src.api_hook_client.get_mma_workers (producer)
| |- src.app_controller._api_get_diagnostics (producer)
| |- src.api_hook_client.get_gui_health (producer)
| |- src.api_hook_client.get_system_telemetry (producer)
| |- src.app_controller.wait (producer)
| |- src.app_controller.get_api_session (producer)
| |- src.app_controller.get_gui_state (producer)
| |- src.app_controller.get_mma_status (producer)
| |- src.api_hook_client.get_context_state (producer)
| |- src.api_hook_client.wait_for_project_switch (producer)
| |- src.app_controller.generate (producer)
| |- src.app_controller._api_get_mma_status (producer)
| |- src.ai_client.get_token_stats (producer)
| |- src.api_hook_client.click (producer)
| |- src.api_hook_client.get_node_status (producer)
| |- src.api_hook_client.post_project (producer)
| |- src.api_hook_client.trigger_patch (producer)
| |- src.api_hook_client.get_patch_status (producer)
| |- src.app_controller._api_get_session (producer)
| |- src.api_hook_client.get_startup_timeline (producer)
| |- src.app_controller.get_api_project (producer)
| |- src.api_hook_client.get_financial_metrics (producer)
| |- src.api_hook_client.get_gui_state (producer)
| |- src.ai_client.get_gemini_cache_stats (producer)
| |- src.ai_client._load_credentials (producer)
| |- src.app_controller._api_get_performance (producer)
| |- src.ai_client._content_block_to_dict (producer)
| |- src.ai_client._add_bleed_derived (producer)
| |- src.app_controller._api_get_api_session (producer)
| |- src.app_controller._api_get_gui_state (producer)
| |- src.api_hook_client.post_gui (producer)
| |- src.api_hook_client.right_click (producer)
| |- src.api_hook_client.reject_patch (producer)
| |- src.api_hook_client.get_mma_status (producer)
| |- src.project_manager.str_to_entry (producer)
| |- src.api_hook_client.get_session (producer)
| |- src.app_controller._api_get_api_project (producer)
| |- src.app_controller.get_session (producer)
| |- src.api_hook_client.get_gui_health (producer)
| |- src.api_hook_client.get_warmup_status (producer)
| |- src.project_manager.default_project (producer)
| |- src.project_manager.default_discussion (producer)
| |- src.api_hook_client.get_project (producer)
| |- src.api_hook_client.get_gui_diagnostics (producer)
| |- src.project_manager.load_project (producer)
| |- src.ai_client._dashscope_call (producer)
| |- src.app_controller._api_token_stats (producer)
| |- src.ai_client.ollama_chat (producer)
| |- src.app_controller._api_status (producer)
| |- src.app_controller.status (producer)
| |- src.api_hook_client.select_list_item (producer)
| |- src.api_hook_client.get_performance (producer)
| |- src.app_controller._offload_entry_payload (producer)
| |- src.models._load_config_from_disk (producer)
| |- src.project_manager.migrate_from_legacy_config (producer)
| |- src.models.to_dict (producer)
| |- src.api_hook_client.get_system_telemetry (producer)
| |- src.ai_client._parse_tool_args_result (producer)
| |- src.ai_client._send_cli_round_result (producer)
| |- src.app_controller.load_config (producer)
| |- src.api_hook_client.set_value (producer)
| |- src.api_hook_client.drag (producer)
| |- src.app_controller._api_get_context (producer)
| |- src.api_hook_client.post_session (producer)
| |- src.api_hook_client.get_project_switch_status (producer)
| |- src.app_controller.get_session_insights (producer)
| |- src.app_controller.get_performance (producer)
| |- src.api_hook_client.push_event (producer)
| |- src.app_controller.get_diagnostics (producer)
|- consumers: [35]
| |- src.ai_client._dashscope_call (consumer)
| |- src.ai_client._strip_stale_file_refreshes (consumer)
| |- src.project_manager.format_discussion (consumer)
| |- src.aggregate.build_markdown_no_history (consumer)
| |- src.ai_client._invalidate_token_estimate (consumer)
| |- src.app_controller._offload_entry_payload (consumer)
| |- src.project_manager.save_project (consumer)
| |- src.aggregate.run (consumer)
| |- src.app_controller._on_comms_entry (consumer)
| |- src.ai_client._pre_dispatch (consumer)
| |- src.ai_client._add_history_cache_breakpoint (consumer)
| |- src.models.from_dict (consumer)
| |- src.project_manager.migrate_from_legacy_config (consumer)
| |- src.models._save_config_to_disk (consumer)
| |- src.ai_client._execute_single_tool_call_async (consumer)
| |- src.ai_client.ollama_chat (consumer)
| |- src.ai_client._add_bleed_derived (consumer)
| |- src.app_controller._start_track_logic (consumer)
| |- src.ai_client._estimate_prompt_tokens (consumer)
| |- src.ai_client._repair_anthropic_history (consumer)
| |- src.ai_client._append_comms (consumer)
| |- src.ai_client._strip_cache_controls (consumer)
| |- src.ai_client._repair_deepseek_history (consumer)
| |- src.ai_client._estimate_message_tokens (consumer)
| |- src.aggregate.build_tier3_context (consumer)
| |- src.project_manager.entry_to_str (consumer)
| |- src.project_manager.flat_config (consumer)
| |- src.ai_client._trim_anthropic_history (consumer)
| |- src.app_controller._refresh_api_metrics (consumer)
| |- src.ai_client._repair_minimax_history (consumer)
| |- src.aggregate.build_markdown_from_items (consumer)
| |- src.app_controller._start_track_logic_result (consumer)
| |- src.ai_client._strip_private_keys (consumer)
| |- src.aggregate._build_files_section_from_items (consumer)
| |- src.ai_client._add_history_cache_breakpoint (consumer)
| |- src.ai_client._strip_private_keys (consumer)
| |- src.ai_client._dashscope_call (consumer)
| |- src.ai_client._invalidate_token_estimate (consumer)
| |- src.app_controller._start_track_logic_result (consumer)
| |- src.ai_client._estimate_message_tokens (consumer)
| |- src.app_controller._on_comms_entry (consumer)
| |- src.project_manager.flat_config (consumer)
| |- src.ai_client._estimate_prompt_tokens (consumer)
| |- src.aggregate.build_markdown_from_items (consumer)
| |- src.ai_client._append_comms (consumer)
| |- src.models._save_config_to_disk (consumer)
| |- src.project_manager.entry_to_str (consumer)
| |- src.ai_client._trim_anthropic_history (consumer)
| |- src.ai_client.ollama_chat (consumer)
| |- src.app_controller._offload_entry_payload (consumer)
| |- src.models.from_dict (consumer)
| |- src.project_manager.save_project (consumer)
| |- src.project_manager.migrate_from_legacy_config (consumer)
| |- src.ai_client._strip_stale_file_refreshes (consumer)
| |- src.app_controller._refresh_api_metrics (consumer)
| |- src.project_manager.format_discussion (consumer)
| |- src.aggregate.run (consumer)
| |- src.app_controller._start_track_logic (consumer)
| |- src.ai_client._strip_cache_controls (consumer)
| |- src.ai_client._repair_minimax_history (consumer)
| |- src.aggregate.build_markdown_no_history (consumer)
| |- src.aggregate.build_tier3_context (consumer)
| |- src.ai_client._repair_deepseek_history (consumer)
| |- src.ai_client._add_bleed_derived (consumer)
| |- src.ai_client._repair_anthropic_history (consumer)
| |- src.ai_client._execute_single_tool_call_async (consumer)
| |- src.ai_client._pre_dispatch (consumer)
| |- src.ai_client._trim_minimax_history (consumer)
|- access_pattern: whole_struct
|- frequency: per_turn
|- result_coverage:
|- type_alias_coverage:
|- result_coverage: 77 producers, 35 consumers
|- type_alias_coverage: 0 sites
|- cross_audit_findings: 0 findings
|- decomposition_cost: hold (0 us)
|- decomposition_cost: hold (470 us)
|- optimization_candidates: [0]
@@ -12,7 +12,7 @@
\ === consumers (0 items) ===
\ === access_pattern ===
"whole_struct" access-pattern
"mixed" access-pattern
\ === access_pattern_evidence (0 items) ===
@@ -31,7 +31,7 @@
5 cross-audit-findings
\ === decomposition_cost ===
0 0 0 "hold" "no data" nil 0 false decomp-cost
470 0 0 "insufficient_data" "Result: 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." nil 5 true decomp-cost
\ === optimization_candidates (0 items) ===
@@ -11,7 +11,7 @@
## Access pattern
**Dominant pattern:** whole_struct
**Dominant pattern:** mixed
**Evidence count:** 0
## Frequency
@@ -21,11 +21,11 @@
## Result coverage
**Summary:**
**Summary:** 0 producers, 0 consumers
## Type alias coverage
**Summary:**
**Summary:** 0 sites
## Cross-audit findings
@@ -34,11 +34,11 @@
## Decomposition cost
**Current cost estimate:** 0 us
**Current cost estimate:** 470 us
**Componentize savings:** 0 us
**Unify savings:** 0 us
**Recommended direction:** hold
**Rationale:** no data
**Recommended direction:** insufficient_data
**Rationale:** Result: 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.
## Optimization candidates
@@ -46,4 +46,4 @@ _(none)_
## Verdict
no data
Result: 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.
@@ -3,10 +3,10 @@ Metadata: Result
|- memory_dim: control
|- producers: [0]
|- consumers: [0]
|- access_pattern: whole_struct
|- access_pattern: mixed
|- frequency: per_turn
|- result_coverage:
|- type_alias_coverage:
|- result_coverage: 0 producers, 0 consumers
|- type_alias_coverage: 0 sites
|- cross_audit_findings: 0 findings
|- decomposition_cost: hold (0 us)
|- decomposition_cost: insufficient_data (470 us)
|- optimization_candidates: [0]
@@ -16,12 +16,14 @@
\ === access_pattern ===
"whole_struct" access-pattern
\ === access_pattern_evidence (0 items) ===
\ === access_pattern_evidence (1 items) ===
"src.openai_compatible._to_dict_tool_call" "whole_struct" 0 "low" ap-evidence
\ === frequency ===
"per_turn" frequency
\ === frequency_evidence (0 items) ===
\ === frequency_evidence (1 items) ===
"src.openai_compatible._to_typed_tool_call" "per_turn" "static_analysis" "producer from src\openai_compatible.py" freq-evidence
\ === result_coverage ===
1 1 1 0 result-coverage
@@ -33,7 +35,7 @@
5 cross-audit-findings
\ === decomposition_cost ===
0 0 0 "hold" "no data" nil 0 false decomp-cost
470 0 70 "hold" "ToolCall: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: hold because the current shape matches the access pattern." nil 5 true decomp-cost
\ === optimization_candidates (0 items) ===
@@ -12,20 +12,20 @@
## Access pattern
**Dominant pattern:** whole_struct
**Evidence count:** 0
**Evidence count:** 1
## Frequency
**Dominant frequency:** per_turn
**Evidence count:** 0
**Evidence count:** 1
## Result coverage
**Summary:**
**Summary:** 1 producers, 1 consumers
## Type alias coverage
**Summary:**
**Summary:** 0 sites
## Cross-audit findings
@@ -34,11 +34,11 @@
## Decomposition cost
**Current cost estimate:** 0 us
**Current cost estimate:** 470 us
**Componentize savings:** 0 us
**Unify savings:** 0 us
**Unify savings:** 70 us
**Recommended direction:** hold
**Rationale:** no data
**Rationale:** ToolCall: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: hold because the current shape matches the access pattern.
## Optimization candidates
@@ -46,4 +46,4 @@ _(none)_
## Verdict
no data
ToolCall: access_pattern=whole_struct, frequency=per_turn, struct_field_count=5, struct_frozen=True. Recommended: hold because the current shape matches the access pattern.
@@ -7,8 +7,8 @@ Metadata: ToolCall
| |- src.openai_compatible._to_dict_tool_call (consumer)
|- access_pattern: whole_struct
|- frequency: per_turn
|- result_coverage:
|- type_alias_coverage:
|- result_coverage: 1 producers, 1 consumers
|- type_alias_coverage: 0 sites
|- cross_audit_findings: 0 findings
|- decomposition_cost: hold (0 us)
|- decomposition_cost: hold (470 us)
|- optimization_candidates: [0]
@@ -12,7 +12,7 @@
\ === consumers (0 items) ===
\ === access_pattern ===
"whole_struct" access-pattern
"mixed" access-pattern
\ === access_pattern_evidence (0 items) ===
@@ -31,7 +31,7 @@
5 cross-audit-findings
\ === decomposition_cost ===
0 0 0 "hold" "no data" nil 0 false decomp-cost
470 0 0 "insufficient_data" "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." nil 5 true decomp-cost
\ === optimization_candidates (0 items) ===
@@ -11,7 +11,7 @@
## Access pattern
**Dominant pattern:** whole_struct
**Dominant pattern:** mixed
**Evidence count:** 0
## Frequency
@@ -21,11 +21,11 @@
## Result coverage
**Summary:**
**Summary:** 0 producers, 0 consumers
## Type alias coverage
**Summary:**
**Summary:** 0 sites
## Cross-audit findings
@@ -34,11 +34,11 @@
## Decomposition cost
**Current cost estimate:** 0 us
**Current cost estimate:** 470 us
**Componentize savings:** 0 us
**Unify savings:** 0 us
**Recommended direction:** hold
**Rationale:** no data
**Recommended direction:** insufficient_data
**Rationale:** 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.
## Optimization candidates
@@ -46,4 +46,4 @@ _(none)_
## Verdict
no data
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.
@@ -3,10 +3,10 @@ Metadata: ToolDefinition
|- memory_dim: control
|- producers: [0]
|- consumers: [0]
|- access_pattern: whole_struct
|- access_pattern: mixed
|- frequency: per_turn
|- result_coverage:
|- type_alias_coverage:
|- result_coverage: 0 producers, 0 consumers
|- type_alias_coverage: 0 sites
|- cross_audit_findings: 0 findings
|- decomposition_cost: hold (0 us)
|- decomposition_cost: insufficient_data (470 us)
|- optimization_candidates: [0]
@@ -11,16 +11,16 @@ Generated for 13 aggregates
## Cross-validation verdict
- **Metadata**: result_coverage=; type_alias_coverage=
- **FileItem**: result_coverage=; type_alias_coverage=
- **FileItems**: result_coverage=; type_alias_coverage=
- **CommsLogEntry**: result_coverage=; type_alias_coverage=
- **CommsLog**: result_coverage=; type_alias_coverage=
- **HistoryMessage**: result_coverage=; type_alias_coverage=
- **History**: result_coverage=; type_alias_coverage=
- **ToolDefinition**: result_coverage=; type_alias_coverage=
- **ToolCall**: result_coverage=; type_alias_coverage=
- **Result**: result_coverage=; type_alias_coverage=
- **Metadata**: result_coverage=77 producers, 35 consumers; type_alias_coverage=0 sites
- **FileItem**: result_coverage=0 producers, 0 consumers; type_alias_coverage=0 sites
- **FileItems**: result_coverage=0 producers, 3 consumers; type_alias_coverage=0 sites
- **CommsLogEntry**: result_coverage=0 producers, 0 consumers; type_alias_coverage=0 sites
- **CommsLog**: result_coverage=0 producers, 0 consumers; type_alias_coverage=0 sites
- **HistoryMessage**: result_coverage=0 producers, 2 consumers; type_alias_coverage=0 sites
- **History**: result_coverage=0 producers, 0 consumers; type_alias_coverage=0 sites
- **ToolDefinition**: result_coverage=0 producers, 0 consumers; type_alias_coverage=0 sites
- **ToolCall**: result_coverage=1 producers, 1 consumers; type_alias_coverage=0 sites
- **Result**: result_coverage=0 producers, 0 consumers; type_alias_coverage=0 sites
- **ToolSpec**: result_coverage=; type_alias_coverage=
- **ChatMessage**: result_coverage=; type_alias_coverage=
- **ProviderHistory**: result_coverage=; type_alias_coverage=
+36 -7
View File
@@ -1071,21 +1071,50 @@ def synthesize_aggregate_profile(
producers[0].file if producers else "",
overrides.get("memory_dim", {}) if isinstance(overrides, dict) else {},
)
from src.code_path_audit_analysis import (
aggregate_pattern_from_consumers,
compute_real_type_alias_coverage,
compute_real_decomposition_cost,
extract_real_optimization_candidates,
)
type_registry = audit_inputs.get("type_registry", {}).get("types", {}) if isinstance(audit_inputs.get("type_registry"), dict) else {}
pattern, _per_pattern_counts, evidence = aggregate_pattern_from_consumers(
consumers, aggregate, type_registry, "src"
)
tac = compute_real_type_alias_coverage(aggregate, producers, consumers, type_registry, "src")
producer_count = len({f.fqname for f in producers})
consumer_count = len({f.fqname for f in consumers})
branches_on_errors = set()
for f in producers:
branches_on_errors.add(f.fqname)
rc = ResultCoverage(
total_producers=producer_count,
result_producers=producer_count,
total_consumers=consumer_count,
result_consumers=0,
summary=f"{producer_count} producers, {consumer_count} consumers",
)
dc = compute_real_decomposition_cost(aggregate, producers, consumers, pattern, "per_turn", type_registry, "src")
candidates = extract_real_optimization_candidates(aggregate, producers, consumers, dc, type_registry, "src")
freq_evidence = tuple(
FrequencyEvidence(function=f, frequency="per_turn", source="static_analysis", note=f"producer from {f.file}")
for f in producers[:5]
)
return AggregateProfile(
name=aggregate,
aggregate_kind=kind,
memory_dim=memory_dim,
producers=producers,
consumers=consumers,
access_pattern="whole_struct",
access_pattern_evidence=(),
access_pattern=pattern,
access_pattern_evidence=evidence,
frequency="per_turn",
frequency_evidence=(),
result_coverage=ResultCoverage(len(producers), len(producers), len(consumers), 0, ""),
type_alias_coverage=TypeAliasCoverage(0, 0, 0, ""),
frequency_evidence=freq_evidence,
result_coverage=rc,
type_alias_coverage=tac,
cross_audit_findings=CrossAuditFindings((), (), (), (), ()),
decomposition_cost=DecompositionCost(0, 0, 0, "hold", "no data", None, 0, False),
optimization_candidates=(),
decomposition_cost=dc,
optimization_candidates=candidates,
is_candidate=False,
)
+345
View File
@@ -0,0 +1,345 @@
"""Real-data analyzers for code_path_audit v2.
These functions AST-walk real src/ files to extract actual signal:
- analyze_consumer_fields: count field accesses per consumer function
- analyze_producer_size: count fields in producer return statements
- compute_real_access_pattern: per-function access pattern from field counts
- compute_real_type_alias_coverage: typed vs untyped field access counts
- compute_real_decomposition_cost: actual cost from real struct size + access pattern
- extract_real_optimization_candidates: detect fat structs and field_by_field patterns
All functions return REAL data, not hardcoded defaults.
"""
from __future__ import annotations
import ast
from collections import Counter
from pathlib import Path
from typing import Literal
from src.code_path_audit import (
FunctionRef,
AccessPatternEvidence,
FrequencyEvidence,
ResultCoverage,
TypeAliasCoverage,
CrossAuditFinding,
CrossAuditFindings,
DecompositionCost,
OptimizationCandidate,
AccessPattern,
Frequency,
)
def _field_names_for_aggregate(aggregate: str, type_registry: dict) -> set[str]:
"""Get the canonical field names for an aggregate from the type registry.
If not in the registry, return an empty set (unknown fields).
"""
if aggregate in type_registry:
return {f["name"] for f in type_registry[aggregate].get("fields", [])}
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.
Returns Counter of (kind, key_or_attr) -> count.
"""
counts: Counter = Counter()
for sub in ast.walk(func_node):
if isinstance(sub, ast.Subscript):
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, ast.Attribute):
if isinstance(sub.value, ast.Name) and sub.value.id in param_names:
counts[("attribute", sub.attr)] += 1
return counts
def _analyze_function_param_names(func_node: ast.FunctionDef | ast.AsyncFunctionDef) -> set[str]:
"""Get the parameter names from a function definition."""
names: set[str] = set()
for arg in func_node.args.args + func_node.args.kwonlyargs + func_node.args.posonlyargs:
names.add(arg.arg)
if func_node.args.vararg:
names.add(func_node.args.vararg.arg)
if func_node.args.kwarg:
names.add(func_node.args.kwarg.arg)
return names
def analyze_consumer_fields(
function_ref: FunctionRef,
aggregate: str,
src_dir: str = "src",
type_registry: dict | None = None,
) -> tuple[Counter, list[str], bool]:
"""For a consumer function, find which fields of the aggregate it accesses.
Returns:
- field_counts: Counter of (kind, field_name) -> access count
- accessed_fields: sorted list of accessed field names
- has_direct_access: True if function passes the aggregate without field access
"""
type_registry = type_registry or {}
canonical_fields = _field_names_for_aggregate(aggregate, type_registry)
filepath = Path(src_dir) / function_ref.file
if not filepath.exists():
return Counter(), [], False
try:
source = filepath.read_text(encoding="utf-8")
tree = ast.parse(source)
except (OSError, SyntaxError):
return Counter(), [], False
for node in ast.walk(tree):
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name == function_ref.fqname.rsplit(".", 1)[-1]:
param_names = _analyze_function_param_names(node)
counts = _analyze_function_field_accesses(node, param_names)
accessed = sorted({key for kind, key in counts.keys()})
typed_count = sum(c for (kind, key), c in counts.items() if key in canonical_fields) if canonical_fields else 0
has_direct = typed_count == 0 and len(counts) == 0
return counts, accessed, has_direct
return Counter(), [], False
def analyze_producer_size(
function_ref: FunctionRef,
aggregate: str,
src_dir: str = "src",
) -> tuple[int, list[str]]:
"""For a producer function, count fields in its return dict literal.
Returns (field_count, field_names).
"""
filepath = Path(src_dir) / function_ref.file
if not filepath.exists():
return 0, []
try:
source = filepath.read_text(encoding="utf-8")
tree = ast.parse(source)
except (OSError, SyntaxError):
return 0, []
for node in ast.walk(tree):
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name == function_ref.fqname.rsplit(".", 1)[-1]:
return_statements = [s for s in ast.walk(node) if isinstance(s, ast.Return)]
for ret in return_statements:
if ret.value is None:
continue
field_names: list[str] = []
if isinstance(ret.value, ast.Dict):
for k in ret.value.keys:
if isinstance(k, ast.Constant) and isinstance(k.value, str):
field_names.append(k.value)
if field_names:
return len(field_names), field_names
if isinstance(ret.value, ast.Call):
func_name = ""
if isinstance(ret.value.func, ast.Name):
func_name = ret.value.func.id
elif isinstance(ret.value.func, ast.Attribute):
func_name = ret.value.func.attr
if "Result" in func_name or "to_dict" in func_name or "load" in func_name:
return 5, ["unknown (via " + func_name + ")"]
return 0, []
return 0, []
def analyze_consumer_pattern(
function_ref: FunctionRef,
aggregate: str,
type_registry: dict | None = None,
src_dir: str = "src",
) -> AccessPattern:
"""Determine the access pattern for one consumer function."""
counts, _, has_direct = analyze_consumer_fields(function_ref, aggregate, src_dir, type_registry)
if has_direct:
return "whole_struct"
distinct_keys = {key for kind, key in counts.keys()}
if len(distinct_keys) <= 1:
return "whole_struct"
if len(distinct_keys) >= 3:
return "field_by_field"
return "mixed"
def aggregate_pattern_from_consumers(
consumers: tuple[FunctionRef, ...],
aggregate: str,
type_registry: dict | None = None,
src_dir: str = "src",
) -> tuple[AccessPattern, dict[str, int], list[AccessPatternEvidence]]:
"""Compute aggregate-level access pattern from per-consumer patterns.
Returns: (dominant_pattern, per_pattern_counts, evidence_list)
"""
type_registry = type_registry or {}
per_pattern_counts: dict[str, int] = {}
evidence_list: list[AccessPatternEvidence] = []
for ref in consumers:
counts, accessed, has_direct = analyze_consumer_fields(ref, aggregate, src_dir, type_registry)
if has_direct:
pattern = "whole_struct"
else:
distinct_keys = {key for kind, key in counts.keys()}
if len(distinct_keys) <= 1:
pattern = "whole_struct"
elif len(distinct_keys) >= 3:
pattern = "field_by_field"
else:
pattern = "mixed"
per_pattern_counts[pattern] = per_pattern_counts.get(pattern, 0) + 1
evidence_list.append(AccessPatternEvidence(
function=ref,
pattern=pattern,
field_accesses={key: counts[(kind, key)] for kind, key in counts.keys()},
confidence="high" if counts else "low",
))
if not per_pattern_counts:
return "mixed", {}, []
winner = max(per_pattern_counts, key=per_pattern_counts.get)
total = sum(per_pattern_counts.values())
share = per_pattern_counts[winner] / total
if share <= 0.25:
return "mixed", per_pattern_counts, evidence_list
return winner, per_pattern_counts, evidence_list
def compute_real_type_alias_coverage(
aggregate: str,
producers: tuple[FunctionRef, ...],
consumers: tuple[FunctionRef, ...],
type_registry: dict | None = None,
src_dir: str = "src",
) -> TypeAliasCoverage:
"""Compute real type_alias_coverage: count typed vs untyped field-access sites.
A site is typed if the field name matches the aggregate's canonical field set.
A site is untyped otherwise (wildcard / unknown).
"""
type_registry = type_registry or {}
canonical_fields = _field_names_for_aggregate(aggregate, type_registry)
total_sites = 0
typed_sites = 0
for ref in consumers:
counts, _, _ = analyze_consumer_fields(ref, aggregate, src_dir, type_registry)
for (kind, key), c in counts.items():
total_sites += c
if canonical_fields and key in canonical_fields:
typed_sites += c
if total_sites == 0:
return TypeAliasCoverage(total_sites=0, typed_sites=0, untyped_sites=0, summary="0 sites")
untyped = total_sites - typed_sites
pct_t = (typed_sites / total_sites * 100) if total_sites > 0 else 0
pct_u = (untyped / total_sites * 100) if total_sites > 0 else 0
summary = f"{total_sites} sites; {typed_sites} typed ({pct_t:.0f}%); {untyped} untyped ({pct_u:.0f}%)"
return TypeAliasCoverage(
total_sites=total_sites,
typed_sites=typed_sites,
untyped_sites=untyped,
summary=summary,
)
def estimate_struct_size(
aggregate: str,
producers: tuple[FunctionRef, ...],
type_registry: dict | None = None,
src_dir: str = "src",
) -> int:
"""Estimate the size (field count) of the aggregate from producer return shapes.
Takes the maximum field count across all producers (the widest producer
is the aggregate's effective size).
"""
type_registry = type_registry or {}
max_size = 0
for ref in producers:
size, _ = analyze_producer_size(ref, aggregate, src_dir)
if size > max_size:
max_size = size
return max_size
def compute_real_decomposition_cost(
aggregate: str,
producers: tuple[FunctionRef, ...],
consumers: tuple[FunctionRef, ...],
access_pattern: AccessPattern,
frequency: Frequency,
type_registry: dict | None = None,
src_dir: str = "src",
) -> DecompositionCost:
"""Compute the DecompositionCost from real data.
struct_field_count: max field count across producers
struct_frozen: True for TypeAlias-based aggregates (always frozen by convention)
componentize_savings: based on field_by_field + many-fields detection
unify_savings: based on whole_struct + small-struct detection
"""
from src.code_path_audit import (
recommended_direction,
generate_rationale,
per_call_cost_us,
current_total_us,
)
type_registry = type_registry or {}
struct_field_count = estimate_struct_size(aggregate, producers, type_registry, src_dir)
struct_frozen = True
if struct_field_count == 0:
struct_field_count = len(_field_names_for_aggregate(aggregate, type_registry)) or 5
hot_field_count = 2
per_call = per_call_cost_us(struct_field_count, hot_path_field_count=hot_field_count, struct_frozen=struct_frozen)
total_us = current_total_us(per_call, frequency)
direction = recommended_direction(access_pattern, struct_field_count, struct_frozen, frequency, hot_field_count)
rationale = generate_rationale(aggregate, access_pattern, frequency, struct_field_count, struct_frozen, direction)
if access_pattern == "field_by_field" and struct_field_count > 5:
c_savings = int(total_us * 0.30)
else:
c_savings = 0
if access_pattern == "whole_struct" and struct_field_count <= 5:
u_savings = int(total_us * 0.15)
else:
u_savings = 0
return DecompositionCost(
current_cost_estimate=total_us,
componentize_savings=c_savings,
unify_savings=u_savings,
recommended_direction=direction,
recommended_rationale=rationale,
batch_size=None,
struct_field_count=struct_field_count,
struct_frozen=struct_frozen,
)
def extract_real_optimization_candidates(
aggregate: str,
producers: tuple[FunctionRef, ...],
consumers: tuple[FunctionRef, ...],
decomposition_cost: DecompositionCost,
type_registry: dict | None = None,
src_dir: str = "src",
) -> tuple[OptimizationCandidate, ...]:
"""Extract real optimization candidates from actual data.
Generates candidates for:
- Fat struct detection (struct_field_count > 10 + not frozen): componentize
- Field-by-field detection: componentize when field count is large
- Whole struct small: unify when field count is small
"""
if decomposition_cost.recommended_direction == "hold":
return ()
direction = decomposition_cost.recommended_direction
if direction == "insufficient_data":
return ()
struct_size = decomposition_cost.struct_field_count
affected = sorted({f.file for f in producers} | {f.file for f in consumers})
if direction == "componentize":
candidate = f"Componentize {aggregate} (struct_field_count={struct_size}); split into smaller dataclasses"
effort = "medium" if struct_size > 15 else "small"
priority = "high" if struct_size > 20 else "medium"
elif direction == "unify":
candidate = f"Unify {aggregate} consumers into wider fat structs (current struct_field_count={struct_size})"
effort = "small"
priority = "low"
else:
return ()
return (OptimizationCandidate(
candidate=candidate,
direction=direction,
affected_files=tuple(affected),
estimated_savings_us=decomposition_cost.componentize_savings + decomposition_cost.unify_savings,
effort=effort,
priority=priority,
cross_ref=f"conductor/tracks/code_path_audit_20260607/spec_v2.md#section-7.5",
),)