feat: persist to disk by default with an ephemeral opt-out #5
No reviewers
Labels
No labels
code-review
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
sam/brainless!5
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/persist-by-default"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Make disk persistence the default, with an explicit
-ephemeralopt-out, and generalize the state-directory name (sessions are not the only statebrainlesswill store).Changes
internal/harness/config.go:Config.SessionDir→StateDir.ResolveStateDir()now takes no argument and returns only the default dir —os.UserConfigDir()/brainless(linux$XDG_CONFIG_HOME/$HOME/.config, macOS~/Library/Application Support, windows%AppData%). It never echoes its input back.cmd/brainless/main.go:STATE_DIRenv /-state-dirflag; new-ephemeralflag.mainis the single place that decides ephemeral vs explicit dir vs default, and errors if-ephemeraland-state-dirare both set. Persists by default.internal/harness/harness.go:Configcarries only the resolvedStateDir(empty = in-memory); the in-memory store is allocated only whenStateDiris empty.ResolveStateDirdefault path.STATE_DIR, and-ephemeral; reconcile the Paseo how-to (--state-dir). Rebased ontomain(incl. the PR #4 docs merge).Notes
linux/arm64,darwin/arm64, andwindows/amd64(CGO_ENABLED=0).os.UserConfigDir()rather than a hand-rolled GOOS switch, so any platform that function supports works out of the box.Verified:
go build ./...,go test ./...,golangci-lint run(0 issues), and the three cross-builds.Resolved all 5 review comments (pushed as
2b6a13f):harness.Newnow only allocatessession.InMemoryService()whenStateDiris empty; otherwise it goes straight to the SQLite store (if/else, no throwaway allocation).mainnow exits with-ephemeral and -state-dir are mutually exclusive.mainno longer force-empties; it only callsResolveStateDir()whenstateDir == "" && !ephemeral.ResolveStateDir()now takes no argument and only returns the default dir; it never echoes input back.main;Configcarries only the finalStateDir(empty = in-memory) andharness.Newjust consumes it.Verified:
go build,go test ./...,golangci-lint run(0 issues),CGO_ENABLED=0build, and darwin/windows cross-builds.2b6a13f0bctofb4855101d