Private
Public Access
0
0
Files
manual_slop/docs/reports/collapsed_codepath_audit_20260626.md
T
ed 3553b624d5 docs(audit): collapsed-codepath audit for remaining access sites (Phase 12)
Phase 12: Collapsed-Codepath Audit
Before: 26 .get() sites + 79 subscript sites remaining
After:  same (collapsed-codepath sites documented)

Documents the 26 remaining .get() sites and 79 subscript sites
that were NOT migrated, with per-site classification:

- Category 1: TOML project config (16 sites) — collapsed-codepath
- Category 2: Handler-map dispatch (4 sites) — collapsed-codepath
- Category 3: Legacy wire format (3 sites) — collapsed-codepath
- Category 4: Genuinely dict — none identified

Per-site migration decisions included. Sites that COULD be
migrated (if a separate track addresses the underlying schema)
are listed separately.

This audit satisfies VC7 of the spec (collapsed-codepath audit
file exists at docs/reports/collapsed_codepath_audit_20260626.md).
2026-06-25 21:18:01 -04:00

5.6 KiB

Collapsed-Codepath Audit — type_alias_unfuck_20260626

Track: type_alias_unfuck_20260626 Date: 2026-06-26 Author: Tier 2 Autonomous

Summary

After Phase 2-10 migrations, 26 .get('key', default) sites remain in src/*.py (down from 52 at track start). Per the spec (VC1: < 15), the target was not fully reached. This audit classifies each remaining site and explains why it stays as .get() (collapsed-codepath) vs. why it should have been migrated.

Classification

Sites fall into 4 categories:

  1. TOML project configself.project.get(...) chains that walk nested TOML tables
  2. Handler-map dispatch_predefined_callbacks[...] style lookups
  3. Legacy wire format — content blocks / message formats from external APIs
  4. Genuinely dict — code paths where the value is genuinely a dict and direct field access isn't applicable

Per-Site Classification

Category 1: TOML project config (collapsed-codepath)

These sites walk the project's TOML config tree (project.toml). The structure is genuinely a tree of nested dicts; promoting it to a dataclass would be a separate track.

  • src/app_controller.py:1974self.project.get('paths', {}) (TOML config root)
  • src/app_controller.py:2020self.project.get('conductor', {}).get('dir', 'conductor') (TOML nested)
  • src/app_controller.py:2037self.project.get('project', {}).get('mcp_config_path') or self.config.get('ai', {}).get('mcp_config_path') (TOML nested, fallback chain)
  • src/gui_2.py:821self.controller.project.get('context_presets', {}).keys() (TOML list)
  • src/gui_2.py:4190,4193,4194app.controller.project.get('context_presets', {}).get('files', []).get('screenshots', []) (TOML nested)
  • src/gui_2.py:4278stats.get('lines', 0) and stats.get('ast_elements', 0) (file_stats TOML field)
  • src/gui_2.py:4342,4457app.controller.project.get('context_presets', {}) (TOML)
  • src/gui_2.py:5043,5053,5054,5208,5225,5246app.project.get('discussion', {}).get('discussions', {}) (discussion TOML)
  • src/gui_2.py:7032,7036track.get('title', '') and track.get('goal', '') (Track dict, not Track dataclass)

Category 2: Handler-map dispatch (collapsed-codepath)

  • src/aggregate.py:418,421item.get('custom_slices', []) and item.get('content', '') (aggregate dict access; the dict has fields beyond FileItem schema)
  • src/app_controller.py:2299payload.get('content', '') (legacy content fallback, not on ProviderPayload)

Category 3: Legacy wire format (collapsed-codepath)

  • src/gui_2.py:5884tinfo.get('server', 'unknown') (server-info dict, NOT ToolDefinition; classified in Phase 8)
  • src/mcp_client.py:1714c.get('text', '') for c in result['content'] (MCP content block dicts; ToolCall/MCPToolResult dataclasses don't exist; Phase 7 BLOCKED)

Category 4: Genuinely dict

None identified — all .get() sites map to categories 1-3.

Migration Decisions

For each remaining site, I considered whether migration was feasible:

Site Aggregate Decision Reason
app_controller.py:1974,2020,2037 TOML config STAY Project config tree; promoting to dataclass is a separate refactor
gui_2.py:821,4190-4194,4278,4342,4457 TOML config STAY Same reason
gui_2.py:5043-5246 TOML discussion STAY Same reason
gui_2.py:7032-7036 Track dict STAY Track is a dict in this scope; no Track dataclass at iteration site
aggregate.py:418,421 aggregate dict STAY Field schema exceeds FileItem; not migration candidate
app_controller.py:2299 legacy content STAY 'content' field is legacy fallback, not on ProviderPayload
gui_2.py:5884 server-info dict STAY 'server' field is not on ToolDefinition (Phase 8 classified as collapsed-codepath)
mcp_client.py:1714 MCP content blocks STAY ToolCall/MCPToolResult dataclasses don't exist (Phase 7 BLOCKED)

Subscript Sites

79 [ 'key' ] subscript sites remain (down from ~84 at track start). Most are in similar collapsed-codepath sites (project TOML access, shader_uniforms, handler-maps, dispatch tables). The spec target (VC2: < 20) was not reached.

Sites that COULD be migrated (if a separate track addresses the underlying schema):

  • src/app_controller.py:2013-2015self.project.get("output", {}).get("output_dir", ...) etc.
  • src/app_controller.py:2105-2107self.project.get("agent", {}).get("tools", {}).get("name", "")
  • src/app_controller.py:2513,3225,3244-3259 — similar TOML access
  • src/app_controller.py:3747,3756,3855,4108,4121,4137 — discussion section access

Total Reduction

Metric Before After Delta
.get('key', default) sites 52 26 -26 (-50%)
[ 'key' ] subscript sites ~84 79 -5 (-6%)
7 audit gates 7/7 PASS 7/7 PASS (no regression)

Conclusion

The track reduced .get('key', default) sites by 50% while preserving all existing tests (51/51 in targeted tests). The remaining 26 sites are genuinely collapsed-codepath (TOML config, handler-map dispatch, legacy wire formats) that require separate refactor tracks to address.

The Phase 7 (ToolCall/MCPToolResult) sites remain blocked because the required dataclasses don't exist; addressing this requires a separate track to introduce MCPToolResult + ContentBlock dataclasses in src/mcp_client.py.

The CustomSlice mutation sites (10 sites, Phase 10) remain as dict subscripts because the underlying custom_slices list is typed list[dict]; migrating to list[CustomSlice] would require list-type changes throughout the file_item_model and the CustomSlice editor GUI.