Feedback ownership, concurrency, and compensation
Domain invariants, Cosmos DB concurrency, caching, and cross-domain compensation rules for Rating API.
Purpose & Scope
This document defines the data ownership, optimistic concurrency, caching, and cross-domain compensation boundaries for Rating APIServicev1.0.0Rating APIInternal HTTP and A2A gRPC service for collecting, listing, deleting, and summarizing customer feedback for Catalog book...PublishesFeedbackCreatedIntegrationEvent, FeedbackDeletedIntegrationEventSubscribesCreateFeedback, DeleteFeedback +3APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs and Rating AgentAgentv1.0.0Rating AgentRead-only review intelligence specialist that summarizes customer feedback over A2A gRPC and map-reduce workflows while ...PublishesAnalyzeText, AnonymizeTextOwnercatalog-experience-teamDiagramRepositoryOpen docs in the ReviewsDomainv1.0.0ReviewsCaptures individual customer feedback for books, publishes rating changes for Catalog discovery, and provides privacy-sc...Ownercatalog-experience-teamDiagramOpen docs subdomain. Use it when modifying feedback mutations, Azure Cosmos DB persistence, Kafka rating events, or read-only AI summarization.
Visual Reference
The visual below illustrates how Rating APIServicev1.0.0Rating APIInternal HTTP and A2A gRPC service for collecting, listing, deleting, and summarizing customer feedback for Catalog book...PublishesFeedbackCreatedIntegrationEvent, FeedbackDeletedIntegrationEventSubscribesCreateFeedback, DeleteFeedback +3APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs persists feedback in Rating DatabaseContainerv1.0.0Rating DatabaseAuthoritative Azure Cosmos DB system of record owned by the Reviews bounded context for customer feedback documents part...Ownercatalog-experience-teamDiagramOpen docs, caches reads in Rating CacheContainerv1.0.0Rating CacheNon-authoritative FusionCache and Redis caching layer owned by the Reviews bounded context for AI-generated book feedbac...Ownercatalog-experience-teamDiagramOpen docs, exchanges rating events with Catalog APIServicev1.0.0Catalog APIInternal HTTP and gRPC service for Catalog product management, hybrid discovery, and authoritative book metadata. PublishesBookUpdatedRatingFailedIntegrationEventSubscribesCreatePublisher, UpdatePublisher +24APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs, and serves read-only summarization.
Loading graph...
Feedback Persistence, Catalog Projection, and Summarization Boundaries
Core Invariants & Design Rules
- Feedback system of record: Rating APIServicev1.0.0Rating APIInternal HTTP and A2A gRPC service for collecting, listing, deleting, and
summarizing customer feedback for Catalog book...PublishesFeedbackCreatedIntegrationEvent, FeedbackDeletedIntegrationEventSubscribesCreateFeedback, DeleteFeedback +3APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs owns individual FeedbackEntityv1.0.0FeedbackRepresents an individual customer's rating and optional written review for a Catalog book.Ownercatalog-experience-teamOpen docs documents in Rating DatabaseContainerv1.0.0Rating DatabaseAuthoritative Azure Cosmos DB system of record owned by the Reviews bounded context for customer feedback documents part...Ownercatalog-experience-teamDiagramOpen docs (Azure Cosmos DB, partitioned by
/bookId); it uses no relational database. Catalog APIServicev1.0.0Catalog APIInternal HTTP and gRPC service for Catalog product management, hybrid discovery, and authoritative book metadata. PublishesBookUpdatedRatingFailedIntegrationEventSubscribesCreatePublisher, UpdatePublisher +24APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs holds only a derivedaverage_ratingandtotal_reviewsprojection on BookEntityv1.0.0BookCanonical sellable title in the product catalog, encapsulating descriptive metadata, pricing, stock availability, taxono...Ownercatalog-experience-teamOpen docs. - Rating & PII constraints: Every feedback rating must be an integer between
0and5inclusive (enforced at both request validation and domain construction). Reviewer names are tagged as PII for automatic log redaction. - Post-commit event publication: Feedback createdEventv1.0.0Feedback createdIndicates that a customer feedback rating was created for a book. Rating API publishes this event so Catalog can update ...Ownercatalog-experience-teamSchemaDiagramOpen docs and Feedback deletedEventv1.0.0Feedback deletedIndicates that a customer feedback rating was deleted for a book. Rating API publishes this event so Catalog can remove ...Ownercatalog-experience-teamSchemaDiagramOpen docs are published only after the Cosmos DB write commits, never speculatively before persistence.
- Compensation without re-emission: When Catalog APIServicev1.0.0Catalog APIInternal HTTP and gRPC service for Catalog product management, hybrid discovery, and authoritative book metadata. PublishesBookUpdatedRatingFailedIntegrationEventSubscribesCreatePublisher, UpdatePublisher +24APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs rejects a feedback event for a missing book via Book rating update failedEventv1.0.0Book rating update failedIndicates that Catalog could not apply a feedback-created event because the referenced book was not found. Ownercatalog-experience-teamSchemaDiagramOpen docs, Rating APIServicev1.0.0Rating APIInternal HTTP and A2A gRPC service for collecting, listing, deleting, and summarizing customer feedback for Catalog book...PublishesFeedbackCreatedIntegrationEvent, FeedbackDeletedIntegrationEventSubscribesCreateFeedback, DeleteFeedback +3APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs reverts and deletes the orphaned feedback without emitting Feedback deletedEventv1.0.0Feedback deletedIndicates that a customer feedback rating was deleted for a book. Rating API publishes this event so Catalog can remove ...Ownercatalog-experience-teamSchemaDiagramOpen docs (preventing a compensation loop).
- Read-only AI summarization: Rating AgentAgentv1.0.0Rating AgentRead-only review intelligence specialist that summarizes customer feedback over A2A gRPC and map-reduce workflows while ...PublishesAnalyzeText, AnonymizeTextOwnercatalog-experience-teamDiagramRepositoryOpen docs reads catalog context via MCP ServerServicev1.0.0MCP ServerInternal stateless Streamable HTTP MCP service that exposes read-only Catalog lookup tools and reusable AI prompts. PublishesListBooksGrpc, GetBookDetailsGrpc +2Ownerai-capabilities-teamDiagramRepositoryOpen docs and raw feedback via Rating APIServicev1.0.0Rating APIInternal HTTP and A2A gRPC service for collecting, listing, deleting, and summarizing customer feedback for Catalog book...PublishesFeedbackCreatedIntegrationEvent, FeedbackDeletedIntegrationEventSubscribesCreateFeedback, DeleteFeedback +3APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs, runs behind Presidio PII middleware, and produces derived insights only—never mutating Rating DatabaseContainerv1.0.0Rating DatabaseAuthoritative Azure Cosmos DB system of record owned by the Reviews bounded context for customer feedback documents part...Ownercatalog-experience-teamDiagramOpen docs or Catalog DatabaseContainerv1.0.0Catalog DatabaseAuthoritative PostgreSQL system of record owned by the Catalog bounded context for books, authors, categories, publisher...Ownercatalog-experience-teamDiagramOpen docs.
Never emit FeedbackDeletedIntegrationEvent during compensation. Deleting an orphaned feedback in response to Book rating update failedEventv1.0.0Book rating update failedIndicates that Catalog could not apply a feedback-created event because the
referenced book was not found.
Ownercatalog-experience-teamSchemaDiagramOpen docs must use the revert path rather than the standard delete path; otherwise Catalog APIServicev1.0.0Catalog APIInternal HTTP and gRPC service for Catalog product management, hybrid
discovery, and authoritative book metadata.
PublishesBookUpdatedRatingFailedIntegrationEventSubscribesCreatePublisher, UpdatePublisher +24APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs would receive a spurious decrement for a book it already rejected.
Boundaries & Guarantees
| Concern | Strategy & Guarantee | Failure / Edge-Case Behavior | Related Resources |
|---|---|---|---|
| Persistence | rating-database stores feedback documents partitioned by /bookId with Wolverine Cosmos DB persistence for durable messaging. | Missing feedback on DELETE returns 404 Not Found (never masked as 204); compensation delete for an already-absent record completes as a no-op. | rating-database, feedback, adr-001-postgresql-feedback-system-of-record |
| Caching | rating-cache caches paged feedback reads (ListFeedbacks) via FusionCache with a 10m TTL tagged by BookId. | Feedback creation, deletion, or compensation invalidates the affected BookId tag so subsequent reads reflect the updated list. | rating-cache, ListFeedbacks |
| Messaging | Emits FeedbackCreatedIntegrationEvent and FeedbackDeletedIntegrationEvent partitioned by BookId / FeedbackId; consumes BookUpdatedRatingFailedIntegrationEvent. | Exhausted retries route to <code>bookworm.{env}.rating.dead-letter-queue</code>; missing-book compensation deletes the orphaned feedback cleanly. | <code>bookworm.{env}.rating.feedback-create</code>, <code>bookworm.{env}.rating.feedback-delete</code>, <code>bookworm.{env}.catalog.book-update-rating-failed</code>, <code>bookworm.{env}.rating.dead-letter-queue</code> |
| Concurrency & Idempotency | Cosmos DB ETag optimistic concurrency prevents lost updates on feedback documents; inbound compensation events use a 24h Redis integration-event idempotency guard; HTTP routes enforce PerUserRateLimit. | Concurrent ETag conflicts fail fast rather than overwriting newer state; duplicate BookUpdatedRatingFailedIntegrationEvent deliveries within 24h are safely ignored. | rating-api, feedback-publication, adr-003-compensate-invalid-feedback-after-catalog-rejection |
POST /api/v1/feedbacks and GET /api/v1/feedbacks are rate-limited (PerUserRateLimit).
DELETE /api/v1/feedbacks/{id} requires the admin policy (admin role +
rating_read/rating_write scopes). GET /api/v1/feedbacks/{id}/summarize requires an
authenticated caller, while Agent-to-Agent (A2A) gRPC calls from Chat APIServicev1.0.0Chat APIInternal HTTP host for BookWorm's interactive multi-agent chat workflow,
agent discovery, and session persistence.
Ownerai-capabilities-teamDiagramRepositoryOpen docs require
the read policy (rating_read scope) via Entra Agent Identity token exchange.
Summarize feedbackQueryv1.0.0Summarize feedbackReturns a generated feedback summary, classification, rating metrics, evidence, and confidence for a book.Ownercatalog-experience-teamSchemaDiagramOpen docs synthesizes themes, sentiment, and confidence from current reviews
at read time. Its output is never persisted back to Rating DatabaseContainerv1.0.0Rating DatabaseAuthoritative Azure Cosmos DB system of record owned by the Reviews bounded context for customer feedback documents part...Ownercatalog-experience-teamDiagramOpen docs and never
overrides the deterministic average_rating maintained by Catalog APIServicev1.0.0Catalog APIInternal HTTP and gRPC service for Catalog product management, hybrid
discovery, and authoritative book metadata.
PublishesBookUpdatedRatingFailedIntegrationEventSubscribesCreatePublisher, UpdatePublisher +24APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs.
Safe Change & Verification Checklist
- Preserve the
/bookIdpartition key and ETag optimistic concurrency configuration on Rating DatabaseContainerv1.0.0Rating DatabaseAuthoritative Azure Cosmos DB system of record owned by the Reviews bounded context for customer feedback documents part...Ownercatalog-experience-teamDiagramOpen docs (feedbackscontainer). - Verify Feedback createdEventv1.0.0Feedback createdIndicates that a customer feedback rating was created for a book. Rating API publishes this event so Catalog can update ...Ownercatalog-experience-teamSchemaDiagramOpen docs and Feedback deletedEventv1.0.0Feedback deletedIndicates that a customer feedback rating was deleted for a book. Rating API publishes this event so Catalog can remove ...Ownercatalog-experience-teamSchemaDiagramOpen docs emit only post-commit, and that compensation revert never emits Feedback deletedEventv1.0.0Feedback deletedIndicates that a customer feedback rating was deleted for a book. Rating API publishes this event so Catalog can remove ...Ownercatalog-experience-teamSchemaDiagramOpen docs.
- Confirm
BookIdcache-tag invalidation in Rating CacheContainerv1.0.0Rating CacheNon-authoritative FusionCache and Redis caching layer owned by the Reviews bounded context for AI-generated book feedbac...Ownercatalog-experience-teamDiagramOpen docs on create, delete, and compensation paths. - Keep
0–5rating validation, PII log redaction, andadmin/readauthorization policies intact. - Run
mise run format,mise run build, andmise run testto verify Rating unit tests and Pact contracts (Rating-Catalog,Catalog-Rating).
Related Resources
- Rating APIServicev1.0.0Rating APIInternal HTTP and A2A gRPC service for collecting, listing, deleting, and summarizing customer feedback for Catalog book...PublishesFeedbackCreatedIntegrationEvent, FeedbackDeletedIntegrationEventSubscribesCreateFeedback, DeleteFeedback +3APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs — Authoritative Reviews API and compensation consumer
- Rating AgentAgentv1.0.0Rating AgentRead-only review intelligence specialist that summarizes customer feedback over A2A gRPC and map-reduce workflows while ...PublishesAnalyzeText, AnonymizeTextOwnercatalog-experience-teamDiagramRepositoryOpen docs — Read-only review summarization agent
- Create feedbackCommandv1.0.0Create feedbackCreates a feedback rating for a Catalog book and returns its generated UUID.Ownercatalog-experience-teamSchemaDiagramOpen docs, Delete feedbackCommandv1.0.0Delete feedbackDeletes an existing feedback record by its UUID.Ownercatalog-experience-teamSchemaDiagramOpen docs, List feedbacksQueryv1.0.0List feedbacksReturns feedback for a book with pagination, sorting, and validation responses.Ownercatalog-experience-teamSchemaDiagramOpen docs, Summarize feedbackQueryv1.0.0Summarize feedbackReturns a generated feedback summary, classification, rating metrics, evidence, and confidence for a book.Ownercatalog-experience-teamSchemaDiagramOpen docs — Feedback operations
- Customer Feedback Publication and ProjectionFlowv1.0.0Customer Feedback Publication and ProjectionRating API persists customer feedback in Cosmos DB and publishes an integration event; Catalog API updates the derived b...Ownercatalog-experience-teamView flowOpen docs — End-to-end feedback publication and compensation flow
- ADR-002: Publish feedback events for Catalog's rating projectionDecision Recordv1.0.0ADR-002: Publish feedback events for Catalog's rating projectionRating publishes committed feedback-created and feedback-deleted events so Catalog can maintain its own eventually consi...Ownercatalog-experience-teamOpen docs, ADR-003: Compensate feedback rejected by CatalogDecision Recordv1.0.0ADR-003: Compensate feedback rejected by CatalogRating removes feedback when Catalog reports that a feedback-created event referenced a missing book, and treats repeate...Ownercatalog-experience-teamOpen docs, ADR-004: Keep AI feedback summarization read-only and governedDecision Recordv1.0.0ADR-004: Keep AI feedback summarization read-only and governedRating generates feedback insights at read time with allow-listed read tools, PII redaction, and rate limits, without pe...Ownercatalog-experience-teamOpen docs
- API and contracts indexCustom DocAPI and contracts indexConsolidated index of BookWorm HTTP v1, gRPC, AG-UI, MCP, A2A, and Kafka/Wolverine contracts grouped by service with aut...Ownerplatform-engineering-teamOpen doc — Consolidated HTTP, gRPC, and Kafka contracts