mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-11-09 21:43:05 +09:00
The third deferred item. An extension installs INTO a running engine rather than getting its own container, so it lives in its own namespace: `backend/templates/extensions/<id>.yaml` with a top-level `extension:` block, discovered by the same operator-wins two-directory scan the app templates use. Dropping a YAML in makes it available with no code change, and a test pins that. Not nested inside the engine template, because pgvector applies to any PostgreSQL-speaking engine rather than to `postgresql.yaml` — nesting would force duplication per host. Not a third `kind:` in the app catalog either: an extension has no compose, port or volume and produces no Application, so every consumer of `list_all_templates` would have had to learn to skip it. The hard part is not the SQL. `CREATE EXTENSION vector` is valid and fails on stock `postgres:16` with "could not open extension control file", because that image does not ship the library. Two layers, and the statement is never sent speculatively: an extension declares which images provide it, so a listing marks an instance unsupported BEFORE anything is clicked; then at install `pg_available_extensions` is queried first and a negative answer is a 409 with a remedy, not an attempt. The live probe overrules the image name in both directions — a private `registry.internal/ops/pg-with-vector` is allowed, and a `pgvector/pgvector` tag that does not actually carry the library is still refused. ServerKit does not recreate a container behind the operator's back. The remedy instead names an engine template that IS capable, found by matching the extension's images against each engine template's compose — hence `postgresql-pgvector.yaml`. TimescaleDB deliberately ships no bundled host and says so rather than implying one exists. Compatibility also needed correcting mid-build: matching on wire protocol alone claimed CockroachDB could host pgvector. It answers on pgwire and cannot load a single extension. Engines opt in with `engine.extensions: true`, which excludes it without any Python naming it. Two fixes fell out. `DatabaseService` had no psql twin of `docker_mysql_execute` — `managed_db_user_service` carried a private copy with a comment saying as much; there is now one implementation and it delegates. And that twin sets `ON_ERROR_STOP=1`, without which psql reports SUCCESS for a statement the server rejected. 57 tests, covering the zero-code-change property, compatibility, the image problem in both probe directions, admin gating, and refusals that must not execute anything. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>