Summary
The Agent model (390 lines) is approaching God Object territory. Three broadcasting methods (broadcast_index_state, broadcast_index_last_seen, broadcast_tab_updates) plus their after_update_commit callback account for ~40 lines that can be cleanly extracted.
Current State
app/models/agent.rb lines 113-156 contain:
broadcast_index_state — replaces state pill on index cards (guarded by saved_change_to_state?)
broadcast_index_last_seen — replaces "Last Seen" on index cards (guarded by saved_change_to_last_seen_at?)
broadcast_tab_updates — broadcasts to overview, configuration, and capabilities tab streams
These are self-contained and have no dependency on other Agent logic.
Proposed Change
Extract an Agent::Broadcasting concern containing all three methods and the after_update_commit callback. This follows the existing pattern (Agent::Benchmarking, SafeBroadcasting) and would reduce the core model to ~350 lines.
Acceptance Criteria
Context
Identified during architecture review. The Agent model has 7+ responsibilities (lifecycle, task assignment, benchmarking, metrics, broadcasting, configuration, state transitions). This extraction reduces cognitive load with zero behavioral change.
Summary
The
Agentmodel (390 lines) is approaching God Object territory. Three broadcasting methods (broadcast_index_state,broadcast_index_last_seen,broadcast_tab_updates) plus theirafter_update_commitcallback account for ~40 lines that can be cleanly extracted.Current State
app/models/agent.rblines 113-156 contain:broadcast_index_state— replaces state pill on index cards (guarded bysaved_change_to_state?)broadcast_index_last_seen— replaces "Last Seen" on index cards (guarded bysaved_change_to_last_seen_at?)broadcast_tab_updates— broadcasts to overview, configuration, and capabilities tab streamsThese are self-contained and have no dependency on other Agent logic.
Proposed Change
Extract an
Agent::Broadcastingconcern containing all three methods and theafter_update_commitcallback. This follows the existing pattern (Agent::Benchmarking,SafeBroadcasting) and would reduce the core model to ~350 lines.Acceptance Criteria
app/models/concerns/agent/broadcasting.rbContext
Identified during architecture review. The Agent model has 7+ responsibilities (lifecycle, task assignment, benchmarking, metrics, broadcasting, configuration, state transitions). This extraction reduces cognitive load with zero behavioral change.