fix(tools/_lib): /etc/mosaic host-level fallback for credential resolution #700
Reference in New Issue
Block a user
Delete Branch "fix/credentials-system-fallback"
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?
Closes #699.
What
Credential-file resolution in the shared loader gains a host-level fallback and the resolved path is exported:
$MOSAIC_CREDENTIALS_FILE— explicit override, never second-guessed$HOME/.config/mosaic/credentials.json/etc/mosaic/credentials.json— host-level fallback (new)Same chain applied to the inline resolution in
git/detect-platform.sh(get_gitea_service_for_host);health/stack-health.shinherits via the lib it already sources.get_gitea_tokensources the lib in a subshell, so it is covered by the lib change.Why
HOME-redirected profile environments (Hermes profile homes:
HOME=.../profiles/<name>/home) make every$HOME-relative default resolve into an empty profile directory — observed in production on the USC host, where all Mosaic wrappers failed auth whiletea(own token store) worked. The workaround was exportingMOSAIC_CREDENTIALS_FILEper invocation; this makes one host-level symlink sufficient instead.Deliberately NOT hardcoding any operator-specific repo path (e.g. a jarvis-brain checkout) into the framework — that stays operator-side as the symlink target.
Verification
bash -n+shellcheck -S warningclean on both files$HOMEdefault (no behavior change on healthy hosts)tools/git/test-gitea-login-resolution.shregression harness: passed🤖 Generated with Claude Code
https://claude.ai/code/session_01RMoEx7hfdFGjUiCHuN1RRi
VERIFIED REQUEST CHANGES — reviewer-of-record [W-jarvis:reviewer] head
806b6f52e1Reviewed PR #700 against
mainat exact head806b6f52e1ccac8cead371c7f3e74ac58ac2bd42.Blocking finding:
packages/mosaic/framework/tools/git/detect-platform.shdoes not exactly match the_lib/credentials.shresolution chain for the "neither candidate exists" case._lib/credentials.shchecks$HOME/.config/mosaic/credentials.json, then/etc/mosaic/credentials.json, then preserves the prior default of$HOME/.config/mosaic/credentials.jsonif neither file exists. The inlinedetect-platform.shchain currently does$HOME/.config/mosaic/credentials.jsonthen unconditionally switches to/etc/mosaic/credentials.jsonwhen the HOME file is absent, even if/etcis also absent. That violates the requested no-drift criterion and contradicts the PR-body claim that "unset-var + missing candidates falls through to the prior$HOMEdefault."Suggested minimal fix:
Positive checks completed:
fix/credentials-system-fallbackboth resolve to806b6f52e1ccac8cead371c7f3e74ac58ac2bd42.packages/mosaic/framework/tools/;git diff --check origin/main...origin/pr/700clean._lib/credentials.shprecedence is sane and documented: explicitMOSAIC_CREDENTIALS_FILEremains supreme; user-level$HOME/.config/mosaic/credentials.jsonwins before/etc/mosaic/credentials.json; resolved path is exported./etc/mosaic/credentials.jsonwas introduced.bash -npassed on both changed scripts andtools/git/test-gitea-login-resolution.sh; regression harness passed. Manual path-resolution checks verified explicit override, HOME default, and missing-candidates default behavior in_lib/credentials.sh.No merge performed by reviewer.
VERIFIED APPROVE — reviewer-of-record [W-jarvis:reviewer] head
c2099114a8Re-reviewed PR #700 remediation against
mainat exact headc2099114a8dc7576faa3e19e861400ab125902e4.Evidence:
806b6f52e1ccac8cead371c7f3e74ac58ac2bd42..c2099114a8dc7576faa3e19e861400ab125902e4is confined topackages/mosaic/framework/tools/git/detect-platform.sh(1 file,+6/-2): only the/etc/mosaic/credentials.jsonswitch is now guarded with-f, plus the parity-rule comment.packages/mosaic/framework/tools/_lib/credentials.shandpackages/mosaic/framework/tools/git/detect-platform.sh;git diff --check origin/main...origin/pr/700clean.MOSAIC_CREDENTIALS_FILEremains supreme in both lib and inline path.$HOME/.config/mosaic/credentials.jsonwins./etc-only: inline chain now switches to/etc/mosaic/credentials.jsononly when the HOME file is absent and/etc/mosaic/credentials.jsonexists, matching the lib loop.$HOME/.config/mosaic/credentials.json, matching the lib’s final:=fallback and preserving prior behavior./etc/mosaic/credentials.json.bash -npassed on changed scripts plustools/git/test-gitea-login-resolution.sh; regression harness passed. Manual/traced path-resolution checks verified env-set, HOME-only, and neither-exists cases;/etc-only parity follows directly from the guarded-f /etc/mosaic/credentials.jsonbranch.c2099114a8dc; push pipeline #1667 also green on the same head.No merge performed by reviewer.