Repository navigation
feat(metal-agent): default the model store and state dir under XDG_DATA_HOME off macOS - #2528
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…TA_HOME off macOS Off macOS the model store and state directory default to $XDG_DATA_HOME/llmkube/models and $XDG_DATA_HOME/llmkube/metal-agent, or ~/.local/share/llmkube/... when XDG_DATA_HOME is unset or not absolute. macOS keeps ~/Library/Application Support/llmkube. The lookup lives in a new leaf package, pkg/datadir. The foreman-agent's self-update install root uses it too, replacing its per-OS files, so a relative XDG_DATA_HOME is now ignored there as well instead of giving a path relative to the working directory. The default-path tests pin concrete paths per OS, and pkg/agent's TestMain unsets XDG_DATA_HOME so no test writes under the developer's data directory. stop-engines logs the state directory it resolved, as stateDir next to engineRecords (formerly records), and the agent's engine records startup line carries stateDir too, so the two can be compared when their environments differ. Flag help and the macOS README give both defaults. The model cache slot refusal, the legacy direct endpoints warning and a test comment say "host" instead of "Mac". Fixes defilantech#2519 Signed-off-by: Christian Nuss <cnuss@users.noreply.github.com>
cnuss
force-pushed
the
split/2519-xdg-default-paths
branch
from
November 13, 2026 03:12
70e7053 to
dfaf02a
Compare
Collaborator
Author
|
Addressed review findings in the squashed commit (dfaf02a):
|
Defilan
approved these changes
Nov 13, 2026
Defilan
left a comment
Member
There was a problem hiding this comment.
macOS resolves exactly as before, a relative XDG_DATA_HOME is ignored in all three callers, and ResolveInstallRoot still errors when it has no absolute root. llmkube metal join keeping the macOS path is fine while join refuses non-darwin hosts.
Small doc nits, none blocking:
pkg/agent/agent.goaround line 287: theStateDircomment still names only the macOS default.pkg/selfupdate/updater.goaround line 70: theInstallRootfield comment omits theXDG_DATA_HOMErule thatResolveInstallRoot's doc now states.cmd/metal-agent/stopengines.go: the--state-dirhelp drops the~/.local/share/llmkube/metal-agentfallback the agent's two help strings give.
Collaborator
Author
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Off macOS, the agent's model store and state directory now default to
$XDG_DATA_HOME/llmkube/modelsand$XDG_DATA_HOME/llmkube/metal-agent. WhenXDG_DATA_HOMEis unset or not an absolute path, the defaults are~/.local/share/llmkube/modelsand~/.local/share/llmkube/metal-agent. macOS keeps~/Library/Application Support/llmkube/....datadir.Dir(home)inpkg/datadir.resolveModelStorePath(cmd/metal-agent/main.go),resolveStateDir(pkg/agent/ingress_wiring.go) andselfupdate.ResolveInstallRoot(the foreman-agent install root) all use it, which replaces selfupdate's per-OSinstall_root_*.gofiles. A relativeXDG_DATA_HOMEused to give the foreman-agent a relative install root; it is now ignored there too (see Miscellaneous fixes).stop-engineslogs the state directory it resolved (stateDironstopping recorded engines, next toengineRecords, which replaces that line'srecordsfield), and the agent'sengine records directorystartup line also carriesstateDir. If the two run with different environments, comparing the lines shows whether they resolved different directories. The README's stop-engines section says so.--model-store,--state-dirandstop-engines --state-dirnow lists both defaults.deployment/macos/README.md: the--state-dirrow in the flag table and the "Model store" section now give the default used off macOS as well.--model-storeand--state-dirstill override the defaults. The ownership and world-writable checks on the store are unchanged.Why
Both defaults were hard-coded to
~/Library/Application Support. On Linux that creates aLibrarydirectory in the user's home, which no Linux tool expects. This is part of #2481. #2520 and #2525 build on it.Fixes #2519
How
dir(goos, home, xdgDataHome)holds the logic, anddatadir.Dircalls it withruntime.GOOSand$XDG_DATA_HOME. A relativeXDG_DATA_HOMEis ignored, as the XDG Base Directory spec requires.TestDirPerOSis a table test covering darwin, Linux withoutXDG_DATA_HOME, Linux with an absolute one, and Linux with a relative one.TestDefaultStateDir,TestResolveModelStorePathandTestResolveInstallRootpin concrete paths for eachruntime.GOOS, withXDG_DATA_HOMEboth unset and set.pkg/agent'sTestMainunsetsXDG_DATA_HOMEnext to its temporaryHOME, so no test writes under the real data directory.The issue's open question stays open: this PR puts the state directory, which holds the ingress TLS key, under
$XDG_DATA_HOMErather than$XDG_STATE_HOME.What I ran:
make gate BASE_REF=origin/mainon the final commit: every step passed.GOOS=linux bin/golangci-lint run ./...andGOOS=darwin bin/golangci-lint run ./...: 0 issues.make lint-deadcodeandGOOS=linux make lint-deadcode: 0 issues.golang:1.27.4container, both withXDG_DATA_HOMEunset and withXDG_DATA_HOME=/xdg.pkg/datadir,pkg/selfupdateandcmd/metal-agentpassed in both runs, and so didTestDefaultStateDirand theTestRunStopEnginestests inpkg/agent. WithXDG_DATA_HOMEpointed at an empty directory, the fullpkg/agentsuite wrote nothing there. (Four envtest tests could not start in that container because the mountedbin/holds a darwin etcd; they pass in the gate.)Assisted-by: Claude Code (Claude Opus 5.5) split this out of #2482, wrote the description and ran the checks above in my session.
Miscellaneous fixes
selfupdate.ResolveInstallRoot(foreman-agent) now ignores a relativeXDG_DATA_HOMEper the XDG spec and falls back to~/.local/share/llmkube/<binary>. Before, a relative value gave an install root relative to the working directory. Only applies when--install-rootis unset.--legacy-direct-endpointswarning ("anyone who can reach this host ..."), and a test comment inexecutor_sha256_test.go.Checklist
make testpasses locallymake lintpasses locallygit commit -s) per DCO