Skip to content

Mailbox manifest and one command to deploy every copy (0.4.0) - #3

Merged
cycle-five merged 11 commits into
masterfrom
mailbox-tool
Nov 20, 2026
Merged

cycle-five merged 11 commits into
masterfrom
mailbox-tool

Conversation

@cycle-five

Copy link
Copy Markdown
Member

What this is

A mailbox is one agent's set of things: its own copy of every broker and its entry in mailroom. Until now a mailbox existed nowhere as one thing. It was an env block copied by hand into each broker's git-ignored wrangler.jsonc, two service bindings and an entry in mailroom's config in another repository, two KV namespaces and four secrets made by hand, and its name typed about nine times with nothing checking they agree. A broker release was 2×N deploys and 2×N checks by hand.

This pull request makes the mailbox the unit: one manifest entry per mailbox, and one command that generates every config from it, deploys and verifies. Design: docs/superpowers/specs/2026-11-19-mailbox-manifest-design.md. Released as 0.4.0; nothing inside a Worker changes except the version number.

Design

packages/mailbox is a new workspace package, TypeScript run directly by Node (22.18 or later).

npm run mailbox -- <check|render|deploy|status> [mailbox...] [--manifest <path>] [--mailroom] [--allow-change] [--no-input]
  • The manifest (mailboxes.jsonc, documented by mailboxes.example.jsonc) holds everything about every mailbox that is not a secret. It is not committed here: the repository is public, and the file decides who may sign in to each broker.
  • Each broker contributes its own shape. The tool takes everything broker-specific from brokers/<name>/wrangler.example.jsonc (the Worker name stem, which variables exist and which are required) and from broker.secrets in its package.json. It contains no broker name and no mailroom source key, so a third broker needs no change to it.
  • Generated, git-ignored files: brokers/<broker>/wrangler.<mailbox>.jsonc per copy, and wrangler.jsonc in mailroom's Worker directory, built from mailroom's own example.
  • deploy, per copy: make sure the KV namespace exists, write the config, deploy (once more on code 10007), list missing secrets and at a terminal hand each to wrangler secret put, then verify the banner version and the OAuth issuer over HTTP. With --mailroom, then deploy mailroom-core. Adding a mailbox is deploy <name> --mailroom; a release is deploy.
  • New mailboxes get a hostname on a domain you own (a hostname pattern in the manifest), as a Cloudflare custom domain, so the address no longer names the Worker behind it.
  • Wrangler is driven through one injected function and HTTP through an injected fetch, so the orchestration is tested without an account (125 tests).

Guards

The tool can reach live Workers, so it refuses rather than guesses:

  • A KV namespace is created only for a Worker that does not exist yet. An existing Worker with no namespace under its pinned id or title is an error; a new, empty namespace would sign everyone out.
  • Two copies may not share a KV namespace, by pin or by title.
  • A duplicated key in the manifest is an error. A pasted mailbox whose name was not changed would otherwise replace a live one.
  • A Worker that does not exist yet is not deployed to a hostname that already resolves; without a terminal wrangler takes a hostname over without asking.
  • Changing a deployed copy's Worker name, KV namespace or PUBLIC_URL, or renaming a binding mailroom already uses, needs --allow-change.
  • Mailroom is deployed only after every chosen copy deployed, has its secrets and verified; its config is planned before any broker is touched.
  • The tool handles secret names only. Values go from the terminal straight to wrangler.

Found by testing against the real account

  • Rendering the real manifest reproduces the hand-kept configs of all four live Workers and of mailroom-core: same names, variables, KV ids and bindings. Wrangler's own binding tables match; the only difference is an optional variable now written as "" on the GitHub copies.
  • Wrangler refuses the first deploy of a config that lists secrets.required while a secret is unset, and a Worker that does not exist cannot be given one. So secret names are declared in package.json, not to wrangler.
  • A throwaway mailbox on a new two-level hostname: Cloudflare issued the certificate by itself, and the name answered three to four minutes after the deploy. The machine's own DNS resolver cached the empty answer from an early probe for half an hour. So the tool asks a public DNS-over-HTTPS resolver first and waits up to ten minutes for a custom domain. The rerun deployed, waited, verified and left local DNS working. Both throwaway Workers, their namespaces and DNS records are deleted.

Also

  • The version test finds every package.json itself.
  • README: "Mailboxes" (manifest, commands, adding a mailbox, releasing) and "Adding a broker".
  • A single hand-kept wrangler.jsonc per broker still works for someone running one copy.

Checked

  • npm run typecheck clean; tests: broker-core 48, mailbox-tool 125, discord-broker 65, github-broker 51.
  • Per-task reviews, a whole-branch review, one fix wave and its re-review.

After merge

npm run mailbox -- deploy for 0.4.0 on the four live Workers, verify, then tag v0.4.0 and release.

🤖 Generated with Claude Code

https://claude.ai/code/session_017zqkE8grD6nh1bNnb2r1X8

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
…example config

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
…anifest

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
wrangler refuses the first deploy of a config with secrets.required.

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
…gler

Wrangler refuses to deploy a config with secrets.required while a secret is
unset, and a Worker that does not exist cannot be given secrets, so a new
mailbox could never have its first deploy. Names now live in each broker's
package.json under broker.secrets; an example with a secrets key is an error.

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
… reference

Duplicate and __proto__ keys, shared KV namespaces, ports and trailing dots in
origins, all problems of a copy in one run, a clear error for a broker without
package.json. The example manifest comments out the mailroom block.

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
…nges, mailroom checks

KV and secret commands run from the repository root; a new custom domain is
refused when it already resolves and is awaited through public DNS for up to ten
minutes; a changed name, KV namespace, PUBLIC_URL or mailroom binding needs
--allow-change; a hand-written mailroom config is kept as .bak; the command line
moves into a tested execute().

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
… paragraphs

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
…name refusal

Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
@cycle-five
cycle-five merged commit 5b870e7 into master Nov 20, 2026
1 check passed
@cycle-five
cycle-five deleted the mailbox-tool branch November 20, 2026 01:23
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