Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/pg-hydradb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ARG PG
FROM postgres:${PG}-bookworm AS build
ARG PG
ARG HYDRADB_REF
RUN apt-get update && apt-get install -y --no-install-recommends build-essential curl \
ca-certificates pkg-config libclang-dev clang postgresql-server-dev-${PG} \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.99.0
ENV PATH=/root/.cargo/bin:$PATH
RUN test -n "$HYDRADB_REF" && mkdir /src \
&& curl -sSfL "https://codeload.github.com/hydra-db/hydradb/tar.gz/${HYDRADB_REF}" | tar -xz -C /src --strip-components 1
WORKDIR /src/crates/pg-hydradb
RUN PGRX_PG_CONFIG_PATH=/usr/lib/postgresql/${PG}/bin/pg_config \
cargo build --release --locked --no-default-features --features pg${PG}

FROM scratch
COPY --from=build /src/crates/pg-hydradb/target/release/libpg_hydradb.so /lib/pg_hydradb.so
COPY --from=build /src/crates/pg-hydradb/pg_hydradb.control /extension/
COPY --from=build /src/crates/pg-hydradb/sql/ /extension/
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,61 @@ jobs:
SELFGRAPH_TEST_PREBUILT: "1"
SELFGRAPH_PY: python

postgres:
needs: [python-build]
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
pg: ["16", "17"]
env:
PG: ${{ matrix.pg }}
HYDRADB_REF: 58390740c6d7f0b2f572b5c0c0170ef59da4a3c5
SG_PG_HYDRADB_URI: postgresql://postgres:[email protected]:5432/postgres
SELFGRAPH_TEST_STORES: kuzu
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
id: extension
with:
path: ${{ runner.temp }}/pg-hydradb
key: pg-hydradb-${{ matrix.pg }}-${{ env.HYDRADB_REF }}-${{ hashFiles('.github/pg-hydradb/Dockerfile') }}
- if: steps.extension.outputs.cache-hit != 'true'
run: >-
docker build --build-arg "PG=$PG" --build-arg "HYDRADB_REF=$HYDRADB_REF"
--output "type=local,dest=$RUNNER_TEMP/pg-hydradb" .github/pg-hydradb
- run: |
docker create --name pg -e POSTGRES_PASSWORD=owner -p 5432:5432 "postgres:$PG-bookworm"
docker cp "$RUNNER_TEMP/pg-hydradb/lib/pg_hydradb.so" "pg:/usr/lib/postgresql/$PG/lib/"
docker cp "$RUNNER_TEMP/pg-hydradb/extension/." "pg:/usr/share/postgresql/$PG/extension/"
docker start pg
for i in $(seq 1 30); do docker exec pg pg_isready -q -h 127.0.0.1 -U postgres && break; sleep 2; done
docker exec pg psql -U postgres -h 127.0.0.1 -c "SELECT version()"
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
with:
enable-cache: true
prune-cache: false
cache-suffix: postgres
cache-dependency-glob: pyproject.toml
python-version: "3.12"
- uses: actions/download-artifact@v4
with:
name: python-dist
path: dist
- run: uv pip install --system "$(ls dist/*.whl)[dev,kuzu,postgres]"
- run: pytest tests/test_pg_hydradb_store.py -v -rs
env:
KUZU_PATH: ${{ runner.temp }}/selfgraph-kuzu
- uses: ./.github/actions/node-deps
- run: npx vitest run test/pgHydradbStore.test.ts
working-directory: typescript
env:
SELFGRAPH_TEST_PREBUILT: "1"

