Skip to content

Step Cache

Leonard Ramminger edited this page Aug 9, 2026 · 1 revision

Step Cache

The step cache skips a whole step when Beez determines the step already produced its outputs and nothing material has changed.

When a step is cacheable

A step is cacheable if it has at least one artifact pattern:

step({
name="compile",
phase="build",
scope="default",
input= { "src/**/*.cpp" },
output= { "build/app" },
run="cmake --build build",
})

No input, output, or mutate means the step always runs.

Skip decision

On each step run, Beez checks (in order):

  1. Per-step index (.cache/index/<name>__<phase>__<scope>.index) if present:

    • Command fingerprint matches (shell command or Lua callback + build.lua hash)
    • Step config fingerprint matches
    • Beez version matches
    • Input file stamps match (path, size, modification time)
    • All recorded outputs still exist on disk
  2. If the index misses, content-addressed key lookup in .cache/entries/<key>.manifest:

    • Key derived from input file content hashes, step identity, config, env, version
    • Skip if manifest exists and outputs still exist

If all checks pass, the step is reported as a cache hit and not executed.

Cache key ingredients

The content-addressed key combines:

ComponentSource
Step identityname, phase, scope
CommandShell run string, or <callback> + hash of build.lua
Input filesContent hash of each file matched by input + mutate globs
Step configSerialized config / configure_step() table
EnvironmentFingerprint of env.hash_vars (see Environment Variables)
Beez versionInstalled Beez version string

Input patterns are the union of input and mutate globs.

What gets stored

After a successful step run:

  • Manifest at .cache/entries/<key>.manifest listing step name and output paths
  • Index at .cache/index/<sanitized-name>__<phase>__<scope>.index with:
    • Cache key, command, config, version
    • Input stamps (path, size, mtime)
    • Output paths
    • Last run duration (for time-saved display)

Output tracking

After execution, Beez records which files the step produced:

Step declaresOutputs recorded as
output globsExpanded glob matches
mutate only (no output)Expanded mutate matches
Neither output nor mutateDirectory snapshot diff under build/ (or dirs from output patterns)

See Artifact Patterns.

Shell vs Lua steps

run typeCommand fingerprint
Shell stringExact command text
Lua functionHash of build.lua (callback body is not hashed separately)

Changing build.lua invalidates Lua callback step cache entries.

Worker subprocess cache

Workers spawned via ctx:spawn() with inputs or outputs can use the same step cache machinery internally (treated as a synthetic step). See Step Context.

Configuration

SettingEffect
cache.enabledMaster switch
cache.pathRoot directory
cache.hash.*Hash algorithm for keys and file content
performance.cache_write_strategyWhen index/manifest writes flush to disk
env.hash_varsEnv vars in key fingerprint

See Cache Settings.

CLI

beez build --no-cache # always run cacheable steps
beez --clean-cache build # wipe cache first

Next steps

Clone this wiki locally