Repository navigation
prototype(integrations): patches read and answer a company email address on Pidgeon - #819
Open
allisonmahmood wants to merge 3 commits into
Open
allisonmahmood wants to merge 3 commits into
allisonmahmood wants to merge 3 commits into
Conversation
…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]>
…nd scenarios Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 21, 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
readorsend, 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:
threads.listandthreads.get,messages.getandmessages.search,labels.list,attachments.text;sendkey:messages.replyandmessages.send, plusthreads.update,labelandunlabelfor 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
idempotencyKeythe 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 devruns the same operations against a fake mailbox seeded fromfixtures/pidgeon-<handle>.json. Sends land in the fake, nowhere else.Try it
upconnects 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_sendconnects withsendaccess;pgn_fake_support_readconnects read-only;pgn_fake_adminandpgn_fake_everythingshow the refusals.To build something yourself, run the environment's
agentand 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.
Reading an attachment, replying and triaging, all as a member, through Patchy.
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.
The connection page: recent calls name each send's subject and recipients
The connect walkthrough, refusing a key that can administer the address
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 sayInvoice No: ….This is the main decision for the build:
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:
Decisions for the build
Settled on 2026-10-21 and planned in #822:
Amended on 2026-10-25, after Pidgeon shipped key rotation and test-mode keys:
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.Amended again on 2026-10-26, after Pidgeon shipped the rest (#822 has the details):
patchy devstill simulates writes on a company's address.Leaves out
What a build owns:
docs/product.md, glossaries, ADR-0013, the initAGENTS.md).The scenario's connect step reuses the Shopify prototype's form-posting helper.
How it was verified
pnpm typecheckpasses across the repo, tests included.vitest run packages/api packages/integrations packages/sdkpasses: 30 files, 188 tests.pnpm dev up pidgeon, then a Playwright walk:agent, described above.pnpm verify, and any real Pidgeon account.Release impact
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.