backends:
if: always()
needs: [backends-python, backends-typescript]
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ invariants below.
- Wire formats match across the two SDKs: result and schema keys, CLI flags, `SELFGRAPH_*` variables, MCP tool names and arguments, warning codes, error codes and text, and LLM prompts. The conformance pair (`typescript/test/conformance/py_side.py` and `ts_side.ts`) covers the deterministic paths, including `from_tables`, schema term forms, `check_answerable`, synonym seeding, and `graph.tiers`. Extend both sides when you add a deterministic behaviour. LLM tiers are covered by mirrored tests with a fake client, not by conformance.
- Run `pre-commit install` once; the hook runs ruff, Biome, and `tsc` on each commit. Lint and format before pushing: `ruff check .` and `ruff format .` (config lives in `pyproject.toml`; CI runs `ruff check` and `ruff format --check`).
- In `typescript/`, lint and format with Biome before pushing: `npm run lint` checks and `npm run format` fixes (config lives in `typescript/biome.json`; CI runs `npm run lint`, `typecheck`, `build`, and `test`).
- The test suite lives in `tests/` and needs a graph backend: a Bolt server (Neo4j by default, or Memgraph), FalkorDB, HydraDB, or embedded Kuzu, selected with `SELFGRAPH_TEST_STORE` (or the first entry of `SELFGRAPH_TEST_STORES`, the TypeScript suite's plural selector). Backend connection details accept the TypeScript `SG_*` names first (`SG_NEO4J_URI`, `SG_NEO4J_PASSWORD`, `SG_MEMGRAPH_URI`, `SG_FALKOR_PORT`, `SG_HYDRADB_URI`, `SG_HYDRADB_TOKEN`), then the bare names (`NEO4J_URI`, `NEO4J_AUTH`, `CYPHER_URI`, `FALKOR_PORT`, `HYDRADB_URI`, `HYDRADB_TOKEN`), so one set of variables drives both suites. If you add tests, drive async code with `asyncio.run(...)` and do not add `pytest-asyncio`. Test an LLM or embedder tier with a small fake object that implements `generate` or `embed`, as `tests/test_tiers.py` does; never call a real model. CI runs both suites on embedded Kuzu with the `tokenizer` extra installed.
- The test suite lives in `tests/` and needs a graph backend: a Bolt server (Neo4j by default, or Memgraph), FalkorDB, HydraDB, or embedded Kuzu, selected with `SELFGRAPH_TEST_STORE` (or the first entry of `SELFGRAPH_TEST_STORES`, the TypeScript suite's plural selector). Backend connection details accept the TypeScript `SG_*` names first (`SG_NEO4J_URI`, `SG_NEO4J_PASSWORD`, `SG_MEMGRAPH_URI`, `SG_FALKOR_PORT`, `SG_HYDRADB_URI`, `SG_HYDRADB_TOKEN`), then the bare names (`NEO4J_URI`, `NEO4J_AUTH`, `CYPHER_URI`, `FALKOR_PORT`, `HYDRADB_URI`, `HYDRADB_TOKEN`), so one set of variables drives both suites. If you add tests, drive async code with `asyncio.run(...)` and do not add `pytest-asyncio`. Test an LLM or embedder tier with a small fake object that implements `generate` or `embed`, as `tests/test_tiers.py` does; never call a real model. CI runs both suites on embedded Kuzu with the `tokenizer` extra installed. The Postgres store tests (`tests/test_pg_hydradb_store.py`, `typescript/test/pgHydradbStore.test.ts`) skip unless `SG_PG_HYDRADB_URI` names a Postgres with pg_hydradb; the CI `postgres` job builds pg_hydradb from the hydradb commit pinned in `ci.yml` (`HYDRADB_REF`) and runs them on Postgres 16 and 17.

## Architecture invariant

Expand Down Expand Up @@ -94,7 +94,7 @@ Cypher. A vector store, GraphRAG, English-to-Cypher, file parsing, and row-level
structured input are out of scope for the core. Do not add them or their
dependencies to the core. Embeddings are allowed only as a seeding tier over a
caller-supplied `Embedder`: the SDK ships no embedding model and stores no vectors.
Schema drafts read table metadata the caller passes, never rows or a database.
Schema drafts read table metadata the caller passes, or a store's own catalog and registry (such as the pg_hydradb tables that `PgHydraDBStore.draft_schema` reads). A draft never reads user rows.

## Commits

Expand Down
Loading