Skip to content

feat(learning): add local learning mode with an MCP server and setup - #434

Draft
nshki wants to merge 28 commits into
nshki/feat/learning/01-storagefrom
nshki/feat/learning/02-local-mode
Draft

nshki wants to merge 28 commits into
nshki/feat/learning/01-storagefrom
nshki/feat/learning/02-local-mode

Conversation

@nshki

@nshki nshki commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Why

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

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.

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

Critical consent and privacy gaps allow screenshot sharing without an active grant, expose internal review details, and leave chat data at risk of being committed to Git.

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

Builds on #433’s storage and scoring foundation to let prototype users collect feedback and approve learnings locally, without Hub. Shared MCP tools prepare the same flow for future Hub integration.

Changes:

  • Add checkout setup, a private MCP configuration, and .replica/ ignore rules.
  • Provide guidance, session submission, usage reporting, human review forms, and background analysis.
  • Connect Pick & Polish notes, document onboarding, and add CLI coverage and public MCP types.
File Description
starter/​.gitignore Ignore local learning data and configuration.
README.md Introduce local learning and its privacy model.
packages/​learning/​test/​cli.test.mjs Cover MCP tools, forms, setup, activity, and background analysis.
packages/​learning/​src/​setup.mjs Prepare local storage and write the private MCP configuration.
packages/​learning/​src/​mcp.mjs Define shared learning tools, schemas, and agent instructions.
packages/​learning/​src/​local-learning.mjs Add background execution, logs, consent, and review forms.
packages/​learning/​src/​cli.mjs Integrate setup, MCP serving, and analysis activity recording.
packages/​learning/​README.md Document local setup, tools, consent, and review.
packages/​learning/​package.json Export the MCP module and declare optional dependencies.
packages/​learning/​package-lock.json Lock the MCP SDK and supporting dependencies.
packages/​learning/​mcp.d.mts Define the public MCP backend and screenshot types.
docs/​README.md Link the learning guide from the documentation index.
docs/​prototype-repository-setup.md Add local learning as an optional onboarding step.
.github/​extensions/​replica-prototype/​skills/​replica-pick-and-polish/​SKILL.md Forward captured notes to a connected learning server.
.github/​extensions/​replica-prototype/​README.md Explain learning without Hub and link setup instructions.

Review effort: Max (adaptive)

Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/setup.mjs Resolved
Comment thread packages/learning/src/setup.mjs Resolved
Comment thread packages/learning/README.md Resolved
Comment thread packages/learning/src/setup.mjs Resolved

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 issues can overwrite linked files, write private chats into tracked stores, and leave learning updates partially applied without a reliable retry path.

9 open issues
5 previously missed issues

In code that hasn't changed since last review

Medium severity Accept underscores in imported session author logins

packages/​learning/​src/​cli.mjs:2158

A Pick & Polish note with a managed-user login such as jdoe_acme rejects the entire session, including its chat messages. The canvas accepts underscores, but sources/agent-sessions.mjs:19,184–187 still rejects them for original-note and reply authors. Align the importer with the supported login syntax and cover both author positions.

Medium severity Show grant IDs and runnable withdrawal commands

packages/​learning/​src/​local-learning.mjs:120

The consent form's stop command is not runnable after the documented setup: the CLI is not installed on PATH, and withdrawal requires a grant ID, purposes, and --by. The form also never gives the person the newly created chat or optional screenshot grant IDs. Provide store-specific commands to list those grants and withdraw their permitted purposes.

Medium severity Show proposal context and evidence lookup before approval

packages/​learning/​src/​local-learning.mjs:177

The form asks a person to approve guidance without showing its support, disagreement, rationale, or evidence references. It does not include the proposal ID either, so the person cannot look up that context from the form. Include the relevant review context and an evidence lookup path before confirmation, as show does in cli.mjs:1193–1225.

Medium severity Do not accept original wording when supplied edits are blank

packages/​learning/​src/​local-learning.mjs:290

Clearing the Wording field to an empty or whitespace-only string drops the edit and accepts the original wording instead. The recorded acceptance therefore differs from the text the person confirmed. Leave the suggestion undecided or ask again when explicitly supplied wording is blank.

Medium severity Validate that screenshots specify exactly one source

packages/​learning/​src/​mcp.mjs:60

This schema accepts screenshots with neither source or with both file and data, although McpScreenshot promises exactly one. A host backend therefore receives input that violates its declared type. Validate the exclusive choice in the shared schema before calling the backend.

16 resolved since last review
1 file not reviewed
  • packages/learning/package-lock.json: Generated file

Review effort: Max (adaptive)

Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/setup.mjs Resolved
Comment thread packages/learning/src/setup.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/mcp.mjs Resolved

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

Critical consent and data-integrity flaws can send commit diffs without permission, store conversations remotely despite local-only assurances, and lose messages during concurrent submissions.

15 open issues
10 resolved since last review
1 file not reviewed
  • packages/learning/package-lock.json: Generated file

Review effort: Max (adaptive)

Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/mcp.mjs Resolved
Comment thread packages/learning/test/cli.test.mjs Resolved
@nshki

nshki commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review

Copilot AI commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

@copilot review

