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

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:
jaredandClaude Opus 5.5 committed 2026-11-25 20:22:06 -05:00
1 parent 13ffc51cb7
commit 7061c40d4d
20 files changed
+1025 -206

No files matched your search

+22 -2
View File
@@ -53,6 +53,9 @@ if (!empty($_GET['category'])) {
if (!empty($_GET['type'])) {
$activeFilters[] = ['type' => 'type', 'value' => $_GET['type'], 'label' => 'Type: ' . $_GET['type']];
}
if (!empty($_GET['source'])) {
$activeFilters[] = ['type' => 'source', 'value' => $_GET['source'], 'label' => 'Source: ' . $_GET['source']];
}
if (!empty($_GET['assigned_to'])) {
$label = match ($_GET['assigned_to']) {
'unassigned' => 'Unassigned', 'me' => 'Me', default => 'User #' . $_GET['assigned_to']
@@ -82,6 +85,7 @@ $_lt_statuses = $GLOBALS['config']['TICKET_STATUSES'];
$currentStatus = isset($_GET['status']) ? explode(',', $_GET['status']) : ['Open', 'Pending', 'In Progress'];
$currentCategories = isset($_GET['category']) ? explode(',', $_GET['category']) : [];
$currentTypes = isset($_GET['type']) ? explode(',', $_GET['type']) : [];
$currentSources = isset($_GET['source']) ? explode(',', $_GET['source']) : [];
$isAdmin = $GLOBALS['currentUser']['is_admin'] ?? false;
$colCount = $isAdmin ? 12 : 11;
@@ -543,6 +547,21 @@ include __DIR__ . '/layout_header.php';
</fieldset>
<?php endif ?>
<!-- Source Filter: which reporter (API key) created the ticket (#123) -->
<?php if (!empty($sources)) : ?>
<fieldset class="lt-filter-group">
<legend class="lt-filter-label">Source</legend>
<?php foreach ($sources as $src) : ?>
<label class="lt-filter-option">
<input type="checkbox" class="lt-checkbox sidebar-filter"
name="source" value="<?= htmlspecialchars($src) ?>"
<?= in_array($src, $currentSources) ? 'checked' : '' ?>>
<?= htmlspecialchars($src) ?>
</label>
<?php endforeach ?>
</fieldset>
<?php endif ?>
<!-- Date Filters -->
<fieldset class="lt-filter-group">
<legend class="lt-filter-label">Created</legend>
@@ -591,7 +610,7 @@ include __DIR__ . '/layout_header.php';
<button type="button" id="lt-sidebar-toggle-btn" class="lt-btn lt-btn-ghost lt-btn-sm"
aria-label="Toggle filter sidebar" title="Toggle filters">&#x22EE;&#x22EE; Filters</button>
<form method="GET" action="" class="lt-search-form" role="search">
<?php foreach (['status','category','type','sort','dir'] as $p) : ?>
<?php foreach (['status','category','type','source','sort','dir'] as $p) : ?>
<?php if (isset($_GET[$p])) : ?>
<input type="hidden" name="<?= $p ?>" value="<?= htmlspecialchars($_GET[$p]) ?>">
<?php endif ?>
@@ -785,7 +804,8 @@ include __DIR__ . '/layout_header.php';
</tr>
<?php else : ?>
<?php foreach ($tickets as $row) :
$creator = htmlspecialchars($row['creator_display_name'] ?? $row['creator_username'] ?? 'System');
// API-created tickets show the reporter (key name) instead of "System" (#123)
$creator = htmlspecialchars(!empty($row['source']) ? $row['source'] : ($row['creator_display_name'] ?? $row['creator_username'] ?? 'System'));
$assignedTo = htmlspecialchars($row['assigned_display_name'] ?? $row['assigned_username'] ?? 'Unassigned');
$pNum = (int)$row['priority'];
$rowStatusSlug = strtolower(str_replace(' ', '-', $row['status']));
+4 -1
View File
@@ -103,7 +103,10 @@ $statusSlug = strtolower(str_replace(' ', '-', $ticket['status']));
$priorityNum = (int)($ticket['priority'] ?? 3);
$currentUserId = $GLOBALS['currentUser']['user_id'] ?? null;
$isAdmin = $GLOBALS['currentUser']['is_admin'] ?? false;
$creator = $ticket['creator_display_name'] ?? $ticket['creator_username'] ?? 'System';
// API-created tickets name the reporter (the API key) instead of "System" (#123)
$creator = !empty($ticket['source'])
? $ticket['source'] . ' (API)'
: ($ticket['creator_display_name'] ?? $ticket['creator_username'] ?? 'System');
// Visibility
$currentVisibility = $ticket['visibility'] ?? 'public';