Skip to content

feat(learning): add PostgreSQL memory provider - #377

Draft
nshki wants to merge 4 commits into
nshki/feat/learning/github-repository-identityfrom
nshki/feat/learning/postgres-provider
Draft

nshki wants to merge 4 commits into
nshki/feat/learning/github-repository-identityfrom
nshki/feat/learning/postgres-provider

Conversation

@nshki

@nshki nshki commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Why

Shared installations need to store learnings in PostgreSQL without giving the running application permission to change the database schema.

What changes

The learning package can use PostgreSQL as a memory provider. It keeps records in its own schema, locks writes by repository, and checks learning versions before updating them. SQLite remains the default.

An operator runs replica-learning migrate with a separate migration connection before using the runtime connection. The guide explains the required permissions and how PostgreSQL backups and old row versions affect deletion.

Storybook screenshots

Not applicable; this does not change story presentation.

@nshki
nshki added this pull request to stack #367 November 25, 2026 17:37
@nshki
nshki requested an adaptive review from Copilot November 25, 2026 17:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved critical defects can terminate the host on database connection failures, persist stale data during concurrent imports, and expose sensitive records through unencrypted remote connections.

9 open issues
1 file not reviewed
  • packages/learning/package-lock.json: Generated file
What changed in this PR

Adds PostgreSQL storage to the learning package for shared installations, while keeping schema migrations separate from runtime access. SQLite remains the default.

Changes:

  • Adds a PostgreSQL provider with scoped write locks, memory-version checks, and redaction.
  • Adds a privileged migration command and environment-based connection configuration.
  • Adds database tests, CI support, and operator guidance for permissions and deletion retention.
File Description
packages/​learning/​test-database/​postgres.test.mjs Adds conformance, migration, permissions, connection, concurrency, and index tests.
packages/​learning/​src/​providers/​postgres.mjs Implements PostgreSQL storage and redaction.
packages/​learning/​src/​providers/​postgres-database.mjs Adds migrations, schema checks, pooling, and sanitized errors.
packages/​learning/​src/​errors.mjs Broadens the commit-outcome documentation beyond disk failures; no behavior change.
packages/​learning/​src/​config.mjs Supports selecting PostgreSQL with an environment-supplied runtime URL.
packages/​learning/​src/​cli.mjs Adds the separate migrate command.
packages/​learning/​README.md Documents PostgreSQL setup, permissions, testing, and retention.
packages/​learning/​package.json Adds the optional driver and database-test command.
packages/​learning/​package-lock.json Locks the PostgreSQL driver and its dependencies.
packages/​learning/​index.mjs Exports the PostgreSQL provider.
packages/​learning/​index.d.mts Declares the provider’s TypeScript interface.
packages/​learning/​contracts/​v1/​provider-manifest.schema.json Expands accepted destination formats, including bracketed IPv6 addresses.
docs/​adr/​0001-learning-extension-architecture.md Records PostgreSQL as a built-in shared-storage option.
.github/​workflows/​learning-ci.yml Adds a PostgreSQL service and runs database tests.

Review effort: Max (adaptive)

Comment thread packages/learning/README.md Resolved
Comment thread packages/learning/src/config.mjs Resolved
nshki and others added 4 commits November 25, 2026 10:48
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 836fcecf-e7a9-4975-acd2-bf761098f711
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 836fcecf-e7a9-4975-acd2-bf761098f711
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 836fcecf-e7a9-4975-acd2-bf761098f711
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 836fcecf-e7a9-4975-acd2-bf761098f711
@nshki
nshki force-pushed the nshki/feat/learning/postgres-provider branch from 6aaff57 to af09950 Compare November 25, 2026 19:16
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.

2 participants