Skip to content

Fold gc --all into --cache all - #144

Merged
janicduplessis merged 2 commits into
mainfrom
@janic/cache-all
Aug 31, 2026
Merged

Fold gc --all into --cache all#144
janicduplessis merged 2 commits into
mainfrom
@janic/cache-all

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Closes #143.

Description

--all named a scope but set a depth. It meant "empty the cache whole rather than trim it by age", and it reached caches only, never devices or project entries. Beside --cache, which does name a scope, the two read as if they contradict each other:

gc --delete --all --cache "compilation cache"

Solution

--cache carries the scope, with all as the reserved name for every cache:

gc --delete --cache all                   empty every cache whole
gc --delete --cache "compilation cache"   empty the matching caches whole
gc --delete --cache all --older-than 30   trim those entries by age
gc --delete                               caches untouched

Emptying whole is what --cache does, since that is what naming a cache asks for, and --older-than still asks for trimming. all is matched before the substring search, so a declared cache directory carrying install cannot answer to --cache all.

collectGcReport derives "empty whole" from the same rule the CLI uses, so the internal API cannot disagree with the flags.

Behavior change

gc --delete --all emptied every cache and reaped devices, dead project entries and stale locks. gc --delete --cache all empties caches and inspects nothing else; the reaping stays with bare gc --delete. Running both is two commands now, and each does one thing.

This split is what keeps the compilation-cache remedy safe: a user recovering a broken build runs gc --delete --cache "compilation cache", and that must not also delete their simulators.

One flag combination also inverts. gc --delete --all --older-than 30 emptied, because the old --all branch ran ahead of the trim branch. gc --delete --cache all --older-than 30 trims, which is what asking for an age filter should mean.

A bare gc --delete still leaves every cache alone, which is the property that separates the safe tier from the destructive one in skill/SKILL.md and docs/field-test-protocol.md.

Risk

--all is removed rather than deprecated, so a script carrying it now fails with unknown option '--all' instead of doing something different quietly. The CLI is pre-1.0 and the flag is documented only in this repo.

Test plan

  • gc --cache all reports every cache and states that devices and project entries were not inspected
  • gc --all exits with unknown option '--all'
  • gc alone still reports without touching caches
  • selectCaches covers all, its case-insensitivity, and a /opt/install/cache directory that must not answer to it
  • guide cleanup and guide settings print --cache all, and the guide contract test now fails if a retired flag reappears in any topic (verified by reintroducing the old text)

`--all` named a scope but set a depth: it meant "empty whole rather than trim
by age", and it reached caches only. Next to `--cache`, which does name a
scope, the pair read as a contradiction.

`--cache` now carries both, with `all` as the reserved name for every cache.
Emptying whole is what `--cache` does, because that is what naming a cache
asks for, and `--older-than <days>` still asks for trimming instead. `all` is
matched before the substring search, so a directory carrying `install` cannot
answer to it.

A bare `gc --delete` still leaves every cache alone, which is the property
that separates the safe tier from the destructive one.

`gc --delete --cache all` empties every cache and inspects nothing else, so
the reaping that `gc --delete --all` also performed stays with bare
`gc --delete`. Each command now does one thing.

Closes #143
The `cleanup` and `settings` guide topics and the website command reference
still told the reader to run `gc --delete --all`, which now exits with
`unknown option`. The website had never documented `--cache` at all.

The guide contract test only asserted that advertised flags are present, so a
flag a command no longer defines could stay in a topic. Assert the retired
flag is absent from the command source and from every rendered topic.

Normalize a blank cache name once in each entry point. A blank-but-present
name selected every cache while marking them emptied, so the internal API
could disagree with the flags even though the CLI rejects the value.

`gc --delete --cache all` empties caches and inspects nothing else, so
SKILL.md no longer describes it as also reaping.
@janicduplessis
janicduplessis marked this pull request as ready for review August 31, 2026 20:42
@janicduplessis
janicduplessis merged commit 8e4eee1 into main Aug 31, 2026
7 of 8 checks passed
@janicduplessis
janicduplessis deleted the @janic/cache-all branch August 31, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gc --all names a scope but sets a depth, and now reads as a contradiction next to --cache

1 participant