Add PostgreSQL repository package#19
Conversation
Add @fedify/botkit-postgres as a PostgreSQL-backed Repository implementation for BotKit, including schema initialization, connection ownership handling, and integration tests guarded by POSTGRES_URL. Update the repository documentation and changelog so the new package and its configuration model are documented alongside the existing repository backends. Closes fedify-dev#11
Handle schema initialization failures without triggering unhandled rejection warnings before callers await repository operations. Preserve follower state when removing one follow request if the same actor still has other follow requests, and add regression tests for both behaviors.
Pass the repository's prepare setting through schema initialization so PostgreSQL deployments that disable prepared statements behave consistently during startup. Add regression coverage for both the public schema helper and the repository constructor path, and document the helper's third argument for PgBouncer-style setups.
Remove stale follower rows when an existing follow request ID is repointed at a different actor, so follower counts, membership checks, and follower iteration stay consistent with the remaining follow request mappings. Add a regression test that reproduces the reassignment case and record the fix in the changelog for the PostgreSQL repository. fedify-dev#11
Guard addFollower() with a follow-request-scoped advisory lock so concurrent workers cannot both observe an unassigned follow request and leave behind a stale follower row. Add a regression test that forces the racing assignment window across two PostgreSQL clients, and record the fix in the changelog. Closes fedify-dev#11
Guard removeFollower() with the same follow-request-scoped advisory lock used by addFollower() so an Undo(Follow) cannot race ahead of an in-flight follow acceptance and leave a stale follower behind. Add a regression test that forces the add/remove interleaving across two PostgreSQL clients, and record the fix in the changelog. Closes fedify-dev#11
Lock follower cleanup by previous follower ID so concurrent reassignment of multiple follow requests away from the same actor cannot leave a stale follower row behind. Factor the cleanup path through a shared helper, add a regression test that forces the concurrent reassignment window, and record the fix in the changelog. Closes fedify-dev#11
Replace workspace and catalog dependency specifiers in the PostgreSQL package metadata with publishable semver ranges so npm consumers can install the package without unsupported protocol errors. Move the Temporal polyfill setup out of tsdown's bundle intro and into runtime source initialization so generated declaration files stay valid for strict TypeScript consumers. Closes fedify-dev#11
Condense the unreleased changelog entry for @fedify/botkit-postgres to describe the package's initial feature set instead of listing internal bug-fix iterations that users have never seen in a released version.
|
@codex review |
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request introduces the @fedify/botkit-postgres package, which provides a PostgreSQL-based repository implementation for BotKit using the postgres.js driver. The new PostgresRepository supports persistent storage for key pairs, messages, followers, and poll votes, featuring concurrency control through advisory locks. The PR also includes updated documentation, integration tests, and necessary dependency updates. I have no feedback to provide.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 658351defa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Acquire follower-level advisory locks in addFollower() before writing followers and follow_requests so cleanup and inserts cannot race on the same actor key. Add a regression test that reproduces concurrent reassignment plus new follow insertion and verifies valid follower state is retained. fedify-dev#19 (comment) Co-Authored-By: OpenAI Codex <codex@openai.com>
|
@codex review |
|
/gemini review |
|
Warning Gemini is experiencing higher than usual traffic and was unable to create the review. Please try again in a few hours by commenting |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d95cd4a8e4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Treat url and maxConnections as conflicting with sql only when they have non-null values, so option spreads that preserve undefined fields do not fail at runtime. Add a regression assertion that verifies undefined mutually exclusive fields remain accepted. fedify-dev#19 (comment) Co-Authored-By: OpenAI Codex <codex@openai.com>
Enable workspace linking for semver-compatible local packages so pnpm install resolves the in-repo @fedify/botkit package instead of failing against the registry for the unreleased 0.4.0 range. Refresh pnpm-lock.yaml after the workspace resolution change. Co-Authored-By: OpenAI Codex <codex@openai.com>
|
@codex review |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new PostgreSQL-backed repository package, @fedify/botkit-postgres, which provides persistent storage for BotKit using the PostgresRepository class. The implementation includes schema initialization, support for both Deno and Node.js runtimes, and concurrency control via PostgreSQL advisory locks. Feedback was provided regarding the global polyfilling of the Temporal API, which contradicts the package's sideEffects: false metadata and should be moved to consumer responsibility. Additionally, a performance optimization was suggested to add a composite index on the poll_votes table to improve the efficiency of voter counting queries.
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The package applies Temporal polyfills at module load time, so its package metadata must not advertise the module as side-effect free. Set sideEffects to true so bundlers preserve the initialization when consumers import the package. fedify-dev#19 (comment) Co-Authored-By: OpenAI Codex <codex@openai.com>
|
@codex review |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the @fedify/botkit-postgres package, providing a PostgreSQL-backed repository implementation for BotKit. The changes include the PostgresRepository class, schema initialization logic, and comprehensive integration tests, along with updated documentation. Feedback was provided regarding a micro-optimization in the internal execute function to avoid unnecessary array allocations by using a type assertion instead of the spread operator when passing parameters to the database driver.
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This PR adds a new PostgreSQL-backed repository package,
@fedify/botkit-postgres, for BotKit.The package introduces
PostgresRepository,PostgresRepositoryOptions, andinitializePostgresRepositorySchema(), with support for either an injected Postgres.js client or an internally managed connection pool, configurable schema names, and optional prepared statement disabling for PgBouncer-style deployments.The implementation includes integration coverage for repository persistence, follower management, schema initialization, prepared statement configuration, and concurrency-sensitive follow/unfollow flows in shared multi-worker deployments.
This PR also updates the PostgreSQL repository documentation and package metadata so the package is publishable and consumable from npm, and so its generated declaration files remain valid for stricter TypeScript consumers.
Closes #11
Testing:
POSTGRES_URL=postgresql://localhost/botkit deno test --allow-env --allow-net=localhost,127.0.0.1 packages/botkit-postgres/src/mod.test.tsPOSTGRES_URL=postgresql://localhost/botkit pnpm --filter @fedify/botkit-postgres testpnpm pack --pack-destination ../../.tmp-pack(verified the packedpackage.jsonand generateddist/mod.d.ts)