Repository navigation
Description
Part of #193. Implements spec §6's definition, connections, credentials, connect flow and discovery; decisions Code-first config … Postgres first and The integration definition, the Postgres integration and its fixture §§ What an integration is, The definition, Connections and credentials, Binding, Discovery. Ticket 9 builds the Postgres operations, the generated surface and the fixture on top.
What to build
packages/integrations gains code, its CONTEXT.md rewritten as built (spec §15), and migration 0005_integrations_baseline (connections per spec §6 and connection_snapshots (connection_id, revision, snapshot, created_at)).
defineIntegration({ name, modes, credentials, metadata?, operations, generate, dev })andoperation({ input, output, errors, run })checking handlers against their schemas; the shared boundary codes declared once inpackages/api(connection_not_declared,access_denied,invalid_request,timeout,too_large,source_unavailable). Thepostgres/module with its credentials schema (a redacted connection string), itsmetadata(the schema snapshot anddiscover) and empty operations until ticket 9.ConnectionStore: the production layer over the platform database and the keyring (PATCHY_CREDENTIAL_KEYS<kid>:<base64 32 bytes>, comma-separated, first active, required at startup; the dev runner writes one intodev.env); AES-256-GCM, fresh nonce, associated datacompany id + connection id + integration,key_id,credential_revision; decryption only at connect test, discovery, rotation and pool creation; no driver error or trace ever serialises a connection string. A dev layer that holds no credentials.- Discovery: a validated whole snapshot (tables, views, columns with types, nullability, primary and foreign keys, enum labels; 500 relations × 200 columns, exclusions named) stored immutably with a server-assigned revision,
connections.metadata_revisionnaming the current; a failed discovery never erases the previous one; snapshots are never deleted in v1. - The pages,
/company/connections(owned here, linked from/company,ui-consistency): the list (handle, integration, description, status, last tested, last discovered) and the forms: connect (handle in the company handle's grammar, description, connection string; parse host, port, database, user, password, sslmode and reject other options; TLS with certificate and hostname verification; refuse superusers andCREATEDB/CREATEROLE; refuse private, loopback and metadata addresses after DNS resolution, re-checked on every reconnect; the blast-radius sentence and the read-only promise from spec §6), test, rotate credentials, retarget (re-discovered, same id), refresh schema, disconnect, reconnect, edit description, delete while no patch declares it. Admins act, members read. The recent-calls list per connection arrives with ticket 9. - Publish resolves
postgresdeclarations: the handle must name a connected connection (connection_not_connected) and the stamp must equal the current snapshot revision (stale_generated: "the warehouse schema changed; runpatchy refresh"); the manifest carries the connection id and the revision.
Admitted at merge
Manifests with postgres declarations resolve at publish; no Postgres operation runs yet (the handler map has none), so a declared connection is inert until ticket 9.
Done when
- Connect refuses a superuser, a
CREATEDBrole, a private address and a non-TLS server, each with its sentence; a stored connection string appears in no log, trace or page; rotating the keyring keeps old rows decryptable; every reverse state on the page works and is tested; a disconnected connection fails a declaring publish withconnection_not_connected. - Discovery against a real Postgres produces a snapshot with keys and enum labels, a second discovery adds a revision and leaves the first row intact, a failing discovery leaves the current revision unchanged.
Surfaces
The wire, migrations, served pages (ui-consistency), vocabulary (Integrations glossary), docs/product.md § Integrations and connections and § Integrations (connect flow, description, blast radius), docs/DEVELOPMENT.md (the keyring), reverse states.
Activity