ai-powered-conversational-intelligence

Prompt 32 — Complete UX, RBAC & Role-Based Navigation Integration

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

Objective

Make the finished product one coherent application: each signed-in caller sees exactly the screens and actions their permissions allow, enforced on the server and not just hidden in the browser, and the chain from client onboarding to semantic approval to recommendation work holds together.

Areas inspected

Gaps found by inspection

  1. Navigation was decided in the browser from role names. Hidden tabs were the only protection. Every screen URL was open to any signed-in user; an unauthorized user typing /platform-admin got a page of failed requests.
  2. Five pages re-derived their actions from role names (SemanticReview, DatabaseOnboarding, Recommendations, TenantAdmin, PlatformAdmin), so the browser held a second copy of the authorization policy.
  3. Onboarding and SME review never met. publish_job built a semantic-contract artifact and created no catalog entries. The SME dashboard never saw onboarding output.
  4. A real routing bug from Prompt 31. The recommendation page was at /recommendations, which is also the governance API’s JSON list route. In production, a hard refresh of that page reached the API (api/main.py registers API routes before the SPA fallback). Also: /recommendations was missing from the dev proxy list (the recurring gap Prompts 26–29 each found), and the dev proxy sent browser reloads of page paths that share an API prefix (/platform-admin, /tenant-admin) to the backend, which answered 404 JSON.
  5. A job with no connection details (no host or database name) made discover and publish return a generic 500, because ConfigurationError escaped the route.
  6. A free-text onboarding label broke publish. The label became the catalog database_id, which names a Chroma collection. Chroma rejects spaces, so publish failed for My Warehouse.
  7. platform_admin is not a base role. It carries no agent.authz grants, so an operator holding only that role had no AI workspace, and the chat tab was shown anyway. This is the existing, deliberate tradeoff; navigation now shows it honestly.

Persona mapping (existing roles only)

No new role was added. Navigation follows permissions, so personas map onto the seeded roles:

Persona Role(s) Screens
Platform Super Admin platform_admin and admin All eight
Tenant Admin admin All except Platform Admin
SME / Semantic Reviewer analyst Chat, knowledge, media, recommendations, onboarding, SME review
Business Analyst analyst Same as SME. The existing model cannot separate them without a new seeded role
Business User user Chat, knowledge, media
Read-only Viewer auditor Tenant dashboard only (no AI grants, so cannot ask questions)

platform_admin alone shows the admin screens but no AI workspace, by design.

Design

Server-side policy, one source of truth — security/navigation.py (pure, no FastAPI or DB):

Endpoints — api/navigation.py:

Frontend:

Onboarding → SME bridge — onboarding/catalog_bridge.py, called from publish_job before the job is marked published:

Failure handling — api/onboarding.py::_engine_for_job: a missing-connection configuration error answers 422 with a message that names no settings, and the job stays pending.

Dev proxy and PWA — vite.config.ts: /recommendations and /navigation added to the proxy and PWA list. The proxy’s bypass sends any Accept: text/html request to the app, so a reload of a page path shared with an API prefix works in development.

API / config / database changes

Tests added

Backend — 63 tests:

Frontend — 57 new tests, plus 6 files updated:

Tests executed and results

Accessibility and responsive checks

Security review

Tenant-isolation review

Performance review

Known limitations

Remaining risks

Prompt 33 should add the two remaining pieces of this prompt: a capability gate for “Confirm and run” in the chat turn, and a seeded sme role that separates the SME reviewer from the business analyst, with its own navigation test. It should also add a browser end-to-end suite (Playwright or similar) that runs the journey and the role matrix against a live server.