Skip to content

Release 0.10.24 - #1964

Merged
neuromechanist merged 61 commits into
mainfrom
dev
Oct 26, 2026
Merged

neuromechanist merged 61 commits into
mainfrom
dev

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Release 0.10.24

This PR promotes dev to main with a regular merge, never a squash. The head is dev at 59f3b45 (version 0.10.24-dev16).

The release ships epic #1893, which moves NEMAR mail onto Cloudflare Email Service and adds support tickets. It contains Phases 1 to 5 and 6a (#1902, #1917, #1916, #1928, #1930, #1940, #1944, #1945, #1952) and per-admin unread markers. It also contains the dataset CI shims on pull_request_target (#1784, #1947), the upstream tag passed through onboard (#1933), the --redo and --concurrency flags on nemar admin pr-reviews start (#1922, #1929), the sharded unit-pure job, and the staging test-account sweep change.

Production keeps sending through Resend: EMAIL_PROVIDER is unset in the production stanza, and switching it is Phase 2's flip after the sending-limit increase and a soak. No routing rule targets the production Worker yet, so the email() handler is inert until the Phase 6 cutover.

Pre-merge checklist (.context/release-safety-playbook.md)

  • Required checks green on the dev head (59f3b45), including integration-dev; the checks on this pull request run on the same head.
  • Migrations: 0100, 0101, 0102, 0103, 0107, 0108, 0109 and 0110 are new. All are CREATE ... IF NOT EXISTS or ADD COLUMN with defaults. 0107's backfill and 0109's rebuild touch only mail_tickets, which this same release creates, so they run on empty tables in production. No existing production table is rebuilt, dropped or rewritten. The 0102 seed points the * queue at the nemarAdmin account, which exists in production with the admin role (checked read-only); if it did not, the insert would still succeed and tickets would fall to the pool.
  • Prod wrangler config: the production stanza adds the send_email binding (noreply@ and support@), the MAIL_INBOUND R2 binding, the EMAIL_OUTBOX producer and the outbox and events consumers with dead-letter queues, and MAIL_RETENTION_DAYS = "730". The bucket, all four production queues and the Email Sending onboarding of the domain exist (checked 2026-10-25), so the deploy does not fail on a missing resource.
  • REPLY_TO changes from info@ to support@ on deploy. Until the cutover, support@ reaches the same monitored inbox through the existing catch-all.
  • Deploy path: deploy-backend.yml still installs the root dependencies before the backend ones (shared/ changes). postal-mime is a new backend dependency with an updated lockfile. auto-tag.yml is unchanged.
  • Env gating: purgeExpiredTickets joins the dev cron allowlist; it touches only that environment's own mail tables. The test-account sweep is gated by isNonProductionEnv at the call site and inside the function. Ticket notices go only to active owners and admins with the preference on, never to senders, and the inbound handler never auto-replies.
  • CHANGELOG.md has the 0.10.24 entry (Changelog for 0.10.24 #1965).
  • Scoped review on the full origin/main...origin/dev diff: one integration-scoped reviewer (Sonnet). No Critical findings. Its three Important items were deploy preconditions, the REPLY_TO change and the 0102 seed; each is answered in the boxes above.
  • A human watches the deploy (see the post-merge watch below).
  • Fresh prod D1 restore floor: Time Travel bookmark 000013bf-00000ce6-00005110-64cf5ca31e52bdf5d534f266b33e7ec2, read 2026-10-26 at about 02:42 UTC. The latest nemarOrg/nemar-db-backup commit is 2026-10-26T02:22:56Z.
  • Rollback plan: the live production Worker version is 1e3405ca-0f0b-4aaa-bc8e-7e78a2d9dba1 (deployed 2026-10-24 00:22 UTC). /health reports 0.10.23 before this release.

Production effects

  • New D1 tables for the broadcast outbox, delivery events and tickets; all empty until the cutover.
  • Account mail carries Reply-To: [email protected].
  • Bounce and complaint events from Cloudflare sending are stored by the events consumer; with Resend still the sender, expect little or no traffic there.
  • The daily ticket retention job runs and finds nothing to purge.

Post-merge watch

  1. deploy-backend.yml on main runs twice (the merge, then the strip commit). Both must reach the /health smoke check, and /health must report 0.10.24.
  2. auto-tag.yml creates v0.10.24, npm-publish.yml publishes it, and sync-dev.yml moves dev to 0.10.25-dev0.
  3. nemar admin mail queues against production lists *, security and conduct.

Rollback

  • Worker: cd backend && bunx cfman wrangler --account sccn rollback 1e3405ca-0f0b-4aaa-bc8e-7e78a2d9dba1 -c wrangler-sccn.toml.
  • Migrations: additive and on new tables only, so old code ignores them; a code rollback needs no data restore.
  • Workflow and script changes revert with the merge commit if it has to be reverted on main.

nemar-bot and others added 30 commits October 23, 2026 23:52
* feat(email): Cloudflare provider behind a flag

Add EMAIL_PROVIDER=cloudflare and a send_email binding path in sendEmail behind the unchanged dev fence. Resend stays the default. Cloudflare error codes map to EmailRejectedError or a plain Error. Tested with a binding recorder and Miniflare's send_email binding.

* feat(email): Cloudflare path for broadcasts

With EMAIL_PROVIDER=cloudflare, sendBroadcast sends one message per allowed recipient through sendEmail; the per-recipient fence and result accounting are unchanged and the Resend batch path stays for production. Tests use the shared binding recorder.

* feat(email): store inbound mail in R2

Add the Worker email() handler. A message routed to the Worker is stored raw at inbound/raw/YYYY/MM/DD/<uuid>.eml with envelope metadata; with no MAIL_INBOUND binding it is rejected. Adds the EMAIL, EMAIL_PROVIDER and MAIL_INBOUND binding types and the ForwardableEmailMessage lint global. Tested against Miniflare R2 and the bundled Worker.

* chore(staging): wire Cloudflare mail for dev

Add the dev send_email binding restricted to the staging senders, the nemar-mail-dev inbound bucket, and EMAIL_PROVIDER, FROM_EMAIL and REPLY_TO for test.nemar.org. Only [env.dev] changes; production stays on Resend.

* docs: ADR 0110 and email epic notes

Record the move to the Cloudflare Email Service as a proposed ADR, add the epic working notes, and link them from the context index.

* fix(email): refuse an unknown EMAIL_PROVIDER

An unknown provider value now throws EmailProviderConfigError instead of using Resend, and that error counts as a certain non-delivery. The resolver returns the provider with its binding, used by sendEmail and broadcast.

* fix(email): bound each broadcast send

On the Cloudflare provider each per-recipient send in sendBroadcast is bounded, so a hung binding fails that recipient instead of holding the admin request.

* fix(email): byte-clamp inbound metadata, retry put

Clamp the three header-derived metadata values by UTF-8 bytes without splitting a character, and retry a failed put once without metadata so the message is kept. The body stays buffered because the retry needs the bytes again.

* feat(email): add a text part on the Cloudflare path

Derive a plain-text alternative from the HTML with a small dependency-free converter; codes and links survive. The Resend request is unchanged.

* docs: align ADR 0110 and epic notes

Match the strict EMAIL_PROVIDER rule and the text part, place the index entry after ADR 0109, and correct the Wrangler pin note.

* fix(email): harden the HTML to text converter

Decode each link label, url and text exactly once and never re-strip decoded text, look entities up in a Map, read unquoted href, cap the input at 256 KiB, and scan blocks and links forward once so unclosed tags cost linear time.
The tag v0.10.23 was created at 2026-10-23T23:51Z, so the entry is dated 2026-10-23. Docs only, tested with the changelog format test.
The apex MX moved to Email Routing on 2026-10-23 with the catch-all forwarding as before, and the soak fallback is limited to refusals that certainly sent nothing. Epic phase table matches the issues.
The live send_email runtime refuses an EmailAddress object whose name is not a string, so a bare reply-to address made every staging send fail. Miniflare accepted it. Tested: email provider, broadcast, binding and inbound suites; typecheck; biome.
* Fall back to Resend on Cloudflare quota refusal

* Bind Cloudflare email in production, no switch

* Sort imports in email-provider test

* Log and harden the Resend fallback
bun install blocked it; the script only links a fallback binary.
Tested: bun install prints no blocked-script notice, lint and typecheck pass.
* feat: queue announcements on the outbox

Migration 0100 adds status and outcome counters to broadcast_emails. sendBroadcast enqueues one message per allowed recipient when the Cloudflare provider and EMAIL_OUTBOX are both present. Tested with real D1 and a recording Queue binding.

* feat: consume the announcement outbox

queue() dispatches broadcast messages to handleOutboxBatch, which sends through sendEmail and records each outcome on the audit row. Rate limits retry after 300s; unknown outcomes are never retried. Exports CLOUDFLARE_LIMIT_CODES.

* feat: announcement status route and CLI

GET /admin/notify/:id reports a queued announcement's counts; nemar admin notify prints the queued result and gains --status. POST answers 502 when enqueueing fails.

* fix: idempotent announcement outcomes

Add broadcast_outcomes keyed by recipient hash; counters move only when the outcome insert took. A partial enqueue records unqueued outcomes and answers 200 with the counts.

* fix: bound outbox retries and pace limits

max_retries 10 with growing limit delay, give up and record a failure on the final attempt, defer the rest of a batch after a limit refusal, skip already-recorded recipients. Names the queues in wrangler and tags the unrecognised-message log.

* fix: show enqueue failure and redaction in CLI

* test: allow 0100's outcomes table after 0098

* fix: dedupe queued recipients by hash key

* test: pin getBroadcastStatus export

Adds the new CLI API export to the per-module pin and the post-split list. Tested: api export surface, notify CLI and route inventory tests.

* feat: store email bounce and complaint events

* feat: route email events, prune after 180 days

* docs: amend ADR 0110 for the soak and events

* test: account for 0101 and events consumers

The outbox retry check now reads only the outbox consumers, and the 0098 schema check lists 0101's table and indexes as a later migration's. Tested: events, outbox, 0098 migration and provider suites.

* fix: delay event retries, tighten ADR 0110

A failed D1 write now retries after a growing delay instead of at once; the ADR states the outbox retry bound, the de-duplication, and that every other event type is dropped. Tested: events and outbox suites, ADR index, typecheck.
* Let an administrator redo a finished review

start takes ?redo=1: a reported commit is restarted on its row through the restart edits use, a running review is never superseded (review_running), the Worker echoes redo, and the audit row records it. No SQL or migration change. Tested with the real handler and router, and with six mutations of the restart rule.

* Add --redo to nemar admin pr-reviews start

Named redo, and start --all --redo for every open pull request with a finished review (drafts, running reviews, exempt pull requests and commits capped for edits stay out). A Worker that predates the flag is detected by the missing echo and the command says so. Tested through the real CLI against the real router, and with four mutations.

* Record start --redo in ADR 0093 and 0107

Amendment of ADR 0093 for the redo and its two limits, the matching notes in ADR 0107 decision 4, and one clause in the AGENTS.md ADR 0093 entry. Docs only.

* Keep a redo off live jobs, blocks and the edit cap

Review findings on the redo: an administrator's start no longer supersedes a job still inside its limit (claimed less than 50 minutes ago, even after the watchdog closed the row), a redo of a blocked contributor's finished review answers contributor_paused and writes nothing, a redo leaves the edit count alone, and an administrator's start is tried again when the row moves under it. The job limit is pinned to the workflow. Tests with five mutations.

* Report an ignored --redo truthfully

A Worker that predates the flag: the answer it gave is reported (a start it made is not hidden), then the command says the flag was ignored and exits 1 without the bug-report hint; a bulk run stops after one answer and keeps its results, in the JSON too. The dry-run list marks the finished reviews and their verdicts, and the help states the block, exemption, running-job and edit-count rules.

* Bring the redo ADR text in line with the code

ADR 0093 amendment: blocks, edit count, the claim window, retries, volume and the name overlap with ADR 0102; ADR 0092 and 0107 pointers; AGENTS.md wording. Docs only.

* Refuse the restart if a job claimed meanwhile

The restart write now also requires the claimed_at it read, so a job that claims the review between the guard and the write is never superseded by an administrator's start; the next try reads the claimed row and the guard refuses it. Tested with an injected claim, redo and plain, and a mutation.

* Polish the ignored --redo report

Say how many were not tried only when some were; report the ignored flag before a fault exit and keep the bug-report hint for a real fault; mark the finished reviews of every verdict in the tests; say in the help that a recent claim holds a start back.

* Tighten the redo ADR wording

ADR 0092 names the 50-minute claim window, ADR 0093 says which starts begin the edit count again and that a blocked redo leaves the result alone. Docs only.
Email on Cloudflare: Phase 2 (production sending prepared)
freshDb and freshDbWithForeignKeys deserialize a copy of a lazily built migrated template. Full backend suite: 8446 pass, 183 s.
unit-pure-shard runs bun test --shard=i/6 with seeded timings; the unit-pure gate keeps the required check name and proves every classified file ran. The file classifier moves to scripts/ci/unit-pure-files.sh, shared with deploy-backend test-gate (left serial). Tier-routing guard reads the script.
Gate proves the exact set of files each shard ran (junit), none twice; deploy gate and shards write the classifier output to a file and refuse an empty list; one unit_pure_due output replaces three copies of the nine-term filter; tier guard pins both callers of the shared script.
The exactly-once block meant for the unit-pure gate was also inserted into the scrub-tools gate, which has no file list, so jq failed to compile and the gate went red although every scrub shard passed. Tested: workflow YAML and tier-routing suites (64 pass).
* 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
* Add a sliding-window scheduler for bulk starts

runPaced keeps at most n of the reviews a run started in progress, starting the next as each leaves in_progress. A read that cannot tell is never taken as finished, and three in a row stop the run. Ctrl-C ends a wait at once and reports what was never tried. Tested on a simulated pool with a virtual clock, with six mutations.

* Add --concurrency to nemar admin pr-reviews start

start --all [--redo] --concurrency n keeps at most n of the reviews the run started in progress, reading the admin list every 30 seconds while it waits. Ctrl-C and three unreadable lists in a row stop the run and list what was never started (as commands for a redo). The unpaced run goes through the same scheduler with no limit. Hint above ten starts at once, plan in --dry-run, concurrency and not_started in the JSON. Tested through the real CLI against the real router with jobs finishing during the run, and with five mutations.

* Record the pacing of a bulk start in ADR 0093

Amendment for start --all --concurrency and the pointer from ADR 0107's note on the output-tokens-per-minute limit. Docs only.

* Keep the pacing honest when the list misleads

Review fixes for the scheduler: a review that leaves the in-progress list is confirmed finished before its slot is freed (a closed pull request or a lagging search also drops out), a start that may have reached the Worker takes a slot, a slot is held at most 100 minutes, a read in flight no longer holds Ctrl-C, and Ctrl-C during the last unreadable read ends as interrupted. Tests with four more mutations.

* Make Ctrl-C and the stop reports reliable

A second Ctrl-C leaves at once and the first says so, one keypress delivered twice counts once, ten unreadable reads (about five minutes) stop the run with a dim line for each, a failed start is listed to be checked, the redo continuation says to run the commands by name, and no markReportedExit before exit 130. Tests for a closed pull request, a hanging list read, a hanging start (paced and unpaced), the unreadable branch and the 128,000 figure.

* Correct the pacing amendment

The overdue time is 90 minutes, not 60; leaving the list is confirmed; the unpaced run's Ctrl-C and JSON change are named; ten unreadable reads; the second amendment is named in ADR 0107. Docs only.

* Hold the slot for a cut connection and name the commit

Round 2 fixes: a start whose connection or response failed (status 0) may have begun the review and takes a slot; the confirmation names the commit the run started so an unreadable GitHub or a moved head no longer reads as finished; both reads are bounded at two minutes; a second Ctrl-C says which start was in flight. The tests observe the front instead of sleeping, kill every child they launch, and cover the dropped response, the unbounded read and the moved head. ADR 0093 follows.
* 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]>
CI: migrated test db template and six unit-pure shards
* 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]>
nemar-bot and others added 24 commits October 24, 2026 23:38
Fork pull requests on dataset repositories now get BIDS validation and version-check: the per-dataset shims trigger on pull_request_target, check out nothing from the pull request, pass only shape-checked identifiers through env, and mint a token scoped to the .github repository.
* test: pin fork shim safety properties

