Events and API reference
Everything gh-maintainer does is recorded as an event. The agent posts events to the status server, which stores them in SQLite, applies their effect (runs, repositories, findings, approvals) and streams them to the widget and the desktop app. This page lists every event type and every HTTP route.
Event envelope
Section titled “Event envelope”Every event has the same envelope:
{ "id": 4211, "runId": "2026-11-29T10:00:03.512Z", "ts": "2026-11-29T10:04:17.090Z", "type": "pr.merged", "repo": "website", "data": { "pr": 42, "title": "Bump lodash from 4.17.20 to 4.17.21" }}| Field | Type | Meaning |
|---|---|---|
id |
integer | Assigned by the status server when the event is stored. Increases monotonically. |
runId |
string | The run that produced the event: the run’s start time as an ISO timestamp. Events created by the status server itself (approve, reject, reconcile) have runId: "server". |
ts |
string | ISO timestamp of the event |
type |
string | One of the types below |
repo |
string, optional | Repository name, without the owner. Missing on run-level events. |
data |
object | Type-specific payload |
Event types
Section titled “Event types”Run events
Section titled “Run events”| Type | When | data |
|---|---|---|
run.started |
A run begins. Any earlier run still marked running is marked aborted. |
dryRun (boolean) |
run.finished |
A run ends, also after a rate limit. Triggers the stale approval cleanup. | merged, approvals, fixes, branchesDeleted, errors (numbers), rateLimited (boolean) |
run.rate_limited |
The remaining REST quota dropped below 100, or GitHub answered with a rate-limit error. The run stops starting new repositories. | remaining (number, or null when unknown) |
Repository events
Section titled “Repository events”| Type | When | data |
|---|---|---|
repo.started |
The agent starts on a repository | none |
repo.done |
The agent finished a repository | status (ok, pending or failing), merged, approvals, fixes, branchesDeleted (numbers), rateLimited (true, only when a rate limit interrupted this repository) |
repo.error |
A repository failed; the run continues with the next one | message (string, with secrets removed) |
repo.findings |
The security module finished a repository | sources (list of finding sources that were checked), findings (list of findings) |
Pull request events
Section titled “Pull request events”| Type | When | data |
|---|---|---|
pr.merged |
A PR was merged, by the agent or through Approve | pr (number), title |
pr.pending |
A Dependabot PR waits | pr, title, reason (checks, blocked, head moved, fixer disabled, cooldown, time budget or error), message (only with error) |
pr.rebase_requested |
The agent commented @dependabot rebase on a conflicting PR |
pr |
pr.fix_pushed |
The fixer pushed a commit | pr, sha (the new head) |
pr.fix_failed |
A fix attempt did not produce a pushable fix | pr, status (no-change, timeout or error), summary |
The meaning of each pr.pending reason is listed in the user manual.
Approval events
Section titled “Approval events”| Type | When | data |
|---|---|---|
approval.requested |
A PR needs a human decision. The agent re-requests open approvals on every run. | pr, title, url, reason (major or ai-fix), ignored (true when the server kept an earlier reject; set by the server only) |
approval.rejected |
Someone clicked Reject (emitted by the server) | pr, reason |
approval.closed |
The PR was merged or closed outside the widget (emitted by the server) | pr, reason (pr already merged or pr closed) |
An approval’s id is <repo>#<pr>, for example website#42.
Branch events
Section titled “Branch events”| Type | When | data |
|---|---|---|
branch.deleted |
A branch was deleted (live mode only) | name, sha (the last commit, for restoring), reason (merged or stale) |
Finding events
Section titled “Finding events”The status server derives these from each repo.findings event by comparing it with the open findings it knows. Only sources listed in sources can resolve findings, so a scanner that failed or an alert type that is disabled never resolves its earlier findings.
| Type | When | data |
|---|---|---|
finding.new |
A finding appeared, or a resolved one came back | the full finding |
finding.resolved |
An open finding is gone | id |
Dry-run events
Section titled “Dry-run events”With dryRun: true, every write to GitHub becomes an action.would_* event instead:
| Type | Replaces | data |
|---|---|---|
action.would_merge |
A merge (and pr.merged) |
pr, method, sha |
action.would_comment |
A PR comment (and pr.rebase_requested) |
pr, body |
action.would_delete_branch |
A branch deletion (and branch.deleted) |
branch |
action.would_push_fix |
A fixer push (and pr.fix_pushed) |
pr, summary |
Treat action.would_ as a prefix: new dry-run event types may be added.
Finding object
Section titled “Finding object”| Field | Type | Meaning |
|---|---|---|
id |
string | Stable id: SHA-1 of repository, source, rule and location |
repo |
string | Repository name |
source |
string | dependabot-alert, code-scanning, secret-scanning, hygiene, workflow, trivy, gitleaks or osv |
rule |
string | Rule or advisory id, for example GHSA-..., unpinned-action or scanner-error |
severity |
string | critical, high, medium or low |
title |
string | Human-readable description |
location |
string, optional | File, job, alert number or rule name |
url |
string, optional | Link to the alert on GitHub |
HTTP routes
Section titled “HTTP routes”The status server listens on port 8080. The ingress exposes only the UI routes, behind basic auth.
| Route | Exposed by the ingress | Auth | Purpose |
|---|---|---|---|
GET / and /assets/* |
yes | basic auth | The web widget |
GET /state |
yes | basic auth | Snapshot |
GET /info |
yes | basic auth | Server version and commit, owner, and the live agent config (read-only) |
GET /stream |
yes | basic auth | Live Server-Sent Events |
POST /approve/:id |
yes | basic auth + JSON content type | Merge an approval |
POST /reject/:id |
yes | basic auth + JSON content type | Reject an approval |
POST /events |
no | bearer EVENT_TOKEN |
Event ingest from the agent |
GET /fix-attempts/:repo/:pr |
no | bearer EVENT_TOKEN |
Last fix attempt for a PR (agent only) |
GET /scan-meta/:repo |
no | bearer EVENT_TOKEN |
Last local scan time (agent only) |
GET /healthz |
no | none | Readiness and liveness probe: {"ok": true} |
GET /info
Section titled “GET /info”Returns what the widget’s Agent config and About views show:
{ "version": "main", "commit": "5c71786…", "owner": "acme", "startedAt": "2026-11-29T10:00:00.000Z", "config": { "owner": "acme", "dryRun": false, "branches": { "staleDays": 90, "keep": ["main"] }, "…": "…" }}config is the agent’s config.yaml (the gh-maintainer-config ConfigMap, mounted read-only into the status server at /config/config.yaml), parsed with the same validation and defaults as the agent. The file is read on every request, so ConfigMap changes appear without a restart (after the kubelet syncs the volume, usually within a minute). When the file is missing or invalid, config is null and configError says why. version is the release version, the branch name for builds of main, or dev for local builds.
POST /events
Section titled “POST /events”The agent’s ingest route. Inside the cluster only.
- Header
Authorization: Bearer <EVENT_TOKEN>. The token is compared in constant time. A missing or wrong token answers401before the body is read. - Body: one event envelope, or an array of at most 1,000, without
id. Maximum body size 5 MB. - Answer:
202 {"accepted": <n>}, or400with the validation issues.
The whole batch is stored in one transaction. An event with malformed data is still stored and streamed, but its effect is skipped. The agent sends batches of at most 500 events and retries on network errors, timeouts, 5xx, 408 and 429.
The NetworkPolicy status-server-ingress admits only agent pods and the ingress controller, so other pods in the cluster cannot reach this route.
GET /state
Section titled “GET /state”A snapshot of everything the widget shows:
| Field | Meaning |
|---|---|
run |
The most recently started run: id, status (running, finished, aborted or error), startedAt, finishedAt, totals; null before the first run |
repos |
Every repository seen: name, status (ok, pending, failing or error), lastRunId, message |
approvals |
Open approvals only: id, repo, pr, title, url, reason, status |
findings |
Open findings only |
lastEventId |
Highest stored event id (0 when there are none) |
dryRun |
data.dryRun of the latest run.started (false when there is none) |
recentEvents |
The last 100 events, newest first |
curl -s -u <user> https://gh-maintainer.example.com/state | jq '.run, .dryRun'GET /stream
Section titled “GET /stream”A Server-Sent Events stream of stored events.
- Pass the last event id you have, either as the
Last-Event-IDheader or as?lastEventId=<id>. The server first replays every stored event after that id, then sends live events. Each event is sent at most once, in ascending id order. - Without an id, the stream sends live events only. The widget loads
/statefirst and passes itslastEventId. - An invalid id answers
400. - A
: pingcomment is sent every 15 seconds to keep the connection open.
Each event frame:
id: 4211event: messagedata: {"id":4211,"runId":"...","ts":"...","type":"pr.merged","repo":"website","data":{"pr":42,"title":"..."}}curl -sN -u <user> 'https://gh-maintainer.example.com/stream?lastEventId=4200'POST /approve/:id and POST /reject/:id
Section titled “POST /approve/:id and POST /reject/:id”:id is the URL-encoded approval id, for example website%2342 for website#42.
Both routes require Content-Type: application/json, otherwise they answer 415. A cross-site form cannot send that content type without a CORS preflight, which the server never answers, so this blocks cross-site request forgery.
/reject/:id accepts an optional body {"reason": "..."} of at most 500 characters. Without a reason, the comment says rejected.
curl -s -u <user> -X POST -H 'content-type: application/json' -d '{}' \ https://gh-maintainer.example.com/approve/website%2342curl -s -u <user> -X POST -H 'content-type: application/json' -d '{"reason":"breaks the build"}' \ https://gh-maintainer.example.com/reject/website%2342| Status | Body | Meaning |
|---|---|---|
200 |
{"ok": true} |
Merged, or rejected |
404 |
{"ok": false, "reason": "approval not found"} |
No approval with this id |
409 |
{"ok": false, "reason": "..."} |
approval not open, approval in progress, pr already merged, pr closed, checks not green, not mergeable, blocked by branch protection or pr changed, re-check |
400 |
validation issues | Invalid reject body |
415 |
Missing JSON content type | |
502 |
{"error": "github error"} |
GitHub failed; the approval stays open |
503 |
{"error": "github rate limited"} |
GitHub rate limit; the approval stays open |
What each check means is explained in Approve.
Retention
Section titled “Retention”The status server deletes events older than 30 days, once at start and then every 24 hours. Runs, repositories, findings, approvals and fix attempts are not pruned. The widget’s activity feed is seeded from the last 100 events.