Skip to content

scratch

scratch #

The scratch: a garbage-collected, content-addressed store of directory trees.

A scratch is five ideas and nothing else. Objects are immutable trees under objects/<hash>, named by their own merkle hash. Names point at them, and outlive what they pointed at. A pin is one living process's hold on an object, and nothing held is ever evicted. A lock admits one writer at a time — one per call being computed, one per state being written, one per machine-wide resource in use. A running row says which call a living process is computing right now, and where. It knows nothing about types: everything above hands it trees.

  • [.root][] — Scratch, one process's handle on a scratch root, and the layout on disk.
  • [.configure][] / [.temporary][] — the process-global scratch: an explicit path, else CG_SCRATCH; or a throwaway one scoped to a block.
  • [.settings][] — the size budget, kept in settings.toml.
  • [.errors][] — RecipeError and its kinds.
  • [.fs][] — the filesystem facts the store reasons with.
  • [.hashing][] — content identity: what a tree is.
  • [.index][] — the SQLite bookkeeping: what exists, what is named, what is held, what is running.
  • [.store][] — how trees move through the store, what keeps them there, and ([.store.memo][]) what the store has for one call key.

This package is the cg.scratch namespace, and the names below are its surface.