* docs: amend ADR 0020 for fork shims

* docs: index the ADR 0020 amendment
Email epic: support tickets, nemar admin mail, retention
* Stop setting Message-ID on ticket replies

* Answer mail reply errors with 409 and 422

* Accept word ticket refs in mail_tickets

* Use three-word ticket references

* Use template literals in mail route test

* Address review of word refs and replies
Sweep CI accounts with open upload requests
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Release review: integration scope, origin/main...origin/dev

One integration-scoped reviewer (Sonnet) read the whole range for production risk only; each phase PR had its own review. Result: no Critical findings, three Important items (each resolved below), three suggestions.

Important

  1. Deploy preconditions. The production stanza adds the nemar-mail R2 bucket, the nemar-email-outbox and nemar-email-events queues with their dead-letter queues, and a send_email binding; a missing resource would fail the deploy after the migrations ran. Resolved: all of them exist in the production account and the domain is onboarded for Email Sending (checked 2026-10-25).
  2. REPLY_TO moves from info@ to support@ on deploy while production still sends through Resend. Resolved: until the receiving cutover, support@ reaches the same monitored inbox through the existing catch-all.
  3. Migration 0102 seeds the * queue to nemarAdmin by username; if the account were absent the assignee would be NULL and tickets would fall to the pool. Resolved: the account exists in production with the admin role (read-only check); resolveAssignee returns null for a fixed queue with no present assignee, which leaves the ticket in the pool rather than orphaned.

