# Scale with map and reduce

> Use the two volume primitives for partitioned work, deterministic aggregation, durable stages, and content-addressed datasets.

`spawn` is for bounded independently meaningful child work. Large cardinality belongs in `map` and `reduce`. These two primitives turn arrays or content-addressed manifests into durable Stages with explicit functions, partitions, budgets, retries, and result identities.

## Map {#map}

A registered partition function processes bounded batches and emits output rows or residue. Input may be divided by rows, bytes, approximate tokens, or stable key buckets. Pure, read-only, and idempotent functions may retry according to their declared effect; when attempts overlap, only one result can commit.

## Reduce {#reduce}

A registered fold combines mapped or existing data globally, by key, or through a bounded tree. Associativity and ordering are explicit. Combiners address hot keys, ordered folds merge sorted streams, and deterministic SQL folds provide a constrained aggregate path. Reduce never hides an unbounded in-memory join inside one Agent invocation.

## Durable volume {#durable-volume}

Stage identity binds the Run, journal position, function version, input manifest, options, and accepted Resources. Partition output is stored by hash, and each committed Stage becomes one ledger fact. A failed partition or exhausted budget rejects the Stage Handle without erasing prior facts.

World effects inside Stage code still cross governed Resources. `map` and `reduce` scale the Agent language; they do not bypass Policy, Credentials, recovery, or audit. Use them after the judgment flow is clear, not as a replacement for `turn`, `ledger`, or `commit`.
