arch: streaming phase pipeline — eliminate sequential recon→hunt→prove blocking
Problem
The orchestrator runs phases strictly sequentially: recon must fully complete before hunt starts, and all hunters must finish before any proving begins. This is the single biggest performance bottleneck.
Current: recon ─── WAIT ─── hunt ─── WAIT ─── prove ─── WAIT ─── output
↑ ↑ ↑
entire recon all hunters all provers
must finish must finish must finish
In orchestrator.py:
recon = await self._run_recon() # BLOCKS entirely
hunt = await self._run_hunt(recon) # BLOCKS entirely
verified = await self._run_prove(recon, hunt) # BLOCKS entirely
For a standard-depth scan: recon ~60s + hunt ~120s + prove ~90s = 270s minimum wall-clock, even though the first hunt findings appear within ~30s of hunt starting and could already be proving.
Architectural Principle Violated
Principle 5 (Asynchronous Parallelism) from our Composite Intelligence framework:
"Decompose to parallelize. Leverage asynchronicity to execute independent tasks concurrently, maximizing throughput and minimizing latency."
Principle 3 (Dynamic Orchestration):
"The flow of control and data is not static; it is fluid and adapts based on the intermediate state of the system."
Design Constraint — Maintain Proper Reasoner DAG
Critical: The streaming pipeline MUST preserve the reasoner-calling-reasoner call graph. The AgentField DAG visualization must show proper parent→child relationships:
orchestrator
├── recon_phase (reasoner)
│ ├── run_architecture_mapper (reasoner)
│ ├── run_dependency_auditor (reasoner)
│ ├── run_config_scanner (reasoner)
│ ├── run_data_flow_mapper (reasoner)
│ └── run_security_context_profiler (reasoner)
├── hunt_phase (reasoner) — starts when recon emits partial results
│ ├── run_injection_hunter (reasoner)
│ ├── run_xss_hunter (reasoner)
│ └── ... (parallel, semaphore-limited)
└── prove_phase (reasoner) — starts when first findings arrive
├── run_verifier (reasoner) — for finding 1
├── run_verifier (reasoner) — for finding 2
└── ...
The DAG edges must be visible. This means we use router.call() properly — NOT raw asyncio bypassing the reasoner graph.
Proposed Approach
Phase 1: Split Recon into "Fast Recon" + "Deep Recon"
- Fast recon (architecture + config): Provides enough context for hunt to start
- Deep recon (data_flow + security_context + dependencies): Runs in parallel with early hunters
- Hunt starts with partial recon context; enriches context as deep recon completes
Phase 2: Hunt→Prove Streaming via asyncio.Queue
- Each hunter pushes findings to a shared
asyncio.Queueas it completes - A prove orchestrator consumes from the queue and dispatches verifiers
- Dedup runs as a filter on the queue (incremental, not batch)
Phase 3: Budget-Aware Streaming
- Prove budget consumption tracked in real-time
- If prove budget is exhausting fast, slow down the queue consumption
- If hunt finds nothing for N strategies, increase concurrency for remaining ones
Implementation Pattern (asyncio.Queue)
async def run_streaming(self) -> SecurityAuditResult:
findings_queue: asyncio.Queue[RawFinding | None] = asyncio.Queue()
# Fast recon — minimum needed for hunt
fast_recon = await self._run_fast_recon()
# Launch hunt and deep recon in parallel
# Hunt pushes findings to queue as they arrive
# Prove consumes from queue
hunt_task = asyncio.create_task(
self._run_hunt_streaming(fast_recon, findings_queue)
)
deep_recon_task = asyncio.create_task(
self._run_deep_recon(fast_recon)
)
prove_task = asyncio.create_task(
self._run_prove_streaming(findings_queue)
)
deep_recon, hunt_result, verified = await asyncio.gather(
deep_recon_task, hunt_task, prove_task
)
# Merge deep recon context for output generation
recon = self._merge_recon(fast_recon, deep_recon)
return await self._generate_output(recon=recon, hunt=hunt_result, verified=verified)
Estimated Impact
- 40-60% wall-clock reduction for standard-depth scans
- Better budget utilization (proving starts earlier, can detect budget exhaustion sooner)
- Improved user experience (progress updates come sooner)
Acceptance Criteria
- [ ] Phases overlap: hunt starts before recon fully completes
- [ ] Prove starts on first findings while hunters still run
- [ ] AgentField DAG shows proper reasoner→reasoner call graph
- [ ] Checkpoint system still works (partial checkpoints for streaming)
- [ ] Budget tracking remains accurate across overlapping phases
- [ ] No regression in finding count or quality (benchmark against DVGA)
- [ ] Wall-clock time measurably reduced vs. sequential baseline
Dependencies
- Blocks: None (can be developed independently)
- Blocked by: None
- Related: #TBD (incremental dedup), #TBD (dynamic adaptation)