Skip to content

refactor(bridges): extract shared codec_bridges core (A-19, Audit-A complete)#79

Merged
AVADSA25 merged 1 commit into
mainfrom
fix/pr3f-bridge-unification
May 23, 2026
Merged

refactor(bridges): extract shared codec_bridges core (A-19, Audit-A complete)#79
AVADSA25 merged 1 commit into
mainfrom
fix/pr3f-bridge-unification

Conversation

@AVADSA25
Copy link
Copy Markdown
Owner

Summary

PR-3F (Option 1, scoped) — the last Audit-A item. Design → docs/PR3F-BRIDGE-UNIFICATION-DESIGN.md.

The audit's full BridgeRouter (unifying process_message) was high-risk/low-value: the headline call_llm dup was already fixed in #71, and the two process_message flows have intentionally drifted (telegram audio/Gemini/briefing; imessage goals/intent) — forcing them into one pipeline would risk regressing a working channel. So this extracts only the genuinely-identical helpers and leaves process_message per-bridge.

New codec_bridges.py

  • load_dispatch() / try_skill(text) — lazy codec_dispatch loader + skill match (+ the _SKIP_SKILLS terminal/GUI set).
  • call_llm(channel, text, llm_cfg, …) — canonical bridge LLM call: persona by channel → codec_llm.call, None-contract preserved, chat_template_kwargs filtered.
  • save_to_memory(channel, conv_id, …) — memory.db write under session_id "<channel>-<conv_id>".

codec_telegram + codec_imessage now from codec_bridges import try_skill and keep thin channel-injecting wrappers for call_llm/save_to_memory, so every process_message call site is unchanged (telegram audio + imessage goal-tracking untouched). Removed telegram's dead sqlite3 import. codec_bridges.py is the documented "add a channel" seed (CLAUDE.md §1).

Updated 2 stale #71 source-invariants (bridges now delegate via codec_bridges).

Test plan

  • tests/test_bridges.py — 10 tests: call_llm persona / None / kwargs-filter / history+override; try_skill skip-set / run / no-match; save_to_memory channel-prefixed session_id; source invariants.
  • Full suite: 1502 passed, 23 known-baseline failures, zero new, 74 skipped.
  • Ruff: zero net-new (removed dead sqlite3).
  • Net −148 LOC in the bridges.
  • Manual (Mac Studio): a Telegram + an iMessage round-trip reply; both persist to memory.db under the right session_id.

🎯 Audit-A (Wave 3, code quality) is complete

A-1..A-22 all closed or verified. The big threads this run: A-11 vision dedup (codec_vision), A-12 LLM-call dedup (codec_llm — every text call site), PR-3D monolith decomposition (A-5/6/7), and A-19 bridge unification (codec_bridges).

🤖 Generated with Claude Code

…omplete)

PR-3F, Option 1 (scoped). The audit's full BridgeRouter (unifying process_message)
was high-risk/low-value: the headline call_llm dup was already fixed in #71, and
the two process_message flows have intentionally drifted (telegram audio/Gemini/
briefing; imessage goals/intent) — forcing them into one pipeline would risk
regressing a working channel. So this extracts ONLY the genuinely-identical
helpers and leaves process_message per-bridge.

New codec_bridges.py:
- load_dispatch() / try_skill(text) — the lazy codec_dispatch loader + skill
  match (+ the _SKIP_SKILLS terminal/GUI set), one copy.
- call_llm(channel, text, llm_cfg, ...) — the canonical bridge LLM call: persona
  selected by channel, routed through codec_llm.call, None-contract preserved,
  chat_template_kwargs filtered.
- save_to_memory(channel, conv_id, user, assistant) — the memory.db write under
  session_id "<channel>-<conv_id>".

codec_telegram + codec_imessage now `from codec_bridges import try_skill` and keep
thin channel-injecting wrappers for call_llm / save_to_memory, so every
process_message call site is unchanged (telegram audio + imessage goal-tracking
untouched). Removed telegram's now-dead sqlite3 import. codec_bridges.py is the
documented "add a channel" seed (CLAUDE.md §1: future WhatsApp/Discord).

Updated 2 stale #71 source-invariants (the bridges now delegate via codec_bridges
rather than calling codec_llm.call directly).

Tests: tests/test_bridges.py (10 — call_llm persona/None/kwargs-filter/history+
override, try_skill skip-set/run/no-match, save_to_memory channel-prefixed
session_id, source invariants). Full suite 1502 passing, 23 known-baseline
failures, zero new. Net -148 LOC in the bridges. Zero net-new ruff.

**Audit-A (Wave 3, code quality) is complete** — A-1..A-22 all closed or verified.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@AVADSA25 AVADSA25 merged commit c12d3fa into main May 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants