Repository navigation
feat(integrations): let agents discover company connections - #264
Conversation
Astra reviewReviewed StandardsNo merge-blocking method or YAGNI findings. The implementation uses the existing connection store and HttpApi patterns. I found no added abstraction or future feature that warrants blocking this change. SpecNo merge-blocking intent findings. Both connection reads admit active members, remain company-scoped, and expose the required hints and snapshot metadata. Missing current snapshots return null. The SDK catalog route and Verification158 tests passed across An isolated CLI check also confirmed that a declared Summary: Standards 0 blockers; Spec 0 blockers. No blocking issue in either axis. |
allisonmahmood
left a comment
There was a problem hiding this comment.
Two-axis review of portal/251-connections-group vs portal/250-read-path (0a1b4c8), against issue #251. Extra passes on intent, the implementation method, and YAGNI.
Standards
Documented
-
detailfailures are labeledget. Effect service conventions ask for the operation as structured context.ConnectionStorageFailed.operationhas no"detail"(ConnectionStore.ts).SqlConnectionStore.detailmaps SQL/schema failures withsafe("get")(SqlConnectionStore.ts:128). A failed handle read looks likegetin diagnostics. Add"detail"and pass it, or keepgeton purpose because this is the same storage read. -
Handle stuffed into
ConnectionNotFound.id. Same rule, entity identifier.get/snapshotput a connection id inid.detailpasses the handle (SqlConnectionStore.ts:119,ConnectionStoreDev.ts:39). Callers that readidget a handle. The HTTP 404 body still uses the generic message, so this is internal. Add ahandlefield, or a lookup error, rather than reusingid. -
ADR-0002's group list is stale.
PatchyApiis still described as theauth,patches,sdkandruntimegroups (docs/adr/ADR-0002-api-is-the-contract-package.md:31-33). This PR addsConnectionsGroup.packages/api/src/api.ts:2still omits connections. Issue #251 also says "ADR-0002 unchanged", so this is a standards/spec collision, not a silent miss.
Judgement
-
takenAtclocks differ. SQL takestakenAtfromconnection_snapshots.created_at(SqlConnectionStore.ts:108-126). Dev useslastDiscoveredAt(ConnectionStoreDev.ts:43-54). Production writes both from the samenow, so live rows match. The API test seed sets them to different instants, and the in-memory fixture has no snapshot timestamp. Same wire field, two clocks in tests/dev. -
Wire assembly is duplicated in SQL and Dev (
{ handle, description, status, snapshot: null | { ...snapshot, revision, takenAt } }). One helper on the port would stop them drifting. -
No 503 case.
ConnectionsApi.test.tscovers 200/401/404. It does not injectConnectionStorageFailed→ 503.ConnectionStoretests never calldetail. -
Project.addshared-table path smuggles HTTP status through a mutableobservedbox andHttpClient.tap(Project.ts:519-538) instead ofresponseMode: "response-only". Copied fromApi.publish. Hidden side channel.
No Effect import/layer/runPromise breaches on the new group. Namespace imports and module-level Schema.encodeSync match the house style.
Spec
(a) Missing or partial. None of the ticket's required behaviour is missing. GET /api/connections and GET /api/connections/:handle, ConnectionSummary fields, connected hint patchy add postgres/<handle>, disconnected reason: not_connected with /company/connections in hint, all → offered, snapshot: null rather than an empty database, bearer / active member, catalog route and Generation.catalog gone, HttpApiTest.groups cases, catalog 404 in ApiGuard, Integrations glossary, CONTEXT-MAP.md, ADR-0002 left unchanged.
(b) Behaviour that was not asked for. Spec: "patchy catalog still compiles against the client until ticket 5 removes it: keep the CLI building by pointing catalog at the new connections route for one merge." The diff also rewrites patchy add shared-table onto GET /api/patches/:patchRef?state=all (declarable, 404 → patch_not_openable, null inventory → source_unavailable), plus ADR-0004, docs/product.md, README, and skills for that path. Ticket 3 owns the patch read path. This PR had to retarget add once the catalog no longer returned shared tables, or the CLI would stop building. Necessary follow-through, wider than the sentence about catalog.
(c) Implemented, but the two detail clocks disagree. Spec: "GET /api/connections/:handle → the connection with its current immutable snapshot and takenAt." SQL uses snapshot created_at. Dev uses lastDiscoveredAt. The connections seed sets those to different instants (2026-02-01 vs 2026-01-02), so the two implementations can disagree on takenAt.
Intent versus issue 251
Full match on the thing the ticket exists for.
#251 is ticket 4 of the portal build. Catalog mixed connections and shared tables. Ticket 3 moved shared tables onto the patches read path. This ticket owns the connections half as a first-class connections group, and deletes GET /api/sdk/catalog so nothing keeps serving the old combined shape.
That is what landed. List is summaries only. Drill-down is one handle's current immutable snapshot, or snapshot: null. Disconnected rows stay listed, and their current snapshot stays readable. No credentials, display host, or business rows. offered.connected means "any postgres is connected", which is what the old catalog did. Member machine token, not admin, not cookie.
The leftover patchy catalog command is the admitted one-merge bridge, not a second discovery product. Skills still teach pnpm patchy catalog. That is ticket 5 (#252). The wire is already list-then-detail. Ticket 5 can delete the command and grep for catalog.
Method
Sound, with nits.
The package cut is the same as PatchesApi / AuthApi / SdkApi. Schemas and ConnectionsGroup live in packages/api. ConnectionsApi is an HttpApiBuilder.group module in packages/integrations, not a second Context.Service. apps/server only mounts the layer. Extending ConnectionStore with detail is the right move. Composing list + snapshot at the handler cannot do this join: get is by id, snapshot() 404s a missing current revision, and takenAt belongs on the snapshot row.
Leaking the wire ConnectionDetail type into the store is the one shape I'd change later. list still returns domain rows and the handler adds hint / reason / offered. getConnection is a pass-through encode. A domain join { handle, description, status, snapshot, revision, takenAt } encoded in the handler would match list. Precedent exists (Patches already returns wire inventory). I would not rewrite this PR for it.
SQL LEFT JOIN ... AND s.revision = c.metadata_revision is the actual rule: current snapshot or null, never an older row pretending to be current. The pending fixture (revision 4, only snapshot 3) proves that. Catalog removal does not break generate or add. Auth is group-level bearer Authorization. No admin check. Cookie is 401, which matches this ticket. Parent #247's "portal reuses this read path with a browser session" is a later consumer of the store, not of cookie /api.
I would ship this shape.
YAGNI
This is the smallest honest 251.
Hardcoded offered: [{ integration: "postgres", connected: rows.some(...) }] is the same one-liner deleted from Generation.catalog. Postgres is the only integration. A registry would be for Gmail.
Hints stay in the HTTP handler. The store stays domain. Schema.encodeSync sits at module scope. Generation.catalog, the Catalog schema, the sdk handler, and the shared-table-list stage are gone. Guard treats /api/sdk/catalog as 404. No patchy list, no inspect command, no extra error class for a missing snapshot.
Dev detail is a second implementation because the in-memory fixture has no snapshot created_at, not because someone invented a port for fun.
The HttpClient.tap status box on shared-table add is the one piece that is not simple. responseMode: "response-only" is already used in the new tests.
README.md still says packages/sdk does "authenticated catalog and generation". CONTEXT-MAP's sdk line was updated. Small leftover, not new machinery.
Summary
Standards: 3 documented findings (worst: ConnectionNotFound.id holding a handle), 4 judgements (worst: takenAt clocks). Spec: 0 missing requirements, 1 follow-through wider than the catalog sentence (add shared-table), 1 wrong-looking takenAt split between SQL and Dev. Method is sound. YAGNI holds. I would merge this and leave the catalog command for #252.
Reviewed with Grok 4.6.
|
Reviewed the Astra conversation comment and Grok's Reviews-tab review against the source. There were no inline review comments. Fixes are in 7e9fb39. Fixed
Kept as is
Astra reported no blockers. No review finding remains unresolved. Verification
Latest-commit CI is now green for |
1f5f321 to
78d6f9e
Compare
7e9fb39 to
aebcfa1
Compare
78d6f9e to
9214ea3
Compare
Add member-readable connection discovery and immutable snapshot details. Keep catalog and declaration editing working against the replacement routes, and update API docs and agent guidance. Closes #251
aebcfa1 to
986ea11
Compare
Agents could list company connections, but finding an existing tool or a usable shared table still required direct API calls. `patchy list` now follows the discovery chain from company patches to a patch's tables, stores and reads, then to individual schemas. It replaces `catalog`, preserves wire JSON and lifecycle refusals, and teaches the same chain in all six skills and the CLI docs. Stacked on `portal/251-connections-group` (#264), which provides the connections API. This PR targets that branch and contains only the CLI discovery work. Closes #252. ## Verification - `pnpm typecheck` and `pnpm lint` passed. - `pnpm test --maxWorkers=4`: 821 tests passed across 78 files. - `pnpm test:packed-cli-e2e` passed, including discovery against two seeded patches through the installed CLI. - Standards and spec reviews completed; all three standards findings addressed, no spec findings. One default-concurrency rerun timed out in an unchanged server startup test. That file passed in isolation, and the full suite passed with four workers without changing any timeout. Implemented with `openai-codex/gpt-6-astra` using Oh My Pi.
Agents need to discover company connections and inspect their schemas without going through the SDK catalog.
Adds member-readable connection routes with connection state, declaration hints, offered integrations and immutable snapshots. Missing snapshots return null. Removes the SDK catalog route and keeps the existing CLI catalog and add commands working against the replacement reads until the discovery CLI lands.
Stacked on
portal/250-read-path(#263). This PR targets that branch, notmain, and contains only the connections work for #251.Closes #251.
Verification:
Implemented with OpenAI GPT-6 Astra using Oh My Pi.