Skip to content

feat(hub): run repository learning loop - #263

Merged
alliscode merged 5 commits into
build/hub/newfrom
alliscode-learnings-backend-apis
Nov 17, 2026
Merged

alliscode merged 5 commits into
build/hub/newfrom
alliscode-learnings-backend-apis

Conversation

@alliscode

Copy link
Copy Markdown
Contributor

Why

Hub can now store repository review conversations, but the Learnings page still needs a backend that turns that evidence into guidance people can review and agents can recall. This upper layer builds on #262 so repository administrators can run that loop without copying comments or prompts between systems.

What changes

The repository Learnings APIs now return exact review evidence, accepted guidance, recall previews, recent runs, and Copilot usage. Administrators can accept, edit, reject, or retire suggestions against the version they reviewed.

An explicit run captures one complete repository review snapshot, imports it into the private learning store, labels bounded batches with Copilot, and consolidates recurring feedback into suggestions. Hub persists progress, usage, and visible failures, and workers recover queued or interrupted work without duplicating active jobs.

Deleting a review comment is serialized with learning mutations. Hub queues durable redaction work, recovers missed jobs, and imports later snapshots with deletion redaction so removed comment text cannot remain eligible evidence.

@alliscode
alliscode requested review from a team and nshki as code owners November 16, 2026 18:01
Copilot AI adaptive review requested due to automatic review settings November 16, 2026 18:01

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

Storage permission or I/O errors can permanently mark comments as redacted without removing their learning-store text, leaving deleted evidence usable indefinitely.

19 open issues
What changed in this PR

Connects Hub’s persisted review conversations to the learning package so administrators can run discovery, review evidence, and approve guidance for agent recall.

Changes:

  • Adds Learnings overview, run, and decision APIs with administrator checks and security audits.
  • Adds persisted runs, worker recovery, usage tracking, and deleted-comment redaction.
  • Extends learning contracts for Hub UUID identities and resolution history.
File Description
packages/​learning/​test/​hub-source.test.mjs Covers UUID identities and resolution history.
packages/​learning/​src/​sources/​hub-review-comments.mjs Imports Hub UUIDs and resolution transitions.
packages/​learning/​README.md Documents stable Hub identities.
packages/​learning/​contracts/​v1/​common.schema.json Allows UUID source identifiers.
hub/​test/​fixtures/​learning/​fail-with-json.mjs Supplies failed-command progress output.
hub/​server/​workers/​configuration.ts Registers learning processors and recovery.
hub/​server/​workers/​configuration.test.ts Checks processor and schedule registration.
hub/​server/​start-server-processes/​index.ts Accepts Learnings dependencies.
hub/​server/​run-api/​index.ts Passes Learnings dependencies into the app.
hub/​server/​routes/​types.ts Adds Learnings route dependencies.
hub/​server/​routes/​index.ts Registers Learnings endpoints.
hub/​server/​routes/​api/​security-audits/​present-security-audit/​index.ts Presents learning audit records.
hub/​server/​routes/​api/​security-audits/​present-security-audit/​index.test.ts Covers learning audit presentation.
hub/​server/​routes/​api/​product/​create-product-route-dependencies/​index.ts Connects deletion locks and redaction callbacks.
hub/​server/​routes/​api/​learnings/​types.ts Defines API records and dependencies.
hub/​server/​routes/​api/​learnings/​runs/​post/​index.ts Authorizes explicit run requests.
hub/​server/​routes/​api/​learnings/​respond-learning-error/​index.ts Maps learning failures to HTTP responses.
hub/​server/​routes/​api/​learnings/​read-learning-session/​index.ts Restores the current learning-session user.
hub/​server/​routes/​api/​learnings/​index.test.ts Covers overview, run, and decision routes.
hub/​server/​routes/​api/​learnings/​get/​index.ts Returns the administrator overview.
hub/​server/​routes/​api/​learnings/​errors.ts Defines route-level learning errors.
hub/​server/​routes/​api/​learnings/​decision/​post/​index.ts Validates and authorizes learning decisions.
hub/​server/​routes/​api/​learnings/​create-learnings-route-dependencies/​index.ts Composes storage, queues, authorization, and audits.
hub/​server/​repositories/​security-audits/​parse-security-audit-event/​types.ts Includes learning audit event types.
hub/​server/​repositories/​security-audits/​parse-security-audit-event/​index.ts Validates learning audit events.
hub/​server/​repositories/​security-audits/​parse-security-audit-event/​index.test.ts Covers learning audit validation.
hub/​server/​repositories/​security-audits/​get-security-audit-data/​index.ts Maps learning events to stored audits.
hub/​server/​repositories/​security-audits/​create-security-audit/​types.ts Defines decision and run audits.
hub/​server/​repositories/​review-comments/​mark-review-comment-learning-redacted/​index.ts Records completed comment redaction.
hub/​server/​repositories/​review-comments/​list-deleted-review-comments/​index.ts Finds pending comment redactions.
hub/​server/​repositories/​review-comments/​create-review-comment-repository/​index.ts Persists durable redaction markers on deletion.
hub/​server/​repositories/​learning-runs/​update-learning-run-progress/​index.ts Saves labeling progress and usage.
hub/​server/​repositories/​learning-runs/​list-queued-learning-runs/​index.ts Finds unfinished runs for recovery.
hub/​server/​repositories/​learning-runs/​list-learning-runs/​index.ts Returns recent runs and usage totals.
hub/​server/​repositories/​learning-runs/​list-learning-runs/​index.db.test.ts Covers history, usage, and active-run uniqueness.
hub/​server/​repositories/​learning-runs/​get-learning-run/​index.ts Loads run context and requester identity.
hub/​server/​repositories/​learning-runs/​finish-learning-run/​index.ts Persists terminal run results.
hub/​server/​repositories/​learning-runs/​create-learning-run/​index.ts Creates or attempts to reuse active runs.
hub/​server/​repositories/​learning-runs/​claim-learning-run/​index.ts Atomically claims queued runs.
hub/​server/​repositories/​learning-runs/​claim-learning-run/​index.test.ts Covers run-claim outcomes.
hub/​server/​integrations/​learning/​run-learning-command/​index.ts Preserves JSON results from failed commands.
hub/​server/​integrations/​learning/​run-learning-command/​index.test.ts Covers failed-command progress preservation.
hub/​server/​integrations/​learning/​run-learning-command/​errors.ts Carries partial command results.
hub/​server/​integrations/​bullmq/​enqueue-recoverable-job/​index.ts Re-enqueues retained terminal jobs.
hub/​server/​integrations/​bullmq/​enqueue-recoverable-job/​index.test.ts Covers recoverable job deduplication.
hub/​server/​index.ts Wires Learnings into runtime composition.
hub/​server/​index.test.ts Covers Learnings runtime wiring.
hub/​server/​domains/​review-comments/​review-comments.db.test.ts Checks redaction markers and stable actors.
hub/​server/​domains/​review-comments/​create-review-comment-service/​index.ts Adds deletion locking and callbacks.
hub/​server/​domains/​learning/​review-comment-learning-source/​types.ts Defines snapshot and evidence-source contracts.
hub/​server/​domains/​learning/​process-review-comment-redaction/​index.ts Runs locked package redaction.
hub/​server/​domains/​learning/​process-review-comment-redaction/​index.test.ts Covers redaction processing.
hub/​server/​domains/​learning/​process-learning-run/​index.ts Orchestrates import, labeling, and consolidation.
hub/​server/​domains/​learning/​process-learning-run/​index.test.ts Covers processing, recovery, and failure progress.
hub/​server/​domains/​learning/​jobs/​redact-review-comment.ts Defines redaction jobs and retries.
hub/​server/​domains/​learning/​jobs/​recover-learning-runs.ts Defines the recovery sweep job.
hub/​server/​domains/​learning/​jobs/​learning-run.ts Defines explicit run jobs and retries.
hub/​server/​domains/​learning/​get-learning-overview/​index.ts Builds suggestions, accepted guidance, and recall previews.
hub/​server/​domains/​learning/​get-learning-overview/​index.test.ts Covers exact evidence resolution.
hub/​server/​domains/​learning/​execute-learning-decision/​index.ts Invokes package decision commands.
hub/​server/​domains/​learning/​create-review-comment-learning-source/​index.ts Captures snapshots and resolves evidence.
hub/​server/​domains/​learning/​create-review-comment-learning-source/​index.test.ts Covers evidence-source matching.
hub/​server/​domains/​learning/​create-learning-job-processors/​index.ts Composes run, recovery, and redaction processors.
hub/​server/​domains/​learning/​create-hub-review-collection/​index.ts Converts snapshots into import collections and digests.
hub/​server/​domains/​learning/​create-hub-review-collection/​index.test.ts Covers collection conversion and digest stability.
hub/​server/​create-app/​index.ts Wires routes and endpoint-specific JSON parsing.
hub/​schema/​user.prisma Relates users to requested runs.
hub/​schema/​review-comment.prisma Adds durable redaction bookkeeping.
hub/​schema/​repository.prisma Relates repositories to learning runs.
hub/​schema/​migrations/​20261113190000_learning_run_foundation/​migration.sql Creates run storage, constraints, and redaction fields.
hub/​schema/​membership.prisma Relates memberships to requested runs.
hub/​schema/​learning-run.prisma Models run state, progress, and usage.
hub/​schema/​learning-run-state.enum.prisma Defines persisted run states.
hub/​docs/​learning-foundation.md Documents learning APIs and processing flows.
hub/​docs/​frontend.md Updates Learnings backend integration status.
hub/​docs/​background-jobs.md Documents learning processors and recovery.
hub/​docs/​architecture.md Updates learning integration architecture.

Review effort: Max (adaptive)

Comment thread hub/schema/learning-run.prisma Resolved
@alliscode
alliscode force-pushed the alliscode-learnings-backend-apis branch from 6592467 to e2b3796 Compare November 16, 2026 21:38
@alliscode
alliscode added this pull request to stack #264 November 16, 2026 21:45
Base automatically changed from alliscode-review-comments-backend to build/hub/new November 17, 2026 00:55
@alliscode
alliscode force-pushed the alliscode-learnings-backend-apis branch from e2b3796 to 6f77176 Compare November 17, 2026 02:02
Ben Thomas and others added 5 commits November 16, 2026 18:03
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@alliscode
alliscode force-pushed the alliscode-learnings-backend-apis branch from 6f77176 to 3cabb41 Compare November 17, 2026 02:07
@alliscode
alliscode merged commit 408feb4 into build/hub/new Nov 17, 2026
64 of 65 checks passed
@alliscode
alliscode deleted the alliscode-learnings-backend-apis branch November 17, 2026 15:58
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