Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
121 changes: 121 additions & 0 deletions .github/workflows/build-pgvector-embedded.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Build pgvector-embedded artifacts

# Rebuilds the prebuilt pgvector artifacts vendored in
# packages/pgvector-embedded/prebuilt/<platform>/ for every platform
# embedded-postgres supports. Run on demand (bump pgvector / PG major) or when
# the build script changes. embedded-postgres ships vanilla PG 18 with no
# pgvector, so each cell compiles pgvector against a same-major PostgreSQL (the
# extension ABI is stable within a major) and uploads the result; a final job
# opens a PR with the regenerated artifacts.
#
# Windows (windows-x64) is intentionally NOT built yet — pgvector on Windows
# needs an MSVC/nmake build the bash script doesn't cover. Follow-up.

on:
workflow_dispatch:
inputs:
pgvector_version:
description: pgvector git tag to build
default: v0.8.1
push:
paths:
- packages/pgvector-embedded/scripts/build.sh
- .github/workflows/build-pgvector-embedded.yml

permissions:
contents: write
pull-requests: write

env:
PGVECTOR_VERSION: ${{ inputs.pgvector_version || 'v0.8.1' }}

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- { platform: darwin-arm64, runner: macos-15 }
# macos-15-intel is GitHub's x86_64 macOS runner. The old macos-13
# (Intel) image was retired Dec 2025, so that label queues forever.
# macos-15-intel runs Intel on macOS 15 (available until ~Aug 2027,
# the last x86_64 macOS image GitHub will offer).
- { platform: darwin-x64, runner: macos-15-intel }
- { platform: linux-x64, runner: ubuntu-latest }
- { platform: linux-arm64, runner: ubuntu-24.04-arm }
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22

- name: Install PostgreSQL 18 dev (macOS)
if: runner.os == 'macOS'
run: |
brew install postgresql@18
echo "PG_CONFIG=$(brew --prefix postgresql@18)/bin/pg_config" >> "$GITHUB_ENV"

- name: Install PostgreSQL 18 dev (Linux)
if: runner.os == 'Linux'
run: |
# Use the official pgdg setup script rather than a hand-rolled
# curl|gpg --dearmor pipe: the latter intermittently fails on GitHub
# runners with "gpg: cannot open '/dev/tty'". The script adds the
# repo + key non-interactively.
sudo apt-get update
sudo apt-get install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
sudo apt-get install -y postgresql-server-dev-18 build-essential
echo "PG_CONFIG=/usr/lib/postgresql/18/bin/pg_config" >> "$GITHUB_ENV"

- name: Build pgvector artifact
run: |
chmod +x packages/pgvector-embedded/scripts/build.sh
PLATFORM=${{ matrix.platform }} packages/pgvector-embedded/scripts/build.sh

- uses: actions/upload-artifact@v4
with:
name: pgvector-${{ matrix.platform }}
path: packages/pgvector-embedded/prebuilt/${{ matrix.platform }}
if-no-files-found: error

open-pr:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: /tmp/pgvector-artifacts

- name: Stage regenerated artifacts
run: |
for dir in /tmp/pgvector-artifacts/pgvector-*; do
platform="$(basename "$dir" | sed 's/^pgvector-//')"
dest="packages/pgvector-embedded/prebuilt/${platform}"
rm -rf "$dest"
mkdir -p "$dest"
cp -R "$dir/." "$dest/"
done

- name: Open PR
env:
GH_TOKEN: ${{ github.token }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
branch="chore/pgvector-embedded-${PGVECTOR_VERSION}-${GITHUB_RUN_ID}"
git switch -c "$branch"
git add packages/pgvector-embedded/prebuilt
if git diff --cached --quiet; then
echo "No artifact changes — nothing to PR."
exit 0
fi
git commit -m "chore(pgvector-embedded): rebuild prebuilt artifacts (${PGVECTOR_VERSION})"
git push -u origin "$branch"
gh pr create \
--base main \
--head "$branch" \
--title "chore(pgvector-embedded): rebuild prebuilt artifacts (${PGVECTOR_VERSION})" \
--body "Regenerated by the build-pgvector-embedded workflow (pgvector ${PGVECTOR_VERSION}, PG 18)."
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,18 @@ jobs:
# the `import` condition and fails to load if dist is absent —
# which transitively breaks every integration file whose import
# graph touches `queue-helpers` / `worker-api` / `connector-catalog`.
#
# pgvector-embedded must build too: the test backend
# (src/__tests__/setup/embedded-postgres-backend.ts) imports
# `@lobu/pgvector-embedded`, so vite resolves its `import` condition
# (./dist/index.js) at transform time even though the embedded backend
# is never started when DATABASE_URL points at the external Postgres.
run: |
cd packages/core && bun run build && cd ../..
cd packages/connector-sdk && bun run build && cd ../..
cd packages/embeddings && bun run build && cd ../..
cd packages/connector-worker && bun run build && cd ../..
cd packages/pgvector-embedded && bun run build && cd ../..

- name: Verify Postgres health (fail fast if pgvector setup is broken)
run: |
Expand Down
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ Rules for agents:
- `packages/cli/src/commands/_lib/connector-run-cmd.ts` — `browser-mirror`, `devtools-active-port`, `executeCompiledConnector`.
- `packages/cli/src/commands/_lib/apply/desired-state.ts` — `yaml` (loaded only on YAML inputs).
- `packages/cli/src/commands/memory/_lib/browser-auth-cmd.ts` — `decryptChromeCookiesMacOS`, `playwright/chromium`.
- `packages/server/src/server.ts` — `./embedded-runtime` is statically imported, but `./server-lifecycle` is lazy: its transitive imports read env at module-eval, and the embedded branch only finalises DATABASE_URL during `main()`. Loading the lifecycle eagerly would snapshot a stale env.
- `packages/server/src/embedded-runtime.ts` — `embedded-postgres` + `@lobu/pgvector-embedded` (and `postgres`) are lazy so the external/prod path (postgres:// URL) never resolves or loads the ~145MB embedded-Postgres binary even though it sits in node_modules. Only reached when DATABASE_URL is a path/file://.
- **Tests** — `await import(...)` inside `beforeAll` / `beforeEach` / `test()` is allowed (load after `vi.mock(...)`); this is the vitest pattern, not a production exemption.

## Scope discipline and branch hygiene
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typecheck:
# Build all TypeScript packages in dependency order
build-packages:
@echo "📦 Building all TypeScript packages..."
@for pkg in core connector-sdk agent-worker openclaw-plugin embeddings connector-worker promptfoo-provider; do \
@for pkg in core pgvector-embedded connector-sdk agent-worker openclaw-plugin embeddings connector-worker promptfoo-provider; do \
echo " 📦 Building packages/$$pkg..."; \
( cd packages/$$pkg && bun run build ) || exit $$?; \
done
Expand Down
60 changes: 44 additions & 16 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading