Auto-init guard: consult merged global+local .hx config#271
Draft
half-ogre wants to merge 2 commits into
Draft
Conversation
Adds failing tests for the cases described in #270: a complete global ~/.hx alone, and global+local merging to a complete config, should both satisfy the auto-init guard. Today both fall through to runInitApp.
Closes #270. The guard added in #267 read only ./.hx via RestoreLocalConfig, so a complete global ~/.hx was treated as missing. That triggered runInitApp, which then failed when the runtime user didn't own CWD (the shipped hyphen-entrypoint.sh's exact scenario in non-root containers). Extract the merge that RestoreConfigFromFile already does into RestoreMergedConfig(file) (Config, bool, error) and have the guard call it. Rename HasCompleteLocalAppConfig -> HasCompleteAppConfig and NeedsLocalAppConfig -> NeedsAppConfig to reflect that the check is no longer local-only. Drop "local" from the guidance message for the same reason; hx init still creates a local .hx, so the suggested remediation is unchanged. Also tighten test isolation: withTempDir now also redirects $HOME to a separate temp dir, so the guard's global-config check doesn't pick up the developer's real ~/.hx during local test runs.
There was a problem hiding this comment.
Code Review
This pull request refactors the configuration validation logic to support merged global and local configurations. It introduces RestoreMergedConfig to read and merge global (~/.hx) and local (./.hx) configs, and updates the auto-initialization guards to check this merged configuration instead of only the local one. Corresponding tests have been updated and expanded to cover these changes. There are no review comments to address, so I have no additional feedback to provide.
osbornm
approved these changes
May 26, 2026
Contributor
Author
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.
Closes #270.
Summary
The auto-init guard added in #267 reads only
./.hxviaRestoreLocalConfig, so a complete global~/.hxis treated asmissing. That triggers
runInitApp, which then fails when the runtimeuser doesn't own CWD — the shipped
cmd/entrypoint/hyphen-entrypoint.shhits this on every cold start in any non-root container.
This PR extracts the merge that
RestoreConfigFromFilealready doesinto
RestoreMergedConfig(file) (Config, bool, error)and has theguard call it. The guard now passes whenever the resolved (merged)
config is complete, matching what the guarded commands themselves see.
HasCompleteLocalAppConfigis renamed toHasCompleteAppConfigandNeedsLocalAppConfigtoNeedsAppConfigto reflect that the check isno longer local-only. The "local" qualifier is also dropped from the
guidance message;
hx initstill creates a local.hx, so thesuggested remediation is unchanged.
Test isolation
cmd/autoinit/autoinit_test.gopreviously isolated only CWD, whichworked while the guard was local-only. Now that the guard reads global,
withTempDiralso redirects$HOME(andUSERPROFILE) to a separatetemp dir so tests can't pick up the developer's real
~/.hx. Themissing-coverage gap that let #270 ship is closed by three new
subtests: global-only complete, global+local merging to complete, and
Ensurepassing through when global is complete.Validation
go test ./cmd/autoinit/— passgo test ./...— pass excepttests/acceptance/TestCLIExitCodes,which fails identically on
main(it expects an unauthenticatedenvironment; a logged-in
hxsession makes the call succeed)