-
Notifications
You must be signed in to change notification settings - Fork 20
feat(server)!: replace PGlite with embedded Postgres; bundle pgvector; earthdistance geo #965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
23080a4
e315039
6fba2ec
85085de
45b8e2f
919d1e6
c6c3561
8d4c257
95bcfe0
aba14f4
81bc467
7e1bbf1
100f7c7
c117da3
1fe2964
0c44ed3
5a54c7d
481cd59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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' }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: The Citations:
Design the workflow to handle missing inputs on Line 30 references The suggested fix (using
🤖 Prompt for AI Agents |
||
|
|
||
| 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 | ||
|
Comment on lines
+48
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n .github/workflows/build-pgvector-embedded.ymlRepository: lobu-ai/lobu Length of output: 5276 🌐 Web query:
💡 Result: Securing GitHub Actions workflows involves two critical practices: pinning actions to immutable commit SHAs and managing credential persistence during checkout [1][2][3]. Pinning Actions to Commit SHAs Referencing actions by version tags (e.g., v4) is insecure because tags are mutable and can be repointed to malicious code by compromised maintainer accounts [4][5][6]. To ensure supply chain integrity, you should pin all third-party actions to their full-length commit SHA [1][7][3]. - Implementation: Replace tag references (e.g., uses: actions/checkout@v4) with the specific SHA (e.g., uses: actions/checkout@b4ffde6) [5][7]. - Documentation: Always include a comment indicating the version tag the SHA corresponds to for easier maintenance (e.g., # v4.1.1) [4][5]. - Automation: Use tools like Dependabot, Renovate, or specialized scanners (e.g., zizmor, pinact) to automate and manage these updates [4][3]. Managing persist-credentials By default, the actions/checkout action configures Git to persist the GitHub token in the local.git/config file [2][8]. This can expose credentials to subsequent steps in the workflow or leak through artifacts if they are improperly managed [2][8]. - Best Practice: Explicitly set persist-credentials to false in your checkout step unless you specifically require the token for Git operations later in the job [1][2]. - Implementation Example: - name: Checkout uses: actions/checkout@v4 with: persist-credentials: false General Security Recommendations - Least Privilege: Grant the GITHUB_TOKEN only the minimum required permissions (default to read-only at the top level and elevate only where necessary) [9][10][11]. - Avoid Secrets Exposure: Do not store sensitive values in plain text; use GitHub Secrets and leverage OpenID Connect (OIDC) for cloud authentication instead of long-lived static secrets [3][12][10]. - Monitor Risks: Periodically audit workflows for unpinned actions, broad permissions, and insecure trigger usage (e.g., pull_request_target) [1][2][13]. Citations:
Pin actions to commit SHAs and disable checkout credential persistence for supply chain security. Lines 44, 45, 72, 82, and 83 use mutable tag refs ( Also applies to: 72-72, 83-83 🧰 Tools🪛 zizmor (1.25.2)[warning] 44-44: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) [error] 44-44: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy) (unpinned-uses) [error] 45-45: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy) (unpinned-uses) 🤖 Prompt for AI Agents |
||
| 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)." | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: lobu-ai/lobu
Length of output: 4464
Scope permissions per job instead of workflow-wide write access.
The
buildjob only performs checkout and artifact upload, requiring read-only access. Theopen-prjob requires write permissions for git operations and PR creation. Restrict workflow-level permissions tocontents: readand add job-level write permissions only toopen-pr.Suggested hardening diff
🧰 Tools
🪛 zizmor (1.25.2)
[error] 26-26: overly broad permissions (excessive-permissions): contents: write is overly broad at the workflow level
(excessive-permissions)
[error] 27-27: overly broad permissions (excessive-permissions): pull-requests: write is overly broad at the workflow level
(excessive-permissions)
🤖 Prompt for AI Agents