Duplicate detection is unchanged, checked by running Tinker's real code. I ran helpers/TicketHash.php from tinker_tickets main, under PHP, on old and new titles for all 11 title shapes Gandalf uses: interface down, no metrics, planned reboot, cluster, Prometheus, UniFi offline, cutsheet mismatch, host unreachable, and three WAN titles. Every pair hashes identically, so open tickets keep matching.
A Python test mirrors the parts of the hash Gandalf titles touch, so a later change can't quietly re-key tickets.
2. Read-only API key for Thor
Routes a key can read:GET /api/status, /api/events, /api/attention and /api/suppressions. Thor sends Authorization: Bearer <key> straight to the LXC (http://10.10.10.61/api/...). nginx there already passes the header through.
What a key can't do:
It can't sign in as anyone or reach any other route.
It's read-only: any other method gets a 403.
A wrong or unknown key gets a 401 even if identity headers are also sent, so a typo never falls back to someone else's identity.
Config: holds only the key's SHA-256, under api_keys: [{name, sha256, scopes: ["read"], sources?}]. sources optionally limits the key to given CIDRs. The README shows how to generate a key.
Suppressions including ended ones:?include_ended=1&hours=N (default 24, max 31 days) returns every suppression in force in that window. Each has started_at, started_by, expires_at, ended_at, ended_by, state (active, ended or expired) and end_known.
Gandalf didn't record when a suppression was removed, so this adds ended_at and ended_by columns. They're added automatically the first time they're needed, and suppressions that already expired get their expiry time filled in as the end.
Removing a suppression now records the user, gandalf for its own modem-restart silence, or expired.
Example: on prod, last night's "switch update" window (03:11:39 to 03:41:39 UTC) will show as expired with both times, which is how Thor tells that night was planned.
cluster_hosts_stalled: already in /api/events. A test confirms it reaches a key holder with its OOM host names.
Verification
699 tests pass. New tests cover: the title format and hash parity; every key case (valid, wrong, no read scope, source limits, unmarked routes, writes, users unaffected); suppression windows in each state; and the schema migration running once.
Real MariaDB run: the new SQL ran against a throwaway MariaDB built from schema.sql. Covered: the migration and its re-run, removing a suppression by hand, expiry cleanup, and the 24-hour window, which correctly leaves out a 5-day-old row.
flake8 and bandit are clean. No em or en dashes.
Rollout after merge
Nothing changes for users. Thor gets a key once it exists. The suppression columns are added by the monitor's first expiry cleanup after deploy, which uses the same ALTER privilege the earlier events migration used.
Refs #66. This covers items 1 and 2, which can ship now. The rest is listed under "What's left".
## 1. Title format with the `[gandalf]` tag
- Every Gandalf title is now built in one place, `ticket_text.title()`, using the shared standard:
- Before: `[monitor-01][auto][production][issue][network][single-node] Interface enp3s0 link-down`
- After: `[monitor-01][auto][gandalf][network] Interface enp3s0 link-down [single-node][production][issue]`
- **Duplicate detection is unchanged, checked by running Tinker's real code.** I ran `helpers/TicketHash.php` from tinker_tickets main, under PHP, on old and new titles for all 11 title shapes Gandalf uses: interface down, no metrics, planned reboot, cluster, Prometheus, UniFi offline, cutsheet mismatch, host unreachable, and three WAN titles. Every pair hashes identically, so open tickets keep matching.
- A Python test mirrors the parts of the hash Gandalf titles touch, so a later change can't quietly re-key tickets.
## 2. Read-only API key for Thor
- **Routes a key can read:** `GET /api/status`, `/api/events`, `/api/attention` and `/api/suppressions`. Thor sends `Authorization: Bearer <key>` straight to the LXC (`http://10.10.10.61/api/...`). nginx there already passes the header through.
- **What a key can't do:**
- It can't sign in as anyone or reach any other route.
- It's read-only: any other method gets a 403.
- A wrong or unknown key gets a 401 even if identity headers are also sent, so a typo never falls back to someone else's identity.
- **Config:** holds only the key's SHA-256, under `api_keys: [{name, sha256, scopes: ["read"], sources?}]`. `sources` optionally limits the key to given CIDRs. The README shows how to generate a key.
- **Suppressions including ended ones:** `?include_ended=1&hours=N` (default 24, max 31 days) returns every suppression in force in that window. Each has `started_at`, `started_by`, `expires_at`, `ended_at`, `ended_by`, `state` (active, ended or expired) and `end_known`.
- Gandalf didn't record when a suppression was removed, so this adds `ended_at` and `ended_by` columns. They're added automatically the first time they're needed, and suppressions that already expired get their expiry time filled in as the end.
- Removing a suppression now records the user, `gandalf` for its own modem-restart silence, or `expired`.
- Example: on prod, last night's "switch update" window (03:11:39 to 03:41:39 UTC) will show as expired with both times, which is how Thor tells that night was planned.
- **`cluster_hosts_stalled`:** already in `/api/events`. A test confirms it reaches a key holder with its OOM host names.
## Verification
- 699 tests pass. New tests cover: the title format and hash parity; every key case (valid, wrong, no read scope, source limits, unmarked routes, writes, users unaffected); suppression windows in each state; and the schema migration running once.
- **Real MariaDB run:** the new SQL ran against a throwaway MariaDB built from `schema.sql`. Covered: the migration and its re-run, removing a suppression by hand, expiry cleanup, and the 24-hour window, which correctly leaves out a 5-day-old row.
- flake8 and bandit are clean. No em or en dashes.
## Rollout after merge
Nothing changes for users. Thor gets a key once it exists. The suppression columns are added by the monitor's first expiry cleanup after deploy, which uses the same ALTER privilege the earlier events migration used.
## What's left in #66
| Item | Status |
|---|---|
| 3. Pre-check Thor's `/api/incidents/covering` | Needs Thor to define the response (which ticket covers it, known condition). It will fail open when Thor isn't configured or doesn't answer. |
| 4. "No Prometheus data" moves to Thor | Builds on item 3. |
| 5. `dedup_key` and backfill | Waits on tinker_tickets#123. |
| 6. Drop the 24 h `recurrence_noted` retry | Waits on Tinker's reopen window. |
| 7. Take over hwmonDaemon's network checks | Separate PR. |
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Titles move to the shared standard [source][auto][gandalf][network]
Summary [scope][production][issue], built in one place
(ticket_text.title). Checked by running Tinker's TicketHash.php: every
Gandalf title shape hashes the same as before, so open tickets keep
matching.
Thor can read /api/status, /api/events, /api/attention and
/api/suppressions with a machine key (Authorization: Bearer, only its
SHA-256 in config, read-only, optional source CIDRs; a wrong key is a
401 and never falls back to identity headers). /api/suppressions
?include_ended=1&hours=N returns every suppression in force in the
window with start, planned end, actual end and who ended it: new
ended_at/ended_by columns, added automatically.
Refs #66 (items 1 and 2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared
scheduled this pull request to auto merge when all checks succeed 2026-11-25 19:57:30 -05:00
jared
merged commit 1c250d6eed into main2026-11-25 19:57:32 -05:00
jared
deleted branch thor-contract2026-11-25 19:57:36 -05:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Refs #66. This covers items 1 and 2, which can ship now. The rest is listed under "What's left".
1. Title format with the
[gandalf]tagticket_text.title(), using the shared standard:[monitor-01][auto][production][issue][network][single-node] Interface enp3s0 link-down[monitor-01][auto][gandalf][network] Interface enp3s0 link-down [single-node][production][issue]helpers/TicketHash.phpfrom tinker_tickets main, under PHP, on old and new titles for all 11 title shapes Gandalf uses: interface down, no metrics, planned reboot, cluster, Prometheus, UniFi offline, cutsheet mismatch, host unreachable, and three WAN titles. Every pair hashes identically, so open tickets keep matching.2. Read-only API key for Thor
GET /api/status,/api/events,/api/attentionand/api/suppressions. Thor sendsAuthorization: Bearer <key>straight to the LXC (http://10.10.10.61/api/...). nginx there already passes the header through.api_keys: [{name, sha256, scopes: ["read"], sources?}].sourcesoptionally limits the key to given CIDRs. The README shows how to generate a key.?include_ended=1&hours=N(default 24, max 31 days) returns every suppression in force in that window. Each hasstarted_at,started_by,expires_at,ended_at,ended_by,state(active, ended or expired) andend_known.ended_atandended_bycolumns. They're added automatically the first time they're needed, and suppressions that already expired get their expiry time filled in as the end.gandalffor its own modem-restart silence, orexpired.cluster_hosts_stalled: already in/api/events. A test confirms it reaches a key holder with its OOM host names.Verification
schema.sql. Covered: the migration and its re-run, removing a suppression by hand, expiry cleanup, and the 24-hour window, which correctly leaves out a 5-day-old row.Rollout after merge
Nothing changes for users. Thor gets a key once it exists. The suppression columns are added by the monitor's first expiry cleanup after deploy, which uses the same ALTER privilege the earlier events migration used.
What's left in #66
/api/incidents/coveringdedup_keyand backfillrecurrence_notedretry🤖 Generated with Claude Code