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:
| Field | Contents |
|---|---|
type | The event type, such as github/pr/merged. |
subject | The id of the node the event is on, or null when the event has no subject. |
actor | The user, agent or integration that caused the event. |
data | The 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.
| Field | Type | Present | Contents |
|---|---|---|---|
event.id | String | always | The event's id. |
event.seq | Int | always | The event's position in the organization's event stream. |
event.type | String | always | The event type. |
event.source | String | always | The source, such as hydra, github or engine. |
event.time | String | always | The time the event happened, in RFC 3339 format. |
event.caused_by | Option[String] | always | The id of the event that caused this one. |
event.subject | the subject kind | when every event type the rule matches has a subject | The subject node with all its fields. |
event.old | Option[ the subject kind ] | when every event type the rule matches is a node event | The subject node as it was before the change. |
event.data | record | always | The event's data fields. |
- When the matched event types have subjects of several kinds,
event.subjecthas the fields those kinds share. - On a
<kind>/createdor<kind>/updatedevent,event.subjectis the node after the change. On<kind>/deleted, it is the node before the delete. event.oldisNoneon<kind>/created.event.datahas typed fields only when the rule matches exactly one event type. A relation event has thedatafieldsfrom,relandto. The node events have noevent.datafields in expressions. Readevent.subjectandevent.oldinstead.- 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.
| Event | Subject | Data fields | Sent when |
|---|---|---|---|
<kind>/created | <kind> | old: null, new: the node's fields | A node is created, or an archived Hydra node is unarchived. |
<kind>/updated | <kind> | old: the fields before, new: the fields after | A 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: null | A 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.
| Event | Subject | Data fields | Sent when |
|---|---|---|---|
relation/created | the from node | from: String, rel: an enum of the relation types, to: String | A relation is added. |
relation/deleted | the from node | from: String, rel: an enum of the relation types, to: String | A 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:
| Event | Subject | Data fields | Sent when |
|---|---|---|---|
issue/commented | issue | body: String, sequence: Int, issue_id: String, org_id: String, created_at: String | Someone 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:
| Relation | From | To |
|---|---|---|
github/check-of | github/check-run | github/pr |
github/authored-by | github/pr | github/user |
github/review-of | github/review | github/pr |
github/reviewed-by | github/review | github/user |
github/status-of | github/status | github/pr |
github/for-issue | github/pr | issue |
GitHub also sends these events:
| Event | Subject | Data fields | Sent when |
|---|---|---|---|
github/pr/merged | github/pr | repo: String, number: Int | The pull request is merged. |
github/pr/closed | github/pr | repo: String, number: Int | The pull request is closed without a merge. |
github/ci/failed | github/pr | repo: String, number: Int, head_sha: String | A check run on the head commit fails. |
github/ci/succeeded | github/pr | repo: String, number: Int, head_sha: String | Every check run on the head commit has finished and none failed. |
github/review/submitted | github/pr | repo: String, number: Int, author: Option[String], state: String, url: String | Someone submits a review. |
github/comment/posted | github/pr | repo: String, number: Int, author: Option[String], url: String | Someone 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:
| Relation | From | To |
|---|---|---|
linear/comment-on | linear/comment | linear/issue |
linear/in-project | linear/issue | linear/project |
linear/child-of | linear/issue | linear/issue |
linear/assigned-to | linear/issue | linear/user |
linear/created-by | linear/issue | linear/user |
linear/in-state | linear/issue | linear/workflow-state |
linear/led-by | linear/project | linear/user |
linear/has-status | linear/project | linear/project-status |
linear/authored-by | linear/comment | linear/user |
Linear also sends these events:
| Event | Subject | Sent when |
|---|---|---|
linear/issue/opened | linear/issue | Someone creates an issue in Linear. |
linear/issue/state-changed | linear/issue | The issue's workflow state changes. |
linear/issue/assigned | linear/issue | The issue gets a new assignee. Removing the assignee sends no event. |
linear/comment/posted | linear/comment | Someone posts a new comment. |
linear/project/state-changed | linear/project | The project's status changes. |
These Linear events have the following data fields:
| Event | Field | Type |
|---|---|---|
linear/issue/opened | identifier | String |
title | String | |
url | String | |
team | String | |
linear/issue/state-changed | identifier | String |
old_state | String | |
old_state_type | String | |
new_state | String | |
new_state_type | String | |
linear/issue/assigned | identifier | String |
old_assignee | Option[String] | |
old_assignee_id | Option[String] | |
new_assignee | String | |
new_assignee_id | String | |
linear/comment/posted | issue | String |
author | Option[String] | |
linear/project/state-changed | name | String |
old_state | String | |
new_state | String |
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.
| Event | Subject | Data fields | Sent when |
|---|---|---|---|
grafana/alert/firing | grafana/alert | The table below lists them. | The alert's stored status changes to firing. |
grafana/alert/resolved | grafana/alert | The table below lists them. | The alert's stored status changes to resolved. |
Both events have the same data fields:
| Field | Type |
|---|---|
fingerprint | String |
alertname | Option[String] |
folder | Option[String] |
starts_at | String |
ends_at | Option[String] |
generator_url | Option[String] |
labels | map of String to String |
annotations | map 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.
| Event | Subject | Data fields | Sent when |
|---|---|---|---|
engine/cron/fired | none | schedule: String, name: String, message: Option[String], scheduled_for: String | A cron rule's schedule fires. Only that rule's agent receives it. |
engine/instance/restarted | the node the agent lives on | message: String, ended_session: String, restart: Int, limit: Int | A 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.