Skip to content

Fix ticket replies on Cloudflare, word refs - #1952

Merged
neuromechanist merged 6 commits into
feature/issue-1893-epic-email-cffrom
feature/issue-1893-ticket-ref-reply
Oct 25, 2026
Merged

neuromechanist merged 6 commits into
feature/issue-1893-epic-email-cffrom
feature/issue-1893-ticket-ref-reply

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Part of epic #1893.

Summary

Staging showed every ticket reply failing: Cloudflare Email Service treats Message-ID as platform-controlled and refuses the whole send. This PR fixes that, moves mail errors off 502, and makes ticket references readable.

  • Reply headers: a reply sends only In-Reply-To and References. sendViaCloudflare checks headers against Cloudflare's allowlist before the binding is called, and the test binding enforces the same allowlist, so a platform-controlled header now fails in tests.
  • Stored Message-ID: sendEmail returns the provider's id; it is stored as the outgoing message's message_id only when it is a valid msg-id, otherwise NULL. Threading of the requester's answer relies on the support+t<ref>@ reply-to plus tag.
  • Statuses: reply_not_sent 502 -> 422, reply_delivery_unknown 502 -> 409, inbound_not_configured 503 -> 409. The website's proxy lost the JSON body of a 502, so the page could not read code. Clients decide by code.
  • Word refs: new tickets get three words from the EFF short word list (amber-falcon-river), plus tag support+t-<ref>@. Legacy ten-character refs keep working and are not rewritten. Creation retries on a ref collision.
  • Migration 0109: rebuilds mail_tickets so its CHECK accepts both forms, preserving rows, ids, indexes, the trigger, the sequence and every child row (children are copied out and restored, because DROP TABLE cascades even with deferred foreign keys).
  • ADR 0112 gets dated amendments for the status change and the ref format.

Contract change for the website

ReplyResponse.header_message_id is now string | null; reply error statuses as above. The website transcription needs the same change.

Test plan

  • bun run typecheck, bun run lint
  • Full backend suite: 8658 pass, 0 fail
  • Migration test on bun:sqlite and Miniflare D1 (rows, ids, indexes, trigger, sequence, cascades, both ref forms, malformed refused)
  • Staging: reply to ticket 2 is delivered; answering it threads back

@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR1952

Version: 0.10.24-PR1952.c4c6893
Commit: c4c6893


🤖 Updated on each push.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review (Sonnet, one round): no blocking defects. Addressed: the 0109 restore now deletes each child table before restoring it, so it is exact even if a cascade were skipped; ADR 0112 body lines on the plus address, Message-ID and reference entropy carry dated amendment markers; the CLI retry comment is rewrapped. Not changed: the EFF word list attribution stays in ticket-words.ts, since the list is reproduced only in source and users see single generated references, not the list. Verified: migration, mail route, ingest tests 124 pass; CLI mail 61 pass; migrations:d1-check replays all 108 migrations on real D1 and the catalog matches.

@neuromechanist
neuromechanist merged commit b384633 into feature/issue-1893-epic-email-cf Oct 25, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-1893-ticket-ref-reply branch October 25, 2026 18:58

This branch was previously deployed

1 inactive deployment
npm — 5eac583d Deployed Oct 25, 2026 by neuromechanist via publish #3965
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