Heuristic:1jehuang Jcode Debounced Status Fanout
| Knowledge Sources | |
|---|---|
| Domains | Multi_Agent_Systems, Optimization |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
Swarm status updates are fanned out to coordinator views via debounced event delivery, preventing flooding when many workers update simultaneously.
Description
The Debounced_Status_Fanout heuristic ensures that when swarm worker status changes occur, the fanout_session_event function delivers updates to the coordinator's swarm view without flooding. Workers frequently report status (started, stopped, progress), and without debouncing the coordinator's TUI would be overwhelmed with redraw requests. The fanout uses bounded event history (MAX_EVENT_HISTORY) to avoid unbounded memory growth.
Usage
Use this heuristic when multiple swarm workers are running concurrently and reporting status. It prevents the coordinator's TUI from being overwhelmed with rapid status updates. Apply when designing any multi-agent fanout system where many workers can update simultaneously.
The Insight (Rule of Thumb)
- Action: Use
fanout_session_eventwith bounded event history (MAX_EVENT_HISTORY). - Value: Status updates are fanned out to session views but bounded to prevent memory growth.
- Trade-off: Some status updates may be coalesced or dropped if they arrive faster than the debounce window.
- Compatibility: Works with the
SwarmMemberregistry andServerEvent::TurnStoppedevent types.
Reasoning
In a swarm with N concurrent workers, each worker may report multiple status updates per second. Without debouncing, the coordinator receives N×updates/sec, causing excessive TUI redraws and potential event queue backpressure. Bounding the event history prevents unbounded memory growth in long-running swarms while still delivering meaningful status changes to the coordinator.
Code Evidence
Fanout usage from crates/jcode-app-core/src/server/swarm.rs:1,127:
use super::state::{MAX_EVENT_HISTORY, fanout_session_event};
// Workers usually have no attached client; the status update below
// is what the coordinator's swarm view shows.
fanout_session_event(
swarm_members,
&descendant,
ServerEvent::TurnStopped {