profile: @identity template's includes need the @, and a test reads it from the file - #574
Merged
Merged
Conversation
…t from the file base.toml's @identity section carries a TEMPLATE a human is told to copy into ~/.config/snug/profiles.d/. Its include line read `["net", "git-ro"]` from ceb24ea until now, which is the spelling that cannot work there: $ snug --dry-run -p work -- true snug: unknown profile "net"; snug's own profiles carry a leading @, so you probably meant "@net" $ echo $? 77 mark (builtin.go) rewrites a builtin's own includes into the @-namespace unconditionally, so bare names are correct INSIDE base.toml; checkName refuses a leading @ in a definition while checkRef passes a REFERENCE through as written, so a user file gets no rewrite. The asymmetry is now stated above the block rather than left for the next reader to hit at runtime. TestIdentityTemplateLoadsAsAUserProfile extracts the block from the EMBEDDED base.toml bytes between two fence comments, strips the leading '#', and loads it through parse(..., trusted=true) — the call loadDir makes for a real profiles.d/*.toml — then resolves BuiltinDefaults()+work and asserts @net and @git-ro actually reached p.Profiles. Reading the bytes is the point: restating the template as a Go literal is a second copy of the text, and that is how the include line drifted with identityconflict_test.go's own "base.toml template" case already pinning the identity half beside it. Negative control: reverting the include line to the bare spelling fails the test with the exact error above; restored, it passes. make gate exit 0. Found while reviewing #454's rewritten description, which claimed this was already fixed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
base.toml's
@identitysection carries a TEMPLATE a human is told to copy into~/.config/snug/profiles.d/. Its include line read["net", "git-ro"]from ceb24ea until now — the spelling that cannot work there:mark(builtin.go) rewrites a builtin's own includes into the @-namespace unconditionally, so bare names are correct INSIDE base.toml.checkNamerefuses a leading @ in a definition;checkRef(file.go:241-263) passes a REFERENCE through aspolicy.NewProfileName(ref), so a user file gets no rewrite. Asymmetry now stated above the block instead of left for the next reader to hit at runtime.TestIdentityTemplateLoadsAsAUserProfileextracts the block from the EMBEDDED base.toml bytes between# TEMPLATE-BEGIN/# TEMPLATE-END, strips the leading#, loads it throughparse(..., trusted=true)— the callloadDirmakes for a realprofiles.d/*.toml— then resolvesBuiltinDefaults()+workand asserts@netand@git-roactually reachedp.Profiles, not merely that it parsed. Reading the bytes is the point: a Go string literal would be a second copy of the text, which is how the include line drifted whileidentityconflict_test.go's own "base.toml template" case sat beside it pinning only the identity half.No golden diff: the template is a comment, and nothing resolves it at runtime.
Verification
go test ./internal/profile/ -run TestIdentityTemplateLoadsAsAUserProfile— pass.["net", "git-ro"]→FAIL ... does not resolve: unknown profile "net"; snug's own profiles carry a leading @, so you probably meant "@net". Restored → pass.make gate— exit 0.profiles.d/: includes resolve; remaining exit 77 is the honest one,ssh_key "/home/michal/.ssh/id_ed25519.pub": ... no such file or directory— the placeholder the template says to fill in.Found reviewing #454's rewritten description, which claimed this was already fixed; that body and its comment thread now carry the measurement.
🤖 Generated with Claude Code