Skip to content

feat(integrations): the integration definition, connections on /company, credentials and discovery #201

Closed

Description

@allisonmahmood

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 }) and operation({ input, output, errors, run }) checking handlers against their schemas; the shared boundary codes declared once in packages/api (connection_not_declared, access_denied, invalid_request, timeout, too_large, source_unavailable). The postgres/ module with its credentials schema (a redacted connection string), its metadata (the schema snapshot and discover) 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 into dev.env); AES-256-GCM, fresh nonce, associated data company 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_revision naming 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 and CREATEDB/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 postgres declarations: 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; run patchy 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 CREATEDB role, 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 with connection_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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions