Repository navigation
Closed
Labels
ready-for-agentFully specified, ready for an AFK agent
Description
Part of #193. Implements spec §6's execution, generated surface, type mapping, errors, bounds and fixture; decision The integration definition, the Postgres integration and its fixture §§ Read-only, The generated surface, Errors, The wire, Bounds and pools, The fixture, The call log; with Dev is local.
What to build
- In
packages/api:postgres.list,get,getMany,queryrequest and response schemas and the codesrelation_unknown,invalid_query,shape_mismatch,invalid_cursor,offset_exhausted; responses{ ok: true, rows }, norowCount, notruncated; a call past 1,000 rows or 8 MB fails during collection. - Execution: one statement over the extended protocol inside
BEGIN READ ONLYwithSET LOCAL statement_timeout(10 s), rolled back, session reset; a 15 s service deadline including queue wait that cancels and destroys the connection; pools keyed by connection id and credential revision (4 per connection per process, idle 60 s, 64 per process), the revision checked at checkout so rotate, retarget and disconnect take effect at once while in-flight calls finish. Handlers registered into the runtime handler map; the alias resolved through the loaded version's manifest to the connection id; projection and validation through the snapshot revision the version names, credentials and access live; every call, denied and failed included, logged with the SQL text forquery. - The type mapping of spec §6 as one module driving the generated types, the projection SQL and the runtime validation (int8 and numeric as strings; NaN and infinities refused; timestamps and dates as specified; domains resolved; unsupported types left out and named).
generate(declaration, snapshot): the per-connection client exposing relations directly (publicat the top, other schemas namespaced, bracketed when not dottable,queryreserved, collisions excluded and named),getandgetManyonly on relations with a usable primary key,list({ eq, range, orderBy, select, limit, cursor })with keyset cursors bound to connection, relation, revision, filters and order on keyed relations and a bounded offset (10,000,offset_exhausted) on unkeyed views, view columns nullable, neverSELECT *; the context file (handle, description, schema listing, exclusions, keyed relations, revision); discovered names escaped in TypeScript, SQL and markdown.query(sql, params, shape)strict as spec §6 says. Generated error unions per method andisPatchyError.dev(snapshot, fixture): one PGlite per connection under.patchy/dev/, built from the snapshot with source-native types, rows loaded fromfixtures/postgres-<handle>.sqlon the privileged init path and validated, the stub's header listing tables and columns and saying views are synthetic; a relation the fixture cannot represent excluded from both surfaces and named; raw SQL using what PGlite lacks fails locally with the reason.- The recent-calls list per connection on
/company/connectionsfrom the runtime log.
Admitted at merge
postgres.* operations run for declared connections through the runtime.
Done when
querywithINSERTfails inside the read-only transaction; a function with a side effect does too; a statement past 10 s istimeoutand the connection is destroyed; a rotated credential is used by the next call and never by an in-flight one after its deadline.listwitheq,range,orderBy,selectand a cursor generates quoted SQL and validated rows for every kind in the mapping; an unkeyed view pages by offset to the bound thenoffset_exhausted; a relation without a key has noget; a call after the admin's refresh schema still projects through the version's own revision; a dropped source column fails that call with a clear code.queryrefuses a missing column, a duplicate name and a null in a non-optional column withshape_mismatch; the fixture layer answers the samelistfrom an agent-authored file and names an excluded relation.- Every call has a log row with the SQL for
queryand none forlist; the recent-calls list renders it.
Surfaces
The wire, vocabulary (Relation, Escape hatch, Dev binding, Fixture), docs/product.md § What patch code sees and § Development, served pages.
Metadata
Metadata
Assignees
Labels
ready-for-agentFully specified, ready for an AFK agent
Activity
feat(integrations): execute Postgres reads with typed clients and fix…