Skip to content

prototype(integrations): patches read and answer a company email address on Pidgeon - #819

Open
allisonmahmood wants to merge 3 commits into
mainfrom
prototype/pidgeon
Open

allisonmahmood wants to merge 3 commits into
mainfrom
prototype/pidgeon

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Prototype, not for merge. It's up so we could try a Pidgeon integration before planning the build. The build plan is #822, with tickets #823–#826.

What changed

Pidgeon gives agents and software real email inboxes over an API. Internal tools need email all the time: a shared support inbox, mailing a quote, reading invoices that arrive as attachments. Patches have no way to reach email today. This prototype makes a company email address on Pidgeon a third integration. It's the first one that can write.

  • One connection is one address. An admin mints a Pidgeon key for a single address, at read or send, and pastes it in the connect form. Patchy reads the key's own description (GET /me). It refuses keys that can administer the address, and keys that reach any number of addresses but one.

  • What patch code gets. Operations that Patchy writes, never raw Pidgeon calls:

    • reads: threads.list and threads.get, messages.get and messages.search, labels.list, attachments.text;
    • with a send key: messages.reply and messages.send, plus threads.update, label and unlabel for triage.

    Patchy fills in the address, so a patch can't read or send as any other one. On a read-only connection the generated client has no write methods. Message text arrives already cleaned by Pidgeon's prompt-injection firewall, with its verdict attached.

  • Sends name their draft. Every send and reply takes an idempotencyKey the patch keeps per email. Pressing Send again after a lost answer can't mail anyone twice.

  • Recent calls show each send's subject, recipients and CC, and who sent it. Message bodies are never kept.

  • Dev never touches the real address (ADR-0013's default for anything that writes). patchy dev runs the same operations against a fake mailbox seeded from fixtures/pidgeon-<handle>.json. Sends land in the fake, nowhere else.

Try it

pnpm dev up pidgeon
pnpm dev open rae        # Support desk, as a member
pnpm dev open allison    # Connections › pidgeon/support, as the admin

up connects an in-memory inbox, [email protected], through the connect form, then publishes Support desk, a tier 1 patch over it. The fake answers these keys:

  • pgn_fake_support_send connects with send access;
  • pgn_fake_support_read connects read-only;
  • pgn_fake_admin and pgn_fake_everything show the refusals.

To build something yourself, run the environment's agent and ask for an email tool in your own words. Tell it to build in the workspace folder.

Look at

A phishing email in the shared inbox. Pidgeon's firewall flags it, Patchy passes the verdict through, and the hidden instruction aimed at an AI is gone from the text.

Support desk showing a flagged message

Reading an attachment, replying and triaging, all as a member, through Patchy.

A reply sent from Support desk, with the thread moved to Waiting

Built by a fresh agent from the skill alone. Asked to stop two people answering the same customer, Claude Sonnet 5.5 combined the inbox with its own table and the member directory. It took 35 turns. Here Jonas opens a conversation Rae has taken.

Jonas sees Rae is handling the conversation

The connection page: recent calls name each send's subject and recipients

pidgeon/support with recent calls

The connect walkthrough, refusing a key that can administer the address

Connect Pidgeon email, refusing an admin key

What trying it showed

  • Fake-only dev lets agents build against mail they imagined. A second fresh agent built a supplier-invoice list in 29 turns. Its parser matched the invoices it had invented for its own fixture, so it found none of the real ones. The demo inbox's invoice says INVOICE INV-3391; the agent's invented ones say Invoice No: ….

    Supplier invoices: 0 found

    This is the main decision for the build:

    • keep dev fake-only;
    • let dev read the real address while sends stay fake, as PostHog's reads already do (ADR-0013 would become "writes are never live");
    • or let an admin copy chosen threads into a fixture.
  • The broker's refusal tells an agent nothing. The generated client first sent cursor: undefined, which the broker refuses as "The broker request is malformed." Fixed in the client, but that message is worth improving for every integration.

  • Pidgeon keeps no per-person state for a key. It has no read state and no assignment, so "who's handling it" lives in the patch's own table. The agent found this from the skill and built it that way.

  • Both agents had to move to tier 1. Tier 2 has no Pidgeon client yet.

  • GPT 6.1 Sol reviewed the prototype. The design fits Patchy's model, and Sol found no way to read or send as another address. Fixed in the second commit:

    • a send key regenerated on every click, which could double-send;
    • unlabel misreading Pidgeon's answer;
    • Pidgeon's 4xx refusals reported as outages;
    • CC missing from recent calls;
    • the fake applying the send policy to only some recipients;
    • the sample ignoring rejected recipients.

Decisions for the build

Settled on 2026-10-21 and planned in #822:

  • Companies bring their own Pidgeon. An admin pastes a Pidgeon admin key, picks one of the addresses it reaches or creates a new one, and Patchy mints and keeps a key for that address alone. The admin key is never stored. This replaces the prototype's pasted address key.
  • Dev reads the real address; writes never leave dev. Sends, replies and triage in dev are simulated. ADR-0013 becomes "writes never run live in dev".
  • Company-wide sending is fine for v1 with three guardrails: new addresses reply-only by default, a durable daily send budget per connection, and recent calls.
  • The build fixes what the prototype left: paging in long threads, a change between read and send access refreshing the snapshot, a byte cap of its own, and the dev door's PostHog-only plumbing.
  • First, a real account. Pidgeon: an account to build against, and a probe of the plan's facts #823 probes the facts the plan rests on before feat(integrations): Pidgeon connections that mint a key for one address #824 builds on them.

Amended on 2026-10-25, after Pidgeon shipped key rotation and test-mode keys:

  • A draft is one email. The same draft key with different mail is refused (idempotency_conflict) rather than sent. The prototype already built the key from the connection and the draft key alone; the content hash the plan added is gone.
  • Rotate needs no admin key. Patchy rotates the address key it stores. Only changing access or replacing a dead key re-mints.
  • Test-mode keys are refused at connect. Dev keeps simulating writes until Pidgeon: an account to build against, and a probe of the plan's facts #823 shows a test key's writes stay out of real conversations.

Amended again on 2026-10-26, after Pidgeon shipped the rest (#822 has the details):

  • Rotate is cut from v1. Replace key gives a connection a new secret.
  • Test-mode keys connect, labelled Test. Pidgeon: an account to build against, and a probe of the plan's facts #823 found their writes land in real conversations, so patchy dev still simulates writes on a company's address.
  • No fake Pidgeon in the build. Tests run on Pidgeon's test mode, on test addresses each run creates. This prototype's fake stays here only.

Leaves out

What a build owns:

  • tier 2;
  • a real Pidgeon account (the form accepts real keys, but only the fake has been exercised);
  • limits registry entries;
  • tests for the new code;
  • HTML bodies and attachment downloads;
  • the docs pass (docs/product.md, glossaries, ADR-0013, the init AGENTS.md).

The scenario's connect step reuses the Shopify prototype's form-posting helper.

How it was verified

  • pnpm typecheck passes across the repo, tests included.
  • Lint is clean on the changed files.
  • vitest run packages/api packages/integrations packages/sdk passes: 30 files, 188 tests.
  • pnpm dev up pidgeon, then a Playwright walk:
    • as Rae: read a flagged message, read an attachment, reply, set the status, send a new email;
    • as Allison: the connections pages and a refused key.
  • Two fresh-agent trials through the environment's agent, described above.
  • One review round with GPT 6.1 Sol, with its fixes.
  • Not run: pnpm verify, and any real Pidgeon account.

Release impact

  • Breaking — requires action from anyone already running this
  • Not breaking — no action required

Never merged. If it were: an additive integration with wire and CLI changes, and no migration.


Built and tested by Claude Opus 5.5 in Claude Code (T3 Code). The builder trials ran Claude Sonnet 5.5, and GPT 6.1 Sol in Codex reviewed the prototype.

allisonmahmood and others added 2 commits October 20, 2026 16:50
…ess on Pidgeon

Never merged. A throwaway slice of a Pidgeon (pidgeon.ai) integration: one
connection is one email address, connected with a key that reaches only it.
Patches read threads and messages through Patchy-written operations and,
when the key can send, reply, send and triage. `pnpm dev up pidgeon` runs it
on an in-memory inbox; `patchy dev` answers from the repo's fixture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… fixes

Sends and replies now require an idempotency key the patch keeps per draft,
so pressing Send again after a lost answer can't mail twice. Unlabel reads
the remaining labels back, Pidgeon's own 4xx refusals become invalid_request,
recent calls keep the subject and CC recipients, the fake applies the send
policy to every recipient, and the generated client drops undefined options
the broker would refuse.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area area:integrations Company connections and integration implementations area:ui Portal and first-party browser pages, shared rendering and styles size:xl Over 1,000 changed lines; review in multiple passes labels Oct 20, 2026
allisonmahmood added a commit that referenced this pull request Oct 28, 2026
…ulates sends (#955)

## What changed

`patchy dev` couldn't run Pidgeon at all: every call failed
`invalid_request`, so a builder's agent built a support desk against
mail it never saw. Now `patchy dev` reads the connected address's real
mail through the instance's dev read door, as the builder, and simulates
every send, reply and triage. Dev's output names what it would have
sent, and nobody receives anything.

Closes #826. Part of #822. **Ships in one release with #921 and #954**,
and stacks on #954.

## Look at

**1. Pressing Send in the Support desk under `patchy dev` sends
nothing.** On `pnpm dev up pidgeon`, I started the workspace repo's
`pnpm patchy dev --json` with the agent launcher's environment, then
drove the desk in Chromium: list, open, type a reply, press **Send
reply**.

```
listed 4 conversations
opened conversation 1: 1 messages
notice: Sent to Lumen Bikes Billing.
after the send, the reloaded conversation has 1 messages
```

`dev.log` names the simulated reply. This session logs JSON; a text
session prints `<viewer> pidgeon/support messages.reply <id>: simulated
in dev, nothing reached Pidgeon`.

```json
{"type":"simulated","viewerId":"usr_env_lumen_allison","connection":"pidgeon/support","operation":"messages.reply","summary":"messages.reply <message id>"}
```

The connection's recent calls on the instance show only Dev reads, the
last one being the desk's reload after the send. There's no write:

```
Dev  patchy dev on Dev environment  threads.list          Allison Mahmood  6 rows  Succeeded
Dev  patchy dev on Dev environment  threads.get <thread>  Allison Mahmood  1 row   Succeeded
Dev  patchy dev on Dev environment  labels.list           Allison Mahmood  5 rows  Succeeded
Dev  patchy dev on Dev environment  threads.get <thread>  Allison Mahmood  1 row   Succeeded
```

`pnpm dev down`: `Pidgeon: revoked 1 key and deleted 1 test address this
environment made.`

**2. A repo whose only live integration is Pidgeon gets the machine
key.** `patchy dev` handed its key to the daemon only when PostHog was
declared. `devLifecycle.test.ts` › "hands the key to a repo whose only
live integration is Pidgeon…", run over #954's `devLifecycle.ts`,
`dev.ts` and `devPreparation.ts`:

```
AssertionError: {"ok":false,"source":"patchy","error":"The instance refused this machine's key: it expired or was revoked, or your account was deactivated. …","code":"access_denied"}: expected 403 to equal 200
```

…and over this head: `Tests  1 passed | 11 skipped (12)`.

**3. The door reads Pidgeon as a published read does, and refuses
writes.** `packages/integrations/src/DevReads.ts` runs `pidgeon.read`
through `pidgeon/Operations.ts`'s new `devReads`, with the same address
checks, slots and held-mail handling. It answers `pidgeon.write`
`invalid_request`, logged. `DevReads.test.ts` › "Pidgeon in patchy dev"
covers:

- both viewers reading as the machine's person;
- held mail staying empty;
- a write sent straight to the door, refused;
- simulated writes reaching neither the door nor Pidgeon;
- a `read` connection's write refused exactly as a published one is;
- a revoked key, a deactivated person and a disconnected address
stopping reads while simulated writes keep working;
- slots shared with published reads, and the key checked again after the
wait (I confirmed the test fails without the fix).

Live: the new `PidgeonDev.live.ts` reads a fresh test address through
the door, finds held mail empty, and shows that a simulated reply leaves
the next read unchanged.

### Decisions you can overturn

1. **No `pending_approval` in dev.** A simulated send always answers
`sent`. The snapshot doesn't carry the address's approval setting, so
dev can't know when Pidgeon would hold a send.
2. **A simulated send's or reply's `threadId` is a `dev_` id.** Dev
can't learn a reply's thread without reaching the instance. Reading a
`dev_` id answers `not_found`, so the desk's new-email view opens onto
`not_found` in dev; the skill says so.
3. **Per-operation body bounds at the door.** The door reads a body up
to the largest live bound, `runtime.pidgeon.bytes` (1 MiB), then holds
each operation to its own; `runtime.posthog.bytes` stays 256 KiB. A
garbage body between 256 KiB and 1 MiB now answers 400 instead of 413.
4. **PostHog's dev client moved into `DevDoor`.** `posthog/Dev.ts` is
now a thin binding over `packages/integrations/src/DevDoor.ts`, which
Pidgeon's binding uses too. Its errors' tags changed from `PostHogDev*`
to `DevDoor*`. Tags aren't on the wire, and PostHog's messages are
unchanged.

Also settled on #826:
- Triage answers are partial: `threads.update` returns the id and the
new status, and `threads.label` returns the label when the snapshot
lists it.
- Dev doesn't apply the send policy, replays, the daily budget, or
exfiltration and held-reply refusals.

### Changes to #954's code

- `pidgeon/Operations.ts`:
  - A read's context no longer carries a patch id; writes keep it.
- `perform`'s tail became `atAddress`, which the door shares. It also
hands the door's refusal of its caller after a slot wait back unchanged.
  - New `devReads`.
  - Published behaviour is unchanged, and #954's suites pass.
- `api/pidgeon.ts`: `PidgeonDevRead`, additive.
- `pidgeon/index.ts`: `live: ["read"]`.
- `pidgeon/Generate.ts` and the `patchy-pidgeon` skill now say what dev
does.

## How it was verified

- **`pnpm verify`** on `c14b999`: all ten suites passed (format, lint,
typecheck, synth, test, postgres-concurrency, cli-smoke, install,
tier2-smoke, browser). The only difference between that commit and this
head is #954's last commit, which changes the Support desk's `App.tsx`,
and no verify suite exercises that file.
- **The live tier, once**, on this branch: 3 files, 19 tests passed. The
account's keys stayed under the harness cap:

  ```
PidgeonOperations.live.ts 87 calls, 2 keys minted, at most 2 active at
once; swept 1 key and 2 addresses after
PidgeonOperations.live.ts 119 calls, 3 keys minted, at most 2 active at
once; swept 1 key and 2 addresses after
Pidgeon.live.ts 81 calls, 7 keys minted, at most 3 active at once; swept
1 key and 1 address after
PidgeonDev.live.ts 31 calls, 1 key minted, at most 1 active at once;
swept 1 key and 1 address after
  ```

- **`pnpm dev up pidgeon`**, the desk under `patchy dev`, then `pnpm dev
down`: as above.

Every surface #826 named:
- the wire: `devRead.ts` and `docs/API.md`;
- the CLI: `packages/patchy` dev, its README and ADR-0004's `dev.log`
lines (no flag or exit code moved);
- the dev loop: `docs/DEVELOPMENT.md` and `patchy-dev-loop`;
- the global `patchy` skill with its lock hash, and the project skills;
- the Integrations glossary, with a new "Simulated write" entry, and
`GLOSSARY-MAP.md`;
- `docs/product.md`;
- ADR-0013, which now says writes never run live in dev and names
Pidgeon beside PostHog, with #819's invoice trial as the evidence.

There's no migration. Prototype #819's fixture door never reached this
stack, so there was nothing to remove.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

Dev only: the door gains one read operation, `patchy dev` gains
Pidgeon's binding, and nothing a published patch does changes.

- **What does a revert leave behind?** Dev calls in `runtime_calls`, in
the shape PostHog's dev reads already use: machine credential, no patch,
`op` `pidgeon.read`. No schema, and no mail, since dev never sent any.
- **Does the release before it still work with that?** Yes. It already
reads machine calls, and its `patchy dev` fails Pidgeon calls
`invalid_request` as before. The stack's own rollback story is #921's
and #954's.

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area area:integrations Company connections and integration implementations area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant