Per the Tier 2 convention, throwaway scripts are committed as archival
artifacts so future agents can understand what was tried during the track.
7 scripts:
- verify_test_format.py: AST + indentation check for new test file
- _check_line_endings.py: CRLF vs LF diagnostic
- _find_tracks_line.py: locate line 27 entry in tracks.md
- _verify_line_66.py: verify new line 66 content
- _update_tracks_md.py: programmatic update of line 27
- _update_state_toml.py: programmatic update of state.toml
- _fix_state_toml_crlf.py: restore CRLF after edits
Updates:
- conductor/tracks.md: entry #27 marked SHIPPED 2026-06-21; BLOCKER
removed for code_path_audit_20260607 (broadcast() TypeError fixed)
- state.toml: status=completed, current_phase=6, all 4 phases marked
completed with checkpoint SHAs, all verification booleans true
NOT shipped (per user instruction):
- The git mv to conductor/tracks/archive/ is the USER's responsibility
- Track directory stays at conductor/tracks/phase2_4_5_call_site_completion_20260621/
- tier2/any_type_componentization_20260621 branch NOT merged (reconnaissance framing)
Tier 2 produced this analysis during phase2_4_5_call_site_completion_20260621
Phase 6e. Supersedes Tier 1's draft at PHASE3_HYPOTHETICAL_PROMOTION.md (kept
as the hypothesis doc; this is the refined version with in-context data
from Phase 6b/6d work in src/ai_client.py).
Key findings:
- Measured 104 history references (Tier 1 estimated 112; 7% under)
- Anthropic dominates per-turn cost (~35-65µs vs Tier 1's 8-15µs estimate)
- Grok/qwen/llama are LOWER than Tier 1 estimated (~400ns vs 2-8µs)
- Total per-session: ~0.5-1.0ms (Tier 1 estimated 1.1-2.4ms)
- Discovered 3 hidden cross-references Tier 1 missed (_strip_private_keys,
_extract_minimax_reasoning, _send_llama_native)
- Recommendations for the future Phase 3 track: anthropic first; use
'with h.lock: msg_list = h.messages' for read snapshots; use
'with h.lock: h.messages = [filtered]' for in-place mutations
Covers all 6 senders (anthropic, deepseek, minimax, grok, qwen, llama)
with per-site cost estimates + hidden cross-references + recommendations.
The audit (code_path_audit_20260607) quantifies these estimates after merge.
Completes the deferred t2_6 task from any_type_componentization_20260621 Phase 2.
The 3 OpenAI-compatible senders now construct OpenAICompatibleRequest with
messages=[ChatMessage(role=, content=)] instead of list[dict] literals.
The _<provider>_history global lists are still dicts (Phase 3 deferred to
a separate track); the migration converts each dict to ChatMessage at
the request-build boundary via list comprehension. The backward-compat
shim in openai_compatible.py:86 (m.to_dict() if hasattr(m, 'to_dict')
else m) handles both ChatMessage and dict transparently.
Verified: 20/20 provider tests pass; tier-1-unit (5 pre-existing
sandbox-pollution failures unchanged); no new regressions.
Phase 5 of any_type_componentization_20260621 changed
WebSocketServer.broadcast(channel, payload) -> broadcast(message: WebSocketMessage)
but did not update internal callers. This produced worker[queue_fallback]
TypeError spam on the GUI thread.
Fixed 2 sites:
- src/app_controller.py:1849 _process_pending_gui_tasks (telemetry broadcast)
- src/events.py:115 AsyncEventQueue.put (events broadcast)
gui_2.py has no internal broadcast callers (grep verified).
Both callers now construct WebSocketMessage(channel=, payload=) at the call site.
test_websocket_broadcast_regression.py 4/4 pass (was 1/4 failing in red phase).
Phase 5 of any_type_componentization_20260621 changed
WebSocketServer.broadcast(channel, payload) -> broadcast(message: WebSocketMessage)
but did not update internal callers in src/app_controller.py + src/events.py.
This adds 4 tests that pin the contract:
- test_websocket_server_broadcast_signature: asserts (self, message) signature
- test_websocket_server_broadcast_rejects_legacy_2arg_call: asserts legacy raises TypeError
- test_websocket_server_broadcast_accepts_websocket_message_instance: smoke test
- test_internal_callers_use_websocket_message_signature: structural grep over src/
The 4th test currently FAILS (red phase), identifying 2 legacy sites:
- src/app_controller.py:1849: self.event_queue.websocket_server.broadcast('telemetry', metrics)
- src/events.py:115: self.websocket_server.broadcast('events', {...})
The structural assertion is reused by code_path_audit_20260607.
The follow-up track now includes Phase 6e: Tier 2 produces the authoritative
Phase 3 cost analysis as part of the follow-up work. Tier 2 is in
src/ai_client.py doing Phase 6b/6d anyway; they have full context to produce
the refined cost hypothesis that Tier 1's draft at PHASE3_HYPOTHETICAL_PROMOTION.md
could not (Tier 1 worked without the 6b/6d ground-truth context).
Tier 1's draft STAYS as the hypothesis doc. Tier 2's PHASE3_TIER2_ANALYSIS.md
is the refined version (per-sender cost summary + hidden call sites table
+ recommendations for the future Phase 3 track + cross-reference to Tier 1
explicit).
Phase 6e tasks (5 total, ~2 commits):
- t6e_1: Profile the 6 senders (codepath catalog + hidden cross-refs)
- t6e_2: Qualitative cost estimation per sender
- t6e_3: Identify hot iteration sites needing 'with h.lock:' pattern
- t6e_4: Author PHASE3_TIER2_ANALYSIS.md
- t6e_5: Phase 6e checkpoint commit + git note
Total estimated commits: 16 -> 18 (still within Tier 2 1-4 hour budget).
Files updated:
- conductor/tracks/phase2_4_5_call_site_completion_20260621/spec.md (+50 lines)
- conductor/tracks/phase2_4_5_call_site_completion_20260621/plan.md (+146 lines)
- conductor/tracks/phase2_4_5_call_site_completion_20260621/metadata.json (+13 lines)
- conductor/tracks/phase2_4_5_call_site_completion_20260621/state.toml (+9 lines)
- conductor/tracks.md (track 27 entry expanded with Phase 6e details)
Per FR8 in conductor/tracks/video_analysis_campaign_20260621/spec.md, mp4 files are too large for git and VTT auto-sub files are regenerable from transcript.json.
Note: existing tracked files in entropy_epiplexity (commit 5c5f347c) are still in history. The gitignore prevents FUTURE commits from adding them. To remove from history requires filter-repo/filter-branch rewrite (out of scope for this commit).
Categorizes the 12 test failures the user observed when running
scripts/run_tests_batched.py after this track:
- 10 failures (mine): Phase 2 NormalizedResponse API migration
incomplete (state.toml t2_6 deferred task); FIXED in commit 30c8b263
- 3 failures (sandbox): test_audit_tier2_leaks.py flags sandbox
files (mcp_paths.toml, opencode.json) as modified; NOT my fault
- 1 failure (pre-existing): test_gui2_custom_callback_hook_works;
live_gui test not touched by this track
Hidden 12th failure:
- worker[queue_fallback] error: WebSocketServer.broadcast() takes 2
positional arguments but 3 were given (appeared 6+ times during
tier-2-mock-app-core but tests still passed; error logged on
GUI thread from app_controller._run_pending_tasks_once_result).
Phase 5 refactored broadcast(channel, payload) to
broadcast(WebSocketMessage); I updated test_websocket_server.py
but missed app_controller.py and events.py callers.
Sections:
1. Executive summary (3 categories of failure)
2. Per-failure categorization (10 + 3 + 1)
3. Hidden 12th failure: WebSocket broadcast callers in app_controller
4. Phase 2 API migration status (8 sites; 5 done, 3 unverified)
5. Recommendations for follow-up track (~5 call sites + ~41 Phase 3)
6. Code-path audit input (5 micro-benchmarks to add)
Follow-up track scope: ~15-20 commits, well-scoped. Should run BEFORE
code_path_audit_20260607 because the worker[queue_fallback] TypeError
spam will confuse the audit's runtime instrumentation.
Auto-generated by scripts/generate_type_registry.py after the Phase
2 + 4 + 5 commits. These were untracked in the working tree because
commit 4a774eb3 was made before Phase 5 (api_hooks) committed.
NEW files (5):
- docs/type_registry/src_mcp_tool_specs.md (Phase 1; ToolSpec + ToolParameter)
- docs/type_registry/src_openai_schemas.md (Phase 2; ToolCall + ChatMessage + UsageStats + NormalizedResponse + OpenAICompatibleRequest)
- docs/type_registry/src_provider_state.md (Phase 3 partial; ProviderHistory + _PROVIDER_HISTORIES)
- docs/type_registry/src_api_hooks.md (Phase 5; WebSocketMessage)
- docs/type_registry/src_log_registry.md (Phase 4; Session + SessionMetadata)
Verified:
uv run python scripts/generate_type_registry.py --check
Registry in sync (22 files checked)
These 5 .md files were generated after the Phase 5 commit (e9fa69dd)
and the Phase 4 commit (fef6c20e); they were left in the working tree
because commit 4a774eb3 (verify) was made after the Phase 2 registry
regen but before Phase 4/5 changes were fully committed.
Phase 2 deferred t2_6: update src/ai_client.py _send_grok + _send_minimax +
_send_llama + _send_gemini_cli (4 functions) to use the new
dataclass API after NormalizedResponse was refactored to
(text, tool_calls: tuple[ToolCall, ...], usage: UsageStats, raw_response).
These 4 callers were left with the old keyword args
(usage_input_tokens, usage_output_tokens, ...) which broke at
runtime: ai_client.send() raised
TypeError: NormalizedResponse.__init__() got an unexpected keyword
argument 'usage_input_tokens'.
FIXES:
- src/ai_client.py L2054: gemini_cli 'adapter unavailable' branch
- src/ai_client.py L2088: gemini_cli normal response branch
- Added: from src.openai_schemas import UsageStats (module level)
- Added backward-compat in src/openai_compatible.py:
messages_dicts = [m.to_dict() if hasattr(m, 'to_dict') else m for m in request.messages]
(accepts both ChatMessage dataclass and dict for backward compat
with existing tests that pass raw dicts)
TEST FIXES:
- tests/test_ai_client_tool_loop.py: _make_normalized_response helper
uses UsageStats instead of usage_*_tokens kwargs
- tests/test_ai_client_tool_loop_builder.py: same
- tests/test_ai_client_tool_loop_send_func.py: same
- tests/test_openai_compatible.py: NormalizedResponse(text=..., usage=UsageStats(...))
+ tool_calls[0].function.name (attribute access) instead of ['function']['name']
- tests/test_auto_whitelist.py: use update_session_metadata() instead of
dict subscript assignment (Session dataclass doesn't support item assignment)
VERIFIED:
uv run pytest tests/test_ai_client_*.py tests/test_openai_*.py \
tests/test_auto_whitelist.py --timeout=30
56 passed in 4.49s (19 previously failing tests now pass)
uv run python scripts/audit_weak_types.py --strict
STRICT OK: 115 weak sites <= baseline 115
uv run python scripts/audit_dataclass_coverage.py --strict
STRICT OK: 200 weak sites <= baseline 207
This commit closes the t2_6 deferred task. The 41-site Phase 3 call-site
migration remains deferred (separate provider_state_migration track).
While running any_type_componentization_20260621, the Tier 2 agent
performed a partial code-path audit + code normalization pass that
wasn't in the original scope. This handoff document frames:
1. What was done (48 of 89 fat-struct sites promoted; 41 deferred)
2. The 5-pattern Any-type taxonomy (Patterns 3/4/5 correctly preserved;
Patterns 1/2 promoted to dataclass/registry)
3. Recommended adjustments for code_path_audit_20260607:
- Instrument the 89 fat-struct sites with hot/cold/init path tags
- Compare pre/post refactor cost for the 48 promoted sites
- Rank the 41 deferred Phase 3 sites by hot-path frequency
- Report per-call cost deltas in microseconds
4. What was NOT done (no runtime profiling; no pre/post benchmarks)
5. Decision points for Tier 1 (merge / reject / cherry-pick)
6. The bigger vision: AI/LLM frontend debugger (rad-debugger analog)
requires typed ProviderHistory, ToolSpec, Session, WebSocketMessage
to step through the agent loop without losing type fidelity
Recommendation: Don't merge this branch yet. Let code_path_audit_20260607
use it as a reconnaissance warm-up; drive the next refactor track from
the audit's per-action cost data.
The 4 newly-promoted dataclasses (mcp_tool_specs, openai_schemas,
log_registry.Session, api_hooks.WebSocketMessage) are the typed-state
foundation that the future debugger UI will read from. The 41 deferred
Phase 3 sites are the last gap: per-turn history manipulation in
src/ai_client.py needs typed state before the debugger can step
through the agent loop losslessly.
Length: 7 sections, 7 paragraphs of Tier 1 decision framing.
Location: docs/handoffs/HANDOFF_CODE_PATH_AUDIT_FROM_any_type_componentization.md
(new directory; complements docs/reports/ which is for reports vs
handoffs which are cross-track input artifacts).
youtube-transcript-api v1.2.4 returns XML parse error on empty response for ALL videos in this campaign. yt-dlp's --write-auto-subs reliably returns 1000s of segments per video. Switched to yt-dlp as the primary path.
Tests updated to mock _fetch_via_ytdlp instead of _fetch_raw_transcript. 8/8 tests passing.