Documentation

Events

An agent receives an event when one of its receives rules matches it. The rule keys are in Agent definition. Subject kinds and their fields are in Data model.

Event names

An event type is <source>/<name>. Hydra's own events print with no source prefix, such as issue/updated. Every other source's events carry the prefix, such as github/pr/merged.

A rule's event key takes an event type or a glob. * matches any run of characters, including /. issue/* matches every issue event.

How a session sees an event

A session gets each matched event in one of two forms.

The created, updated and deleted events of Hydra's kinds issue, patch, document, label, session and board arrive as a summary. The summary names the node, the change and who made it, such as "Issue i-abcdef was updated by alice:". An update lists each field that changed. Long text, such as an issue description, does not print. Several updates of one node in one turn arrive as one summary.

Every other event arrives as a line that names the event type and its subject, followed by a JSON block with these fields:

FieldContents
typeThe event type, such as github/pr/merged.
subjectThe id of the node the event is on, or null when the event has no subject.
actorThe user, agent or integration that caused the event.
dataThe event's data. The tables below list the data fields for each event type.

Event fields in expressions

A rule's where reads the event as event. Only a receives rule's where can use it. The syntax is in Expression language.

FieldTypePresentContents
event.idStringalwaysThe event's id.
event.seqIntalwaysThe event's position in the organization's event stream.
event.typeStringalwaysThe event type.
event.sourceStringalwaysThe source, such as hydra, github or engine.
event.timeStringalwaysThe time the event happened, in RFC 3339 format.
event.caused_byOption[String]alwaysThe id of the event that caused this one.
event.subjectthe subject kindwhen every event type the rule matches has a subjectThe subject node with all its fields.
event.oldOption[ the subject kind ]when every event type the rule matches is a node eventThe subject node as it was before the change.
event.datarecordalwaysThe event's data fields.
  • When the matched event types have subjects of several kinds, event.subject has the fields those kinds share.
  • On a <kind>/created or <kind>/updated event, event.subject is the node after the change. On <kind>/deleted, it is the node before the delete.
  • event.old is None on <kind>/created.
  • event.data has typed fields only when the rule matches exactly one event type. A relation event has the data fields from, rel and to. The node events have no event.data fields in expressions. Read event.subject and event.old instead.
  • Expressions cannot read event.actor.
agents:
  reviewer:
    prompts: [/agents/reviewer/prompt.md]
    runs_when:
      review:
        lives_on: issue
        where: self.status == "review"
        mode: headless
        receives:
          - event: issue/updated
            where: event.subject.id == self.id && event.old.exists(o => o.status != event.subject.status)
          - event: issue/commented
            where: event.subject.id == self.id && event.data.sequence > 1
          - event: relation/created
            where: event.subject.id == self.id && event.data.rel == "has-patch"

Node events

Every node kind of every source sends three events. The subject is the node.

EventSubjectData fieldsSent when
<kind>/created<kind>old: null, new: the node's fieldsA node is created, or an archived Hydra node is unarchived.
<kind>/updated<kind>old: the fields before, new: the fields afterA node's fields change. Hydra sends no event for a write that leaves every field unchanged.
<kind>/deleted<kind>old: the node's fields, new: nullA node is deleted, or a Hydra node is archived.

The node kinds are listed under each source below. An integration's first import of a source's existing nodes sends no events.

Relation events

Every relation of every source sends these events. Both carry the Hydra event name with no prefix.

EventSubjectData fieldsSent when
relation/createdthe from nodefrom: String, rel: an enum of the relation types, to: StringA relation is added.
relation/deletedthe from nodefrom: String, rel: an enum of the relation types, to: StringA relation is removed.

from and to are node ids. rel is the relation type. A relation type of another source keeps its prefix, such as github/for-issue. A node id of another source keeps its prefix, such as github/acme/web#42.

Hydra

Hydra has the node kinds issue, patch, document, session, board and label. Each kind sends the node events, such as issue/updated, patch/updated and session/created.

The relation/created and relation/deleted events use the relation types in Hydra relations.

Hydra also sends these events:

EventSubjectData fieldsSent when
issue/commentedissuebody: String, sequence: Int, issue_id: String, org_id: String, created_at: StringSomeone adds a comment to the issue. sequence starts at 1 on each issue.

GitHub

