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 establishes the storage and package contracts that later layers build on.
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.
Applied learnings can be scored against later evidence. Repeated issues can produce suggested updates 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.
The default recurrence rules now allow one prototype and one reviewer. They also count questions, praise, and performance feedback. A checkout using a local store can suggest a learning from one thread or session. Teams can configure the thresholds.
Scoring and suggested updates send evidence to Copilot, and scoring may include screenshots. Known secret patterns are scrubbed, but other confidential Build content may remain. Administrators should consider what they permit before enabling these features.
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 Hub image smoke check is updated for the package's SDK version. The scripted demo is removed; the Agent Memory Repo consolidator and publisher remain available. Local learning mode and the agent MCP server come in the next layer. Hub changes come in layers 3 to 5.
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.
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.
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.
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.
Follow-up: repository deletion now cleans up screenshot files left by failed reports or interrupted removal. Same-scope reports and deletions take a lock, and shared or still-referenced legacy images are retained. The change includes regression coverage for failures, recovery, migration, and concurrent deletion.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The ignore-rule check accepts tracked store files, allowing private review evidence to be written into files that subsequent commits and pushes can expose.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved critical issues can allow evidence transmission and screenshot-report success after consent ends, while named-pipe screenshots can block reporting indefinitely.
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
Keep score ordering stable when review permission changes and serialize dismissal with score writes. Restore the reusable memory repository example while retaining removal of its scripted demo.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
…named pipes
Local usage reports could send screenshots to Copilot without a consent grant, and a named pipe given as a screenshot made the command wait forever.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
Drafting an update now confirms evaluation consent and the learning's current version right before evidence is sent to Copilot.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
Migrating a repository failed when one of its learnings had been deleted, and a usage report resent after migration was stored twice.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
An edited message without its own time was dated when it was resent instead of when it was first sent.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
…cores
Review comments, reports and Build diffs reach Copilot as evidence. Scoring and
labeling now fence that evidence the way update drafting already does, escaping
"<" so the text cannot close the fence and pose as instructions. Comments that try
to give the labeler orders are replaced with a fixed note before Copilot reads them.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
…valuator
Scoring now checks that each screenshot is a PNG within the size limit and
matches its recorded digest before attaching it. A host that returns the wrong
file for a digest can no longer send it to Copilot.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
Keep one deterministic event ID when multiple agents label copies of the same comment. Reversing the input now leaves both the proposal and its reviewed evidence unchanged.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
…434)
<!-- Use a conventional commit-style title, such as "fix(hub): retain
prototype history". -->
## Why
<!-- Explain the problem and why this change matters in a short,
plain-English paragraph. Link the issue when applicable. -->
People prototyping alone need a way to turn their feedback into
learnings without deploying Hub. This second of five stacked pull
requests builds on the storage and scoring in #433.
## What changes
<!-- Describe what becomes different for a first-time reader. Explain
necessary terms. Include accurate Mermaid diagrams when they clarify the
proposal, using before/after diagrams when helpful. Add screenshots for
meaningful UI changes. -->
<!-- Omit validation sections, checklists, and routine test/CI summaries
such as "CI is green" or "tests passed". Mention only known verification
gaps that affect the change, not disclaimers about drafting this
description. -->
<!-- For UI changes, prune obsolete and duplicate stories in the
affected catalogues as part of the change. Explain removed UI or
consolidated coverage where needed; see
hub/docs/storybook.md#ui-changes-and-pull-request-evidence. -->
`replica-learning setup` prepares local learning in a prototype checkout
and writes a private MCP configuration. After restarting Copilot CLI
with that configuration, an agent can get accepted guidance, submit
conversations, and report which learnings it used. A person decides
whether to share chats and whether to accept suggestions. Clients with
form support show decisions in forms; other clients provide commands for
the person to run.
Saved feedback is analyzed in the background. The canvas also passes
completed Pick & Polish notes and confirmed replies to the learning
server. The starter ignores `.replica/`, and the setup and canvas guides
explain how to try the flow.
This layer now sits on the latest storage layer. That layer saves an
applied update and its decision together, so the earlier recovery step
for half-finished applies is gone.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
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 establishes the storage and package contracts that later layers build on.
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.The default recurrence rules now allow one prototype and one reviewer. They also count questions, praise, and performance feedback. A checkout using a local store can suggest a learning from one thread or session. Teams can configure the thresholds.
Scoring and suggested updates send evidence to Copilot, and scoring may include screenshots. Known secret patterns are scrubbed, but other confidential Build content may remain. Administrators should consider what they permit before enabling these features.
Learning CI now starts PostgreSQL and runs the package's database tests. The Hub image smoke check is updated for the package's SDK version. The scripted demo is removed; the Agent Memory Repo consolidator and publisher remain available. Local learning mode and the agent MCP server come in the next layer. Hub changes come in layers 3 to 5.