From aefde2dede30a31e9aa4ecfd35088b0709446e82 Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Tue, 24 Nov 2026 19:39:25 -0500 Subject: [PATCH 1/3] pgvector-go: goal record, task brief approved --- context/goals/v1.data.extensions.md | 234 ++++++++++++++-------------- 1 file changed, 114 insertions(+), 120 deletions(-) diff --git a/context/goals/v1.data.extensions.md b/context/goals/v1.data.extensions.md index 4eaa040..b8839fa 100644 --- a/context/goals/v1.data.extensions.md +++ b/context/goals/v1.data.extensions.md @@ -1,8 +1,8 @@ # goal · v1.data.extensions -- **State:** idle -- **Task:** none -- **Branch:** none +- **State:** building +- **Task:** pgvector-go +- **Branch:** pgvector-go ## Tasks @@ -12,144 +12,124 @@ 4. [ ] pgvector-go 5. [ ] principles -## Task brief · pgvector-sql +## Task brief · pgvector-go **Problem** -The extension stage and sqlint's `extensions` key exist, but no extension module uses them yet. -pgvector, the first case, needs four things: +sqlate's migrator now manages extensions, and sqlate's `postgres/pgvector` names pgvector's +metrics. go-database has neither yet: -- a module that names its native forms, its catalog name and its metrics; -- an image that builds it from source, with a pin that currency watches; -- live proof against that image that the stage manages it and that the per-space partial HNSW - index works; -- a real export that sqlint's key resolves, so that sqlint can be released. +- admin's `Status` reports only migration sets. It says ready while `Verify` fails on an + extension. +- No go-database module resolves a configured metric or shows how an application uses pgvector-go. +- go-database has no live tests. -pgvector-go then builds on this module's released metric table. +capstone-athena needs all three before it stores embeddings. **Behaviors** -1. A new module, `github.com/standards-lab/sqlate/postgres/pgvector`, with its own `go.mod`, - changelog and `doc.go`. Its package names: - - the extension's catalog name, `vector`; - - the metrics `l2`, `cosine` and `inner product`, mapped to the operators `<->`, `<=>` and `<#>` - and to the opclasses `vector_l2_ops`, `vector_cosine_ops` and `vector_ip_ops`. - - The table covers the `vector` type only and has no distance-function field. The package imports - only the standard library. -2. The module's `sqlint.toml` exports `[export.native_forms]`. Each form is named after pgvector's - own name, so a finding reads `"<=>" (cosine_distance, from )`. The forms are: - - the six distance operators, each named for its function: `<->` l2_distance, `<#>` - negative_inner_product, `<=>` cosine_distance, `<+>` l1_distance, `<~>` hamming_distance and - `<%>` jaccard_distance; - - `vector` only where a type goes (`AS vector`, `vector(`), and `halfvec` and `sparsevec` as bare - words; - - the index methods `hnsw` and `ivfflat` after `USING`; - - the callable functions `l2_distance`, `inner_product`, `cosine_distance`, `l1_distance`, - `hamming_distance`, `jaccard_distance`, `vector_dims`, `vector_norm`, `l2_norm`, - `l2_normalize`, `binary_quantize`, `subvector`, `array_to_vector`, `array_to_halfvec` and - `array_to_sparsevec`, each followed by `(`; - - the `hnsw.*` and `ivfflat.*` settings. - - No form matches an unquoted identifier named `vector`, and none matches a portable statement. -3. sqlate's root `sqlint.toml` lists the module under `extensions`, and the root check resolves it - through the committed go.work. The check fails if the module's export is refused or a form - doesn't compile. -4. The compose image is still `FROM postgres:19.0-alpine`. On top of it, the image builds pgvector - from source: - - the version is `ARG PGVECTOR_VERSION`, with a default of the latest tag (0.8.7); - - the source is fetched by `ADD` from pgvector's git repository at `v${PGVECTOR_VERSION}`; - - both `make` and `make install` run with `with_llvm=no`, and `make` also runs with - `OPTFLAGS=""`; - - the build tools are removed in the same layer. - - `pg_available_extensions` then offers `vector` at that version, and the HEALTHCHECK, user and - database are unchanged. -5. Currency also reads Dockerfile ARGs. In each compose Dockerfile, an `ARG _VERSION=` - whose `ADD` line names a GitHub `.git#v${_VERSION}` URL is compared with that - repository's highest semver tag, read from tags rather than releases. A trailing ARG is - reported as `: / -> `, and currency exits non-zero. Other - ARGs are ignored, and a failed lookup fails currency. -6. The module's integration tier, behind the `integration` tag and using `SQLATE_DSN` and - `pgtest`, proves the stage against the image: - - `MigratedWith` and a declaration of `vector` install it at the image's default; - - `Extensions` reports it installed at the default and not pending, and `Verify` passes; - - a removal is refused while a `vector` column depends on the extension, and succeeds once a set - migration drops the column. -7. The same tier proves the per-space recipe on one untyped `vector` column, with a partial HNSW - index per space over a typed cast (`(embedding::vector(n)) `, `WHERE space = `): - - a query that repeats the cast and the space predicate plans an index scan on its space's - index; - - the same query without the cast doesn't use the index; - - an insert of the wrong dimension into an indexed space fails. - - The tier uses enough rows, or a planner setting, that the plan assertion is deterministic, and - every metric in the metric table is exercised through its opclass and operator. -8. `mise run integration` runs the integration tier of both `postgres` and the new module, and - `mise run acceptance` covers both. The check, build, tidy, test and lint tasks include the new - module, and go.work uses it. -9. The guide documents: - - the module: the extension name, the metric table, its forms, and why the root config lists it - although no `Options.Extensions` declares it (a test-only listing); - - the canonical Dockerfile, with its pin and build flags, and that a consumer copies it; - - the currency ARG check; - - the per-space recipe, its repeated cast and its dimension check; - - that the integration tier now covers two modules. -10. The new module's changelog records `v0.1.0`. sqlint's changelog turns Unreleased into `v0.5.0`. +1. go-database's base module requires sqlate v0.8.0, claude-plugins 0.24.0 and mise-action + v5.3.0, and its currency reports none of them trailing. +2. `admin.Status` gains `Extensions` (`extensions` in JSON). It has one entry per declaration, in + declared order, each with name, removed, installed, default and pending. The list is empty, + never nil, when no extension is declared. +3. `Status.Ready` is false when any declaration doesn't match the database: one pending, one the + image doesn't offer, or one with no update path to the default. The service's readiness follows + `Status` as it does for sets. +4. `ErrExtensionUnavailable` and `ErrNoUpdatePath`, from `Start`, `Verify` and the schema verbs, + wrap in `admin.ErrConflict` with the migrate sentinel still in the chain, and mark the service + not ready. +5. Before `Start` applies, it logs each pending extension as `extension pending; applying`, with + its name and its installed and default versions, beside the pending sets. +6. A new module, `github.com/standards-lab/go-database/postgres/pgvector`, with its own changelog + and `doc.go`: + - Its package exports `ParseMetric(name string) (Metric, error)` and a sentinel + `ErrUnknownMetric`. + - `Metric` is sqlate's `pgvector.Metric`; the package declares no type of its own. + - `ParseMetric` matches a name exactly against sqlate's `pgvector.Metrics()`. An unknown name + returns an error that unwraps to `ErrUnknownMetric` and names it, with no I/O. + - The package imports only the standard library and sqlate's `postgres/pgvector`. pgvector-go + v0.4.1, go-database v0.13.0 and sqlate's `postgres` v0.9.0 are required for the tests only. +7. The package doc shows pgvector-go used directly, in the packages the application's design + declares: `pgvector.NewVector` for a parameter, and `sql.Null[pgvector.Vector]` with `Slice()` + for a nullable column. Domain types hold `[]float32`. The doc also shows a metric resolved from + configuration with `ParseMetric`. +8. go-database has a compose stack: + - It copies sqlate's canonical PostgreSQL image: `postgres:19.0-alpine`, with pgvector built + from source and pinned by `ARG PGVECTOR_VERSION`. + - It publishes `127.0.0.1:${POSTGRES_PORT:-5438}` and keeps its data on tmpfs. + - `mise run db:up` builds and starts it and waits until it is healthy, and `db:down` stops it. +9. go-database's currency is sqlate's script. It checks the requirements, Go, tools, actions, + image lines, the Dockerfile's `FROM` line and its source ARGs. It keeps go-database's comment on + failing scans, and mise installs crane for the image checks. +10. The module's integration tier sits behind the `integration` tag and uses `GO_DATABASE_DSN` and + `pgtest`: + - `admin.Start` with `vector` declared activates it. `Status` then reports it installed at the + image's default, not pending, and `Ready`. + - A `vector` column round-trips `pgvector.NewVector` values, and a NULL, through + `sql.Null[pgvector.Vector]`, over pgx's `database/sql` adapter. + - Each metric's operator orders a nearest-neighbor query. +11. `mise run integration` runs the tier against a running stack. `mise run acceptance` brings the + stack up, runs the tier, brings the stack down whatever the result, and prints the stack's log + on failure. +12. The check, build, tidy, test and lint tasks include the new module, and go.work uses it. The + check vets, fixes and lints the `integration`-tagged suite with its tag. +13. The README and the standards file name the module and its dependency line. The README says the + integration tier runs locally only, through `mise run acceptance`. +14. The base changelog records `v0.13.0`: the sqlate requirement, `Status.Extensions`, the + readiness rule and the error mapping. The module's changelog records `v0.1.0`. **Test seams** -- The module's unit tests: the metric table, and each form, parsed from the module's own - `sqlint.toml` with BurntSushi/toml, matched against a positive and a portable sample - (behaviors 1–2). -- The root check's sqlint run under go.work (behavior 3). -- `mise run currency` against the Dockerfile (behavior 5). -- `pgtest.MigratedWith` and `migrate.Migrator` in the module's integration tier, through - `mise run acceptance` (behaviors 4, 6 and 7). +- `admin.Service` over sqlate's `sqltest`, with a dialect that implements + `migrate.ExtensionCatalog` (behaviors 2–5). +- `ParseMetric`'s unit tests (behavior 6). +- `mise run currency`, and `mise run db:up` offering `vector` (behaviors 1, 8 and 9). +- `pgtest.MigratedWith` and `admin.New` in the module's integration tier, through + `mise run acceptance` (behavior 10). **Slices** -1. The module, its export and the root listing. - - The package, with the extension name and the metric table. - - The `sqlint.toml` forms, with unit tests. - - go.work, the module list in the mise tasks, and the root `extensions` entry. - - The guide's module and forms prose, and the changelog entries for the module and sqlint. - - Done when the check passes with the module listed. -2. The image and its currency. - - The Dockerfile builds pgvector 0.8.7 from source. - - currency.sh gains the generic ARG check. - - The guide's Dockerfile and currency prose. - - Done when `mise run db:up` offers `vector` 0.8.7, currency exits 0, and lowering the ARG default - by hand makes currency report pgvector trailing. -3. The live proof. - - The module's integration tier proves the stage and the per-space recipe; its `go.mod` requires - `postgres` v0.9.0. - - `mise run integration` runs both modules. - - The guide's recipe and integration prose. - - Done when `mise run acceptance` passes and the check passes. +1. Upgrade go-database: sqlate v0.8.0, claude-plugins 0.24.0, mise-action v5.3.0. Done when + currency exits 0 with the current script and the check passes. +2. admin's extension status: `Status.Extensions`, the readiness rule, the error mapping and the + pending log, with unit tests; admin's doc.go and the base changelog's Unreleased entry. Done + when the check passes. +3. The module and `ParseMetric`: the package, its unit tests, its doc with the pgvector-go usage, + its changelog; go.work, `GO_MODULES`, the README and the standards file. Done when the check + passes with the module listed. +4. The compose stack and currency: the copied Dockerfile, the compose files, `db:up`/`db:down`; + sqlate's currency script with the comment carried over, and crane. Done when `mise run db:up` + offers `vector` 0.8.7, currency exits 0, and lowering the ARG default by hand makes currency + report pgvector trailing. +5. The live proof: the integration tier and the module's test requirements, with go-database + bridged by a `replace` until `v0.13.0` is tagged; the `integration` and `acceptance` tasks, the + check's tagged pass, and the README's local-only note. Done when `mise run acceptance` passes + and the check passes. **Out of scope** -- go-database's helpers, compose stack and integration tier (pgvector-go). -- `halfvec`, `sparsevec`, `bit` and `l1` in the metric table, and any distance function or score - conversion in the API. -- Forms for vector arithmetic and for `avg` and `sum` over vectors, which no expression can tell - apart from core SQL. -- Upgrading the ARG in `mise run upgrade`, as with the `FROM` line. -- An integration job in CI. Vetting and linting the integration suites under their tag. -- Releasing `postgres` or the base module, neither of which changes. +- Wrapping pgvector-go's types, a `migrate.Extension` helper, SQL generation, a space registry, and + distance or score conversion. +- pgvector-go's pgx module and an AfterConnect hook. +- `halfvec` and `sparsevec` helpers. +- An integration job in CI, and changes to the CI workflow. +- Upgrading the ARG in `mise run upgrade`. +- A `postgres` release, and any change to sqlate. **Door** -One-way for both tags. Once `sqlint/v0.5.0` is pushed, the `extensions` key, `[export] reason` -and the extension finding format are public. Once `postgres/pgvector/v0.1.0` is pushed, the -extension name, the metric table and the exported forms are public. The Dockerfile, the currency -check and the tests stay two-way. +One-way for both tags. Once `v0.13.0` is pushed, `Status.Extensions`, its JSON shape, the +readiness rule and the `ErrConflict` mapping are public. Once `postgres/pgvector/v0.1.0` is pushed, +`ParseMetric`, `ErrUnknownMetric` and the module path are public. The compose stack, the currency +script and the tests stay two-way. **Release** -`sqlint/v0.5.0`, `postgres/pgvector/v0.1.0` +`v0.13.0`, then `postgres/pgvector/v0.1.0`, whose `go.mod` pins go-database `v0.13.0` in place of +the `replace`. + +## Progress + +slices 0/5 committed · standards — · spec — · editor — ## Decisions @@ -167,6 +147,17 @@ check and the tests stay two-way. check in `scripts/currency.sh`. - pgvector-sql: an extension module's live proof runs in its own module's integration tier, with that module requiring `postgres` for `pgtest`. The engine module never requires its extensions. +- pgvector-go: Applications use pgvector-go's root module directly, in the packages their design + declares: `pgvector.NewVector` in, `sql.Null[pgvector.Vector]` and `Slice()` out; domain types + hold `[]float32`. go-database wraps no vector type. Rejected: `Param`/`Dest` wrappers over + `[]float32` (indirection the import rule already makes unnecessary), and a `migrate.Extension` + helper. +- pgvector-go: go-database's `postgres/pgvector` holds `ParseMetric`, returning sqlate's + `pgvector.Metric`, and the integration tier; its package needs pgvector-go only in tests. +- pgvector-go: `admin.Status.Ready` is false on any extension mismatch (pending, unavailable, no + update path); admin wraps `ErrExtensionUnavailable` and `ErrNoUpdatePath` in `ErrConflict`. +- pgvector-go: go-database's integration tier uses `GO_DATABASE_DSN` on 5438 and a tmpfs stack, + runs locally only, and the check vets, fixes and lints it with its tag. ## Pending edits @@ -195,3 +186,6 @@ check and the tests stay two-way. `postgres/migrate_live_test.go` and its copy in `postgres/pgvector` lose a Scan error; pgvector's forms tests copy sqlint's stripping, and can go through `sqlint.Lint` once `sqlint/v0.5.0` is tagged. `roadmap/index.toml`: add it to `backlog`. +- coordinator · `context/postgres-extensions.md`, "The modules": go-database's module is not + helpers over pgvector-go; applications use pgvector-go directly, and the module holds + `ParseMetric` and the integration tier. From cb927204f6bcddcc4eeb096bf30cf8c43b406c6c Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Tue, 24 Nov 2026 19:54:23 -0500 Subject: [PATCH 2/3] pgvector-go: editor: goal record decisions and pending edits --- context/goals/v1.data.extensions.md | 75 +++++++++++++---------------- 1 file changed, 33 insertions(+), 42 deletions(-) diff --git a/context/goals/v1.data.extensions.md b/context/goals/v1.data.extensions.md index b8839fa..f965a70 100644 --- a/context/goals/v1.data.extensions.md +++ b/context/goals/v1.data.extensions.md @@ -129,7 +129,7 @@ the `replace`. ## Progress -slices 0/5 committed · standards — · spec — · editor — +slices 5/5 committed · standards ✓ · spec ✓ (1 gap, accepted: currency.sh comment) · editor ✓ ## Decisions @@ -137,55 +137,46 @@ slices 0/5 committed · standards — · spec — · editor — built from source, pgvector pinned by `ARG PGVECTOR_VERSION`. Rejected: pgvector/pgvector's Debian images, PGDG on Debian, and a version declared in Go. - plan: Shipped migration sets declare no extensions; only the application does. -- plan: go-database's module is `go-database/postgres/pgvector`. It uses pgvector-go's root module - over `database/sql` and depends on `sqlate/postgres/pgvector`'s metric table. -- extension-stage: A removed declaration still installed is pending: `Verify` unwraps to - `ErrPending` and `Extensions` marks it pending, so `admin.Status` reports it not `Ready`. - sqlint-extensions: rejected sqlfluff and squawk, which lint against a fixed dialect and can't read a module's exported deny list. -- pgvector-sql: go-database copies sqlate's canonical `compose/postgres/Dockerfile` and the ARG - check in `scripts/currency.sh`. - pgvector-sql: an extension module's live proof runs in its own module's integration tier, with that module requiring `postgres` for `pgtest`. The engine module never requires its extensions. -- pgvector-go: Applications use pgvector-go's root module directly, in the packages their design - declares: `pgvector.NewVector` in, `sql.Null[pgvector.Vector]` and `Slice()` out; domain types - hold `[]float32`. go-database wraps no vector type. Rejected: `Param`/`Dest` wrappers over - `[]float32` (indirection the import rule already makes unnecessary), and a `migrate.Extension` - helper. -- pgvector-go: go-database's `postgres/pgvector` holds `ParseMetric`, returning sqlate's - `pgvector.Metric`, and the integration tier; its package needs pgvector-go only in tests. -- pgvector-go: `admin.Status.Ready` is false on any extension mismatch (pending, unavailable, no - update path); admin wraps `ErrExtensionUnavailable` and `ErrNoUpdatePath` in `ErrConflict`. -- pgvector-go: go-database's integration tier uses `GO_DATABASE_DSN` on 5438 and a tmpfs stack, - runs locally only, and the check vets, fixes and lints it with its tag. +- pgvector-go: go-database wraps no pgvector-go type; applications use pgvector-go directly + (go-database's `postgres/pgvector/doc.go`). Rejected: `Param`/`Dest` wrappers over `[]float32`, + which the import rule already makes unnecessary, and a `migrate.Extension` helper. ## Pending edits -- coordinator · `references.md`: add the new sub-modules to sqlate's and go-database's entries, and - pgvector and pgvector-go under upstream sources. -- coordinator · `context/postgres-extensions.md`: delete it once `principles` promotes it, and - remove its `context/README.md` entry and the pointers in `data-intelligence.md` and - `migration-sets.md`. +- coordinator · `references.md`: add sqlate's `postgres/pgvector` and go-database's + `postgres/pgvector` sub-modules to their repositories' entries, and pgvector and pgvector-go + under upstream sources. - coordinator · `roadmap/v1.data.extensions.toml`: sqlint-extensions' summary adds moving postgres onto sqlate v0.8.0 and releasing `postgres/v0.9.0`. -- coordinator · `context/postgres-extensions.md`: the check fails on any installed version with no - update path to the image's default (read through `pg_extension_update_paths`), not only a newer - one; a migrate dialect capability supplies the standard pair. -- coordinator · `context/postgres-extensions.md`, "sqlint": an extension module with no forms - declares an empty `[export.native_forms]` table beside `[export] reason`, not `forms = []`; an - `extensions` entry is a module path or a directory of the tree. -- coordinator · `context/postgres-extensions.md`, the image build: `make install` also needs - `with_llvm=no`, since the official image's PostgreSQL is built `--with-llvm` (llvm21); the - extension's catalog name is `vector`, not `pgvector`; pgvector publishes git tags but no GitHub - releases, so currency reads tags (`git ls-remote --tags`). -- coordinator · `roadmap/sqlate-test-tier.toml`: create the goal ("sqlate's test-tier - follow-ups", repos `["sqlate"]`), whose summary lists: the check doesn't vet, fix or lint the - `integration`-tagged suites of `postgres` and `postgres/pgvector` with their tag, as - tests-and-docs.md and release-and-ci.md require; sqlate has no CI integration job, and building - pgvector adds about 10 seconds to one; the live tests' `text` helper in - `postgres/migrate_live_test.go` and its copy in `postgres/pgvector` lose a Scan error; +- coordinator · `context/postgres-extensions.md`, for `principles` to promote: + - the check fails on any installed version with no update path to the image's default (read + through `pg_extension_update_paths`), not only a newer one; a migrate dialect capability + supplies the standard pair. + - "sqlint": an extension module with no forms declares an empty `[export.native_forms]` table + beside `[export] reason`, not `forms = []`; an `extensions` entry is a module path or a + directory of the tree. + - the image build: `make install` also needs `with_llvm=no`, since the official image's + PostgreSQL is built `--with-llvm` (llvm21); the extension's catalog name is `vector`, not + `pgvector`; pgvector publishes git tags but no GitHub releases, so currency reads tags + (`git ls-remote --tags`). + - "The modules": go-database's module holds no helpers over pgvector-go. Applications use + pgvector-go directly, and the module holds `ParseMetric` and the integration tier. + - once `principles` promotes the note, delete it, and remove its `context/README.md` entry and + the pointers in `data-intelligence.md` and `migration-sets.md`. +- coordinator · `roadmap/sqlate-test-tier.toml`: create the goal ("test-tier follow-ups for sqlate + and go-database", repos `["sqlate", "go-database"]`), whose summary lists: sqlate's check doesn't + vet, fix or lint the `integration`-tagged suites of `postgres` and `postgres/pgvector` with their + tag, as tests-and-docs.md and release-and-ci.md require; neither sqlate nor go-database has a CI + integration job, and building pgvector adds about 10 seconds to one; the live tests' `text` + helper in `postgres/migrate_live_test.go` and its copy in `postgres/pgvector` lose a Scan error; pgvector's forms tests copy sqlint's stripping, and can go through `sqlint.Lint` once `sqlint/v0.5.0` is tagged. `roadmap/index.toml`: add it to `backlog`. -- coordinator · `context/postgres-extensions.md`, "The modules": go-database's module is not - helpers over pgvector-go; applications use pgvector-go directly, and the module holds - `ParseMetric` and the integration tier. +- coordinator · `roadmap/sqlate-extension-match.toml`: create the goal ("admin follows sqlate's + extension match rule", repos `["sqlate", "go-database"]`): admin's readiness (`matched` in + `admin/service.go`) re-derives sqlate's unexported `classify` from `ExtensionStatus` fields; + sqlate could export whether a declaration matches, and admin call it. `roadmap/index.toml`: add + it to `backlog`. From 4fe7031c17fca15c0747ca009d835a5478d22934 Mon Sep 17 00:00:00 2001 From: Jaime Still Date: Tue, 24 Nov 2026 20:01:30 -0500 Subject: [PATCH 3/3] pgvector-go: goal record, task shipped --- context/goals/v1.data.extensions.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/context/goals/v1.data.extensions.md b/context/goals/v1.data.extensions.md index f965a70..af05f56 100644 --- a/context/goals/v1.data.extensions.md +++ b/context/goals/v1.data.extensions.md @@ -1,15 +1,15 @@ # goal · v1.data.extensions -- **State:** building -- **Task:** pgvector-go -- **Branch:** pgvector-go +- **State:** idle +- **Task:** none +- **Branch:** none ## Tasks 1. [x] extension-stage 2. [x] sqlint-extensions 3. [x] pgvector-sql -4. [ ] pgvector-go +4. [x] pgvector-go 5. [ ] principles ## Task brief · pgvector-go @@ -127,10 +127,6 @@ script and the tests stay two-way. `v0.13.0`, then `postgres/pgvector/v0.1.0`, whose `go.mod` pins go-database `v0.13.0` in place of the `replace`. -## Progress - -slices 5/5 committed · standards ✓ · spec ✓ (1 gap, accepted: currency.sh comment) · editor ✓ - ## Decisions - plan: The image is an extension's sole version source: `postgres:19.0-alpine` with each extension