awa doctor — diagnose and repair local state
On this page
awa doctor [--repair] [--capacity] [--strict]
awa doctor inspects the durable .awa/ state — the checkpoint store, blob
store, run cache, worktree index, lock files, and the .awa/ git guard — and
prints a one-line health verdict plus one line per finding. It also
raises local evidence/privacy findings: secret-looking env allowlist names,
a secret-looking top-level file a checkpoint would store bytes for, overly broad
.awa/ permissions, and nested or ancestor .awa markers (see
awa help privacy). Separately from those integrity and privacy
checks, it reports how much the .awa/ store holds and warns when that reaches a
configurable size (see "Store size advisory" below); --capacity also sizes the
watched generated-output roots (see "Watched-root audit" below).
awa doctor # report health and any findings
awa doctor --repair # also perform the safe, mechanical repairs
awa doctor --capacity # also size the watched generated-output roots
awa doctor --strict # recompute hashes instead of trusting stat signatures
awa doctor --json # machine-readable findings (severity, subsystem, code)
Each finding is tagged by the action it invites: [repaired] for one --repair
fixed, [repairable] for one --repair would fix, otherwise its severity.
--repair performs only safe, mechanical fixes (such as restoring the .awa/
git guard or removing an orphaned temp artifact); it never touches your worktree.
The exit status is the diagnosis, not an awa failure (like awa run, there is
no "awa:" error line): a healthy or warnings-only run exits 0, while unrepaired
errors or unrepaired repairable findings exit 5 (local state needs an action).
That code does not mean damage on its own: an unrepaired guard file earns it just
as a corrupt record does, so read the findings rather than the code.
Finding codes
Every finding carries a stable machine code from a closed set, so a script can branch on the code rather than on the message. They group by subsystem:
config-invalid a config layer is present but not valid
pattern-* an exclusion pattern in config or a root ignore file
can never match (a warning), or that check could
not run; nested ignore files warn when scanned
required-dir-* a required .awa/ directory is missing or wrong
checkpoint-* a checkpoint record, manifest, exclusion frontier,
or blob is corrupt, missing, or in a schema this
awa cannot read
incomplete-checkpoint-* a checkpoint directory has no header (interrupted
or still running), or could not be inspected
run-* a stored run's metadata, pointer, or payload is
corrupt, or in a schema this awa cannot read
restore-recovery-* a restore recovery observation is unreadable, in a
format this awa cannot read, or its captured
content is gone — that restore can no longer be
undone
index-* the worktree index is unreadable, schema-invalid,
or stale
lock-stale, lock-unknown a lock file left behind, or one awa cannot classify
orphan-temp, temp-unreadable a leftover temp artifact under .awa/, or a temp
location awa cannot read
state-gitignore-* the awa-owned .awa/ git guard is missing,
ineffective, or unreadable
awa-tracked-by-git .awa/ content is tracked by git — evidence is being
committed
git-check-failed that git check could not be run at all
state-permissions-too-broad .awa/ is readable beyond its owner
env-allowlist-suspicious an allowlisted env name looks like a secret
env-allowlist-injects-code an allowlisted env name can load or execute code
in the wrapped command (LD_PRELOAD, DYLD_*,
BASH_ENV, NODE_OPTIONS, RUBYOPT, ...)
content-storage-enabled a secret-looking top-level file is in checkpoint
scope and not hash-only, so its bytes may be stored
content-capture-check-incomplete
that file check could not inspect a candidate or
an ignore file; the answer is unknown, not clean
nested-*, ancestor-* another .awa marker below or above this root, or a
nested-marker scan that could not complete
store-capacity-threshold the .awa/ store's logical bytes reached
doctor.store_warning_size (a warning; exit 0)
watched-root-capacity-threshold
a watched root's logical bytes reached
doctor.watched_root_warning_size (a warning; exit 0)
repair-failed a repair was attempted and did not succeed
Store size advisory
Every plain awa doctor run also sizes the .awa/ store and prints one store:
line (JSON: store_capacity). The figure is the sum of the logical lengths of the
regular files under .awa/ — records, manifests, blobs, captured output, temp,
config, and the derived index — as listed during the walk. Each path counts once,
so a hard-linked file counts once per path; directories, symlinks (never followed),
and special files count nothing, and no file is opened or read. It is not disk
usage (allocated blocks, compression, or snapshots are not seen), not what
awa gc would reclaim, and says nothing about the worktree or generated output.
When that figure reaches doctor.store_warning_size (default 1GiB; see
awa help config) doctor reports a
store-capacity-threshold warning. It is not repairable and on its own leaves
health at warning and the exit status at 0; --repair never deletes or changes evidence because of its
size. The next step is a look at retention, not automatic cleanup:
awa gc --dry-run # what the configured retention would remove, and why
gc only manages awa's own records; it does not shrink generated project
output. Set store_warning_size = "off" under [doctor] to disable the advisory
and its walk, or a larger size if this project is expected to keep more evidence.
The walk is bounded: it examines at most 1,000,000 entries and descends at most 32 directory levels. The measurement is one of:
exact every entry was measured; 0 really means an empty store
partial a lower bound: the walk stopped at its entry budget
(work-budget), skipped levels past its depth limit (depth-limit),
or could not stat or list some entries (unreadable-entries)
unmeasured .awa/ could not be opened for sizing (unavailable); no figure
disabled the advisory is off; no walk ran
A partial figure that already reaches the threshold still warns — the store holds at least that much. A partial figure below it does not show the store is small. Files that change during the walk are counted as seen, not as an atomic snapshot. Sizing has its own budget and never shortens the integrity checks; an interrupted doctor exits as interrupted rather than reporting a partial size.
Watched-root audit (--capacity)
awa doctor --capacity adds a watched roots: summary (JSON:
watched_root_capacity, null without the flag). It searches for the real
directories the effect-root selectors name — the built-ins and
[run].extra_effect_roots (see awa help run) — and sizes each like the
store: logical lengths of regular files, no file read, symlinks and .awa/.git
never entered. A root nested in another root counts once, inside the outer one. It
takes no paths and does not see the rest of the worktree or the disk; use system
tools such as du for that.
Three bounds are reported separately. The search stops after 2,000,000 entries or
100,000 directories (work-budget) and notes unreadable directories
(unreadable-entries); when incomplete, the found count is not a total. Each root
is exact (0 means empty), partial — a lower bound after 1,000,000 entries
(work-budget), 64 levels (depth-limit), 4,000,000 entries across all roots
(aggregate-budget), or unreadable entries — or unmeasured (unavailable, or
aggregate-budget already spent). Only the 20 found roots with the largest observed figures are listed — a partial
figure is a lower bound, so this is no ranking of actual sizes — and
the omitted count is given; "none found" from a complete search means no matching real directory,
not that the project has no output.
There is no default size warning. Set [doctor] watched_root_warning_size to warn
per root at or above that size, partial figures included; a partial figure below
it is not compliance. The warning is not repairable and leaves exit 0, and
--repair --capacity repairs only .awa/ state: gc manages awa's records, never
project output.
What --repair will and will not do
--repair performs exactly five safe, mechanical, awa-owned fixes, each for the
findings that name it:
- restores the awa-owned
.awa/.gitignoreguard when it is missing or ineffective; - removes an orphaned temp artifact under a known
.awatemp location; - removes a lock record it proved stale — never one it cannot classify;
- invalidates the worktree index when it is unreadable or stale, so the next scan rebuilds it. The index is acceleration-only state, so dropping it loses nothing durable;
- removes the leftover files of a checkpoint publication that has no header,
after waiting out running writers and looking again. A directory with a header
of any kind, or holding anything awa does not recognize, is left whole. The
files go even if the header was lost rather than never written; stored content
stays for
awa gc.
Everything else is diagnosed and left alone, including two cases worth knowing
about before you reach for --repair expecting them. Overly broad .awa/
permissions are reported, not changed: the finding names the exact chmod to
run, because changing your filesystem permissions is your decision. And
reclaiming unreferenced records is awa help gc's job — doctor never
deletes a committed checkpoint, run, or blob.
It never touches your worktree, a run, a blob, a checkpoint with a header, or content it does not recognize, and never rewrites a corrupt record into a plausible-looking one. A finding it cannot fix safely stays reported — but only the findings the five repairs above cover are counted as repairable, so a finding doctor will never fix does not hold the exit code at 5 forever.
When to use --strict
--strict is not a doctor-local flag: it is the shorthand for the global
--trust-mode strict, which doctor honors. That is why it appears in the usage
line but not in the per-command flag table.
By default the checks trust stat signatures (size and modification time) where
they can. --strict recomputes content hashes instead. It is slower — on a large
store, substantially — and it is the right choice when you suspect a file changed
without its metadata changing, after a crash, or after copying a project between
machines or filesystems.
--repair and --strict combine: awa doctor --repair --strict diagnoses by
content and then applies the safe fixes that diagnosis found.