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:

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]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

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
“The planner studies the repo and produces selectors: relevance tests concrete enough to run deterministically over the whole codebase, with no model in the loop.”article, stated
“Each match emits a signal: a compact record of where the match occurred, which selector produced it, and what evidence triggered it.”article, stated
“Signals from matching files are grouped into bounded batches, and the Devin orchestrator assigns each batch to a fresh child worker session for analysis.”article, stated
“The Reducer consumes the structured outputs, deduplicates overlapping results, reconciles local conclusions, and applies global prioritization to produce one coherent result.”article, stated

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
“the result is only trustworthy if the entire codebase was considered. And the local-task toolkit doesn’t transfer cleanly.”article, stated
“Coverage is guaranteed by construction: the deterministic pass produces a finite work queue, every shard is assigned to an investigation agent, and the scan is complete only when that queue is exhausted.”article, stated
“Tokens are then spent only on the candidates that survive the selectors, and only on one bounded shard at a time.”article, stated
“It reasons over the workers’ compressed conclusions rather than replaying their full contexts or re-reading the entire codebase.”article, stated

Models used: coding agents · GPT-5.4-high with Mini-SWE-Agent (study context) · Devin child worker sessions

Scale

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.

“The agent greps, opens the wrong files, backtracks, and re-decides what to inspect next. On a large repo, selection can dominate analysis.”article, stated
“No explicit coverage boundary. A search-driven agent stops when it decides it’s done - not when a finite work queue has been exhausted.”article, stated

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.

“Where classic MapReduce processes the entire input using handwritten instructions, here an agent decides what matters for the current codebase given the task.”article, stated

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.

“The selectors are an inspectable, version-controlled artifact. You can read them, test them against known examples, and tune their recall to the task at hand”article, stated

Patterns

batch-offline-processing (agent-reasoning)

The deterministic pass creates a finite queue that can be sharded and investigated in parallel.

“3. No explicit coverage boundary. A search-driven agent stops when it decides it’s done - not when a finite work queue has been exhausted.”article, stated

multi-agent-orchestration (security-scanning)

Multiple focused investigation agents run over bounded shards before results are reduced.

“First, an agent synthesizes a deterministic relevance test. That test runs over every source file and produces a finite set of candidates. The candidates are then divided into bounded batches, investigated in parallel, and reduced into a single result.”article, stated

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.

“1. The agent spends most of its budget finding the work rather than doing it. The agent greps, opens the wrong files, backtracks, and re-decides what to inspect next. On a large repo, selection can dominate analysis.”article, stated

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.

“Completeness now rests on selector recall: a file that matches no selector never reaches a worker. We take this trade deliberately.”article, stated
“The selectors are an inspectable, version-controlled artifact. You can read them, test them against known examples, and tune their recall to the task at hand”article, stated

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.

“It reasons over the workers’ compressed conclusions rather than replaying their full contexts or re-reading the entire codebase.”article, stated

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.

“3. No explicit coverage boundary. A search-driven agent stops when it decides it’s done - not when a finite work queue has been exhausted.”article, stated

Evaluation

Security Swarm is evaluated on real CVEs with recall and cost comparisons.

Metrics: recall · cost

“Their Security Swarm implementation achieved 72% recall on real CVEs from the GitHub Advisory Database, outperforming alternative security scanners at a fraction of the cost.”summary, stated

Outcomes

The source claims lower cost than alternative scanners.

“Their Security Swarm implementation achieved 72% recall on real CVEs from the GitHub Advisory Database, outperforming alternative security scanners at a fraction of the cost.”summary, stated