Agentic MapReduce for Whole-Codebase Security Scanning
devin · Tech · 2026 · source Agentic: yes · promotional bias: low · source-backed · extracted with prompt 0.5.2 (schema v2)
Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.
Problem
Domain: Codebase security scanning
Cognition needed agents to reason over entire codebases for security tasks where completeness matters.
Constraints:
- Large repositories
- Context bottlenecks
- Explicit coverage boundaries
- Cost
Architecture
Agentic MapReduce separates whole-codebase analysis into Plan, Shard, Map, and Reduce. A planner agent reads the repository and writes deterministic selectors. Those selectors run over the entire codebase and emit compact signals, which are grouped into bounded batches. The Devin orchestrator assigns each batch to a fresh child worker session for focused reasoning. A reducer then deduplicates and reconciles worker outputs, including cross-shard relationships, so tokens are spent on relevant code and compressed findings rather than open-ended repository exploration.
Diagram confidence: explicit (topology described by the source).
flowchart LR planner-agent[Planner agent] --> deterministic-selectors[Deterministic selectors] deterministic-selectors --> signal-queue[Signal queue] signal-queue --> devin-orchestrator[Devin orchestrator] devin-orchestrator --> map-worker-sessions[Map worker sessions] map-worker-sessions --> reducer-session[Reducer session] reducer-session --> security-swarm-result[Security Swarm result]
Components
| Component | Role | Interacts with |
|---|---|---|
planner-agent |
Studies the repository and authors deterministic selectors that identify relevant code for the task. | deterministic-selectors |
deterministic-selectors |
Versionable relevance tests such as Tree-sitter, compiler, graph, schema, or lexical queries that run without a model over the codebase. | signal-queue |
signal-queue |
Finite set of compact candidate records showing where a selector fired and what evidence triggered it, grouped into bounded batches. | devin-orchestrator |
devin-orchestrator |
Assigns bounded signal batches to fresh child Devin worker sessions for analysis. | map-worker-sessions |
map-worker-sessions |
Parallel child sessions that inspect every candidate in a shard from focused context and emit structured findings. | reducer-session |
reducer-session |
Aggregates, deduplicates, reconciles, prioritizes, and reasons across worker findings to produce one coherent result. | security-swarm-result |
security-swarm-result |
Final vulnerability report produced by Security Swarm after whole-repo selection, parallel investigation, and reduction. | — |
Data flow
The planner studies the repository and authors selectors. The deterministic shard stage runs those selectors over every source file and emits signals with provenance. Matching signals are grouped into bounded batches and assigned by the Devin orchestrator to fresh child worker sessions. Each worker investigates its shard and emits structured findings. The reducer consumes only the workers' compressed outputs, deduplicates overlapping results, reconciles local conclusions, and can reason across shards before producing the final security result.
4 supporting quotes
Why this architecture
Whole-codebase tasks need an explicit coverage boundary. Agentic MapReduce spends reasoning once to synthesize selectors, uses deterministic execution to define the finite candidate set, parallelizes focused investigation, and reduces compressed findings. This makes completeness inspectable and keeps cost tied to relevant code rather than the full repository exploration path.
4 supporting quotes
Models used: coding agents · GPT-5.4-high with Mini-SWE-Agent (study context) · Devin child worker sessions
Scale
- The architecture is motivated by repositories as large as 50k files where a single search-driven agent cannot reliably bound coverage.“Point a single search-driven agent at a 50k-file repo, and ask it to remediate every instance of a problem, and three things go wrong.”article, stated
- Repository exploration consumed 56.2% of tool-use turns and 46.5% of main-agent tokens in the cited coding-agent trajectory study.“found that reading and searching consumed more than half of all tool-use turns and nearly half of the main agent’s tokens.”article, stated
- Security Swarm was evaluated on real CVEs spanning dozens of cases, more than a dozen languages, and multiple vulnerability classes.“The set spans dozens of cases across more than a dozen languages and vulnerability classes: RCE, SSRF, path traversal, auth bypass, unsafe deserialization, decompression-bomb DoS, and more.”article, stated
- The benchmark reports 72% recall for Devin Security Swarm at $90.23 per run.“Security scanner recall and cost per run: Devin Security 72% at $90.23, Claude Security 68% at $131.87, Codex Security 48%”article, stated
Alternatives considered (roads not taken)
A single search-driven agent traversing the whole repository
Rejected because: It spends budget finding work, carries unrelated evidence through a growing context, and stops when it decides it is done rather than when a finite queue is exhausted.
Classic MapReduce with handwritten instructions over the whole input
Rejected because: The agentic variant uses a planner to decide what matters for the current codebase and task, then runs that decision deterministically.
Treat selector recall as implicit in an agent's search behavior
Rejected because: Selectors are inspectable, testable, and version-controlled, while a search agent's claim to have looked everywhere is unfalsifiable.
Patterns
batch-offline-processing (agent-reasoning)
The deterministic pass creates a finite queue that can be sharded and investigated in parallel.
multi-agent-orchestration (security-scanning)
Multiple focused investigation agents run over bounded shards before results are reduced.
Tradeoffs
How to scale whole-codebase reasoning.
Chose deterministic queue plus parallel agents over single search-driven agent.
Rationale: The source says search-driven agents spend budget finding work and carry unrelated context.
Where to place the completeness guarantee for whole-codebase work.
Chose inspectable deterministic selectors with explicit recall risk over a search-driven agent's implicit claim that it looked everywhere.
Rationale: Selector recall can be read, tested, versioned, and tuned; an agent's open-ended search boundary is not falsifiable.
How the final stage should reason over many worker investigations.
Chose a reducer that consumes structured compressed worker outputs over replaying worker transcripts or re-reading the entire codebase.
Rationale: The reducer keeps global reasoning focused and cheaper while still deduplicating, reconciling, and connecting findings across shards.
Gotchas (what bit them)
Search-driven agents waste budget and lack coverage boundaries on whole-codebase tasks.
Root cause: Exploration dominates and context becomes a shared bottleneck.
Resolution: Agentic MapReduce separates deterministic coverage from focused reasoning.
Evaluation
Security Swarm is evaluated on real CVEs with recall and cost comparisons.
Metrics: recall · cost
Outcomes
- Security Swarm achieved 72% recall on real CVEs, according to the summary.
The source claims lower cost than alternative scanners.