Repository navigation
Email epic: support tickets, nemar admin mail, retention - #1942
Merged
Merged
Conversation
* feat: add support ticket tables (migration 0102) * feat: ticket assignment and visibility rules * feat: parse and thread inbound mail into tickets * feat: ticket inbound mail after the raw put * feat: release tickets on demotion, revoke, delete * refactor: move clampUtf8Bytes to lib/utf8 * fix: tighten ticket schema checks and indexes * fix: reserved restricted tags, tombstone unlink * fix: authorise threading, verified auth, reopen * fix: let a ticket's own restriction bind assignment * fix: strict alignment, guarded reopen events
* feat: threading headers on sendEmail * feat: support_tickets email preference * feat: escalation owner on mail queues * feat: notify admins of new tickets * feat: support ticket admin routes * chore: production MAIL_INBOUND binding * docs: ADR 0111 support tickets * fix: use 3a restricted tags and reply_failed * fix: escalation owner cleared when not owner * fix: mail routes hide counts, replays, reopens * fix: idempotent replies, trimmed References * docs: ADR 0111 review fixes * fix: announce reprocessed tickets before 404 * fix: reopen guard, References keeps root * docs: ADR 0111 key lifetime rules * test: expect support_tickets in --all update Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
* Add terminalSafeText for ticket text Co-Authored-By: Claude Opus 5.5 <[email protected]> * Add mail admin API client functions Co-Authored-By: Claude Opus 5.5 <[email protected]> * Add nemar admin mail command group Co-Authored-By: Claude Opus 5.5 <[email protected]> * Escape direction marks and zero-width characters Co-Authored-By: Claude Opus 5.5 <[email protected]> * Harden admin mail errors, names and usage exits Co-Authored-By: Claude Opus 5.5 <[email protected]> * Name exit 4 in the mail help line Co-Authored-By: Claude Opus 5.5 <[email protected]> * Print mail output only once fully built A failed name lookup partway through show, queues or away no longer leaves a partial render on stdout. --json detection in usage errors ignores arguments after --. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Stop advising a retry on delivery unknown The server answers every repeat of a reply_delivery_unknown key the same way and never sends it, so the CLI no longer tells the caller to retry with it. It says to read the thread and that only a new key sends again. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Escape every invisible format character The display escape set now covers Unicode category Cf (soft hyphen, invisible operators, tag characters) and the invisible look-alikes outside it (combining grapheme joiner, Hangul fillers, variation selectors). Astral code points are written as \u{...}. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Type reply and note message ids as numbers ReplyResponse.message_id is the stored row id, a number; the contract said string. Adds NoteResponse for the note route. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1942Version: 🤖 Updated on each push. |
neuromechanist
marked this pull request as draft
October 24, 2026 20:39
* Add ticket summary route and purged guards Co-Authored-By: Claude Opus 5.5 <[email protected]> * Purge expired tickets daily, keep summaries Co-Authored-By: Claude Opus 5.5 <[email protected]> * Add admin mail summarize and --needs-summary Co-Authored-By: Claude Opus 5.5 <[email protected]> * Update allowlist pins for the ticket purge Co-Authored-By: Claude Opus 5.5 <[email protected]> * Keep exclusion and spam status on purge Co-Authored-By: Claude Opus 5.5 <[email protected]> * Harden ticket purge after review round 1 Co-Authored-By: Claude Opus 5.5 <[email protected]> * Gate inbound and ticket writes on purged_at Co-Authored-By: Claude Opus 5.5 <[email protected]> * Say when a reply was sent but not recorded Co-Authored-By: Claude Opus 5.5 <[email protected]> * Renumber support ADR to 0112, migration to 0107 The upstream-freshness epic (#1046) already holds ADR 0111 and migrations 0104-0106. This epic keeps 0102 and 0103 and moves its later numbers past theirs so both epics merge to dev without a collision. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
* feat: idempotency key for ticket notes Optional Idempotency-Key on the note route, stored in mail_note_keys (migration 0108), purged with the ticket. Tested with real D1. ADR 0112 updated. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat: nemar admin mail note sends a key The CLI always sends an Idempotency-Key on a note (generated or --idempotency-key), prints it first, and advises a retry with it after a network failure or 5xx. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix: race loser must not log or bump a note A keyed note's ticket bump and event run only when the preceding statement changed a row. A missing stored key after the batch is a 500. Tests: race, late purge, cascade. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat: note retry on 408 and 429, help, ADR CLI note retries with its key on 408 and 429 (replies unchanged); help documents intent-not-text and JSON Lines stderr; ADR 0112 sentence. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
neuromechanist
marked this pull request as ready for review
October 24, 2026 21:14
0107 adds the mail_tickets_activity_default trigger; the 0098 schema test excluded mail tables and indexes but not triggers. Tested: the migration test passes locally. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The ADR index must be gapless and this epic adds 0112. 0111 is the upstream re-pull ADR, copied unchanged from its epic branch with its index lines, so dev reads 0110-0112 in order. Tested: adr-index test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 tasks done
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Batch 2 of epic #1893 into
dev: inbound mail becomes support tickets, an admin API andnemar admin mailwork them, and tickets are reduced to a summary after the retention period. Admins may be people or agents (thenemarAdminagent is the default assignee of ordinary queues); nothing distinguishes the two.Authentication-Results, threaded (plus address,In-Reply-To,References), tagged, queued, spam-flagged and assigned (fixed,round_robin,pool, away windows).securityandconductrestricted to owners; conduct exclusion. Migration 0102./admin/mailAPI (list, detail, reply with threading headers andIdempotency-Key, note, assign, status, escalate, queues, availability, reprocess),support_ticketsnotifications, productionMAIL_INBOUND, ADR 0112. Migration 0103.nemar admin mail, with--jsonand exit codes for agents, never-twice replies, escaping of untrusted text.summarize,--needs-summary) and a daily purge afterMAIL_RETENTION_DAYS(730 production, 30 staging) keeping only the summary. Migration 0107.Numbering: the upstream-freshness epic (#1046) holds ADR 0111 and migrations 0104-0106; this epic took 0112 and 0107-0108 so both land without collision.
Production is unaffected until the Phase 6 cutover: no production routing rule targets the Worker. Gates for that cutover: nemarOrg/docs#84 (privacy policy), the Cloudflare limit increase, a staging soak.
Part of #1893. The website Mail tab (nemarOrg/website#480) merges to
stagingafter this.Local end-to-end run (2026-10-24)
Local Worker (local D1, R2, queue and mail capture; no account, no secrets), CLI and website against it:
nemarAdmin; security@ is invisible to admin and agent (list, show exit 3, web 404), visible to ownerweb-key through the proxyAfter merge (staging)
*assignee (dev D1 has nonemarAdmin; production does, and its migration assigns it), restricted queuesfixedwith an owner, escalation ownersecurity@invisible to the test-admin key, visible to the test-owner keyTest plan
🤖 Generated with Claude Code