You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(learning): add PostgreSQL storage, scoring, and update contracts - #433
Hub's learning work needs a package that can keep learnings for a whole team, tell whether they help, and suggest when to change them. Today the package stores learnings only in SQLite or local files, and it can't say whether an agent's use of a learning went well. This is the first of five stacked pull requests that bring Learning v2 to Hub. It changes only the learning package, so later layers can build Hub features on a reviewed base.
What changes
The replica-learning package can now store everything in PostgreSQL as well as SQLite. It also tracks what happens after a learning is accepted:
Each learning belongs to a repository by its GitHub repository ID rather than its name, so a rename doesn't split its history. migrate-scope moves older stores, and import-sqlite copies a stopped Hub SQLite store into PostgreSQL.
Agents can report sessions and which learnings they used. The package records what it recalled for each session.
Each learning gets a score from later review evidence. When evidence starts to contradict a learning, the package suggests an update for a person to approve.
A single analyze command runs the daily loop for one checkout. It labels new comments and suggests learnings. With --commit, it also scores and proposes updates.
flowchart LR
A[Review comments and agent sessions] --> B[analyze]
B --> C[Suggested learnings]
C -->|person approves| D[Accepted learnings]
D --> E[Agents recall and report use]
E --> F[Scores]
F -->|evidence disagrees| G[Suggested updates]
G -->|person approves| D
Loading
Learning CI now starts PostgreSQL and runs the package's database tests. The removed demo and examples are replaced by the CLI and README. Local learning mode and the agent MCP server come in the next layer. Hub changes come in layers 3 to 5.
The learning package gains what Hub needs to keep and judge learnings:
- a PostgreSQL provider, scope migration to GitHub repository IDs
- contracts and store support for agent sessions, recall deliveries,
usage reports, scores, and suggested updates
- an analyze command that runs labeling, consolidation, and scoring
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved critical issues can expose withdrawn or redacted evidence, bypass screenshot path restrictions, and delete images still referenced by other repositories.
This PR establishes the learning-package foundation for Learning v2 in Hub, adding shared storage support and a feedback loop from agent usage to scores and human-approved updates.
Changes:
Extends storage contracts for PostgreSQL, repository identity, deletion, and decision consistency.
Adds agent-session evidence, usage tracking, screenshots, scoring, and update proposals.
Expands regression coverage and database CI, updates architecture guidance, and removes obsolete demos.
File
Description
packages/learning/test/updates.test.mjs
Tests update thresholds and dismissed-issue reconsideration.
Refuse hard-linked screenshots, check who sent a resent message before
its text, let a later relabel replace a no-label judgment, rank update
evidence by score time before capping it, and keep each drafting run's
proposals together with the newest score it read.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
…pies
A repository migration can keep two copies of the same Hub comment. The
recurrence consolidator now weighs a labeler's no-label judgment against
its labels across those copies, so a later reassessment that finds no
label stops an older label from proposing its theme.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Unresolved critical issues can expose score text after consent withdrawal, allow image reads outside the permitted directory, and delete screenshots still needed by another scope.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Path-based image opening allows a directory swap to bypass containment
packages/learning/src/cli.mjs:1856
The parent directory can change between the containment check and this pathname-based open; NO_FOLLOW protects only the final component. With concurrent changes to the report directory, the command can read an image outside the allowed directory and later pass it to evaluation. Use a directory-handle-based containment mechanism that remains valid through opening the file, or stage inputs in a directory the report writer cannot modify.
Repositories that share a local data directory now each leave an owner
marker beside a screenshot image, so deleting one repository keeps images
another still uses.
A kept score is returned only while its version's evidence still permits
review, matching outcomesFor, so a retried score no longer hands back
reasoning built on withdrawn evidence.
The screenshot path comment and README now say the containment checks do
not stop a process that renames folders under the report mid-command.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
Addressed the items from the latest review summary in 947e1f3:
Screenshots shared by repositories in one data directory. Each repository now leaves a small owner marker beside an image, and an image is removed only when no other repository's marker is left. A repository's old names from a migration count as its own.
Kept score text after consent is withdrawn.scoreFor, and so a retried recordScore, now returns a stored score only while its version's evidence still permits review. That is the same rule outcomesFor already used.
Folder swaps during report-usage. Node has no way to open a file relative to a held folder, so this can't be fully closed. The containment checks stop wrong or crafted paths. A process that renames folders mid-command already runs with the same access. The code comment and README now say so and ask that the report's folder be kept away from other accounts.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A critical race between put() and remove() can delete another repository’s image because deletion relies on a stale owner-marker scan without a shared cross-process per-digest lock.
Removing a screenshot now moves the image aside and checks the owner
markers again before deleting it. A save in another process writes its
marker before it looks for the image, so a save that found the image is
seen by the second check and the image is put back.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to weigh cross-cutting risks in sensitive screenshot retention, session-input handling, terminal output, and failed-reassessment accounting.
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
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's learning work needs a package that can keep learnings for a whole team, tell whether they help, and suggest when to change them. Today the package stores learnings only in SQLite or local files, and it can't say whether an agent's use of a learning went well. This is the first of five stacked pull requests that bring Learning v2 to Hub. It changes only the learning package, so later layers can build Hub features on a reviewed base.
What changes
The
replica-learningpackage can now store everything in PostgreSQL as well as SQLite. It also tracks what happens after a learning is accepted:migrate-scopemoves older stores, andimport-sqlitecopies a stopped Hub SQLite store into PostgreSQL.analyzecommand runs the daily loop for one checkout. It labels new comments and suggests learnings. With--commit, it also scores and proposes updates.Learning CI now starts PostgreSQL and runs the package's database tests. The removed demo and examples are replaced by the CLI and README. Local learning mode and the agent MCP server come in the next layer. Hub changes come in layers 3 to 5.