GitHub has the node kinds github/pr, github/check-run, github/user, github/review and github/status. Each kind sends the node events, such as github/pr/updated.

The relation/created and relation/deleted events use these relation types:

RelationFromTo
github/check-ofgithub/check-rungithub/pr
github/authored-bygithub/prgithub/user
github/review-ofgithub/reviewgithub/pr
github/reviewed-bygithub/reviewgithub/user
github/status-ofgithub/statusgithub/pr
github/for-issuegithub/prissue

GitHub also sends these events:

EventSubjectData fieldsSent when
github/pr/mergedgithub/prrepo: String, number: IntThe pull request is merged.
github/pr/closedgithub/prrepo: String, number: IntThe pull request is closed without a merge.
github/ci/failedgithub/prrepo: String, number: Int, head_sha: StringA check run on the head commit fails.
github/ci/succeededgithub/prrepo: String, number: Int, head_sha: StringEvery check run on the head commit has finished and none failed.
github/review/submittedgithub/prrepo: String, number: Int, author: Option[String], state: String, url: StringSomeone submits a review.
github/comment/postedgithub/prrepo: String, number: Int, author: Option[String], url: StringSomeone posts a comment or a review comment on the pull request.

repo is owner/name. author is the GitHub login. state is the review state in lowercase, such as approved, changes_requested or commented. The PR and CI events go out once per change of the stored pull request.

Linear

Linear has the node kinds linear/issue, linear/project, linear/comment, linear/user, linear/workflow-state and linear/project-status. Each kind sends the node events, such as linear/issue/updated.

The relation/created and relation/deleted events use these relation types:

RelationFromTo
linear/comment-onlinear/commentlinear/issue
linear/in-projectlinear/issuelinear/project
linear/child-oflinear/issuelinear/issue
linear/assigned-tolinear/issuelinear/user
linear/created-bylinear/issuelinear/user
linear/in-statelinear/issuelinear/workflow-state
linear/led-bylinear/projectlinear/user
linear/has-statuslinear/projectlinear/project-status
linear/authored-bylinear/commentlinear/user

Linear also sends these events:

EventSubjectSent when
linear/issue/openedlinear/issueSomeone creates an issue in Linear.
linear/issue/state-changedlinear/issueThe issue's workflow state changes.
linear/issue/assignedlinear/issueThe issue gets a new assignee. Removing the assignee sends no event.
linear/comment/postedlinear/commentSomeone posts a new comment.
linear/project/state-changedlinear/projectThe project's status changes.

These Linear events have the following data fields:

EventFieldType
linear/issue/openedidentifierString
titleString
urlString
teamString
linear/issue/state-changedidentifierString
old_stateString
old_state_typeString
new_stateString
new_state_typeString
linear/issue/assignedidentifierString
old_assigneeOption[String]
old_assignee_idOption[String]
new_assigneeString
new_assignee_idString
linear/comment/postedissueString
authorOption[String]
linear/project/state-changednameString
old_stateString
new_stateString

identifier is the issue's Linear key. issue is the node id of the commented issue, such as linear/<uuid>. author is null for a comment from a bot other than Hydra's app.

Grafana

Grafana has one node kind, grafana/alert. It sends the node events, such as grafana/alert/updated. Grafana has no relation types.

EventSubjectData fieldsSent when
grafana/alert/firinggrafana/alertThe table below lists them.The alert's stored status changes to firing.
grafana/alert/resolvedgrafana/alertThe table below lists them.The alert's stored status changes to resolved.

Both events have the same data fields:

FieldType
fingerprintString
alertnameOption[String]
folderOption[String]
starts_atString
ends_atOption[String]
generator_urlOption[String]
labelsmap of String to String
annotationsmap of String to String

Expressions cannot read labels and annotations. The agent's session receives them in data.

Engine

The agent engine sends these events itself. A rule's event key cannot name them.

EventSubjectData fieldsSent when
engine/cron/firednoneschedule: String, name: String, message: Option[String], scheduled_for: StringA cron rule's schedule fires. Only that rule's agent receives it.
engine/instance/restartedthe node the agent lives onmessage: String, ended_session: String, restart: Int, limit: IntA headless agent's run ended while its where still matches, and the engine starts a new session. It is the new session's first event.

schedule is <agent>/<name>. name and message are the cron rule's name and message keys.