Skip to content

♻️ Refactor Claude connector internals to reduce argument counts #76

@Robdel12

Description

@Robdel12

Context

Follow-up from #71 (Clippy allow audit). Five #[allow(clippy::too_many_arguments)] sites remain in the Claude connector:

  • connector-claude/src/lib.rsClaudeConnector::new (8 params)
  • connector-claude/src/lib.rsevent_loop (6 params, all Arc<Mutex>)
  • connector-claude/src/lib.rsdispatch_stdout_message (14 params — worst case in codebase)
  • connector-claude/src/lib.rshandle_assistant_message (9 params)
  • connector-claude/src/session.rsClaudeSession::new (9 params, public API)

Why these were deferred

The Claude connector uses a shared-state pattern where multiple Arc<Mutex<>> references are passed through the event loop pipeline. Refactoring requires either:

  • Introducing a ClaudeEventLoopState struct that groups the shared state (preferred)
  • Or restructuring the connector to use an actor/struct with methods

ClaudeSession::new is a public API boundary — changing it requires coordinating all callers.

dispatch_stdout_message with 14 parameters is the single worst offender in the codebase and would benefit most from a state struct.

Recommended approach

  1. Create ClaudeEventLoopState grouping the Arc<Mutex> fields
  2. Refactor event_loopdispatch_stdout_messagehandle_assistant_message chain to pass the struct
  3. Create ClaudeSessionConfig for ClaudeSession::new / ClaudeConnector::new

Acceptance Criteria

  • All 5 #[allow(clippy::too_many_arguments)] in connector-claude removed
  • make rust-ci passes

Follow-up from #71: I_kwDORFu4Vs71Vr9-

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readySmall task suitable for agent dispatch

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions