google/capsem/dev-cache

Claude Code and agent skill by google/capsem

Trust tier 4
  • vendor
Source check pending

Checking that the SKILL.md file is still in the repository.

Capsem's unified cache control plane. Use for cache inventory, retention, cleanup, test reuse, or disk, Docker/Colima, Tart, Cargo, Python, Node, BuildKit, and VM asset cache work.

Install

npx vskill@latest install google/capsem/dev-cache

SKILL.md

The same SKILL.md was published earlier as google/capsem/dev-cache.

Cache Control

One authority

config/cache.toml is the only cache inventory and policy. Every independently accounted cache has exactly this common contract:

  • description: what expensive work the bytes preserve;
  • scope: disk, docker, or tart;
  • max_size_bytes: the usage ceiling that triggers enforcement;
  • warm_size_bytes: the retained target after crossing the ceiling;
  • prune_strategy: lru, generational, ephemeral, none, docker, or

tart.

Age and count fields are optional refinements. They never replace the common contract. Do not introduce storage-availability rails, warning thresholds, or a second config table. Cache decisions are based exclusively on owned usage.

This authority covers retained build and developer artifacts. Bounded runtime maps, connection pools, socket buffers and admission queues have a different lifetime: their shared capacity relationships live in config/data/runtime-limits.toml, are validated and generated by capsem-proto/build.rs, and are guarded by tests/citadel/test_runtime_limit_authority.py. Do not copy a runtime ceiling into cache code or put a runtime object cache in config/cache.toml. A runtime cache must remain bounded by the generated capacity, expose hit, miss, eviction and occupancy telemetry where those states exist, and preserve the logger DB boundary instead of caching ledger projections in a route or UI process.

The [cache] table owns every in-memory cache count and freshness window: DNS answers and positive/negative TTLs, TLS leaves, ledger query batches, SQLite prepared statements, service diagnostics and resume state, update checks, image-catalog refresh/retry and image-verification batching. Preserve their current behavior by importing capsem_proto::CACHE_*; a local literal, even when two crates currently agree, is a second authority. Add a new field, build-time validation, generated constant, benchmark runtime-limits field and Citadel consumer assertion together when a new bounded runtime cache is introduced. User overrides remain the typed-settings follow-up in issue #349.

Typed boundary

Programs use CacheRegistry, CacheRequest, CacheOperation, and CacheMutationResult from capsem_builder.cache. They select a stable cache ID and do not branch on storage mechanism or discover backend locations.

The registry owns backend dispatch:

  • DiskBackend inventories repository cache stages through CachePaths;
  • RuntimeBackend inventories and mutates Docker or Tart through their native

adapters;

  • Docker-on-Colima is still the docker cache. Colima is an implementation

detail of that backend, never a separately billed cache;

  • Docker image repositories are child cache IDs but use the same contract and

request/result types as every other owner.

A producer that must place disk bytes asks CachePaths or the gate's cachelayout.stage_path() for its configured stage. It must not reconstruct a path from repository literals, environment variables, or a backend name. A consumer that only inspects or controls a cache uses CacheRegistry and never receives its path.

A shared cache stage must not contain or be contained by a prefix export. Exports are replaceable product views; shared stages are retained authorities. Overlapping them makes a successful export erase its own receipts and traps an exact-source run in a repair loop. VM generations live in the assets cache stage, while cache/target/assets remains only the assembled runtime view.

Pinned external executables use CachedToolPolicy and materialize(). The policy declares one HTTPS URL and SHA-256 per host platform; the primitive downloads once, verifies before atomic publication, installs mode 0555, and returns a typed hit/miss result. A subsystem must not invent its own downloader or tool directory.

Short-lived results from mutable services use CleanVerdict, reusable(), and record_clean(). The subject digest covers the complete typed policy and exact input bytes. Only success is recorded; malformed, future-dated, expired, or non-matching receipts are misses. The owning cache stage supplies the maximum age, count, warm size, and maximum size.

CachePaths is loaded through load_paths(). The loader resolves the policy-owned authority_environment; a gate prefix exports that variable once so every producer sees the outer shared cache even when its output path crosses a prefix symlink. Producers never read or interpret the environment variable themselves.

With no explicit authority, load_paths() resolves a linked Git worktree to the checkout that owns the common .git directory. All branches of one local repository therefore share one cache inventory. Do not create a cache beside each worktree or pass a worktree path as implicit storage. Administrative cleanup of a retired location uses the typed CLI's explicit --repository with --policy-repository; ordinary operators stay on just cache.

All models are strict, frozen Pydantic models with extra="forbid". Keep every module at or below 300 lines and put tests in the matching test module.

Operator interface

The public entry point is just cache. These are the complete supported inspection and lifecycle commands:

bash
just cache stats # usage, warm/max contract, state, description
just cache stats --json # typed machine-readable inventory
just cache stats --offline # disk inventory without native runtime calls
just cache contract <cache-id> # the five-field common contract
just cache verify # containment and complete disk accounting
just cache prune [cache-id] # deterministic preview; defaults to all
just cache prune <id> --apply --reason "why"
just cache enforce <cache-id> --reason "why"
just cache clean <cache-id> # explicit cold-clean preview
just cache clean all --apply --reason "why"

prune follows ordinary age/count policy and only recovers to warm_size_bytes after usage crosses max_size_bytes. enforce is an applied preflight and fails if protected state prevents compliance. clean is the explicit cold operation; it still preserves active leases and protected generations.

Docker's per-repository generation retention refines the total capacity contract; it does not exempt inactive images from pressure. After ordinary reclamation, total-pressure eviction selects owned, inactive, noncurrent, unprotected images by last use until warm size is reached. Retire all owned aliases and count image bytes once; active/current/protected images retain their protection, and an unavoidable overage remains an error.

Cargo's ordinary retention selects whole compilation units under each cargo_target_roots entry: a unit's fingerprint, build output, libraries, dep-info, executables and verified signed copies share one metadata hash and are removed together, fingerprint first, least recently used first. Every gate prefix salts workspace units with its checkout path, so incremental-only retention let stale prefixes fill the stage until enforcement refused every run (issue #205). Paths Cargo does not name by unit, such as uplifted binaries, count toward capacity but are never selected.

Retention is ordered by owner, not only by clock (issue #276). The workspace wrapper links each unit's fingerprint directory to the checkout that compiled it (capsem-owner, a symlink, so reading it moves no atime and measuring never counts it). A unit whose checkout is gone is reclaimed on every prune, whatever its age. Under pressure other checkouts' units go first, then shared or unrecorded ones (third-party crates, sccache hits, units from before the link existed), and the working set -- the calling checkout (--policy-repository, the bounded command's root) and the cache authority -- last. Plain LRU made the next build of the current head cold whenever other checkouts had compiled since. The copies themselves stay: the salt cannot go until Cargo freshness is content-based, and -Zchecksum-freshness is still unstable on the pinned toolchain. Native Cargo output locks protect the whole stage and are acquired again through deletion; even an explicit cold clean preserves their lock inodes.

The Cargo maximum is held around compilation, not by any one step. Every exclusive gate command whose plan claims workspace_binaries holds CargoCacheBound (gate/cachecontrol.py), which enforces before the first step and after the last, failed runs included; run-bounded-command.py enforces before and after direct Cargo. Do not add an enforcement step to a fragment: a prerequisite of the host build left clippy, coverage and every other compile unbounded, and nothing enforced after any compile, until the target reached 237 GB against 180 GiB.

The objects store (object_store = true) is retained the same way, one generation at a time: a component receipt together with the objects no other receipt names, receipt first. An object two receipts share belongs to neither and is collected once no receipt names it; an unreferenced object (a canonicalized package or release view, whose bytes live on in the hardlinked view) is its own generation. componentcache.restore treats a missing or corrupt object as a miss, never an error, and a hit moves the receipt's clock; never touch an object's times, which are its hardlinked outputs' times. Every reader and publisher holds leases.shared_use(paths, "objects"), so a prune never removes bytes in use. Before this the stage was none, grew past its cap, and failed every prune on the machine.

A leased ephemeral stage (test-temp) is scratch, not retention: a generation lives exactly as long as a process holds its lease. The owner leases run-<pid> before creating it and, at exit, releases the lease and removes the run and its lease through operations.reclaim_generation, the same guarded, journaled path a prune takes. A run no process leases (its owner was killed) has no live owner, and prune reclaims it whatever its age or size; a lease file whose generation is gone is collected too, and never counts toward maximum_count. Removal takes each lease exclusively, so a reused pid that leased after the plan keeps its directory (ApplyResult.busy). Before this, a dead run aged like a retained generation below a 200 GiB maximum: one ~7 GB run per release precheck and 1,900 lock files filled the disk while prune offered 21 MB.

That liveness does not depend on the authority, so such a stage is swept whole (cache/namespaces.py, issue #272): every other sha256(authority)[:8] namespace's runs and leases are entries keyed <namespace>/<run> under the same lease guard, and an emptied namespace is removed with rmdir, never recursively. Only a real directory with a namespace name is entered; a symlink, a pre-namespace capsem-test-* directory, or a file that is not a run or a lease is never touched. Prune once saw only its own namespace, and about 350 retired ones held 2.4 GB.

The source-keyed Python stages (python-pycache, python-pytest) gain a generation for every Python-source state any checkout launches a gate or bounded command from, and nothing but a complete gate's package and install rails used to prune them: python-pycache reached 5.4 GB against 2 GiB. The launcher that creates a generation leases it and then enforces both stages (pythonenv.bound_source_keyed); a warm launch pays nothing.

Retained cache lifetime ends only through these typed operations. Do not add consumer-boundary releases, post-test eviction hooks, or other subsystem lifecycle paths that bypass the owner's warm/max/age/count policy.

Every applied mutation is exact, ownership-scoped, and journaled. Do not use broad docker system prune, direct Tart deletion, rm over cache roots, or backend-specific cache CLI commands. Foreign Docker/Tart resources are visible only as native totals and are never deleted by Capsem.

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 31 Oct 2026.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill CERTIFIED badge
[![vskill CERTIFIED](https://verified-skill.com/api/v1/skills/google/capsem/dev-cache/badge)](https://verified-skill.com/skills/google/capsem/dev-cache)

Something wrong with this skill or its page? Tell us.