Skip to content

Idempotency key for ticket notes - #1945

Merged
neuromechanist merged 4 commits into
feature/issue-1893-epic-email-cffrom
feature/issue-1941-note-idempotency
Oct 24, 2026
Merged

neuromechanist merged 4 commits into
feature/issue-1893-epic-email-cffrom
feature/issue-1941-note-idempotency

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

POST /admin/mail/tickets/:id/note accepts an optional Idempotency-Key (same format as replies, unique per ticket), so a note retried after a lost response is stored once. Notes send no mail, so there is no pending or unknown state: the note and its key are written in one batch, and a repeat of the key returns the stored message_id and writes nothing. Note keys live in their own table (migration 0108), so a note key and a reply key never collide. The retention purge deletes note keys with the rest of a ticket. nemar admin mail note always sends a key, prints it before sending, and after a network failure or a 5xx says to retry with it.

Closes #1941
Part of epic #1893.

Test plan

  • Same key stores one note and replays its id; different keys or none store separate notes; bad key refused; note and reply keys are separate namespaces; a purged ticket refuses a keyed note (mail-admin-routes, 5 new)
  • Purge deletes note keys and keeps them when its re-check declines (ticket-retention)
  • CLI: generated and supplied keys, local refusal of a bad key, retry guidance on 503 and network failure, none on 4xx (5 new)
  • migrations, cron wiring, route inventory, export surface, typecheck, lint

🤖 Generated with Claude Code

neuromechanist and others added 4 commits October 24, 2026 13:54
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]>
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]>
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]>
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]>
@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR1945

Version: 0.10.24-PR1945.5b70965
Commit: 5b70965


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 75a26cf into feature/issue-1893-epic-email-cf Oct 24, 2026
13 of 14 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-1941-note-idempotency branch October 24, 2026 21:05

This branch was previously deployed

1 inactive deployment
npm — 5b70965d Deployed Oct 24, 2026 by neuromechanist via publish #3930
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant