Skip to content

test: add a real-Postgres e2e suite with add and search tests - #56

Merged
TheGreatAxios merged 4 commits into
cl-9105-memory-delete-arktype-schema-and-enum-lockstep-testsfrom
cl-9064-memory-add-shared-real-postgres-test-harness-in-tests
Sep 27, 2026
Merged

TheGreatAxios merged 4 commits into
cl-9105-memory-delete-arktype-schema-and-enum-lockstep-testsfrom
cl-9064-memory-add-shared-real-postgres-test-harness-in-tests

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stacked on #55; merge that first.

  • tests/lib/db-harness.ts creates a fresh database per suite on the server named by TEST_DATABASE_URL, applies Interchange's migrations (@intx/db runMigrations) and memory's, and drops the database afterwards. It mounts createMemoryRoutes on a Hono<TenantEnv> app behind a stand-in tenant middleware that seats the caller from a bearer token and refuses a path naming another tenant.
  • bun run test runs src/ and tests/. CI runs it against a pgvector/pgvector:pg17 service. Without TEST_DATABASE_URL the end-to-end suites skip locally and fail in CI. CONTRIBUTING describes the setup.
  • Suites (lexical-only, no embedding endpoint):
    • add and search: search ranks added documents by relevance, and another tenant sees none of them.
    • grants, forget and purge: a missing memory:search grant gets 403. Forget is allowed for the creator only. Purge removes the document, its versions and its chunks.
    • migrations: a second run leaves the memory schema unchanged and creates no tables in public. A replay behind a long reader waits for it instead of failing. Three concurrent runners on a fresh database, then on a migrated one, all succeed. With a non-public host schema the foreign keys target that schema, and a replay against a different host schema fails. A database left by the 0.1.0 runner before 0004 gets the temporal_class backfill exactly once.
    • distill tick: a tick through the tenant routes writes one inferred claim per shared capture, each linked by derived_from, and a replay from the returned cursor writes nothing.

Verification

  • TEST_DATABASE_URL=… bun run test: 428 pass against a local pgvector Postgres 16. No memory_test_* databases are left behind.
  • bun run test without the variable: 418 pass, and the end-to-end suites skip.
  • bun run typecheck passes.

Closes CL-9064
Closes CL-9085
Closes CL-9086
Closes CL-9088
Closes CL-9087

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review, two passes.

Verdict: ready for review.

  • Every suite runs against real pgvector Postgres and cleans up its database.
  • The suites skip cleanly without TEST_DATABASE_URL.
  • Lexical-only coverage and the run-scoped caveat are noted in the description.

@TheGreatAxios
TheGreatAxios force-pushed the cl-9064-memory-add-shared-real-postgres-test-harness-in-tests branch from 2089726 to 82f8b5f Compare September 25, 2026 07:02
@TheGreatAxios
TheGreatAxios force-pushed the cl-9064-memory-add-shared-real-postgres-test-harness-in-tests branch from 82f8b5f to bb66414 Compare September 25, 2026 18:31
@TheGreatAxios
TheGreatAxios force-pushed the cl-9064-memory-add-shared-real-postgres-test-harness-in-tests branch from bb66414 to b07f9a4 Compare September 26, 2026 01:32
@TheGreatAxios TheGreatAxios changed the title Add a real-Postgres end-to-end suite test: add a real-Postgres e2e suite with add and search tests Sep 26, 2026
@TheGreatAxios
TheGreatAxios force-pushed the cl-9064-memory-add-shared-real-postgres-test-harness-in-tests branch from b07f9a4 to 02abcaf Compare September 26, 2026 01:36
@TheGreatAxios
TheGreatAxios added this pull request to stack #61 September 26, 2026 01:57
The shared test harness creates a fresh database per suite on the server
named by TEST_DATABASE_URL, applies Interchange's migrations and
memory's, mounts createMemoryRoutes under a stand-in tenant middleware,
and drops the database afterwards. The first suite adds documents over
HTTP, checks that search ranks them by relevance, and checks that
another tenant sees none of them. bun run test now runs the unit and
end-to-end suites, and CI runs it against a pgvector service; without
TEST_DATABASE_URL the end-to-end suites skip.
A second run leaves the memory schema unchanged and creates no tables in
public, and a replay behind a long reader fails on the lock timeout
instead of blocking. With a non-public host schema the foreign keys
point at that schema's tenant and principal tables, and replaying
against a different host schema fails instead of passing silently. A
database the ledger runner left before the temporal model gets the
temporal_class backfill exactly once.
A caller without memory:search gets 403, only a document's creator can
forget it, and purge removes the document with its versions and chunks.
A tick over tenant-shared captures writes one inferred claim per
document through the HTTP client, and a second tick from the returned
cursor writes nothing.
@TheGreatAxios
TheGreatAxios force-pushed the cl-9064-memory-add-shared-real-postgres-test-harness-in-tests branch from 02abcaf to 5407084 Compare September 27, 2026 00:32
@TheGreatAxios
TheGreatAxios merged commit 6a82fb8 into main Sep 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant