Skip to content

feat(hub): persist review conversations - #262

Merged
alliscode merged 9 commits into
build/hub/newfrom
alliscode-review-comments-backend
Nov 17, 2026
Merged

alliscode merged 9 commits into
build/hub/newfrom
alliscode-review-comments-backend

Conversation

@alliscode

@alliscode alliscode commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Why

The Learnings backend needs a durable, repository-scoped source of review conversations before it can import comments or run labeling and consolidation. The rebuilt Hub persisted repositories, prototypes, and Builds, but review threads still existed only in retained frontend fixtures.

What changes

Hub now stores review threads and comments against a repository, prototype branch, and successful Build. The existing review API can create roots and replies, edit or soft-delete an author's messages, and resolve or reopen threads while retaining ordered resolution history.

Soft-deleted messages keep their source text in Hub while product reads and learning snapshots omit it. The separate learning redaction workflow can therefore remove copied versions without making source soft deletion destructive. The learning backend can capture one complete repeatable-read repository snapshot through captureRepositoryReviewSnapshot() without adding another review store or starting learning jobs in this layer.

@alliscode
alliscode requested review from a team and nshki as code owners November 16, 2026 17:51
Copilot AI adaptive review requested due to automatic review settings November 16, 2026 17:51
Ben Thomas and others added 4 commits November 16, 2026 10:02
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>

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 identifier helper fails type-checking, and all six review mutations lack origin checks, allowing a same-site foreign origin to resolve threads using a signed-in member's cookie.

9 open issues
What changed in this PR

Adds durable review conversations to Hub and a repository snapshot interface for future learning imports. Review UI wiring and learning jobs remain outside this change.

Changes:

  • Persists threads, replies, soft deletion, and ordered resolution history.
  • Adds authenticated review APIs and repeatable-read repository snapshots.
  • Adds migration, domain, and API coverage, with supporting documentation.
File Description
hub/​test/​database/​review-comments-migration/​index.db.test.ts Tests upgrades and conversation persistence.
hub/​server/​routes/​index.ts Registers review endpoints.
hub/​server/​routes/​api/​review-comments/​respond-review-error/​index.ts Maps review errors to HTTP responses.
hub/​server/​routes/​api/​review-comments/​read-review-session/​index.ts Restores review request sessions.
hub/​server/​routes/​api/​review-comments/​read-review-identifiers/​index.ts Validates route identifiers.
hub/​server/​routes/​api/​review-comments/​present-review-thread-comments/​index.ts Produces flat comment responses.
hub/​server/​routes/​api/​review-comments/​index.db.test.ts Covers API access and conversation behavior.
hub/​server/​routes/​api/​repositories/​prototypes/​review-comments/​resolution/​post/​index.ts Resolves threads.
hub/​server/​routes/​api/​repositories/​prototypes/​review-comments/​resolution/​delete/​index.ts Reopens threads.
hub/​server/​routes/​api/​repositories/​prototypes/​review-comments/​replies/​post/​index.ts Creates replies.
hub/​server/​routes/​api/​repositories/​prototypes/​review-comments/​post/​index.ts Creates review threads.
hub/​server/​routes/​api/​repositories/​prototypes/​review-comments/​get/​index.ts Lists prototype conversations.
hub/​server/​routes/​api/​repositories/​prototypes/​review-comments/​comment/​patch/​index.ts Edits author-owned comments.
hub/​server/​routes/​api/​repositories/​prototypes/​review-comments/​comment/​delete/​index.ts Soft-deletes author-owned comments.
hub/​server/​routes/​api/​product/​types.ts Adds the review service dependency.
hub/​server/​routes/​api/​product/​create-product-route-dependencies/​index.ts Wires the persistent review service.
hub/​server/​repositories/​review-comments/​types.ts Defines stored thread projections and results.
hub/​server/​repositories/​review-comments/​create-review-comment-repository/​index.ts Implements transactional reads and mutations.
hub/​server/​repositories/​review-comments/​capture-repository-review-snapshot/​index.ts Reads complete repository snapshots consistently.
hub/​server/​domains/​review-comments/​types.ts Defines review and snapshot contracts.
hub/​server/​domains/​review-comments/​serialize-review-thread/​index.ts Converts stored records into domain threads.
hub/​server/​domains/​review-comments/​review-comments.db.test.ts Covers persistence, scope, deletion, and history.
hub/​server/​domains/​review-comments/​parse-review-body/​index.ts Validates comment text.
hub/​server/​domains/​review-comments/​parse-review-anchor/​index.ts Validates element and area anchors.
hub/​server/​domains/​review-comments/​errors.ts Defines review errors.
hub/​server/​domains/​review-comments/​create-review-comment-service/​index.ts Coordinates validation, persistence, and retries.
hub/​server/​domains/​review-comments/​create-review-comment-service/​index.test.ts Covers exhausted transaction retries.
hub/​server/​domains/​review-comments/​capture-repository-review-snapshot/​index.ts Exposes snapshots for future learning imports.
hub/​schema/​user.prisma Links users to review records.
hub/​schema/​review-thread.prisma Defines scoped threads and resolution state.
hub/​schema/​review-thread-resolution-state.enum.prisma Defines resolution transition values.
hub/​schema/​review-thread-resolution-event.prisma Stores ordered resolution events.
hub/​schema/​review-comment.prisma Stores messages and deletion markers.
hub/​schema/​repository.prisma Links repositories to threads.
hub/​schema/​prototype.prisma Adds thread relations and composite scope identity.
hub/​schema/​migrations/​20261113170000_review_comment_backend/​migration.sql Creates review tables, indexes, and constraints.
hub/​schema/​build.prisma Links Builds to review threads.
hub/​docs/​review-collaboration.md Documents review behavior, APIs, and snapshots.
hub/​docs/​README.md Links the review backend guide.
hub/​docs/​learning-foundation.md Documents the available snapshot integration point.
hub/​docs/​frontend.md Clarifies API availability and deferred UI wiring.
hub/​docs/​database.md Documents review persistence invariants.
hub/​docs/​architecture.md Updates backend capabilities and remaining work.

Review effort: Max (dynamic)

Comment thread hub/server/routes/index.ts Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@alliscode
alliscode force-pushed the alliscode-review-comments-backend branch from d04b353 to f543e4f Compare November 16, 2026 18:21
Ben Thomas and others added 3 commits November 16, 2026 10:34
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 added this pull request to stack #264 November 16, 2026 21:45

@nshki nshki 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.

Thanks @alliscode. One minor logic change request. When comments are soft-deleted, it would be great to only set deletedAt instead of also clearing body. That way we're not losing data when something is marked as soft-deleted, and relevant queries for the data shouldn't include soft-deleted records.

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

Copy link
Copy Markdown
Contributor Author

@nshki Thanks — I made that distinction explicit. Soft deletion now sets deletedAt without clearing the stored Hub body or edit timestamp. Product API responses and learning snapshots mask deleted bodies as null, so ordinary readers and the importer do not receive the source text, while the separate learning redaction workflow still removes any copies already stored in the learning provider. I added persistence, API, snapshot/privacy, migration, and learning redaction coverage.

@alliscode
alliscode merged commit 56ab5aa into build/hub/new Nov 17, 2026
49 checks passed
@alliscode
alliscode deleted the alliscode-review-comments-backend branch November 17, 2026 00:55
alliscode added a commit that referenced this pull request Nov 17, 2026
<!-- 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. -->

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

<!-- 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. -->

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.

---------

Co-authored-by: Ben Thomas <bentho@Bens-MacBook-Pro.local>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

3 participants