Ticket contract for automated reporters: dedup_key, source, links, reopen window (#123)
Lint / JS (eslint) (push) Successful in 14s
Lint / PHP (phpcs PSR-12) (push) Successful in 44s
Lint / PHP requirements (version + extensions) (push) Successful in 42s
Lint / Deploy (push) Skipped
Lint / Notify on failure (push) Skipped
Lint / PHP (phpcs PSR-12) (pull_request) Successful in 1m15s
Lint / JS (eslint) (pull_request) Successful in 34s
Lint / PHP requirements (version + extensions) (pull_request) Successful in 42s
Lint / Deploy (pull_request) Skipped
Lint / Notify on failure (pull_request) Skipped
Security / PHP Security (semgrep) (push) Successful in 4m13s
Security / PHP Security (semgrep) (pull_request) Successful in 3m25s
Lint / JS (eslint) (push) Successful in 14s
Lint / PHP (phpcs PSR-12) (push) Successful in 44s
Lint / PHP requirements (version + extensions) (push) Successful in 42s
Lint / Deploy (push) Skipped
Lint / Notify on failure (push) Skipped
Lint / PHP (phpcs PSR-12) (pull_request) Successful in 1m15s
Lint / JS (eslint) (pull_request) Successful in 34s
Lint / PHP requirements (version + extensions) (pull_request) Successful in 42s
Lint / Deploy (pull_request) Skipped
Lint / Notify on failure (pull_request) Skipped
Security / PHP Security (semgrep) (push) Successful in 4m13s
Security / PHP Security (semgrep) (pull_request) Successful in 3m25s
From the thor#1 plan: each reporter (gandalf, hwmonDaemon, thor) decides
what "the same problem" is, and Tinker enforces it.
- dedup_key on create_ticket_api.php (scope:subject:kind, A-Za-z0-9_.:-,
case-sensitive). The hash becomes sha256("key:" + key) and the title is
not looked at; an invalid key is a 400. Keyless callers hash exactly as
before (checked over every prod title).
- Recurrence window for every reporter, keyed or not: a match on a ticket
closed under AUTO_REOPEN_WINDOW_DAYS (7) ago reopens it as before
(subject to the Workflow Designer); an older one gets a new ticket that
takes over the dedup slot (tickets.hash stays UNIQUE, the old ticket
gives it up), carries the key, records recurrence_of, is linked
relates_to, and gets a history comment. action: new_recurrence.
- GET api/tickets_api.php?dedup_key= returns the newest ticket with that
key plus its recurrence chain; ?source= filters the list.
- New api/ticket_link_api.php (link/unlink, read_write) through
DependencyService::link()/unlink(), now shared with MCP
link_tickets/unlink_tickets; audit rows record the key name.
- tickets.source records the API key name. Shown as the creator instead of
"System" on the dashboard and ticket page, a Source filter in the
sidebar, source in MCP results and a search_tickets filter. Comments the
create API writes name the reporter instead of a hard-coded
"hwmonDaemon", and system-linked comments display that name.
- Migration 008 (dedup_key, source, recurrence_of). Scripts:
backfill_ticket_source.php (pre-#123 tickets, where certain) and
backfill_dedup_keys.php (mapping file supplied by the app).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
13ffc51cb7
commit
7061c40d4d
20 files changed
+1025
-206
No files matched your search
@@ -108,8 +108,9 @@ All Bearer-authenticated, rate-limited, and (like `create_ticket_api.php`) exemp
|
||||
|
||||
| Endpoint | Method | Scope | Purpose |
|
||||
|----------|--------|-------|---------|
|
||||
| `/create_ticket_api.php` | POST | read_write | Create a ticket (hwmonDaemon, external tools) |
|
||||
| `/api/tickets_api.php` | GET | read | List/triage the queue (`?status=`, `?priority=`, `?host=` [title match], `?page=`, `?limit=`) **or** read one (`?ticket_id=NNN`) with its comments |
|
||||
| `/create_ticket_api.php` | POST | read_write | Create a ticket (gandalf, hwmonDaemon, thor, external tools). Optional `dedup_key`; see [Automated Ticket Creation](#automated-ticket-creation-hwmondaemon) |
|
||||
| `/api/tickets_api.php` | GET | read | List/triage the queue (`?status=`, `?priority=`, `?host=` [title match], `?source=` [reporter, comma-separated], `?page=`, `?limit=`) **or** read one (`?ticket_id=NNN`) with its comments **or** look one up by key (`?dedup_key=K`: the newest ticket with that key in any status, plus `recurrences`, the earlier tickets of its chain) |
|
||||
| `/api/ticket_link_api.php` | POST | read_write | Link two tickets: `{ticket_id, other_ticket_id, relation}`, read as "ticket_id relation other_ticket_id" (`blocks`, `blocked_by`, `relates_to`, `duplicates`); add `"action": "unlink"` to remove one (found from either side). Same checks and audit entries as the Dependencies tab and MCP. 404 for a missing or hidden ticket, 409 if already linked or circular |
|
||||
| `/api/ticket_comment_api.php` | POST | read_write | Add a comment: `{ticket_id, comment_text, markdown_enabled?}` |
|
||||
| `/api/ticket_status_api.php` | POST | read_write | Change/close status (workflow-validated): `{ticket_id, status, comment?}` — `comment` is required for transitions that require one (e.g. → Closed); it is posted as the close reason in the same call |
|
||||
|
||||
@@ -127,7 +128,7 @@ claude mcp login tinker # add --no-browser on a headless machine, the
|
||||
|
||||
| Tool | Scope | What it does |
|
||||
|------|-------|--------------|
|
||||
| `search_tickets` | `tickets:read` | Search/list tickets you can see (text, status, priority, category, assignee `me`/`unassigned`/username), paginated |
|
||||
| `search_tickets` | `tickets:read` | Search/list tickets you can see (text, status, priority, category, assignee `me`/`unassigned`/username, `source` reporter), paginated; results include `source` |
|
||||
| `get_ticket` | `tickets:read` | One ticket's details + comments, its links (Dependencies tab, phrased from this ticket's side incl. `duplicated_by`) and a `blocked` flag (any open `blocked_by`) |
|
||||
| `find_similar_tickets` | `tickets:read` | Open tickets with similar titles, by title text or an existing ticket (same finder as the ticket page's possible-duplicates list) |
|
||||
| `create_ticket` | `tickets:write` | Create a ticket (title, description, priority, category, type, visibility, assignee) |
|
||||
@@ -225,7 +226,10 @@ Content-Type: application/json
|
||||
|
||||
**Key behaviours:**
|
||||
- Authenticated via `Authorization: Bearer` header — API key stored in `/etc/hwmonDaemon/.env`
|
||||
- **Deduplication**: Generates a SHA-256 hash from the issue category, hostname, and device (no time window). A repeat alert matching an existing **open** ticket updates its title/description and escalates the priority if the condition worsened; if the matching ticket was already **closed**, it is reopened instead of creating a new one
|
||||
- **Source**: the API key's name (`gandalf`, `hwmonDaemon`, `thor`) is stored in `tickets.source` and shown as the creator instead of "System"; the dashboard has a Source filter. Comments this endpoint writes (escalation, recurrence) are authored by the key name too. Tickets from before #123: `php scripts/backfill_ticket_source.php --dry-run`, then without
|
||||
- **`dedup_key` (preferred, #123)**: the reporter decides what "the same problem" is by sending `dedup_key` (`scope:subject:kind`, 1-128 of `A-Za-z0-9_.:-`, case-sensitive, e.g. `host:compute-storage-01:oom`, `cluster:ceph:BLUESTORE_SLOW_OP_ALERT`). The hash is then `sha256("key:" + dedup_key)` and the title is not looked at; an invalid key is a 400. When an app starts sending keys, give its existing tickets theirs with `php scripts/backfill_dedup_keys.php --map=file.json [--dry-run]` (the app supplies `{ticket_id: dedup_key}`), or its next reports open duplicates
|
||||
- **Deduplication without a key**: Generates a SHA-256 hash from the issue category, hostname, and device (no time window). A repeat alert matching an existing **open** ticket updates its title/description and escalates the priority if the condition worsened
|
||||
- **Recurrence (every reporter, keyed or not)**: a report matching a **Closed** ticket that closed less than `AUTO_REOPEN_WINDOW_DAYS` (default 7) ago reopens it, if the Workflow Designer allows an unattended reopen (no admin, no comment); otherwise the recurrence is noted on it and it stays Closed (`recurrence_noted`). A ticket closed longer ago is left alone: a **new ticket** takes over the dedup slot, carries the same `dedup_key`, records the old one in `recurrence_of`, is linked `relates_to` it, and gets a history comment (times seen in the last 7 and 30 days, when it last cleared). Response `action`: `created`, `updated`, `deduplicated`, `reopened`, `recurrence_noted` or `new_recurrence` (with `previous_ticket_id`)
|
||||
- Cluster-wide issues (Ceph health, etc.) deduplicate across all nodes (hostname excluded from hash)
|
||||
- Automated network tickets are keyed per problem, not just per host: on the optional `check_code` payload field when sent (it must name the instance, e.g. `iface_down:enp3s0`), otherwise on the title text outside the `[tags]`. After deploying this change (#116), run `php scripts/rehash_network_tickets.php --dry-run`, then without `--dry-run`, so open network tickets keep matching their alerts. The hash logic lives in `helpers/TicketHash.php`
|
||||
- `description` is rendered as markdown on the ticket page, the same as markdown comments (#114). Reporters should send markdown: `##` sections, tables for key/value data and fenced code blocks for raw command output. Fixed-width box layouts lose their alignment.
|
||||
@@ -302,6 +306,7 @@ Content-Type: application/json
|
||||
| `/api/tickets_api.php` | GET | Bearer: list/triage queue or read one ticket + comments |
|
||||
| `/api/ticket_comment_api.php` | POST | Bearer: add a comment (read_write scope) |
|
||||
| `/api/ticket_status_api.php` | POST | Bearer: change/close status, workflow-validated (read_write scope) |
|
||||
| `/api/ticket_link_api.php` | POST | Bearer: link or unlink two tickets (read_write scope) |
|
||||
| `/api/update_ticket.php` | POST | Update ticket with workflow validation |
|
||||
| `/api/assign_ticket.php` | POST | Assign ticket to user |
|
||||
| `/api/add_comment.php` | POST | Add comment to ticket |
|
||||
@@ -438,6 +443,7 @@ tinker_tickets/
|
||||
│ ├── 005_attachment_thumbnails.sql # ticket_attachments.thumbnail_filename
|
||||
│ ├── 006_api_key_visibility_scope.sql # api_keys.see_all_visibility (public-only by default)
|
||||
│ ├── 007_notification_retry_queue.sql # Queue for failed Matrix webhook retries
|
||||
│ ├── 008_dedup_key_source.sql # tickets.dedup_key, source, recurrence_of (#123)
|
||||
│ └── migrate.php # CLI migration runner (tracks applied migrations)
|
||||
├── mcp/
|
||||
│ ├── server.php # MCP endpoint (/mcp): OAuth resource server; only file that loads vendor/
|
||||
@@ -446,12 +452,16 @@ tinker_tickets/
|
||||
│ ├── Tools/ # TicketReadTools, TicketWriteTools
|
||||
│ └── ToolCatalog.php # Tool registry + which tools need tickets:write
|
||||
├── scripts/
|
||||
│ ├── backfill_dedup_keys.php # Give existing tickets a reporter's dedup_keys from its mapping file (#123)
|
||||
│ ├── backfill_ticket_source.php # Set tickets.source on pre-#123 API tickets where the reporter is certain
|
||||
│ ├── check_requirements.php # Verify PHP extensions/config prerequisites
|
||||
│ └── cleanup_orphan_uploads.php # Delete orphaned upload files past grace period (cron)
|
||||
│ ├── cleanup_orphan_uploads.php # Delete orphaned upload files past grace period (cron)
|
||||
│ └── rehash_network_tickets.php # One-off re-key of open network tickets (#116)
|
||||
├── services/
|
||||
│ ├── AssignmentService.php # Assign/unassign (shared by assign_ticket.php + MCP)
|
||||
│ ├── AutoTicketService.php # Automated tickets: insert, reopen window, recurrence chains (create_ticket_api.php)
|
||||
│ ├── CommentService.php # Add/edit/delete comments (shared by the comment endpoints + MCP)
|
||||
│ ├── DependencyService.php # List/add/remove ticket links (shared by ticket_dependencies.php + MCP)
|
||||
│ ├── DependencyService.php # List/add/remove ticket links (shared by ticket_dependencies.php, ticket_link_api.php + MCP)
|
||||
│ ├── SimilarTicketService.php # Similar-title finder (shared by check_duplicates.php + MCP)
|
||||
│ └── TicketCreationService.php # Create ticket (shared by TicketController + MCP)
|
||||
├── uploads/ # File attachment storage (served only via PHP; nginx: internal)
|
||||
|
||||
Reference in new issue
Block a user