CatoandClaude Opus 5 d1de3a167c ci(auto-merge): hand the sweep a PAT so workflow PRs stop stalling (#2)
GITHUB_TOKEN cannot merge a PR that touches .github/workflows. The sweep tries,
the merge API refuses, it logs "leaving for the next sweep", and repeats — while
still exiting 0. So the failure is invisible: every run reports success and the
PR simply never merges.

That is not hypothetical. ai-kit #11 (bump actions/checkout) sat green, CLEAN
and MERGEABLE for nine days; aoz-housing #122 (bump actions/upload-artifact)
for nine more. Both had to be merged by hand today. Every Dependabot
`github_actions` bump in the fleet is in this class, permanently.

A PAT fixes a second thing that costs more: THROUGHPUT. A dispatch made with
GITHUB_TOKEN emits no workflow_run, so after each merge nothing wakes the sweep
to take the next PR — it waits for the cron, and GitHub throttles scheduled
workflows to roughly hourly regardless of what the cron says. Observed in
fleetcrown: sweeps ~50-65 minutes apart against a */10 schedule. A PAT-created
dispatch does emit workflow_run, so the queue drains at CI speed instead.

The reusable workflow has always supported this — GH_TOKEN is
`secrets.token || github.token`. This just passes it.

SAFE BEFORE THE SECRET EXISTS: an undefined secret resolves to empty, and the
fallback picks github.token. So this changes nothing until FLEET_PAT is created
as an organisation secret, and needs no second pass afterwards.


Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 14:58:48 +00:00

@bitbaum/mail-kit

The fleet's one email layer. One provider (Resend), one env contract, one call shape, zero runtime dependencies.

Exists because the fleet grew ~12 bespoke email implementations across three provider styles, and a dead SMTP credential silenced two apps' outbound mail for months without anyone noticing. Uniformity is the fix.

Install

pnpm add @bitbaum/mail-kit

Use

import { sendMail, isMailConfigured, mailHealth, conventionalFrom } from "@bitbaum/mail-kit";

const result = await sendMail({
  to: "person@example.ch",
  subject: "Your invoice",
  html: "<p>…</p>",
  attachments: [{ filename: "invoice.pdf", content: pdfBuffer, contentType: "application/pdf" }],
});

if (!result.sent) {
  // result.error, result.status?, result.retryable — sendMail NEVER throws.
  logger.error("invoice email failed", result);
}
  • sendMail never throws. A thrown email error inside a server action reaches nobody and destroys the form; a { sent: false } you must look at is deliverable. Callers where delivery matters check .sent.
  • isMailConfigured() — gate flows that depend on an email arriving (password reset, invoices). A placeholder key and a production sandbox sender (@resend.dev) count as unconfigured: both look configured and deliver to nobody.
  • mailHealth() — key-validity + domain-status probe for /api/health. A passing probe does not prove delivery; only a real send does.
  • options.idempotencyKey — pass from crons/queues so a retried job cannot double-send (Resend dedupes for 24h).

Env contract (the whole of it)

Var Meaning
RESEND_API_KEY required to send
RESEND_FROM sender — Name <addr> or bare address (optional if every call passes from)

Fleet conventions

  • The shared Resend account is on the free tier: 1 verified domain, 100 emails/day, 3,000/month. Hitting the daily cap surfaces as { sent: false, status: 429, retryable: true }.
  • Only fleetcrown.orangecat.ch is verified, so every app sends as <app>@fleetcrown.orangecat.ch — conventionalFrom("My App") builds it.
  • A daily canary on the box sends one real email and alerts Telegram when it fails — that, not this package, is what proves delivery keeps working.

What this is not

  • Not a template engine — apps own their HTML.
  • Not a queue — retryable tells a caller whether a retry can help; scheduling one is the caller's decision.
  • Not for bulk — newsletters go through Listmonk.
S
Description
No description provided
Readme MIT
215 KiB
0 Stars 2 Watchers 0 Forks
Languages
TypeScript 99.2%
JavaScript 0.8%