CDX-301e · Module 1
Fan-Out / Fan-In
4 min read
Fan-out/fan-in is the foundational parallelism pattern in Codex Cloud. Fan-out: decompose a large task into N independent sub-tasks and submit them simultaneously, each in its own microVM. Fan-in: collect the results from all N sub-tasks, merge them, and produce a unified output. The pattern maps directly to how you would manage a team of developers — assign non-overlapping work streams, let everyone execute in parallel, then integrate the results.
The critical constraint is independence. Fan-out only works when sub-tasks do not modify the same files. If two tasks both edit src/auth/middleware.ts, the fan-in merge will produce conflicts that require manual resolution — negating the time savings of parallel execution. The decomposition step is where all the design effort goes: you need to partition the work along file boundaries, module boundaries, or layer boundaries so that each task has its own non-overlapping scope.
Fan-in strategies vary by use case. For code changes, fan-in means merging branches — each task creates a branch, and you merge them sequentially into main, resolving any unexpected conflicts. For analysis tasks, fan-in means aggregating reports — each task produces a structured output (JSON, markdown), and a final step combines them into a summary. For test tasks, fan-in means collecting results — pass/fail counts, coverage numbers, failure logs — into a single dashboard view.
Do This
- Decompose along module or directory boundaries where file ownership is clear
- Verify zero file overlap before submitting parallel tasks — check with a dry run
- Use structured output formats (JSON) for analysis tasks to simplify fan-in aggregation
Avoid This
- Fan out tasks that modify shared configuration files — merge conflicts are guaranteed
- Assume parallel tasks will complete in the same order they were submitted
- Skip the merge review step — auto-merged code still needs human verification