ai-powered-conversational-intelligence

Prompt 31 — Recommendation & Action Dashboard

Mandatory first step: 00_MASTER_IMPLEMENTATION_CONTRACT.md (read and applied).

Objective

Build the recommendation-focused experience on top of the governed recommendation APIs (Prompts 17 and 18): a reviewer can see what the platform suggested, why, on what evidence, and act on it — accept, reject, partially useful, resolve, assign an owner, add notes — with every action governed, tenant-scoped, rate-limited, logged, and recorded in an append-only trail.

Areas inspected

Gaps found by inspection

  1. No owner concept. A record could not be assigned to anyone.
  2. No note/comment action. The audit trail only held status changes.
  3. Race in status transitions. submit_feedback validated the in-memory status and then committed an unconditioned UPDATE. Two reviewers acting on the same record could both succeed. The same bug class Prompt 27 fixed for the semantic catalog.
  4. Mutations not on the structured security log, and the three transition routes had no rate limit.
  5. No frontend consumer for the governed lifecycle. Only the tenant-admin summary read the list and metrics.

Existing functionality reused

Files

Created

Modified

API changes (backward compatible)

Route Change
GET /recommendations New optional owner_user_id and unassigned query params. Response gains owner_user_id, owner_display_name
GET /recommendations/{id} Response gains the same two owner fields
GET /recommendations/{id}/events Each event gains event_type (default status_change) and detail
POST /recommendations/{id}/notes New. Body {note} (1–4000 chars). Never changes status
POST /recommendations/{id}/owner New. Body {owner_user_id} (null clears). Missing, inactive, cross-tenant, or non-reviewer owner → the same 404
POST /recommendations/{id}/feedback, /resolve, /expire Unchanged contract. Now rate-limited and logged

No existing field was removed or renamed. Existing clients ignore the new fields.

Database changes

Migration b7e2d4a1c9f0 (revises a4c7e2b9d6f5), purely additive:

Apply with alembic -c identity/alembic.ini upgrade head. downgrade() removes only what upgrade() added.

Configuration

No new settings. Relevant existing ones:

Security review

Tenant-isolation review

Performance review

Testing

Backend (tests/test_api_recommendation_actions.py, tests/test_recommendation_actions_repository.py) — 46 tests:

Frontend (lib/recommendationDisplay.test.ts, pages/Recommendations.test.tsx):

Known limitations

Remaining risks

Prompt 32 (final in the series) should close the remaining operational gaps across the platform: a cursor-paginated recommendations list, OIDC support for the governance routes, and an end-to-end browser test of the lifecycle with a real database.