cachedir

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cachedir owns the one directory under codeaf's state root that holds nothing but caches: ~/.codeaf/cache, where every task worker's toolchain caches live (internal/exec's sweCacheRoot puts go-mod, go-build, cargo, npm and pip under it).

The package exists so that "delete the cache" is one verb with one blast radius, written down once. Everything in this directory is re-downloadable by construction — a module cache is content-addressed, a build cache is derived — so deleting it costs cold builds and nothing else. What it must NEVER touch is everything beside it under the state root: the journal, the CAS, the v3 session files, the config and the credentials are a person's own things, and a "cache clean" that reached them would be data loss wearing a janitor's name. Both surfaces that offer the verb — `codeaf cache clean` and the chat's /cache clean — call in here rather than spelling a path of their own, so the radius cannot drift between them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean() (int64, error)

Clean deletes the cache directory whole and reports how many bytes that freed. A cache that is already absent is zero bytes freed and no error.

The chmod walk first is not decoration: Go's module cache is written read-only, directories included, precisely so nothing edits a module in place — and a read-only directory is one os.RemoveAll cannot empty. Owner write is added back onto every directory before the removal, and a chmod that fails is skipped rather than fatal, because the removal itself is about to say definitively whether the tree could be taken down.

func Human

func Human(size int64) string

Human is the byte figure as a person reads it: whole bytes under a kilobyte, one decimal above, stepping through KB, MB and GB. One formatter shared by both surfaces, so the CLI's answer and the chat's answer to "how big" can never disagree about what 514 MB is called.

func Root

func Root() string

Root is the cache directory itself. It is the parent of exec's toolchain root on purpose: anything a future lane files under cache/ is cache by address, and this verb reaps it without being taught its name.

func Size

func Size() int64

Size is how many bytes the cache holds right now. A cache that does not exist, or a corner of it that cannot be read, counts as zero — this figure decides what a person is told they would free, and the honest answer to an unreadable entry is to promise less rather than fail the question.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL