Skip to content

profile: @identity template's includes need the @, and a test reads it from the file - #574

Merged
vyskocilm merged 1 commit into
mainfrom
identity-template-include
Sep 11, 2026
Merged

vyskocilm merged 1 commit into
mainfrom
identity-template-include

Conversation

@vyskocilm

Copy link
Copy Markdown
Contributor

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 — 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; checkRef (file.go:241-263) passes a REFERENCE through as policy.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.

TestIdentityTemplateLoadsAsAUserProfile extracts the block from the EMBEDDED base.toml bytes between # TEMPLATE-BEGIN/# TEMPLATE-END, strips the leading #, 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, 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 while identityconflict_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.
  • Negative control: include line reverted to ["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.
  • End-to-end, template pasted into a real 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

…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>
@vyskocilm
vyskocilm merged commit cddfe9e into main Sep 11, 2026
5 checks passed
@vyskocilm
vyskocilm deleted the identity-template-include branch September 11, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant