hermes: match --events issue_comment, not pull_request_comment

A timeline comment on a PR never reached the route. Gitea reuses the same
strings in two namespaces and they collide:

  subscription name            wire name (X-GitHub-Event)   what it is
  pull_request_comment         issue_comment                comment on a PR
  issue_comment                issue_comment                comment on an issue
  pull_request_review_comment  pull_request_comment         review on a PR

The hook's `events` array takes the subscription name; Hermes matches
--events against X-GitHub-Event, the wire name, produced by
HookEventType.Event() in modules/webhook/type.go. So --events
pull_request_comment was selecting review submissions and could never match a
comment -- the exact inversion of what it reads like.

That also explains both observed failures. The review submission matched
(wire name pull_request_comment) and reached the filter, which correctly
dropped it on action=reviewed since a PullRequestPayload carries no comment
object. The timeline comment arrived as issue_comment, matched nothing, and
was dropped by the events filter before the script ever ran.

gitea.nix and hermes-agent.nix now deliberately name the same event
differently, so both carry the table and say the other is not a typo.

issue_comment on the wire also covers comments on plain issues. The hook does
not subscribe those, and the filter's is_pull check drops them regardless, so
widening the hook later cannot leak issue comments into the agent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S94o42aQ8VkBmEWvDem5xa
This commit is contained in:
2026-08-23 08:46:31 +02:00
co-authored by Claude Opus 5
parent 6116ec4e5a
commit e75f474726
3 changed files with 46 additions and 9 deletions
+25 -6
View File
@@ -311,11 +311,30 @@ in
# exact format AND X-GitHub-Event, unconditionally, for every webhook type,
# which is precisely what Hermes validates and reads the event name from.
#
# --events pull_request_comment narrows the route to the one event the prompt
# handles; Gitea sends that value distinctly from issue_comment, so plain
# issue comments never reach the agent. A route carries exactly one prompt,
# so another event means either branching on {action} in the prompt or a
# second subscription plus a second Gitea hook at /webhooks/<name>.
# --events issue_comment, NOT pull_request_comment. Gitea uses the same
# strings in two different namespaces and they collide:
#
# subscription name wire name (X-GitHub-Event) what it is
# ----------------------- -------------------------- ----------------
# pull_request_comment issue_comment comment on a PR
# issue_comment issue_comment comment on an issue
# pull_request_review_comment pull_request_comment review on a PR
#
# The hook's `events` array (services/dev/gitea.nix) takes the SUBSCRIPTION
# name; Hermes matches --events against X-GitHub-Event, i.e. the WIRE name,
# which comes from HookEventType.Event() in modules/webhook/type.go. So
# "pull_request_comment" here would match review submissions and never a
# comment -- the exact inversion of what it reads like. X-GitHub-Event-Type
# carries the subscription name, but Hermes does not look at it.
#
# issue_comment on the wire covers comments on plain issues too; the hook
# does not subscribe those, and the filter's is_pull check drops them anyway
# if the hook is ever widened.
#
# A route carries exactly one prompt, so another event means either branching
# on {action} in the prompt or a second subscription plus a second Gitea hook
# at /webhooks/<name>. Review comments would need that: they arrive as a
# PullRequestPayload with action "reviewed" and no comment object at all.
#
# No --deliver: it defaults to `log`. The prompt tells her to answer in the
# pull request, so the PR comment IS the delivery.
@@ -380,7 +399,7 @@ in
hermes webhook subscribe gitea-pr-comments \
--secret "$GITEA_HERMES_WEBHOOK_SECRET" \
--description "Gitea PR comments -> L.U.N.A." \
--events pull_request_comment \
--events issue_comment \
--script gitea-pr-comment-filter.py \
--prompt "$prompt"
'