f0a6b32704
TIER-2 READ AGENTS.md, conductor/workflow.md, conductor/edit_workflow.md,
conductor/tier2/githooks/forbidden-files.txt,
conductor/tracks/tier2_leak_prevention_20260620/spec.md,
conductor/code_styleguides/data_oriented_design.md,
conductor/code_styleguides/error_handling.md,
conductor/code_styleguides/type_aliases.md before Phases 3-10.
Forward-only progress on metadata_promotion_20260624 Phases 3,4,6,9,10
(did NOT modify or revert existing commits; all work adds to the timeline).
Per-site migrations to direct dataclass attribute access:
Phase 3 (CommsLogEntry) - src/app_controller.py:2278,2303,2311:
Added `comms_entry = CommsLogEntry.from_dict(entry)` after payload
extraction; replaced dict access with `.source_tier`, `.model`.
Phase 4 (HistoryMessage):
- src/synthesis_formatter.py:24,37: added HistoryMessage.from_dict
conversion for msg dicts in format_takes_diff.
- src/gui_2.py:7794: added HistoryMessage.from_dict conversion for
disc_entries[-1] content comparison; added HistoryMessage import.
Phase 6 (UsageStats) - src/app_controller.py:2299-2311:
Added `u_stats = models.UsageStats(...)` with field-name mapping
(dict cache_read_input_tokens -> UsageStats.cache_read_tokens).
Replaced dict access with `.input_tokens`, `.output_tokens`.
Phase 9 (RAGChunk) - src/app_controller.py:251,4171, src/ai_client.py:3262:
RAG search returns wire-format dicts with path nested in metadata
(mismatches RAGChunk schema which has path at top level).
Per-site resolution: direct dict access with explicit key checks.
Documented schema mismatch in commit.
Phase 10 (SessionInsights) - src/gui_2.py:4926-4934:
Added `SessionInsights.from_dict(...)` for session insights dict;
replaced .get() pattern with direct attribute access.
Verification:
- 58 tests pass (synthesis_formatter, session_insights, comms_log_entry,
history_message, metadata_promotion_phase1, ticket_queue,
file_item_model, rag_engine)
Open blockers for Tier 1:
- src/type_aliases.py:91 ToolCall: TypeAlias = Metadata should be
TypeAlias = "openai_schemas.ToolCall" (Phase 0 typo; blocks Phase 7)
- src/models.py:537 FileItem.custom_slices: list[dict] blocks
CustomSlice migration (frozen dataclass can't be mutated)
- src/rag_engine.py:367 search() returns List[Dict] not List[RAGChunk]
(return-type cascade needed)
- ToolDefinition not wired into per-vendor tool builders (sites
construct wire dicts)
- Remaining Phase 10 aggregates (DiscussionSettings, MMAUsageStats,
ProviderPayload, UIPanelConfig, PathInfo, ContextPreset) deferred
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
from src.type_aliases import HistoryMessage
|
|
|
|
|
|
def format_takes_diff(takes: dict[str, list[dict]]) -> str:
|
|
"""
|
|
[C: tests/test_synthesis_formatter.py:test_format_takes_diff_common_prefix, tests/test_synthesis_formatter.py:test_format_takes_diff_empty, tests/test_synthesis_formatter.py:test_format_takes_diff_no_common_prefix, tests/test_synthesis_formatter.py:test_format_takes_diff_single_take]
|
|
"""
|
|
if not takes:
|
|
return ""
|
|
|
|
histories = list(takes.values())
|
|
if not histories:
|
|
return ""
|
|
|
|
min_len = min(len(h) for h in histories)
|
|
common_prefix_len = 0
|
|
for i in range(min_len):
|
|
first_msg = histories[0][i]
|
|
if all(h[i] == first_msg for h in histories):
|
|
common_prefix_len += 1
|
|
else:
|
|
break
|
|
|
|
shared_lines = []
|
|
for i in range(common_prefix_len):
|
|
msg = HistoryMessage.from_dict(histories[0][i])
|
|
shared_lines.append(f"{msg.role}: {msg.content}")
|
|
|
|
shared_text = "=== Shared History ==="
|
|
if shared_lines:
|
|
shared_text += "\n" + "\n".join(shared_lines)
|
|
|
|
variation_lines = []
|
|
if len(takes) > 1:
|
|
for take_name, history in takes.items():
|
|
if len(history) > common_prefix_len:
|
|
variation_lines.append(f"[{take_name}]")
|
|
for i in range(common_prefix_len, len(history)):
|
|
msg = HistoryMessage.from_dict(history[i])
|
|
variation_lines.append(f"{msg.role}: {msg.content}")
|
|
variation_lines.append("")
|
|
else:
|
|
# Single take case
|
|
pass
|
|
|
|
variations_text = "=== Variations ===\n" + "\n".join(variation_lines)
|
|
|
|
return shared_text + "\n\n" + variations_text |