Skip to content

Queue and Event System

Queue and Event System

The BugTraceAI-CLI uses per-specialist task queues and an internal event bus to coordinate the scanning pipeline. This architecture enables parallel execution, deduplication, metrics tracking, and real-time event streaming.


Queue Architecture

Consolidation Phase
|
+---------------+---------------+
| | |
+-----v-----+ +-----v-----+ +-----v-----+
| XSS Queue | | SQLi Queue| | SSRF Queue| ...
| (15 items)| | (8 items) | | (5 items) |
+-----+-----+ +-----+-----+ +-----+-----+
| | |
+-----v-----+ +-----v-----+ +-----v-----+
| XSS Agent | | SQLi Agent| | SSRF Agent|
+-----+-----+ +-----+-----+ +-----+-----+
| | |
+-------+-------+-------+-------+
| |
+-----v-----+ +-----v-----+
| Event Bus | | Validation |
| | | Queue |
+-----------+ +-----------+

Per-Specialist Queues

Each specialist agent has its own dedicated task queue. Findings from the consolidation phase are distributed to the appropriate queue based on vulnerability type.

Queue Properties

PropertyDescription
IsolationEach specialist has its own queue — no cross-contamination
PriorityItems are ordered by priority score from the analysis phase
BoundedQueues have configurable maximum size
PersistentQueue state survives agent restarts

Queue Mapping

Queue NameSpecialist AgentFuzzer
xssXSS AgentGo XSS Fuzzer
sqliSQLi AgentPython AI
ssrfSSRF AgentGo SSRF Fuzzer
idorIDOR AgentGo IDOR Fuzzer
lfiLFI AgentGo LFI Fuzzer
rceRCE AgentPython AI
xxeXXE AgentPython AI
jwtJWT AgentPython AI
openredirectRedirect AgentPython AI
prototype_pollutionPrototype AgentPython AI
cstiCSTI AgentPython AI
mass_assignmentMass Assignment AgentPython AI
header_injectionHeader Injection AgentPython AI
api_securityAPI Security AgentPython AI
file_uploadFile Upload AgentPython AI

The full set of 15 specialist queues matches the queue assignment in Scanning Pipeline and the agent roster in Specialist Agents.


Deduplication

Before a finding is added to any specialist queue, it passes through deduplication logic:

  1. URL + Parameter matching: Identical URL and parameter combinations are merged
  2. Payload similarity: Near-identical payloads targeting the same endpoint are deduplicated
  3. Cross-phase dedup: Findings already in the validation queue are not re-queued

This prevents specialist agents from wasting time on duplicate targets.


Metrics Tracking

The queue system tracks detailed metrics for monitoring and performance analysis:

Per-Queue Metrics

MetricDescription
queue_depthCurrent number of items in the queue
items_processedTotal items consumed by the specialist
items_remainingItems still waiting to be processed
processing_rateItems processed per second
average_latencyAverage time from queue entry to processing

Per-Agent Metrics

MetricDescription
findings_discoveredNumber of vulnerabilities found
payloads_attemptedTotal payloads tested
success_ratePercentage of attempts that found vulnerabilities
elapsed_timeTotal agent runtime

Global Metrics

MetricDescription
total_depth_reachedMaximum crawl depth achieved
total_urls_processedTotal URLs processed across all phases
total_throughputAggregate requests per second
scan_durationTotal wall-clock scan time

Metrics are accessible via the GET /api/scans/{id}/metrics API endpoint.


Event Bus

The internal event bus is the communication backbone of the scanning engine. All scan events flow through the event bus, which distributes them to interested consumers.

Event Flow

Scanning Engine --> Event Bus --> WebSocket Endpoints
|
+--> Metrics Collector
|
+--> Logger
|
+--> Internal Consumers

Published Events

EventSourceDescription
scan_startedPipelineScan execution began
phase_transitionPipelineMoving to a new pipeline phase
target_discoveredDiscoveryNew URL or endpoint found
finding_queuedConsolidationFinding added to specialist queue
exploitation_attemptSpecialistPayload delivery attempted
finding_discoveredSpecialistVulnerability confirmed
validation_startedValidationBrowser validation initiated
validation_completeValidationBrowser validation finished
scan_completePipelineScan execution finished
errorAnyError occurred in any component

Verbose (Dotted) Events

In addition to the canonical events above, the pipeline emits fine-grained verbose events using a dotted namespace (for example exploit.* and auth.*). These pass through the event bus under their own event type and drive the live Swarm Graph and scan console in the WEB dashboard.

EventSourceDescription
exploit.<type>.level.startedSpecialistAn agent began an escalation level (e.g. exploit.xss.level.started, levels L1-L6) for a target
exploit.<type>.level.completedSpecialistAn escalation level finished, carrying its per-level confirmation status
auth.phase.startedAuthPre-scan authentication / auth-discovery phase began
auth.stepAuthAn individual login step ran during automatic authentication
auth.success / auth.failedAuthAuthentication completed successfully or failed

Event Structure

{
"event": "finding_discovered",
"scan_id": "scan_abc123",
"timestamp": "2026-02-10T14:35:22Z",
"seq": 44,
"data": {
"finding_id": "finding_007",
"type": "XSS",
"severity": "HIGH",
"agent": "xss"
}
}

WebSocket Consumption

The event bus feeds directly into the WebSocket endpoints (/ws/scans/{id} and /ws/global). Events are transformed into the WebSocket event format documented in WebSocket Events.


Queue Lifecycle

During a Scan

  1. Phase 1-2: Discovery and analysis populate the potential findings list
  2. Phase 3: Consolidation deduplicates and distributes to specialist queues
  3. Phase 4: Specialists consume from their queues in priority order
  4. Phase 4: Successfully exploited findings are placed in the validation queue
  5. Phase 5: The validation agent processes the validation queue

Queue States

StateDescription
EMPTYNo items in queue
ACTIVEItems present, specialist is consuming
PAUSEDScan is paused, queue frozen
DRAININGScan stopping, processing remaining items
COMPLETEAll items processed

Parent: BugTraceAI-CLI

See also: Scanning Pipeline | Specialist Agents | WebSocket Events