Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d45f51e
feat(hub): store learnings in a dedicated database scoped by reposito…
nshki Nov 28, 2026
4439c42
fix(hub): give the learning login every privilege the package needs
nshki Nov 29, 2026
c050cff
fix(hub): keep pre-upgrade review snapshots when reviews are unchanged
nshki Nov 29, 2026
7a86ebd
feat(learning): list redaction follow-ups without re-checking every r…
nshki Nov 29, 2026
46b5473
perf(hub): load learning follow-ups without a full store check
nshki Nov 29, 2026
c90d4ad
fix(hub): let the local developer administer the decision walkthrough
nshki Nov 29, 2026
4799e32
fix(infrastructure): skip the release lease when provisioning has no …
nshki Nov 29, 2026
90702fc
style(infrastructure): restore original formatting
nshki Nov 29, 2026
9d45773
style(hub): format learning database test
nshki Nov 30, 2026
3b6a5fd
refactor(hub): keep migration notice rendering in the UI layer
nshki Nov 30, 2026
27d7b2a
test(infrastructure): cover private-preview lease recovery
nshki Nov 30, 2026
d6a90c8
fix(hub): redact learning fixture credentials
nshki Nov 30, 2026
514b586
fix(learning): display migration follow-ups accurately
nshki Nov 30, 2026
741d0c2
fix(hub): parameterize learning database grants
nshki Nov 30, 2026
f3b52fd
fix(hub): isolate local repositories from GitHub sync
nshki Nov 30, 2026
b297a12
test(azure): cover learning reference limits
nshki Nov 30, 2026
896a006
fix(hub): process training withdrawals after repository access changes
nshki Nov 30, 2026
2175de3
fix(infrastructure): require durable learning storage for existing in…
nshki Nov 30, 2026
2b06803
fix(learning): expose redaction follow-ups in the public types
nshki Nov 30, 2026
f71596d
fix(learning): carry the lockfile correction into layer 3
nshki Nov 30, 2026
b56b95e
chore(learning): sync layer 3 with its reviewed parent
nshki Nov 30, 2026
a041c21
fix(hub): separate withdrawal authority from deletion input
nshki Nov 30, 2026
80a612b
fix(hub): refuse credential-bearing Learning command results
nshki Nov 30, 2026
e499cf3
chore(learning): sync reviewed fixes from the parent layer
nshki Nov 30, 2026
5f0ece0
fix(hub): wait for timed-out learning subprocesses to exit
nshki Nov 30, 2026
c330b29
chore(learning): carry worker privacy fixes through the stack
nshki Nov 30, 2026
c1939f0
fix(hub): preserve public identifiers when checking command results
nshki Nov 30, 2026
39829f8
chore(learning): sync screenshot path validation from Solo
nshki Nov 30, 2026
d779525
chore(learning): sync the Solo lint correction
nshki Nov 30, 2026
8f1f76e
chore(learning): sync validated theme hints from the parent layer
nshki Nov 30, 2026
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
5 changes: 4 additions & 1 deletion .github/workflows/hub-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ jobs:
with:
node-version: ${{ matrix.node }}
cache: npm
cache-dependency-path: hub/package-lock.json
cache-dependency-path: |
hub/package-lock.json
packages/learning/package-lock.json
- run: npm ci --engine-strict
- run: npm ci --prefix ../packages/learning --ignore-scripts --engine-strict
- run: npm run ${{ matrix.command }}
env:
TEST_DATABASE_URL: ${{ matrix.command == 'test:database' && 'postgresql://replica:replica@127.0.0.1:5432/postgres' || '' }}
Expand Down
4 changes: 4 additions & 0 deletions hub/.devcontainer/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
working_dir: /workspaces/replica/hub
volumes:
- ../..:/workspaces/replica:cached
- postgres-socket:/var/run/postgresql:ro
environment:
DATABASE_URL: postgresql://replica:replica@db:5432/replica
TEST_DATABASE_URL: postgresql://replica:replica@db:5432/postgres
Expand All @@ -26,6 +27,8 @@ services:
- "127.0.0.1:5432:5432"
volumes:
- postgres-data:/var/lib/postgresql
- postgres-socket:/var/run/postgresql
- ./learning-role.sql:/docker-entrypoint-initdb.d/learning-role.sql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U replica -d replica"]
interval: 5s
Expand All @@ -34,3 +37,4 @@ services:

volumes:
postgres-data:
postgres-socket:
1 change: 1 addition & 0 deletions hub/.devcontainer/decision-walkthrough.compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
ARTIFACT_STORAGE_PROVIDER: filesystem
ARTIFACT_STORAGE_DIRECTORY: /workspaces/replica/hub/storage/decision-walkthrough-artifacts
REPLICA_LEARNING_ROOT: /workspaces/replica/hub/storage/decision-walkthrough-learning
REPLICA_LEARNING_DATABASE_URL: ""
REPLICA_LEARNING_CLI: /workspaces/replica/packages/learning/bin/replica-learning.mjs
REPLICA_DECISION_RUNTIME_URL: http://127.0.0.1:8010
REPLICA_DECISION_RUNTIME_AUTHENTICATION: environment-token
Expand Down
2 changes: 2 additions & 0 deletions hub/.devcontainer/learning-role.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE ROLE replica_learning_runtime LOGIN NOINHERIT NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS PASSWORD 'replica-learning-dev';
GRANT CONNECT ON DATABASE replica TO replica_learning_runtime;
2 changes: 1 addition & 1 deletion hub/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ SCHEDULED_JOB_CONCURRENCY=1
# Run `npm run setup` before starting a database-backed API.
DATABASE_URL=postgresql://replica:replica@127.0.0.1:5432/replica

# Only database-enabled tests require this URL and CREATEDB permission.
# Database tests need CREATEDB; the learning grant test also needs CREATEROLE.
TEST_DATABASE_URL=postgresql://replica:replica@127.0.0.1:5432/postgres

# --- Required shared settings ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ function mockState(administerHub: boolean) {
}

describe("settingsLearnings()", () => {
it("preserves successful follow-up messages without describing them as read failures", () => {
const administrator = mockState(true)
const message = "Rebuild the learning because its review evidence was removed."
const state = { ...administrator.learnings, loadError: message }

const result = settingsLearnings(administrator.workspace, state, null)

expect(result.accessDenied).toBe(false)
if (result.accessDenied) throw new Error("The administrator must receive Learnings.")
expect(result.loadError).toBe(message)
})

it("uses repository permissions for learning actions and Hub administration for navigation", () => {
const state: LearningsResponse = {
accessDenied: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,7 @@ export function settingsLearnings(
path: `/repositories/${repositoryId}/learnings/runs`,
available: state.permissions.requestRun && state.runAvailable,
},
loadError: state.loadError
? `Hub could not read this repository's learnings: ${state.loadError}`
: null,
loadError: state.loadError,
identityNotice:
state.identityReviewCount > 0
? "Earlier suggestions or accepted learnings need identity revalidation. Hub keeps their history, but agents cannot use those versions. Find learnings again, then review any rebuilt suggestions."
Expand Down
3 changes: 1 addition & 2 deletions hub/client/pages/learnings-page/stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,7 @@ export const LoadError: Story = {
suggestions: [],
learnings: [],
recall: { text: "", count: 0 },
loadError:
"Hub could not read this repository's learnings: The learning store failed its integrity checks; run verify.",
loadError: "The learning store failed its integrity checks; run verify.",
},
},
}
17 changes: 10 additions & 7 deletions hub/docs/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ Review threads bind one non-removed repository, one reviewable prototype, and on

Decision-model tables store repository settings, pinned input digests, runtime job and candidate references, promotion generations, Build evaluation references, and decimal usage or cost metadata. They do not store credentials, screenshots, tasksets, adapters, evaluation reports, or model weights. Database checks enforce training bounds, positive promotion generations, nonnegative usage and cost, and complete quantity/unit and amount/currency pairs.

For PostgreSQL learning stores, the latest decision-review snapshot keeps its content digest, snapshot ID, and capture time per repository. It contains no review text and is removed with its repository. SQLite keeps this checkpoint in its existing store directory; see [learning storage](learning-foundation.md).

Candidate rows also store the runtime's held-out baseline and candidate metrics, per-learning metric changes, and an optional administrator rejection. Rejection fields must be absent together or include a time and reason. Build evaluation rows keep typed page-level findings in their bounded summary rather than copying screenshot bytes.

Runtime copy rows keep content-free provider references and provenance selectors. Runtime deletion rows keep selectors, pending and failure counts, safe receipt metadata, and completion times. They never store evidence bodies, screenshots, labels, prompts, adapters, or model artifacts.
Expand All @@ -104,16 +106,17 @@ Validate schema changes on both a fresh database and an upgrade from the exact b

The Azure installation separates database provisioning, migrations, and normal data access:

| Principal | Access |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Administrator | One-time database and role provisioning; never passed to Hub or its setup job. |
| `replica_migration` | Can create schemas in this database and owns `public`, `bullmq`, and their migration-created objects. Runs setup, not the long-running app. |
| `replica_runtime` | Uses both schemas, reads/writes application and queue data, uses sequences and executes queue functions. Cannot create schemas, change permanent schema objects, create roles, truncate tables, or change migration ledgers. BullMQ requires read access to its ledger and temporary-table permission for bulk jobs. |
| Principal | Access |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Administrator | One-time database and role provisioning; never passed to Hub or its setup job. |
| `replica_migration` | Can create schemas in this database and owns `public`, `bullmq`, and their migration-created objects. Runs setup, not the long-running app. |
| `replica_runtime` | Uses both schemas, reads/writes application and queue data, uses sequences and executes queue functions. Cannot create schemas, change permanent schema objects, create roles, truncate tables, or change migration ledgers. BullMQ requires read access to its ledger and temporary-table permission for bulk jobs. |
| `replica_learning_runtime` | Uses the separate learning schema for learning operations. It does not access Hub application or queue data. |

`server/scripts/provision-database-access/` creates the two login roles and schema ownership on a fresh database. It requires administrator access over the private database network and separate passwords of at least 16 characters. Existing roles, public tables, or a pre-existing BullMQ schema cause failure and rollback rather than adopting unknown permissions. Use a reviewed ownership migration for existing installations.
`server/scripts/provision-database-access/` creates the three login roles and schema ownership on a fresh database. It requires administrator access over the private database network and separate passwords of at least 16 characters. Existing roles, public tables, or a pre-existing BullMQ schema cause failure and rollback rather than adopting unknown permissions. Use a reviewed ownership migration for existing installations.

When `DATABASE_RUNTIME_ROLE=replica_runtime`, setup runs `server/scripts/grant-runtime-database-access/` after Prisma and BullMQ setup. That script initializes the two queues' lazy ID sequences before granting data access, so runtime never needs permanent schema creation rights. It refreshes grants for newly migrated tables, sequences, and functions, excludes the Prisma ledger, and permits only reading BullMQ's ledger. Product additions that need other database capabilities must explicitly update and verify this contract.

Local development keeps its existing database user and leaves `DATABASE_RUNTIME_ROLE` unset. See the [Azure installation guide](../../infrastructure/README.md) for private-network provisioning, secret references, release ordering, and recovery.
Local development keeps its existing database user and leaves `DATABASE_RUNTIME_ROLE` unset. See the [learning package guide](../../packages/learning/README.md) for learning database privileges and the [Azure installation guide](../../infrastructure/README.md) for fresh and existing-install provisioning, secret references, release ordering, and recovery.

The [database-enabled test projects](testing-and-operations.md#parallel-database-tests) use separate databases for every project, worker, and test run. Setup deploys the committed migrations and clears records before each case. Tests do not use the development database for records.
2 changes: 2 additions & 0 deletions hub/docs/decision-model-control-plane.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ Saved Build evaluations list the persisted page-level findings. Each finding nam

Training withdrawal is selector-based. Hub records the export, grant, evidence, and taskset identifiers, enumerates content-free copy references from the repository's configured runtime, requests deletion, and persists the durable receipt. Pending and completed revocations block taskset upload, training, promotion, rollback, and evaluation for matching inputs. A scheduled recovery pass polls pending receipts after restart. The overview exposes only safe selectors, state, pending and failure counts, and receipt times; PostgreSQL never stores screenshots, learning text, labels, prompts, adapters, or model bytes from the receipt flow.

When a repository's learning store cannot be read, including when its GitHub ID is missing, withdrawal discovery remains pending against its saved training jobs. The scheduled job reports failure and retries discovery, while still processing withdrawals and deletion receipts from other repositories. Operators must restore the repository's verified GitHub ID or repair its store before Hub can determine which runtime copies need deletion.

## Agent visual critic

The prototype canvas exposes `evaluate_prototype` for an authoring agent to request explicit visual feedback while iterating. The action accepts only bounded PNG captures for named routes and the supported desktop or narrow, light or dark view combinations. Agents capture those images through the isolated browser canvas or the existing Replica Build capture path. The action never sends the user's prompt, Copilot session ID, local preview origin, Hub credential, or runtime credential.
Expand Down
Loading
Loading