Skip to content

feat(acp): inject requester git email into [Context] for commit trailers#1308

Open
wpfleger96 wants to merge 2 commits into
mainfrom
duncan/agent-commit-signing
Open

feat(acp): inject requester git email into [Context] for commit trailers#1308
wpfleger96 wants to merge 2 commits into
mainfrom
duncan/agent-commit-signing

Conversation

@wpfleger96

Copy link
Copy Markdown
Collaborator

Summary

Agents currently fall back to git config user.email for commit trailers, which resolves to the repo owner's identity — not the human who triggered the turn. NIP-01 kind:0 already has a standard email field; this change stores it and surfaces it in every prompt so agents can use the correct identity.

Changes

DB migration

  • migrations/0004_user_git_email.sql: adds nullable git_email TEXT column to users table

buzz-db

  • UserProfile gains a git_email: Option<String> field
  • update_user_profile accepts an additional git_email: Option<&str> parameter; the dynamic SQL builder handles it the same way as other nullable profile fields (empty string → NULL)
  • get_user and get_user_by_nip05 SELECT the new column
  • Db::update_user_profile wrapper updated to match

buzz-relay

  • handle_kind0_profile parses the NIP-01 standard email field from kind:0 content and passes it to update_user_profile; no domain validation (unlike NIP-05) — the user is responsible for setting a valid git email
  • The NIP-05 collision retry path also forwards git_email so it is written even when the NIP-05 handle is contested

buzz-acp

  • PromptProfile gains git_email: Option<String>
  • parse_kind0_profile_lookup extracts the email field (empty strings filtered to None)
  • format_context_hints accepts sender_pubkey and profile_lookup; emits Requester-Git-Email: Name <email> when the triggering event's author has a git_email set, omits the line entirely when absent

nest_agents.md

  • "Discovering the human's identity" rule updated: prefer Requester-Git-Email: from [Context] when present; fall back to git config user.email when absent

Tests

  • test_parse_kind0_profile_lookup_extracts_email — email field parsed into git_email
  • test_parse_kind0_profile_lookup_ignores_empty_email — empty string treated as absent
  • test_format_context_hints_emits_requester_git_email_when_present — line appears in [Context]
  • test_format_context_hints_omits_requester_git_email_when_absent — line absent when no email
  • test_format_context_hints_requester_git_email_uses_nip05_as_name_fallback — name falls back to nip05_handle
  • embedded_migrator_contains_all_schema_migrations updated for migration 4

Notes

Profile UI for setting email is out of scope for this PR. Users can set it in any Nostr client via kind:0; the relay syncs it on receipt. A profile settings field can be a follow-up.

Agents currently fall back to `git config user.email` for commit trailers,
which resolves to the repo owner's identity — not the human who triggered
the turn. NIP-01 kind:0 already has a standard `email` field; this change
stores it and surfaces it in every prompt so agents can use the correct
identity.

- Add nullable `git_email` column to `users` table (migration 0004)
- Parse the NIP-01 `email` field from kind:0 events in `handle_kind0_profile`
  and store it via `update_user_profile`
- Add `git_email` to `PromptProfile`; parse it in `parse_kind0_profile_lookup`
- Emit `Requester-Git-Email: Name <email>` in `[Context]` when the triggering
  event's author has a git_email set; omit the line entirely when absent
- Update `nest_agents.md`: prefer `Requester-Git-Email:` from `[Context]`
  over `git config user.email`; fall back to git config when absent

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
@wpfleger96 wpfleger96 force-pushed the duncan/agent-commit-signing branch from 6336503 to 7d3d759 Compare June 26, 2026 17:32
@wpfleger96 wpfleger96 marked this pull request as draft June 26, 2026 17:39
Address Thufir review findings:
- side_effects.rs: document that empty string for git_email is intentional
  and that empty_to_none in the DB layer owns the "" → NULL conversion,
  consistent with display_name, avatar_url, about. Prevents future readers
  from adding a redundant filter.
- nest_agents.md: replace "verified" with "self-reported" for the
  Requester-Git-Email identity description — the email is user-asserted,
  not cryptographically verified.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
@wpfleger96 wpfleger96 marked this pull request as ready for review June 26, 2026 19:32
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