Clean areas

  • Migrations 0100-0103 and 0107-0110: no collision with main (which ends at 0099); all CREATE ... IF NOT EXISTS or ADD COLUMN with defaults; 0107's backfill and 0109's rebuild touch only mail_tickets, created in this same release and empty in production.
  • Env and bindings: EMAIL_PROVIDER unset means Resend; an invalid value or a missing binding throws rather than silently switching. EMAIL_FALLBACK unset. Nothing new sends through Cloudflare in production.
  • Env gating: purgeExpiredTickets touches only that environment's own mail tables and deletes nothing if MAIL_RETENTION_DAYS is invalid; the test-account sweep is gated by isNonProductionEnv at the call site and inside the function; ticket notices go only to active owners and admins with the preference on, never to senders.
  • email() handler: raw R2 put first (retried once without metadata, then throws so Email Routing reports the failure); ticket ingest after it, failures there swallowed because the raw message is the record; no auto-reply path.
  • Deploy path: root install before backend install is unchanged; postal-mime added with the lockfile; auto-tag.yml unchanged. The dataset CI shims on pull_request_target check out nothing from the pull request and validate every event field, so no fork code runs with secrets; they reach dataset repositories only through the template sync.
  • Contract: new routes are additive; an older published CLI is unaffected.

Suggestions

  • Capture a Time Travel bookmark: done, in the PR body.
  • After deploy, check that the nemar-email-events consumer sees no unexpected traffic.
  • Watch both deploys (merge and strip commit).

A changelog entry for 0.10.24 lands on dev before merge; it changes only CHANGELOG.md, so it does not reopen this review.

neuromechanist and others added 2 commits October 25, 2026 20:58
* Changelog for 0.10.24

* Fix exit codes and onboard note
@neuromechanist
neuromechanist merged commit f5a7554 into main Oct 26, 2026
42 checks passed

This branch was previously deployed

1 inactive deployment
npm — 59f3b45e Deployed Oct 26, 2026 by github-actions[bot] via publish #4000
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.

2 participants