Documentation
¶
Overview ¶
Package home resolves the one directory codeaf owns: its state root.
Everything durable the resident keeps — the journal, the workspace, the CAS, the craft repo, measured profiles, the model catalog, the router ledger, the promoted skills shelf — lives under a single directory so that "where does codeaf keep my things" has exactly one answer. That answer is ~/.codeaf, and CODEAF_HOME moves it wholesale.
The override exists for the same reason the directory exists: a disposable run — the UX suite driving the real binary, a second brain on the same laptop, a sandbox — must be able to move every file codeaf writes without moving the user's HOME, and without a per-file flag for each of them. Narrow overrides that already exist (chat --db, CODEAF_PROFILE_DIR) still win where they apply; this only changes the default they fall back to.
Index ¶
Constants ¶
const EnvVar = "CODEAF_HOME"
EnvVar names the override. It is exported so help text and doctor output can say the same word the code reads.
Variables ¶
This section is empty.
Functions ¶
func Adopt ¶
func Adopt(logf Logf)
Adopt moves an untouched legacy state root to the current name once. It is a boot operation, not root resolution: the real binary calls it from main, and the testing guard makes an accidental library call harmless in test binaries.
func Contains ¶
Contains reports whether path is the directory root or something under it. It is here because "is this file inside that root" is the state root's own question, and it is asked by the packages that refuse to touch the state of whoever started a test binary — internal/lane's, today; internal/calllog still carries a private copy of this from #352, and should adopt this one, so that the same omission cannot be a defect in one place and not the other.
It compares by path elements rather than by string prefix, so a sibling named like the root — /state/root-2 beside /state/root — is not mistaken for a child of it. An empty root contains nothing, which is what "the environment named no root" has to mean.
func DefaultUnder ¶
DefaultUnder is the state root a login whose home directory is base gets when CODEAF_HOME says nothing. It is exported for the one caller that has to name it for a login it is not resolving from the environment — a background timer written before its definition carried a home ticked exactly this — so the directory's name stays spelled in one place.
func Dir ¶
func Dir() string
Dir is the state root. It is CODEAF_HOME when set, ~/.codeaf otherwise, and a bare relative ".codeaf" in the pathological case of a process with no home directory at all — the same last resort the callers used before, kept so a missing HOME degrades to a working directory instead of an error path that no caller was written to handle.
Inside a test binary it is that answer unless the answer is the root the process was handed rather than one the test chose, in which case it is a throwaway directory of this process's own. See undertest.go: a test may not resolve the state of whoever ran it. Outside a test binary the gate is not there at all and this is [resolve] exactly as it has always been.
func InheritedDir ¶
func InheritedDir() string
InheritedDir is the state root this process was started with, ungated.
It exists for the two callers that genuinely want the person's own root and are themselves tests: `internal/session`'s guard, which counts the files under the real journal trees to catch a path resolved from somewhere clever, and the e2e harness, which copies the person's provider credentials out of their real config.json before putting a throwaway home in front of the binary. Anything that is not a guard or a credential read wants Dir.
func StoreDir ¶
StoreDir names one of a store's own directories — the workspace its jobs write into, the scratch they spill into — beside the store file.
It is keyed to the STORE and not to the store's directory, which is the whole point. `--db` is a narrow override that moves the journal without moving the state root, so two stores pointed at one folder used to share one `workspace` underneath it: four probe databases in /tmp all wrote into /tmp/workspace, and each run's deliverables landed among the others' with nothing on disk saying which brain produced which file. A directory named after the store can only ever hold one store's work.