Finding — medium: Run bounded-analysis follow-ups without relying on the MCP server. The detached launcher only relays the analysis exit code (packages/learning/src/local-learning.mjs:24-29), while follow-up runs start in the MCP server’s child-close handler (packages/learning/src/cli.mjs:2232-2250). If Copilot closes the server while a run has more work, the detached run survives and exits with the “more work” code, but no process starts the next batch; remaining feedback waits for another tool call or a manual run. Keep continuation in the detached worker or a persistent queue.

Verification: I found no failed Actions runs on either stacked branch; the latest Learning CI run is still in progress. My focused local run could not complete because @modelcontextprotocol/sdk is not installed.

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

Critical flaws can bypass withdrawn consent and grant restrictions, reuse stale repository scopes, and expose unmarked untrusted content to the agent.

13 open issues
15 resolved since last review
1 file not reviewed
  • packages/learning/package-lock.json: Generated file

Review effort: Max (adaptive)

Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/mcp.mjs Resolved
Comment thread packages/learning/src/mcp.mjs Resolved
Comment thread packages/learning/src/store.mjs Resolved
Comment thread packages/learning/src/store.mjs Resolved
@nshki
nshki force-pushed the nshki/feat/learning/02-local-mode branch from 9a66024 to 0b8e4a0 Compare November 28, 2026 16:18
@nshki
nshki requested an adaptive review from Copilot November 28, 2026 16:20

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

The origin check accepts a different host with the same repository path, causing the server to reuse the previous GitHub scope and consent grants for guidance and chat storage.

8 open issues
13 resolved since last review
1 file not reviewed
  • packages/learning/package-lock.json: Generated file

Review effort: Max (adaptive)

Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/mcp.mjs Resolved

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

Critical grant-handling defects can expose proposals outside the selected allowlist and suppress fresh consent when existing grants do not cover the submitted evidence.

12 open issues
8 resolved since last review
1 file not reviewed
  • packages/learning/package-lock.json: Generated file

Review effort: Max (adaptive)

Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/updates.mjs Resolved
@nshki
nshki requested an adaptive review from Copilot November 29, 2026 01:20
Comment thread packages/learning/src/cli.mjs Resolved

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.

Comment thread packages/learning/src/cli.mjs Resolved
Comment thread packages/learning/src/store.mjs Resolved
Comment thread packages/learning/src/cli.mjs Resolved
@nshki
nshki force-pushed the nshki/feat/learning/02-local-mode branch from d128501 to 0b0c118 Compare November 30, 2026 08:52
@nshki
nshki requested an adaptive review from Copilot November 30, 2026 08:52

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.

Comment thread packages/learning/src/labeling.mjs Resolved
Comment thread packages/learning/src/mcp.mjs Resolved
Comment thread packages/learning/src/mcp.mjs Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
@nshki

nshki commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review

Comment thread packages/learning/src/mcp.mjs Resolved

Copilot AI commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

@copilot review

Review found one issue: --max-requests can be exceeded by a single scoring operation. The cap is checked before score at packages/learning/src/cli.mjs:1829, but askBest() can send multiple requests (including a probe and fallback), and the CLI accounts for usage only after the operation. A run with a limit of 1 can therefore send more than one Copilot request. Enforce the remaining budget at each send, including fallback and failure paths.

CI note: the base branch’s latest Learning CI run passed. On this branch, Learning CI and Hub image smoke failed at npm ci with E401 (invalid registry authentication), before tests or the image build ran.

Return fixed safe summaries to agents while keeping original failures available to host diagnostics.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
@nshki

nshki commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review

Copilot AI commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

@copilot review

Findings

  • [P1] Enforce the remaining request budget at each send — packages/learning/src/cli.mjs:1839 checks the cap only before starting a score operation, then counts usage after it returns. askBest() can send multiple requests for one score, including an unbudgeted Auto probe and a fallback; a failed step is counted as only one request. A run can therefore exceed --max-requests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
@nshki

nshki commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in commit 837b53a: analysis now enforces the cap for every authorized model send, including fallback probes, and counts failed sends for both scoring and drafting. Added focused regression coverage. @copilot review

Copilot AI commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Fixed in commit 837b53a: analysis now enforces the cap for every authorized model send, including fallback probes, and counts failed sends for both scoring and drafting. Added focused regression cov...

No further findings in 837b53a. The focused evaluation, labeling, and update tests pass locally. Learning CI and Hub image smoke both stop at npm ci with E401, before their checks run, so the CLI integration path remains unverified.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352

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

The Auto probe can inherit an unintended schema and fail before the real request, while authorization failures during fallback can discard accumulated usage and underreport costs.

2 open issues
5 resolved since last review
1 file not reviewed
  • packages/learning/package-lock.json: Generated file

Review effort: Balanced (adaptive)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 459b160c-a7ab-4c14-8a06-098ca9096352

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.

🔵 Needs a closer look

Human assessment is needed to evaluate cross-cutting correctness risks in consent recovery, feedback freshness, labeling validation, and usage accounting.

No open issues 🎉

2 resolved since last review
1 file not reviewed
  • packages/learning/package-lock.json: Generated file

Review effort: Max (adaptive)

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.

4 participants