Repository navigation
feat(hub): persist review conversations - #262
Conversation
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>
There was a problem hiding this comment.
🟡 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
Infer requested property names in the return type · New Require origin checks for review mutations · New Validate anchors against PostgreSQL's JSONB size representation · New Reject NUL characters in review text and anchors · New Recheck repository state after the read transaction · New Cap build numbers at the PostgreSQL integer limit · New Reject IDs above the PostgreSQL integer limit · New Return review errors in the expected response shape · New Move review decisions from the repository into the domain · New
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)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
d04b353 to
f543e4f
Compare
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>
nshki
left a comment
There was a problem hiding this comment.
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>
|
@nshki Thanks — I made that distinction explicit. Soft deletion now sets |
<!-- 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>



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.