awa run — deterministic run cache
On this page
awa run [flags] -- <command> [args...]
awa run executes a command and records its output and observed state. A clean
run that left that state unchanged becomes reusable: a later run with the same
key replays the stored result instead of executing the command.
Result model
hit— a stored result was replayed; the command did not execute.miss— the command executed; the result may be stored if cacheable.uncached— the command executed but the result was not made reusable (e.g. skipped inputs without--allow-skipped-inputs).
A hit or miss returns the wrapped command's own exit code. Stdout and stderr are
captured separately; their interleaving is neither recorded nor promised.
Outside --json, --display full writes each stream's exact bytes, complete
stdout before complete stderr; other displays and JSON claim no full byte
replay.
Cache key
The key covers the command, the run input scan (files the command could read), the working directory relative to the project root, and the relevant environment. The same command started from another directory is a different key, so make the directory explicit:
awa run --cwd ./packages/api -- npm test
Trust mode
The trust mode sets how closely the input scan compares files and is part of
the key. Set it with [hashing].trust_mode, or per invocation with the global
--trust-mode <mode> or the --strict shorthand:
normal— the default balance of hashing and stat signatures.strict— always hash content, never trust size and modification time. Use it when a file may change without its metadata changing.fast— stat-only comparison. It can miss a same-size, same-mtime rewrite, so its runs are recorded but never reusable (fast-trust-mode).
Mutation guard
A mutating or failed execution is still recorded as history. Only a clean run that left its required observed state unchanged — inputs and watched roots, minus what a matched validation policy waives — becomes reusable. The cache prefers a false miss (re-run unnecessarily) over a false hit (skip work that mattered).
The before/after observations show that observed state changed during the run, not which process wrote it: an edit made elsewhere while the command runs produces the same verdict, and a watched root does not name its writer. Unchanged endpoints do not rule out a write that was undone or happened outside the observed scope.
Effect observation
awa run also watches generated-output roots with a bounded stat signature:
every baseline exclude, such as node_modules and target; build, dist,
out, and coverage, which the input scan still sees; and any
[run].extra_effect_roots. .awa/ and .git/ are neither scanned nor watched.
Deleting or changing watched state after a reusable run misses
(effect-state-differs); a root that cannot be observed safely is never
reusable (effect-state-unavailable). An exclude you add yourself is not
watched: see "Effect roots vs excludes" below. A hit covers observed inputs and
the project-local observation policy; by default not files outside the project
root, and never network services, clocks, or home-directory config.
Latency diagnostics
A note appears only for a cause awa can name, past the shared interactive threshold, at most two per invocation. Neither cause is a misconfiguration or can be disabled:
large-effect-root(run.effect-observation, hintrecord-mode, absent under--record) — a watched generated-output root dominated state observation.full-input-rehash(run.input-observation, hintreview-run-scope) — reading the inputs was slow enough to notice; a hit pays it too.
Both appear on run, run explain, run ls, and status (JSON:
data.diagnostics.performance[]). Note and hint text, count meanings, and the
safe response are in awa help troubleshooting.
Display and flags
--display changes only this invocation's terminal output, never capture, the
key, or the exit code; the other flags below change execution or caching:
--display full default; stream/replay the full output
--display summary metadata plus a short excerpt
--display tail:<n> the last n lines
--display none awa diagnostics only, no command output
--refresh ignore any existing hit, publish a fresh result
--no-cache neither read nor write the cache
--no-cache-failures execute, but do not cache a failed result
--allow-skipped-inputs allow caching when the input scan skipped files
--cwd <path> set the execution directory (part of the key)
Stdin
A terminal or the null device gives the command no input. --allow-tty passes
the terminal, and piped or redirected input is passed through; both are unkeyed,
so the run is not reusable (stdin-not-keyed).
--stdin null gives the command EOF whatever awa's input is, and keys the run
as if its input were the null device; other reuse conditions still apply. Use it
only when the command reads no input. awa leaves its own input unread, so an
upstream producer may block or get a broken pipe. Not with --allow-tty.
Footer and inline diagnosis
Each execution or hit ends with a stderr footer:
awa run: record-only 1a2b3c4d5e6f exit=0 duration=1.2s cwd=.
inspect: awa run show <full-run-id> --tail 200
The summary names the state (stored, hit (replay), record-only,
uncached), short id, exit, duration and cwd, plus not-reusable(<reason>)
for a technical reason; --record/--no-cache is named by its state. A tail
is a window, not the full or permanent log; an unrecorded run gets no inspect:.
Lines appear only as needed: validation/probe facts, truncation, skipped
inputs, a mutation warning with exact compare: if recorded, and a nearest-run
diagnosis ending in awa run ls --near, or run show <id> --tail 50 for a
deliberate recording. For a stored run's reuse now,
awa run explain --from-run <id> --to-now uses today's config and environment,
not the past mode or decision, and runs no probes.
Why a run is not reusable
The footer, run ls, run explain, and stored runs name the cause with a
closed token; switch on the token, not on prose. Validation-policy and
identity-probe causes (external-facts-*) are in
awa help validation.
The observed state no longer matches what was recorded:
input-tree-differs the input tree changed (the only one with a path sample)
mutated-state observed state changed during the run
effect-state-differs watched generated output changed or was deleted
effect-state-unavailable a watched root could not be observed safely
fast-trust-mode observed under fast trust; recorded, never reusable
A recorded key fact no longer matches:
expired older than the run TTL
env-mismatch an allowlisted environment fact differs
cwd-mismatch the execution directory differs
config-mismatch another keyed fact differs (scope, trust mode, ...)
platform-mismatch recorded on a different OS or architecture
The stored evidence cannot be replayed honestly:
payload-missing the stored output is absent or fails its hash
corrupt the stored metadata could not be decoded
post-scan-failed the post-run observation scan failed
Policy declined to make the run reusable:
non-cacheable-policy caching was forbidden for this invocation
record-only captured as supervised history, never offered
no-cache ran without reading or writing the cache
stdin-not-keyed piped or tty stdin is not part of the key
skipped-inputs the scan skipped inputs without the allow flag
capture-disabled output capture was off, so nothing was stored
failed-not-cached the command failed and policy declines to cache it
Inspect and explain
awa run log --command <text> history of executions, any reuse state, newest first
awa run show <run-id> metadata only: exit, reuse, stream byte counts
awa run show <run-id> --tail 200 captured output; or --stdout, --stderr
awa run ls runs reusable for the current state
awa run ls --near also recent non-reusable candidates: reason, changed-path sample
awa run explain -- <command> the cache decision, without running
run ls and run explain assess reuse now; they are not history. A run
missing from ls is still in run log, and a failed or record-only run is
read without changing any cache policy. --last instead of an id selects the
newest run. Finding and reading runs: awa help inspect.
None of these runs identity probes. If validation policy
probes are approved but have not run, explain says incomplete with no key
unless another rule decides, and run ls lists the run as unassessed: unknown,
not a miss. With --json, run ls and run explain share one near-miss shape;
see awa help json.
An unmet [[run.required_env]] makes awa run exit 1 before
probes, observation, cache lookup, replay or execution; explain says refused
(env-requirement-unmet), run ls not reusable.
Evidence and privacy
Captured stdout/stderr is stored verbatim and never redacted, so a printed
secret is stored. Output over the capture limit is stored truncated, and the
footer, replay, and run show state the omitted byte count. The child does not
inherit your environment: it gets the built-in baseline (your locale
unchanged), what env_allowlist adds, the names a matching required_env
declaration requires, and the advisory marker AWA_RUN=1, all keyed; passed
values are stored only as a redacted identity. See
awa help privacy.
Effect roots vs excludes
The central run-cache decision for a generated or scratch directory:
- The command writes output you need afterwards, or has side effects
(deploy, migration, formatter, live probe) →
awa run --record. A replay recreates no files, so it could report success with the output missing. - One exact check rewrites a directory whose prior contents cannot change
its result and whose files are not needed after a replay → a
[[run.validation]]policy for result-only reuse (awa help validation). Both assertions must hold; awa checks neither. - The command only reads a generated directory the run input scan no longer
sees →
[run].extra_effect_roots, so later changes to it invalidate reuse. - The input scan still sees that directory → configure nothing; its contents already key the run.
- No command's result depends on the path, even if one writes it (scratch,
logs) →
[run].extra_excludesor.awaignore.
An effect-root selector is literal, never a glob: a name such as
extra_effect_roots = ["bin"] matches at any depth, for example across
monorepo packages; a path such as ["artifacts/bin"] matches only there, not
other/bin or other/artifacts/bin.
Rules:
- Writing to a watched root during the run makes the result non-reusable, unless a matched validation policy waives that exact directory.
- The watched set is the built-in effect roots plus
extra_effect_roots. An exclude neither silences a watched root nor is watched itself, so an excluded, unwatched directory is invisible to the cache for every command. - Never exclude a real dependency to get hits: a miss is cheaper than a false hit.
- awa will not auto-edit config to improve the cache hit rate.