Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical migration and PostgreSQL integration defects can modify retained SQLite data, bypass import safeguards, and break provisioning, existing tests, and learning workflows.
9 open issues
PostgreSQL export writes stabilization files to a missing legacy directory · New PostgreSQL selection discards operator learning configuration · New Image smoke check omits the required learning password · New Retry fixture omits the required learning-password reference · New Missing SQLite databases are mistaken for empty histories · New Import mutates the SQLite source before destination verification · New PostgreSQL is enabled before operators can import SQLite histories · New Docker database URLs lack a supported TLS transport · New Unmapped legacy scopes wrongly fail redaction · New
What changed in this PR
Adds PostgreSQL-backed learning storage so Hub processes can share durable history, alongside an offline SQLite import path and separate learning database credentials.
Changes:
- Routes Hub learning and decision-model commands through private PostgreSQL configuration.
- Adds SQLite history import, migration mappings, import receipts, and database regression coverage.
- Extends Azure provisioning, local development setup, and operator cutover documentation.
| File | Description |
|---|---|
packages/learning/test-database/postgres.test.mjs |
Covers imports, upgrades, rollback, and concurrency. |
packages/learning/test-database/postgres-v1.sql |
Pins the original schema for upgrade checks. |
packages/learning/src/providers/sqlite.mjs |
Validates stored rows and inventories scopes. |
packages/learning/src/providers/postgres.mjs |
Adds mappings, imports, and write guards. |
packages/learning/src/providers/postgres-database.mjs |
Adds mapping and import-receipt tables. |
packages/learning/src/config.mjs |
Adds import orchestration and storage guards. |
packages/learning/src/cli.mjs |
Exposes the offline import command. |
packages/learning/README.md |
Documents privileges and SQLite import. |
infrastructure/README.md |
Documents provisioning and operator cutover. |
infrastructure/azure/variables.tf |
Validates separate learning secret references. |
infrastructure/azure/tests/deployment.tftest.hcl |
Checks learning credentials and setup wiring. |
infrastructure/azure/setup.tf |
Supplies learning migration and grant settings. |
infrastructure/azure/roles.tf |
Grants access to the learning secret. |
infrastructure/azure/provision/tests/provision.tftest.hcl |
Covers fresh and learning-only provisioning. |
infrastructure/azure/provision/main.tf |
Supports both provisioning modes. |
infrastructure/azure/post/types.ts |
Types the optional learning secret. |
infrastructure/azure/post/index.ts |
Includes learning references in deployment checks. |
infrastructure/azure/post/index.test.ts |
Covers preservation of learning configuration. |
infrastructure/azure/post/configure/index.ts |
Adjusts the available secret-reference limit. |
infrastructure/azure/installation.tfvars.example |
Shows optional learning database configuration. |
infrastructure/azure/install/secrets/index.ts |
Creates learning secrets and provisioning markers. |
infrastructure/azure/install/provision/index.ts |
Orchestrates learning-role provisioning and cleanup. |
infrastructure/azure/install/inputs/index.ts |
Validates saved learning settings. |
infrastructure/azure/install/index.ts |
Selects learning storage during installation. |
infrastructure/azure/install/index.test.ts |
Covers provisioning, recovery, and backend selection. |
infrastructure/azure/application.tf |
Passes the runtime learning secret reference. |
hub/test/fixtures/learning/report-runtime.mjs |
Reports subprocess configuration and failure cleanup. |
hub/server/utils/parse-azure-secret-configuration/types.ts |
Adds the learning-only provisioning mode. |
hub/server/utils/parse-azure-secret-configuration/index.ts |
Validates learning-related startup references. |
hub/server/utils/parse-azure-secret-configuration/index.test.ts |
Covers the new reference contracts. |
hub/server/scripts/setup/index.ts |
Runs learning migrations and runtime grants. |
hub/server/scripts/setup/index.test.ts |
Checks learning setup under the lock. |
hub/server/scripts/provision-learning-database-access/index.ts |
Creates the learning login for existing installations. |
hub/server/scripts/provision-database-access/index.ts |
Creates the learning login during fresh provisioning. |
hub/server/scripts/grant-learning-database-access/index.ts |
Grants learning-schema runtime privileges. |
hub/server/scripts/azure-entrypoint/run/index.ts |
Dispatches learning-only provisioning. |
hub/server/scripts/azure-entrypoint/run/index.test.ts |
Checks provisioning inputs and workload isolation. |
hub/server/integrations/learning/run-learning-command/index.ts |
Supplies private PostgreSQL configuration and credentials. |
hub/server/integrations/learning/run-learning-command/index.test.ts |
Covers credential isolation, guards, and cleanup. |
hub/server/index.ts |
Passes learning storage into decision-model composition. |
hub/server/domains/learning/redact-legacy-review-comment/index.ts |
Forwards PostgreSQL credentials for legacy redaction. |
hub/server/domains/learning/read-learning-configuration/index.ts |
Reads the optional learning database URL. |
hub/server/domains/learning/process-review-comment-redaction/index.ts |
Enables redaction without local PostgreSQL configuration files. |
hub/server/domains/learning/process-review-comment-redaction/index.test.ts |
Covers database-backed legacy redaction dispatch. |
hub/server/domains/learning/prepare-learning-store/index.ts |
Skips local store creation for PostgreSQL. |
hub/server/domains/learning/prepare-learning-store/index.test.ts |
Checks preparation without local directories. |
hub/server/domains/learning/get-learning-overview/index.ts |
Reads PostgreSQL learnings without local configuration. |
hub/server/domains/learning/get-learning-overview/index.test.ts |
Covers database overview reads and missing SQLite stores. |
hub/server/domains/learning/execute-learning-decision/index.ts |
Sends decisions to the selected database. |
hub/server/domains/learning/execute-learning-decision/index.test.ts |
Covers decisions without local store creation. |
hub/server/domains/learning/create-learning-job-processors/index.ts |
Threads database configuration through learning workers. |
hub/server/domains/learning/create-learning-job-processors/index.test.ts |
Checks database-backed worker redaction. |
hub/server/domains/decision-model/create-hub-decision-taskset-source/index.ts |
Uses configured learning storage for taskset operations. |
hub/server/domains/decision-model/create-hub-decision-taskset-source/index.test.ts |
Checks database-backed training consent reads. |
hub/server/domains/decision-model/create-configured-decision-model-job-processors/index.ts |
Passes learning storage into decision-model workers. |
hub/docs/learning-foundation.md |
Explains storage selection and migration safeguards. |
hub/docs/development.md |
Documents local learning-role setup. |
hub/docs/deployment.md |
Documents learning credentials and setup lifecycle. |
hub/docs/database.md |
Describes the separate learning runtime role. |
hub/.devcontainer/learning-role.sql |
Creates the local learning login. |
hub/.devcontainer/decision-walkthrough.compose.yaml |
Keeps walkthrough learning storage on SQLite. |
hub/.devcontainer/compose.yaml |
Configures local learning database credentials and initialization. |
Review effort: Max (adaptive)
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
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
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
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
force-pushed
the
nshki/feat/hub/learning-postgres
branch
from
November 25, 2026 21:09
c5ed62f to
311bdbc
Compare
weastler
approved these changes
Nov 25, 2026
Write PostgreSQL checkpoints on the advisory-lock connection and migrate them after the existing Hub schema. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 50605b0b-6b69-4743-b6d9-6918b6c9878a
Hub database tests run the learning command and need its optional PostgreSQL driver. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 50605b0b-6b69-4743-b6d9-6918b6c9878a
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 50605b0b-6b69-4743-b6d9-6918b6c9878a
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 50605b0b-6b69-4743-b6d9-6918b6c9878a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Why
Hub needs durable learning storage that can be shared across its processes. Existing SQLite installations should keep their history and remain usable until an operator chooses to move it.
What changes
When a learning database URL is configured, Hub passes it privately to the learning command and uses a separate PostgreSQL login. An offline import copies existing SQLite history and its migration mappings without changing the source. It refuses to overwrite an occupied destination or hide a known unimported store.
The draft proposes storing the review snapshot checkpoint in Hub's database when PostgreSQL is selected. Hub writes it using the same connection that holds the execution lock. SQLite continues to use its existing checkpoint file. Switching back from PostgreSQL needs a separate verified migration.
New Azure installations provision the learning login and secret. Existing installations remain on SQLite until an operator provisions the login and performs the documented cutover. The wizard changes are in a separate commit for @weastler.
The Azure installation has not been exercised in a deployment.
Storybook screenshots
No Hub or canvas presentation changes.