Skip to content

raphaelvigee/scratch driver - #403

Draft
raphaelvigee wants to merge 1 commit into
masterfrom
raphaelvigee/scratch-driver
Draft

raphaelvigee/scratch driver#403
raphaelvigee wants to merge 1 commit into
masterfrom
raphaelvigee/scratch-driver

Conversation

@raphaelvigee

Copy link
Copy Markdown
Member

Stack created with GitHub Stacks CLIGive Feedback 💬

…ctory

Adds the declaration half of scratch caching: a target kind that names a
mutable, non-hermetic directory persisting across runs, which many targets can
share. Nothing mounts, locks or stores anything yet — a declaration is inert on
its own, and the engine work that gives it meaning lands on top of this.

Declaring it as a target rather than inline at each use site is the point.
Settings live in exactly one place, so two consumers cannot disagree about a
slot's `access` or `version` — that whole class of error becomes inexpressible
rather than something to detect and report. The addr is the cache's identity, so
packages give namespacing for free (`//go:cache` and `//rust:cache` need no
agreed prefix convention) along with visibility and `heph query revdeps`.

It is a builtin driver shaped exactly like `plugingroup`, so no new Starlark
global is introduced: `target(driver = "scratch", …)` is the surface, and
`#[derive(Spec)]` supplies both the parser and the BUILD-file LSP schema.

Two settings are author assertions heph cannot check, and both are documented as
such with conservative defaults:

- `access = "shared"` says the tool is safe under concurrent access. Go's build
  cache is the motivating case — forcing it exclusive would serialize a whole Go
  build. Defaults to `exclusive`.
- `platform = "any"` says the contents are portable, which lets one slot serve
  every machine. It asserts two things, not one: no host dependence *and* no
  embedded absolute paths. Defaults to `os_arch`, because restoring a
  host-specific cache onto the wrong host is the one mistake here that is not
  merely slow.

Mount-path validation lives on the declaration rather than at each use, so a bad
path is reported once at its source. A mount is a symlink out of the sandbox, so
absolute and `..`-escaping paths are rejected; so is mounting at the workspace
root, which would replace the consumer's whole tree.

Design doc: docs/SCRATCH.md.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FArWjycMDyWeSfHHtpgtoU
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.

1 participant