NIP-OA: owner mapping never materialized for direct relay members — kind:44200 turn metrics rejected with 403
Summary
When an agent connects with a valid NIP-OA auth tag (BUZZ_AUTH_TAG via buzz-acp) but is also a direct relay member, the agent→owner mapping is never materialized — so the agent's kind:44200 (agent-turn-metric, NIP-AM) events are rejected with HTTP 403, breaking the turn pipeline. Removing the tag restores it. Net effect: opting a direct-member agent into NIP-OA makes it worse off.
Environment
Self-hosted relay (compose bundle, ghcr.io/block/buzz:main), BUZZ_REQUIRE_RELAY_MEMBERSHIP=true, BUZZ_ALLOW_NIP_OA_AUTH=true. Agent runs headless via buzz-acp with BUZZ_AUTH_TAG (empty conditions string; tag verified against the test vectors in docs/nips/NIP-OA.md, and buzz-acp logs owner resolved from BUZZ_AUTH_TAG: <owner>).
What happens (read-only trace of main, 2026-08-30)
- buzz-acp sends
x-auth-tagon HTTP bridge requests (crates/buzz-acp/src/relay.rs~L405) and embeds the tag in the WS AUTH event. check_relay_membership(crates/buzz-relay/src/api/mod.rs) returnsMembershipDecision::Memberfor the agent before inspecting the auth tag — the NIP-OA branch only runs when the caller is not a direct member.materialize_nip_oa_owneris only invoked on theViaOwnerpath (e.g.crates/buzz-relay/src/handlers/auth.rs), so for a direct-member agentusers.agent_owner_pubkeyis never set.- The agent's turn metric then fails the ownership check in
crates/buzz-relay/src/handlers/ingest.rs(if kind_u32 == KIND_AGENT_TURN_METRIC→is_agent_owner→AuthFailed: "restricted: agent-turn-metric \p` tag must be the registered owner of this agent"), surfaced as 403accepted:falseviaapi/bridge.rs`.
The divergence looks related to the "deliberate Phase-1 asymmetry" comment near the moderation-restriction check in ingest.rs.
Expected
A cryptographically valid auth tag should materialize the agent→owner mapping regardless of how membership was satisfied — direct membership and ViaOwner delegation shouldn't diverge in owner registration.
Suggested fix
In the auth paths, when a valid auth tag is present, call materialize_nip_oa_owner even when membership resolves as Member. Alternatively, let the kind:44200 ownership check fall back to verifying the self-proving auth tag on the event/connection.
Workaround (untested, for the record)
Temporarily remove the agent from the relay roster so its next connection is admitted ViaOwner (which materializes the first-write-wins mapping), then re-add it. Non-obvious and racy for operators.
Follow-up with a more severe side effect found while testing the workaround on the same setup:
When the agent→owner mapping IS materialized (users.agent_owner_pubkey set), the agent's chat messages stop being published entirely.
Timeline on a self-hosted relay (main image, buzz-acp agent, Claude harness):
- Baseline (no mapping, no auth tag): agent replies normally. Its
kind:44200turn metrics are silently rejected with 403 (the asymmetry reported above) — chronic but harmless. - Applied the roster workaround (remove from roster → reconnect with valid
BUZZ_AUTH_TAG→ViaOwneradmission materializes the mapping → re-add to roster). Confirmedusers.agent_owner_pubkeyset in Postgres, andkind:44200now accepted. - From that point on, the agent goes silent in channels: on @mention it publishes 👀/💬 reactions (kind 7), their deletions (kind 5) and the turn metric (44200) — but never the kind:9 chat message. The ACP harness transcript proves the model DID generate the reply text. No rejection appears anywhere in relay logs (bridge shows only accepted events; nothing on WS). A manual
kind:9publish via buzz-cli with the same agent key is accepted, so the relay accepts the kind — the suppression happens in the publishing path only when the mapping exists. - Full stack restart (fresh containers, fresh caches) did not help. Clearing the mapping (
UPDATE users SET agent_owner_pubkey = NULLfor the agent) + restart immediately restored normal chat replies. Reproduced across multiple turns both ways.
Net: for direct-member agents, the materialized NIP-OA mapping currently trades "metrics rejected" for "chat dead". Until that's understood, operators should probably avoid materializing the mapping on this path.
Another data point on the workaround, and specifically on the "chat goes dead" follow-up above — the difference appears to be step 2's re-add to the roster.
We ran the same migration on a self-hosted closed relay (BUZZ_REQUIRE_RELAY_MEMBERSHIP=true, BUZZ_ALLOW_NIP_OA_AUTH=true, relay and buzz-acp both built from 779af88) for 8 headless buzz-acp agents, but left the agents out of relay_members permanently — only the owner stays a member, and every agent is admitted purely via MembershipDecision::ViaOwner.
Result so far:
users.agent_owner_pubkeymaterialized for all 8.kind:44200accepted (first one in three weeks).kind:9chat still published normally by an agent with the mapping set — confirmed ineventsfor one agent that took a turn after the switch. Not yet exercised on the other seven, so that part is n=1.
So the suppression in the follow-up may be tied to the mapping plus direct roster membership, not to the mapping alone. If that holds, "remove from roster and leave it removed" is a better workaround than "remove, materialize, re-add".
On the root cause, the short-circuit is exactly where #6072 points — check_relay_membership (crates/buzz-relay/src/api/mod.rs) returns MembershipDecision::Member before the NIP-OA branch is reached, and the backfill in handlers/auth.rs is gated on !require_relay_membership, so on a closed relay neither path runs for a direct member.
One operational trap worth writing down for anyone applying the workaround: BUZZ_AUTH_TAG is JSON, so how you store it matters. systemd EnvironmentFile copes with the bare value, but a shell source of the same file strips the inner double quotes and the harness then logs BUZZ_AUTH_TAG verification failed: invalid input: invalid JSON and silently falls back to unauthenticated. Single-quoting the value survives both.
Another data point for the "leave it out of relay_members" workaround, plus what came after it on the desktop side.
Setup: self-hosted closed relay at 40220d5 (v0.2.1). Three agents: two headless buzz-acp under systemd, and one agent connected through a different harness's Buzz channel plugin (not buzz-acp). All three had been enrolled with buzz-admin add-member. Owner tags minted with empty conditions, verified against the NIP-OA vectors, and read back intact from each running process's environment.
Relay side — matches #6072 and polcar's report. With the tag delivered and the agents still in relay_members, users.agent_owner_pubkey stayed NULL for all three. After remove-member plus a restart, each was admitted via ViaOwner with no refusals, and the mapping materialized. We did it one agent at a time, checking each before the next, since a bad tag would have locked it out. The agents stay out of relay_members permanently; only the humans are direct members.
After the mapping: the buzz-acp agents' kind:44200 turn metrics are now accepted (200), which is the symptom this issue was opened for. The plugin-based agent replies normally to mentions.
Desktop side — two further steps before the agents looked like agents, both invisible from the relay:
- The desktop decides "agent" from the agent's latest
kind:0carrying exactly one valid auth tag (profile_valid_oa_owner_pubkey), not from the relay mapping. Ours predated the tag, so all three still showed as people until the profile was republished with it (#5492). - Once they were agents, they stopped being mentionable:
getAgentMentionAdmissionadmits an agent only if a verified ownerkind:30177policy'srespond_toincludes the viewer. Desktop-created agents get one automatically; hand-provisioned ones don't. Channel re-adds asbotgo through the mention flow, so those were blocked too until the policies existed.
So for a hand-provisioned agent on a closed relay, the full path was: tag → out of relay_members → profile with tag → owner policy → re-add to channels (they come back as bot). We've written up a feature request for doing the owner-side steps from the desktop: #8012.