Skip to content

feat(integrations): Attio connections with a read-only workspace key - #967

Merged
allisonmahmood merged 11 commits into
mainfrom
feat/attio-connections
Oct 28, 2026
Merged

allisonmahmood merged 11 commits into
mainfrom
feat/attio-connections

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What changed

Companies keep their customers, deals and pipelines in Attio, and Patchy had no way to connect it. Now an admin pastes a read-only Attio access token and Patchy checks it, reads the workspace's objects, lists and attributes, and keeps that shape. A key that can write is refused, naming the scope. A builder runs patchy add attio/crm and gets the declaration and a context listing every object, list and attribute. Patches can't read records yet: that's #966, built on this branch's first commit, and the two ship in one release.

Closes #965. Part of #963.

Look at

The connection page, direction A (Allison's pick from the mocks). It opens with the options discovery skipped and what it left out, then each object and list as a counted row that opens to its attributes. Ten rows show per group and the rest fold behind "N more". Captured over the offline Attio double with synthetic data, the deals row opened:

The attio/crm connection page: skipped options and exclusions first, then objects and lists

A key that gained a write scope. Test, Refresh and Reconnect each run the key check. When it finds the stored key can write, the connection is disconnected exactly as Disconnect does it, unless a concurrent Replace key already saved a newer key. The page keeps naming the scope, whose check found it and when, and the way back:

Disconnected: this key can now write, with Reconnect and Replace key

Refusals at the key field: a write scope on connect, a key from another workspace on Replace key

A key with Notes Read-write refused under the field

Replace key refused: this key reads the workspace Globex, not Acme

The key check fails closed (attio/Source.ts). GET /v2/self must answer an active workspace token holding Records, Object configuration, List entries, List configuration and User management at Read, with no :read-write scope and a workspace id. Extra read scopes are accepted. Each refusal names what to change. A deleted key answers like an unknown one (#964's last checks), so both read as "Attio doesn't know this key".

Discovery reads every object, list and attribute (show_archived=true, so archived attributes can be named), then select and status options while it has budget: 45 s or 2,000 requests. It marks the attributes it skipped and never drops one. Every bound in the limits registry refuses the moment it's passed, saving nothing. Connect is one submit: the check refuses within a second, then discovery runs for at most 60 s. A second submit by the same name while one runs is refused, connect_in_progress.

Admission. At most 4 calls and discoveries per workspace per process, shared by every connection to it, inside 6 for all of Attio. AttioSource.send and withSlot are what #966's runtime calls use. Peak memory with all 6 slots at their worst (five calls each collecting and decoding a 16 MiB answer, beside a discovery producing a 7 MiB, 50,000-attribute snapshot) was 292, 353 and 293 MiB above baseline over three runs. That's under the 512 MiB the parent sets, so the host bound stays at 6.

The live tier never blocks a merge. pnpm test:attio reads Patchy's probe workspace with the read-only key. The Attio live workflow runs it on main and on this repository's PRs that touch Attio, queued and never cancelled, with Pidgeon's fork and Dependabot exclusions. attio-live is informational and not meant to be required. The case about a custom object skips once the workspace drops to Attio's Free plan. Pidgeon's live config and harness now name only Pidgeon's files (harness.ts → pidgeonHarness.ts).

patchy add attio/crm in a pnpm dev up attio environment
$ patchy add attio/crm --json
{"ok":true,"alias":"crm","declaration":{"kind":"attio","handle":"crm"},"generated":["patchy/_generated/client.ts","patchy/_generated/index.json","patchy/_generated/manifest.json","patchy/_generated/context/crm.md","patchy/_generated/uses/crm.ts"],"skills":["patchy-attio"],"addedCapabilities":[],"warnings":[]}
$ patchy list connections attio/crm
attio/crm  Northwind's CRM in Attio: companies, people, deals and the sales pipeline.  connected
Workspace: Patchy (patchy)
Snapshot revision: 1
Objects:
  probe_deals (Probe deals)
    record_id: text
    …

How it was verified

Done means (#965) Shown by
An admin connects the probe workspace as attio/crm with Patchy read and sees its objects and lists pnpm dev up attio connected it through the connect page in a browser: 7 objects, 7 lists, 373 attributes, one archived attribute named. Live: "replaces a connection's key with the same key"
Patchy setup and Patchy bare are refused, naming the scopes Offline over the same answers: setup → "List configuration, List entries, Object configuration and Records are Read-write"; bare → the four missing scopes named (attio/Source.test.ts, attio/Connections.test.ts). The setup key never ran anywhere
A builder runs patchy add attio/crm and gets the declaration and context file Above, and cliRepo.test.ts "adds an Attio declaration with its context and skill, and removes them again"
  • pnpm verify: all passed (format, lint, typecheck, synth, 2,438 tests, postgres-concurrency, cli-smoke, install, tier2-smoke, browser).
  • pnpm test:attio with the read key: 4 passed in 19 s, 234 requests, none rate-limited. Making the custom-object case look for a missing object skips it rather than failing.
  • Offline over the scripted Attio (test/attio.ts, hand-written in the probe's shapes):
    • every key-check refusal;
    • discovery paging, each bound, the option budget, the deadline, and the exclusions;
    • every error class;
    • the write-scope disconnect: zero upstream calls after it, the admin attributed, a concurrent Replace key left connected, and Reconnect after the fix;
    • Replace key from another workspace, and a failed rediscovery leaving the old key and snapshot;
    • busy across two keys to one workspace;
    • the pages;
    • rollback: the release before hides an Attio row and its snapshot, and older CLIs never list one.
  • Not checked: none of feat(integrations): patches read Attio records, list entries and members #966's reads. Allison's two remaining probe steps are answered on Attio: Patchy's probe workspace and a probe of the plan's facts #964 (a scope edit shows in /v2/self within seconds; a deleted key reads as unknown).

Release impact

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

New integration, no migration. The connections API adds attio rows only for callers that ask for them, and DeclarationMetadata.attio defaults to empty for older generations. It ships in one release with #966 and isn't deployed alone.

One-way: production can't roll back past this release while any patch version declares an Attio connection. The release before can't decode a manifest that declares kind: "attio", so it can't serve those patch versions. The only recovery is rolling forward to this release or later (docs/OPERATIONS.md › Rolling back), as with Pidgeon's #921.

  • What does a revert leave behind? Attio connection and snapshot rows in the existing connections and connection_snapshots tables, each connection's read-only key encrypted under the keyring, and any patch version that declares an Attio connection. Nothing is created or changed in anyone's Attio workspace.
  • Does the release before it still work with that? No for patches whose current version declares Attio: they need this release to serve, and recovering them means rolling forward. Everything else, yes. The release before reads only the integrations it ships (feat(integrations): the connections page works for no connections, one, or thirty #657), so Attio rows stay hidden from its connections page, patchy list connections, lookups and deletion checks, and its CLIs never ask for them. Tests run that release's integration list against an Attio row, and an older CLI's integration filter against the API. Rolling back is safe only while no published patch version declares Attio.

Built by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, through T3 Code.

Before and after, as Ada Park (admin)

Before is a4df431 (where this branch left main) and after is 61594b0 (feat/attio-connections), both on the team scenario, from pnpm dev compare.

/company/connections/connect

1280px, after

After: /company/connections/connect at 1280px

1280px, before

Before: /company/connections/connect at 1280px

Width Before After
390px Before: /company/connections/connect at 390px After: /company/connections/connect at 390px
/company/connections/connect/attio

1280px, after

After: /company/connections/connect/attio at 1280px

1280px, before

Before: /company/connections/connect/attio at 1280px

Width Before After
390px Before: /company/connections/connect/attio at 390px After: /company/connections/connect/attio at 390px
  • Before at 1280px answered 404; 1 browser error(s): Failed to load resource: the server responded with a status of 404 (Not Found).
  • Before at 390px answered 404; 1 browser error(s): Failed to load resource: the server responded with a status of 404 (Not Found).

allisonmahmood and others added 8 commits October 28, 2026 02:25
…empty client

The contract #966 builds on. `AttioSnapshot` keeps a workspace's objects
and lists by slug and id, each attribute's type, cardinality, reference
targets and active options, and what discovery left out and why. `attio`
joins the integrations, the declaration and generated-metadata schemas,
publish's declaration checks and the CLI (`attio(handle)`,
`patchy add attio/<handle>`, `patchy list connections`). Generation
writes an empty client and a context naming every object, list and
attribute. Discovery's bounds and Attio's admission join the limits
registry.

The connection pages and admin actions for Attio are placeholders until
the key check, discovery and the picked page design land.

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

The Attio source checks a key at `/v2/self` and fails closed: it must be
active, a workspace token, hold every read scope Patchy needs and no
`:read-write` scope. Discovery reads every object, list and attribute,
then select and status options while it has budget, marking the rest.
Every bound refuses the moment it's passed; one gate per workspace sits
inside one for all of Attio.

In the store, connect, Test, Refresh, Replace key and Reconnect run the
check. A check that finds the stored key can write disconnects the
connection as Disconnect does, naming the scopes and the admin, unless a
newer key replaced it meanwhile. Replace key refuses another workspace's
key and saves its key and snapshot together or not at all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`pnpm test:attio` reads Patchy's probe workspace with its read-only key
(`ATTIO_TEST_READ_KEY`): the key check, discovery within its bounds and
deadline, and Replace key with the same key through the store. A case
about a custom object skips when the workspace's plan has none. The
harness paces itself to about 20 requests a second and sits out a 429
outside the call's deadline. It only reads, so it sweeps nothing.

The `Attio live` workflow runs it on main and on this repository's pull
requests that touch Attio, one run at a time and never cancelled, with
Pidgeon's fork and Dependabot exclusions. `attio-live` is never a
required check: offline tests carry correctness, and this tier only
catches Attio drifting. Pidgeon's live config and harness now name only
Pidgeon's files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The connect page is the shared form inside its walkthrough: which scopes
to set to Read, never Read-write, that every member reads what the key
reads, and that builders' agents read the CRM while building. One
submit runs the key check, which refuses under the key within a second,
then discovery; a second submit by the same name while one runs is
refused rather than run beside it. No script, nothing animates.

The connection page names the workspace and the key's scopes, then opens
with the options discovery skipped and what it left out, then each
object and list as a counted row that opens to its attributes, ten of
each before the rest fold. A key a check found writable stays named, with
whose Test, Refresh or Reconnect found it and the way back, until
Replace key or Reconnect clears it. Replace key names the workspace the
new key must read.

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

The attio scenario's connection pastes ATTIO_TEST_READ_KEY, from the
environment or dev.env, into the connect page as an admin would, and
skips the connection without it. It only reads, so down has nothing to
take down in Attio.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…act and dev loop

Connecting Attio in docs/product.md: the key check, discovery, lifecycle
and admission. The Integrations glossary gains the workspace snapshot,
the key check and the workspace gate. ADR-0004, the CLI README and the
global patchy skill name attio/<handle>; DEVELOPMENT, the dev-loop skill
and scenarios/README cover pnpm dev up attio and the live tier, which is
never a required check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each Attio discovery bound now has its own sentence, naming the object
or list where it applies, rather than the registry's measure text. The
attributes bound counts what a snapshot keeps; its measure no longer
claims archived attributes count.

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 28, 2026
…exclusions

- Once a check finds the stored key can write, the disconnect runs to its
  end even if the request that asked goes away, so a writable key is
  never left connected. Asking Attio stays interruptible.
- A call's byte budget is spent chunk by chunk as answers arrive, so
  requests collecting at once share it rather than each seeing all of it.
- Discovery counts every kept object and list, every exclusion and every
  option list toward the snapshot's bytes as it reads them, so an
  archive-heavy object is refused before its next page is asked for.
- An attribute exclusion names its owner by kind and slug, since an
  object and a list may share a slug.
- Write-scope handling catches with `catchTags`, as the service
  conventions ask.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Independent review, round 1 (GPT 6.1 Sol, xhigh): 1 P0, 2 P1, 1 P2, 1 P3. Each finding was checked against the code; all five are real and fixed in d09bbf2.

  1. P0 — cancellation could leave a writable key connected. If Test found a write scope and the request went away while the disconnect waited for the row lock, the disconnect rolled back. Fixed: once a check (Test, Reconnect) or Refresh finds the key can write, the disconnect runs uninterruptibly; asking Attio stays interruptible. Test: "disconnects a key Test found writable even when Test's request goes away while it waits". It holds the row lock in another transaction, interrupts Test, then releases the lock. It fails on the previous code with expected 'connected' to equal 'disconnected'.
  2. P1 — concurrent requests could overspend a shared byte budget. Fixed: collect checks and spends the budget chunk by chunk. Test: two 8-byte answers against a 10-byte budget, exactly one refused.
  3. P1 — discovery didn't charge everything to the snapshot's byte bound as it grew. Fixed: kept objects and lists, every exclusion as it's found, and each option list (with its key) all count as they're read. Test: an object of 600 archived attributes under a 4,000-byte bound is refused without the second page ever being requested.
  4. P2 — exclusions named their owner by slug alone. Fixed: AttioExclusion.in is { kind: "object" | "list", slug }, and the page, context and CLI use it. Test: an object and a list sharing a slug show "1 left out" once.
  5. P3 — catchTag for a known tag. Fixed: catchTags.

Opus 5.5 (Claude Code)

…es, list exclusions

- docs/API.md renders the exclusion's `in` as `{ kind, slug }`.
- Discovery's running count of the snapshot's bytes never counts more
  than the snapshot holds, so a workspace that fits the 8 MiB bound is
  never refused; the exact size is still checked at the end.
- The page's Left out note and `patchy list connections` mark an
  attribute left out of a list, so it's never taken for an object's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Independent review, round 2 (GPT 6.1 Sol, xhigh): 0 P0, 1 P1, 2 P2. Each was checked against the code; all three are real and fixed in 9625884.

  1. P1 — docs/API.md was stale after round 1 changed AttioExclusion.in, which fails markdown.test.ts. Regenerated.
  2. P2 — discovery's running byte count overcounted slightly (a comma per element, braces on option properties), so a workspace just under 8 MiB could be refused. The running count now never exceeds what the snapshot holds, and the exact encoded size is still checked at the end. Test: "keeps a snapshot exactly at the byte bound, and refuses one byte over", which fails on the previous code with expected 'Failure' to equal 'Success'.
  3. P2 — the page's Left out note and patchy list connections still named an excluded attribute's owner by slug alone. The page now marks a list's (deals.old_owner (list)) and the CLI says on list deals. The page test covers an object and a list sharing a slug.

Opus 5.5 (Claude Code)

…connect guard

- A slot is taken as Semaphore's own withPermits takes one: only the
  waiting can be interrupted, never the taking, so an interrupted caller
  never holds a workspace's or Attio's slot it won't release.
- A connect claims and releases its name in one acquireUseRelease, so an
  interrupted connect never leaves its name reading connect_in_progress.
- The Options skipped note marks a list's attributes, as Left out does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Independent review, round 3 (GPT 6.1 Sol, xhigh): 0 P0, 2 P1, 1 P2. Each was checked against the code; all three are real and fixed in 54ef343.

  1. P1 — an interrupted caller could keep an admission slot. withSlot took a permit inside restore, so an interruption landing just after the take left the permit held with no release installed. Fixed the way Effect's own Semaphore.withPermits works: only the waiting is interruptible (on a take-and-release probe), and the take itself runs with interruption masked, its release installed in the same step.
  2. P1 — an interrupted connect could keep its name claimed. The claim was set before the effect that cleared it began. Fixed with Effect.acquireUseRelease: the check-and-claim is the acquire, the clear is the release.
  3. P2 — the Options skipped note named a list's attribute like an object's. Fixed: list-owned attributes are marked (list), as in Left out.

Both interruption races sit at a single step boundary. The new tests, "never leaves a slot held by a caller interrupted as one frees up" and "releases a connect's name however the connect is interrupted", interrupt around those boundaries many times and guard the behaviour, but neither failed on the previous code in two runs. The fixes rest on Effect's documented patterns rather than a red test.

Opus 5.5 (Claude Code)

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Independent review, round 4 (GPT 6.1 Sol, xhigh) on 54ef343: no findings, 0 P0, 0 P1, 0 P2, 0 P3. Round 3's fixes hold, and the targeted tests, including the generated-doc and skill-lock checks, pass.

Opus 5.5 (Claude Code)

@allisonmahmood allisonmahmood added the one-way Rolling production back past this PR would break the release before it label Oct 28, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked 54ef343934ca84c0f64a8fdff022ea848d340300 (base a4df431561f4967ae73e1beac03ea618462e5254) on attio / Northwind Sales, by GPT-6.1 Sol in the Codex harness through T3 Code. I did not write this change.

Done means

  • Admin connects the probe workspace as attio/crm and sees its objects and lists: passed. pnpm dev up attio connected through the browser form with the read-only key. The admin page showed workspace Patchy (patchy), 7 objects, 7 lists and 373 attributes, revision 1, and named the archived attribute it excluded. Expanded Deals and Probe pipeline showed their attributes, types, options and parent/reference relationships. Test succeeded; Refresh retained those counts and advanced to revision 2.
  • Setup and bare keys are refused, naming the scopes: passed offline. Scripted /v2/self answers matching the probe refused setup with “List configuration, List entries, Object configuration and Records are Read-write”; bare named the missing Object configuration, List entries, List configuration and User management scopes. The page refusal sits at the key field and does not echo the key. No real write-capable key was used.
  • Builder gets the declaration and context: passed. Initialized a tier 1 repo, ran the following, and inspected the literal kind: "attio", handle: "crm" declaration, context, project skill and valid empty client factory. The context contains the discovered objects, lists, attributes, options and exclusions. Refresh, remove and add again succeeded; remove deleted the generated context and client.
{"ok":true,"alias":"crm","declaration":{"kind":"attio","handle":"crm"},"generated":["patchy/_generated/client.ts","patchy/_generated/index.json","patchy/_generated/manifest.json","patchy/_generated/context/crm.md","patchy/_generated/uses/crm.ts"],"skills":["patchy-attio"],"addedCapabilities":[],"warnings":[]}

Golden journeys

  • Sign in / find and open / publish / tier 1 use: passed. Signed-out company and patch requests returned 401, private, no-store and the sign-in door. Priya signed in, found the published repo on Home, opened its Notes frame and saved “Acceptance sample note”; Allison subsequently saw the saved note. The connect form returned 403 for Priya. Retire showed the retired notice; Restore served the frame again at the same address.
  • Connection way out and back: passed. Disconnect showed Disconnected and Reconnect. CLI refresh then refused connection_not_connected with exit 2. Reconnect rechecked the stored key, retained snapshot revision 2 and restored CLI refresh. Deletion was refused while a stored published version declared the connection.
  • Existing integrations and other shared journeys: the head's successful CI run covers offline tests on Node 22/24/26, Clerk, browser, CLI, installation, Postgres concurrency and tier 2. These were inspected rather than repeated in full locally.

Additional risks checked

The focused local run covered malformed/inactive/user-level/missing/write-scope keys, discovery paging and every bound, skipped options and exclusions, deadlines, error classes and redirects, workspace/host admission and cancellation, writable-key disconnection and attribution, concurrent key replacement, failed replacement preserving the old state, and older-release/older-CLI filtering. Shared connection pages and CLI repo commands were included.

Focused offline tests: 6 files passed; 90 tests passed.
Attio live: 1 file passed; 4 tests passed.
Attio live run: 234 requests, 0 rate-limited and sat out.

Rollback answers: match the diff, and one-way is present. There is no migration or infrastructure change; connection/snapshot rows and encrypted credentials remain, as do published manifests declaring Attio. The previous manifest schema cannot decode those declarations, so such versions require rolling forward. Older integration filtering hides the new rows. The successful CI rollback rehearsal exercised base → PR → base → PR for its existing journeys; it does not establish that an Attio-declaring version can survive rollback.

Not run

Notes

  • Non-blocking documentation omission: docs/product.md:69 still lists only Postgres, PostHog and Pidgeon as supported published connection declarations. The tier 1 publication above confirms Attio declarations are now accepted; add Attio to that summary. Its dedicated connection section already documents the new behavior.

All browser tabs and the throwaway dev instance started for this run were closed/removed. The tracked checkout is unchanged.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

On the acceptance note: docs/product.md:69 should list Attio among the connection declarations publish accepts. This goes into #966's docs pass, which edits the same integration summaries in docs/product.md. That keeps this PR's head at 54ef343, the commit the verdict checked.

Opus 5.5 (Claude Code)

@allisonmahmood
allisonmahmood merged commit eeb469a into main Oct 28, 2026
23 checks passed
@allisonmahmood
allisonmahmood deleted the feat/attio-connections branch October 28, 2026 08:38
allisonmahmood added a commit that referenced this pull request Oct 28, 2026
…ers (#968)

## What changed

An Attio connection gave a patch a workspace it couldn't read: the
generated client was empty. Now a tier 1 page, or a tier 2 action
through `ctx.connections`, reads the workspace's records, list entries
and members through a client typed from the connection's snapshot:
`objects.<slug>.list/get/getMany`, `lists.<slug>.list/get` and
`members.list()`. Patchy builds every request from typed arguments,
checks the workspace's current attributes on every call before decoding
anything, and nothing can write to Attio. `patchy dev` reads the real
workspace through the instance, by the snapshot the repo was generated
from.

Closes #966. Part of #963. Stacked on #967 (#965, Attio connections);
they ship in one release.

## Look at

- **The parent's journey, published and in `patchy dev`, against
Patchy's probe workspace.** `pnpm dev up attio` now publishes two
scenario patches over `attio/crm`. **Deal desk** (tier 1), as Priya, a
member: Lead deals sorted by value, each company resolved in one
`getMany` for the page; choosing an owner filters by `owner`, More deals
follows `cursor`, and a deal opens with `get` and its pipeline entries
by `parent`.

![Deal desk, published, as
Priya](https://github.com/user-attachments/assets/26c11f2f-18f3-4188-9e68-6476aa98cd7e)

**Pipeline review** (tier 2) in `patchy dev`: a read-only action pages
every In Progress deal through `ctx.connections` (1,219 deals, three
pages of 500, read through the instance's dev door), totals them by
owner and resolves the five largest deals' companies.

![Pipeline review in patchy
dev](https://github.com/user-attachments/assets/72663d44-fc0d-4edd-973d-c4ace516bb58)

Probe data is synthetic ("Probe deal 0350", "Probe Co 0322"). The whole
journey on a fresh instance at the head, from `pnpm dev film
--after-only` (the base has no reads to film): Lead deals, then In
Progress, the largest opened with its pipeline entry, the next page,
then the tier 2 review (filmed at `e5780a5`, the same tree as the head
before its rebase onto #967's latest).


https://github.com/user-attachments/assets/e0d837af-d430-4a4b-a44f-ccbe542c4c48


- **Every row of #963's filter table is exact against Attio itself.**
`AttioReads.live.ts` reads every deal, person and company unfiltered,
then sends each filter as Patchy builds it, pages it to its end, and
compares the ids Attio answers with the same filter evaluated locally:
text (case-insensitive `eq`, `$in` too, `contains`), number, rating,
checkbox (`false` matches unset), currency, date, timestamp (full ISO
only), select, multiselect (has / has any), status with emoji, phone,
location, record references with one target, many and several targets,
actor references, personal name, email, domain and interaction, each
with `null` where the table allows it. Plus option-order and
descending-value sorts with empties placed as the probe says, paging
with heavy ties (every deal once), the journey, `getMany` with a
duplicate and a missing id, and an unknown option title refused
`invalid_request` with `reason: "option"`.

  ```
✓ every row of the filter table, exactly > matches deals as evaluated
here, for every type, empty included
✓ every row of the filter table, exactly > matches people and companies
on names, emails, domains and interactions
✓ order, paging, gets and the journey > orders by option, amount and
name with empties lowest, repeating and skipping nothing
✓ order, paging, gets and the journey > walks the parent's journey:
deals by stage and owner, a deal, its companies, its pipeline
✓ order, paging, gets and the journey > reads a custom object while the
workspace's plan keeps them
  Attio live run: 733 requests, 0 rate-limited and sat out.
  Test Files  1 passed (1)   Tests  5 passed (5)
  ```

The offline tests carry correctness (the live tier is never required):
`Query.test.ts` pins the exact request for every row, `Values.test.ts`
every type decoded filled and empty with Attio's metadata dropped, and
the schema check's refusals.

- **Nothing is decoded until the schema matches, and `null` is
verified.** Beside its query, each call reads the object's or list's
attributes with `show_archived=true` and fails `shape_mismatch` naming a
snapshot attribute that's gone, archived, renamed (`renamedTo`, by id),
retyped or changed between single and multi, a reference whose targets
lost a snapshot object, a reference value naming an unknown object slug,
or an entry under another parent. `null` on a select, status or
reference reads the current options or targets first and excludes them;
every returned row is then checked empty, and one that isn't fails
`source_unavailable`, never a wrong answer (`Operations.test.ts`).

- **Typed errors and the sentinel.** `invalid_request`, `invalid_query`,
`shape_mismatch`, `not_found` and `access_denied` carry Attio's own
details, narrowed with `isPatchyError(error, code, "attio")`; Postgres,
PostHog and Pidgeon details narrow as before (`Generate.test.ts`
compiles a consumer of each). `Runtime.test.ts` runs the journey through
the runtime wire and a tier 2 action in workerd, with a sentinel in a
filter value, a record value, a member email, Attio's error message and
a garbled answer: none reaches `runtime_calls`, a log line or a refusal,
and nor does the key.

## How it was verified

- `pnpm verify` on the head, `c42462d` (rebased onto #967's `54ef343`):
`PASS format, lint, typecheck, synth, test (239 files, 2,499 tests),
postgres-concurrency, cli-smoke, install, tier2-smoke, browser (81)`. An
earlier run failed `cli-smoke` only: the packed `patchy` declarations
named `@patchy/api/attio-types`, which a patch can't resolve, so the
client now carries its own copy of the type table, held to the host's by
`Generate.test.ts`.
- CI's `attio-live` passes on the PR with the repo secret, running
`Attio.live.ts` and `AttioReads.live.ts`.
- `pnpm test:attio` (`AttioReads.live.ts`) against the probe workspace
with the read key: 5 of 5 passed, as above. #967's `Attio.live.ts` runs
in the same tier.
- Offline: the Attio files (`Query`, `Values`, `Operations`, `Generate`,
`Runtime` tests, 70+ cases) cover the exact request per filter-table
row; each refusal before upstream with zero requests (unknown slug,
unsupported operator, refused `null`, over 100 values, date-only
timestamp, foreign cursor, over 500 ids, ambiguous bare id, undeclared,
public, cross-company); `getMany` with duplicates, missing ids and none
(no request); every Attio refusal class (401, 403 with scope, 404,
`merge_in_progress`, `standard_object_disabled`, `unknown_filter_*`,
`validation_type`, malformed-query codes, 429 with `Retry-After`, 5xx,
HTML 4xx/5xx, unreadable bodies); the 16 MiB raw and 8 MiB decoded
bounds; a queued call whose viewer was deactivated or whose connection
was disconnected sending nothing, `busy` and `timeout`.
- The gateway allows Attio in actions, read-only ones included, refuses
queries and mutations, and caps arguments at `runtime.attio.bytes`. The
dev door decodes an older revision by its own snapshot after a Refresh,
refuses a revision of another connection, and refuses a dev read without
one. `patchy dev`'s tier 2 test sends the declaration's revision to the
door.
- Not checked here: Attio's `merge_in_progress` and interaction values
are docs-only (the probe workspace has none), so they're offline only.

## Changes outside this PR's own files

- `scenarios/attio/scenario.json` (#965's): `"patches": []` now lists
the two patches, and `scenarios/README.md` says so.
- `devPreparation.ts`: an Attio declaration needs no fixture and counts
in generation's metadata, as PostHog's and Pidgeon's do. Without it
`patchy dev` asked for `fixtures/shared-crm.sql`.
- `DevDoor.read` takes `args: unknown`: the instance decodes them, and
Attio's six dev reads share one generic sender.
- `skills/patchy/SKILL.md` names Attio among the integrations dev reads
live; `skills-lock.json` is refreshed.

- Every integration summary that listed Postgres, PostHog and Pidgeon
now names Attio where it's true (`ae01484`): `docs/product.md` (the
tiers' connections, publish's accepted declarations at line 69, which is
#967's behaviour, what reads live in dev and has no fixture, what counts
as a read), `GLOSSARY-MAP.md`, ADR-0004's dev-read paragraph, and
`patchy dev`'s missing-key refusal, since `readsLive` counts Attio.

## Release impact

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

Additive: six runtime operations, the `@patchy/api/attio-types` subpath,
three registry limits (`runtime.attio.bytes` 256 KiB, `attio.call.bytes`
16 MiB, `attio.call.concurrent` 4), an optional `revision` on a dev
read's connection, a project skill and two scenario patches. Existing
patches, connections and commands behave as before.

- **What does a revert leave behind?** Patch versions whose generated
client calls `attio.*`. No schema, no rows, and nothing in Attio:
nothing is ever written there.
- **Does the release before it still work with that?** No, for a patch
whose current version calls `attio.*`: the release before has no Attio
operations, so that patch fails until we roll forward. It ignores
everything else, and it hides Attio connections, as #967 set up. Hence
`one-way`. #967 is the same boundary (the release before can't read an
Attio connection or its declarations) and should carry the label too;
this PR and #967 ship in one release.

Made by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, running in
T3 Code.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Oct 28, 2026
## What changed

This PR adds release 21's What's new entry, written from `f30d8fe`. It
covers everything merged since release 20's `through` (`c5175bd`), and
sets the `patchy` release to `0.21.0` in `packages/patchy/package.json`
and `CURRENT_RELEASE`. With this release, patches can read a company's
Attio CRM through a read-only connection.

| Change | PRs |
| --- | --- |
| New: Patches can read your Attio CRM | #967, #968 |
| Behind the scenes: Patchy refuses an Attio key that can change
anything, and stops using a connected key that later gains that power |
#967 |

One merged PR gets no line: #962 is release 20's own entry.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`. "Integrations" is the sidebar's own
label. "Read-only key" matches the connect page's walkthrough.
- **Rollback safety, from the live commit `a4df431` (release 20) to
`f30d8fe`.** Both PRs in the range are labelled `one-way`:
- **#967 (connections).** Release 20 hides Attio connections, as #657
set up. But it can't decode a patch version that declares `kind:
"attio"`, so such a patch needs this release to serve.
- **#968 (reads).** Release 20 has no `attio.*` operations, so a patch
whose version calls them fails until we roll forward.
- Neither PR has a migration or infrastructure change.
`rollback-rehearsal` passed on both landed heads.

**Rollback line:** Rolling back past #967 would break any patch whose
current version declares or reads Attio, because release 20 can't read
an Attio declaration or serve its reads, so fix forward instead. Until a
published patch version declares Attio, rolling back to `a4df431`
(release 20) is safe.

## How it was verified

- **Tests.** `whatsNew.test.ts`, `WhatsNewPages.test.ts` and
`schemas.test.ts` pass (21 tests). Typecheck passes for core, api and
the CLI, and prettier passes on the changed files.
- **The stack.**
- #967 had four GPT 6.1 Sol review rounds, the last clean, and #968 had
two.
- Each got an acceptance verdict of PASS with notes on its accepted
head, and landed with all 23 checks passing, `attio-live` and
`rollback-rehearsal` included.
- #968's rebase onto main left its tree byte-identical to the accepted
head, and `main`'s tree at `f30d8fe` is identical to it.
- **Deploy state.** The live commit, pinned from `/healthz/deep`, is
`a4df431` (release 20). The Deploy run updated last succeeded, and none
is unfinished.

## Release impact

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

Text and version numbers only. The `0.21.0` bump tells CLIs and patch
repos installed before this deploy to upgrade, as every release does.

- **What does a revert leave behind?** Nothing: no rows, no schema.
- **Does the release before it still work with that?** Yes.

Made by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, running in
T3 Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Nov 7, 2026
…1266)

## What changed

Plenty of companies keep their mail with a plain hosting provider: an
IMAP mailbox with a username and password, and no Google or Microsoft
API. Patchy had no way to connect one. Now an admin connects a mailbox
by its server, port, username and password. Patchy logs in once on a
fresh session to check it, keeps the mailbox's folders, and refuses a
mailbox that falls short by naming the requirement it misses. A builder
runs `patchy add imap/<handle>` and gets the declaration and a context
listing the folders.

Patches can't read mail through it yet. That's #1262 (reads) and #1264
(attachments), stacked on this branch; all three ship in one release.

Part of #1250. Closes #1251.

## Look at

**The pages: mock A, trimmed to match the other integrations**
(Allison's pick from the
[mocks](https://post.patchyhq.com/d/b7f3rv4gdtx0)). They are the shared
connect frame and the shared connection page that Postgres, PostHog and
Attio use, with IMAP filling in only its own words and fields. There's
no new layout and no new component.

The connect page is the shared walkthrough. It shows what a mailbox
needs, then the login, then how to use it. Port and security are one
choice, because the security follows the port. A short Company-wide
access note sits beside the fields:

![The IMAP connect page: what a mailbox needs, the login form with one
port choice, and using
it](https://github.com/user-attachments/assets/0243cb54-5fa0-4242-b4d2-8a07d81ccf4c)

A failed Test re-renders the form with the refusal under its field,
keeping everything typed except the password. A certificate that doesn't
name the host lists the names it does carry:

![The certificate refusal under Server, naming the certificate's
names](https://github.com/user-attachments/assets/4b9c322c-394c-465e-9c25-2f67ed29c4de)

The connected page shows the server and username, the folder count and
first folders, and recent calls:

![The connected imap/invoices
page](https://github.com/user-attachments/assets/a9a67af4-5a5f-40fd-b063-5e2df15d8a93)

**A refused password pauses the connection.** The page keeps a notice
with the two ways out, Replace password and Test again, and a Paused
tag. The connection counts under Needs attention on the index:

![A paused connection: the notice with Replace password and Test
again](https://github.com/user-attachments/assets/4bbda0eb-5547-43f4-a031-80058f2c8ea8)

![The index: 1 connection needs attention, imap/invoices is
paused](https://github.com/user-attachments/assets/6f38ab7d-b832-4486-865a-e36b5f2cb93a)

<details><summary>The way out: the shared Replace password page, then
the resumed connection</summary>

![Replace the password for
imap/invoices](https://github.com/user-attachments/assets/9d1f8fb4-c65b-4801-85c4-f2c83001a507)

![Password replaced and tested, the pause
gone](https://github.com/user-attachments/assets/802d1b65-ada6-4fcc-8c86-3ddd4dae10a8)

</details>

**Two fixes on the shared connection page, for every integration.**

- The recent-calls table clipped its Outcome column at desktop width:
six columns with a 720px minimum sat in the roughly 620px beside the
facts. Recent calls now span the page below the reads and the facts.
Before and after, on the same page at 1280px:

![Before: Outcome cut off at the right
edge](https://github.com/user-attachments/assets/84190eba-6bff-4592-9490-d03d500971ad)

- The intro above recent calls was Postgres's wording on every page.
Each integration now says what its calls keep and never keep. IMAP's:
"Each call keeps its operation, who made it, when, how long it took and
how much it read; subjects, bodies, addresses and search values are
never logged."

**The transport** (`imap/Source.ts`, `imap/Network.ts`):

- The host resolves, and every address must be public.
- The session dials only the checked address.
- TLS 1.2 or later is verified against the typed host, with SNI.
- Port 993 is TLS and 143 requires STARTTLS; any other port is refused.
- CAPABILITY must name IMAP4rev1 or IMAP4rev2 and allow a password login
before the password is sent.
- A `PREAUTH` greeting is refused, since the password would never be
checked.
- Referrals are never followed.

Test names each failure: the name doesn't resolve, a private address,
the port, TLS, an untrusted certificate, a certificate for another name,
no STARTTLS, not IMAP4, login disabled, no password asked, the
credentials refused, or no INBOX.

**The login pause** (`SqlConnectionStore.ts`):

- Only a `NO` to `LOGIN` or `AUTHENTICATE` pauses, coded
`AUTHENTICATIONFAILED`, `AUTHORIZATIONFAILED`, `EXPIRED` or uncoded.
ImapFlow's `authenticationFailed` is never read.
- The pause is recorded on the connection's row, so no host process logs
in with it until an admin's Test, Replace password or Reconnect works.
- A refusal that lands after a later login of the same password worked
and was saved pauses nothing.
- `patchy list connections` marks a paused mailbox, with the way out
instead of an add hint.

**Loopback mailboxes are a layer, never configuration.**
`apps/server/src/start.ts` launches with production's network. The dev
runner's own entrypoint, `scripts/dev/src/server.ts`, launches with the
loopback one for its local mailboxes.

## How it was verified

| Done means (#1251) | Shown by |
| --- | --- |
| An admin connects a mailbox on Dovecot or GreenMail by host, port,
security, username and password | `pnpm test:imap` connects, tests,
refreshes and deletes a mailbox on Dovecot over TLS and STARTTLS, and on
GreenMail (5 passed, about 18 s). `pnpm dev up imap` connects one
through the connect page above, in a browser |
| A mailbox that misses a requirement fails its Test, which names it |
Offline over a scripted IMAP server on loopback (`imap/Source.test.ts`,
Node and Bun): every refusal before login with nothing sent, DNS
rebinding, a certificate for another name with its names listed, an
untrusted CA, a TLS 1.1 server, 143 without STARTTLS, `PREAUTH`, no
IMAP4, login disabled, no INBOX, parser and byte bounds. Live: 143 on
GreenMail, a certificate for another name, and a wrong password on both
servers |
| A wrong password pauses the connection until it's replaced, without
further logins | `imap/Connections.test.ts`: a refused login pauses, and
a second process neither hands out the password nor logs in. Replace
password and Test unpause it. `NO [UNAVAILABLE]`, `NO [REFERRAL]`, `BAD`
and a throttle don't pause. A stale refusal after another admin's
successful Test doesn't pause (red without the fix, green with it) |
| `pnpm dev up imap` gives a connected local mailbox | Shown in the
screenshots, which are of that environment |

- `pnpm build`, `pnpm typecheck` (uncached) and `pnpm lint` passed.
`pnpm check` passed format, lint, typecheck and synth; its offline tests
passed except suites that fail only on this machine:
  - the CLI's stub-server tests, which fail from a stray `GET /` probe;
- the installer tests, which can't find npm beside this machine's
`node`;
  - one execution test under load.
Each passed rerun alone except the installer's, whose files this PR
doesn't touch.
- The connections API lists an IMAP row only to a caller that decodes
IMAP, so CLIs from before never see one. The release before IMAP's store
hides IMAP rows.
- The screenshots are `pnpm dev shot` and Playwright captures of this
worktree's `imap` environment, which holds scenario data only. `pnpm dev
compare` can't show them, because main has no IMAP pages and the pause
needs a refused login. Before and after for the calls table are the same
page before and after the fix commit. At phone width the table scrolls
inside its wrapper, as before.
- `pnpm verify` ran locally at `0084d76`: format, lint, typecheck,
synth, postgres-concurrency, tier2-smoke and browser passed. test, test
(bun), cli-smoke and install failed for this machine's reasons:
- the CLI suites hit the stray `GET /` probe, and a Supervisor test
timed out under load;
- test (bun) passed all 2,596 tests, and its 3 errors are that probe's
empty body;
- cli-smoke and install fail because this machine's `node` has no npm
beside it.

  CI passes all four on its runners.
- Not checked: a real public mail host, and a pause on a real server
(the test servers keep one password).
- Locally, `pnpm dev up` fails to install the environment's CLI because
the repo-pinned npm 12 refuses the instance's tarball (`EALLOWREMOTE`).
I ran the runner directly with Bun.

## Release impact

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

This is a new integration with no migration. The connections API adds
`imap` rows only for callers that ask for them, and the new `paused`
fields are optional. `DeclarationMetadata.imap` defaults to empty for
older generations.

**One-way: production can't roll back past this release while any patch
version declares an IMAP connection.** The release before can't decode a
manifest that declares `kind: "imap"`, so it can't serve those versions.
The only recovery is rolling forward, as with Attio's #967.

- **What does a revert leave behind?** IMAP connection and snapshot rows
in the existing `connections` and `connection_snapshots` tables, each
password sealed under the keyring, and any patch version that declares
`imap`. Nothing in anyone's mailbox is changed.
- **Does the release before it still work with that?** No, for patches
whose version declares IMAP: they need this release to serve. Everything
else works: the release before reads only the integrations it ships
(#657), so IMAP rows stay hidden from its pages, CLI and lookups.
Rolling back past this PR would break any patch version that declares
`imap`, so fix forward instead.

## Review

Grok 4.7 reviewed the backend at `a4deaa8` and found no P1s. Its three
P2s are fixed in `08626e4`: a stale refusal could re-pause after a
success, the CLI hid a pause, and `PREAUTH` skipped the login. Grok then
reviewed the pages at `0084d76`: no P1s and no UI-consistency findings.
Its one P2 is fixed in `f9897e7`: a posted security that disagreed with
the port answered 422 with no visible error, because the form has no
security control. The refusal now sits under Port, and a page test
covers it (red without the fix).

Built by Claude Opus 5.5 in Claude Code, reviewed by Grok 4.7.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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 one-way Rolling production back past this PR would break the release before it size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(integrations): Attio connections with a read-only workspace key

1 participant