Commit Graph

182 Commits

Author SHA1 Message Date
7ef727f968 fix: Recommended badge no longer clips outside Templates card
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 14:09:26 -06:00
35131e353b fix: eliminate 422 race condition — RBAC headers sync before queries
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 14:05:46 -06:00
ee1c2f70f8 fix: set RLS tenant context for chat conversation lookups
Chat API queries on web_conversations need tenant context set before
RLS policies allow the SELECT. Also fixes crypto.randomUUID fallback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 13:34:38 -06:00
5b02b233f3 fix: chat WebSocket connects to correct remote host
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 13:26:36 -06:00
ebf6e76174 feat: make Ollama model configurable via OLLAMA_MODEL env var
- Add OLLAMA_MODEL setting to shared config (default: qwen3:32b)
- LLM router reads from settings instead of hardcoded model name
- Create .env file with all configurable settings documented
- docker-compose passes OLLAMA_MODEL to llm-pool container

To change the model: edit OLLAMA_MODEL in .env and restart llm-pool.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 13:22:18 -06:00
22c6a44ff6 fix: map all model_preference values to LiteLLM router groups
Added balanced/economy/local groups alongside fast/quality so all 5
agent model_preference values resolve to real provider groups.
All default to local Ollama qwen3:32b, commercial as fallback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 13:20:23 -06:00
2444c61022 fix: chat page shows tenant picker for platform admins
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 13:10:49 -06:00
84d2e775ad fix: register RLS hook on gateway — agent creation was failing with policy violation
The gateway never called configure_rls_hook(engine), so SET LOCAL
app.current_tenant was never set for any DB operation through the
portal API endpoints. All tenant-scoped writes (agent creation, etc.)
failed with "new row violates row-level security policy."

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 12:40:08 -06:00
2127d1a844 feat: portal font upgrade — DM Sans + JetBrains Mono
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 12:19:33 -06:00
01e685b18b feat: premium portal UI — glass-morphism and luminous design system
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 12:15:58 -06:00
012566c8ee feat: portal UI revamp — brand identity and visual polish
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 11:54:33 -06:00
7469f39259 docs(phase-6): complete Web Chat phase execution 2026-03-25 10:41:50 -06:00
9af4ad5816 docs(06-03): complete web chat human verification plan
- Created 06-03-SUMMARY.md for human-verify checkpoint completion
- All CHAT requirements (CHAT-01–CHAT-05) confirmed by human review
- STATE.md updated: 25/25 plans complete, session recorded
- ROADMAP.md updated: Phase 6 marked Complete (3/3 summaries)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 10:37:59 -06:00
7281285b13 docs(06-02): complete web chat portal UI plan
- Add 06-02-SUMMARY.md with full execution record
- Update STATE.md: progress 96%, decisions recorded, session updated
- Update ROADMAP.md: phase 6 plan progress (2/3 summaries)
2026-03-25 10:36:22 -06:00
3c10bceba7 docs(06-01): complete web chat backend infrastructure plan 2026-03-25 10:28:44 -06:00
56c11a0f1a feat(06-01): WebSocket endpoint, chat REST API, orchestrator wiring, gateway mounting
- Create gateway/channels/web.py with normalize_web_event() and /chat/ws/{conversation_id}
  WebSocket endpoint (auth via first JSON message, typing indicator, Redis pub-sub response)
- Create shared/api/chat.py with GET/POST/DELETE /api/portal/chat/conversations* REST API
  with require_tenant_member RBAC enforcement and RLS context var setup
- Add chat_router to shared/api/__init__.py exports
- Mount chat_router and web_chat_router in gateway/main.py (Phase 6 Web Chat routers)
- All 19 unit tests pass; full 313-test suite green
2026-03-25 10:26:54 -06:00
c72beb916b feat(06-01): add web channel type, Redis key, ORM models, migration, and tests
- Add ChannelType.WEB = 'web' to shared/models/message.py
- Add webchat_response_key() to shared/redis_keys.py
- Create WebConversation and WebConversationMessage ORM models (SQLAlchemy 2.0)
- Create migration 008_web_chat.py with RLS, indexes, and channel_type CHECK update
- Pop conversation_id/portal_user_id extras in handle_message before model_validate
- Add web case to _build_response_extras and _send_response (Redis pub-sub publish)
- Import webchat_response_key in orchestrator/tasks.py
- Write 19 unit tests covering CHAT-01 through CHAT-05 (all pass)
2026-03-25 10:26:34 -06:00
c0fa0cefee docs(06-web-chat): create phase plan 2026-03-25 10:08:44 -06:00
5e4dd34331 docs(06): add research and validation strategy 2026-03-25 10:02:39 -06:00
03e38f3692 docs(06): research web chat phase — WebSocket, Redis pub-sub, channel adapter, portal UI 2026-03-25 10:01:45 -06:00
1b086b8c82 docs(state): record phase 6 context session 2026-03-25 08:38:50 -06:00
4077512a38 docs(06): capture phase context 2026-03-25 08:38:50 -06:00
d0afd66e85 docs: add Phase 6 — Web Chat interface for AI Employees 2026-03-24 22:45:32 -06:00
58a1295e5f docs(phase-5): complete Employee Design phase execution 2026-03-24 20:54:45 -06:00
999c6ce55b docs(05-04): complete RBAC gap closure and wizard error fix plan
- Added 05-04-SUMMARY.md
- Updated STATE.md with decisions and session info
- Updated ROADMAP.md with Phase 5 plan progress (4/4 complete)
2026-03-24 20:52:31 -06:00
b287a95014 docs(05-employee-design): create gap closure plan for RBAC and error handling fixes 2026-03-24 20:50:30 -06:00
969cc4f917 docs(05-03): complete employee design human verification — Phase 5 complete 2026-03-24 20:42:19 -06:00
b917f7c54c docs(05-02): complete employee creation UI frontend plan
- Three-option entry screen, template gallery, 5-step wizard, advanced mode
- SUMMARY.md created with task commits, deviations, decisions
- STATE.md updated with decisions, metrics, session
- ROADMAP.md updated with phase 5 plan progress
- Requirements EMPL-01, EMPL-05 marked complete
2026-03-24 20:40:53 -06:00
c688b76c13 docs(05-01): complete agent templates backend plan — system prompt builder, migration 007, template API
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 20:33:44 -06:00
f9ce3d650f feat(05-01): template list/detail/deploy API + RBAC + integration tests
- Create shared/api/templates.py with templates_router
- GET /api/portal/templates: list active templates (any authenticated user)
- GET /api/portal/templates/{id}: get template detail (any authenticated user)
- POST /api/portal/templates/{id}/deploy: create Agent snapshot (tenant_admin only)
- customer_operator returns 403 on deploy (RBAC enforced)
- Export templates_router from shared/api/__init__.py
- Mount templates_router in gateway/main.py (Phase 5 section)
- 11 integration tests pass (list, detail, deploy, RBAC, 404, snapshot independence)
2026-03-24 20:32:30 -06:00
d1acb292a1 feat(05-01): AgentTemplate ORM model, migration 007, and system prompt builder
- Add AgentTemplate ORM model to tenant.py (global, not tenant-scoped)
- Create migration 007 with agent_templates table and 7 seed templates
- Create shared/prompts/system_prompt_builder.py with build_system_prompt()
- AI transparency clause always present (non-negotiable per Phase 1 decision)
- Unit tests pass (17 tests, all sections verified)
2026-03-24 20:27:54 -06:00
bffc1f2f67 docs(05-employee-design): create phase plan — 3 plans in 3 waves 2026-03-24 20:11:56 -06:00
5f0b74cf8c docs(05): add research and validation strategy 2026-03-24 20:05:39 -06:00
84d8059eac docs(phase-5): research employee design phase 2026-03-24 20:04:47 -06:00
40eb3106ab docs(state): record phase 5 context session 2026-03-24 19:59:49 -06:00
6a9516ed8b docs(05): capture phase context 2026-03-24 19:59:49 -06:00
03ec956379 docs: add Phase 5 — Employee Design wizard and agent templates 2026-03-24 19:33:23 -06:00
188ef4f6e1 fix: runtime deployment — CORS, Slack guard, litellm GitHub, CPU torch
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 19:31:57 -06:00
1b51499818 docs(phase-4): complete RBAC phase execution 2026-03-24 17:24:39 -06:00
279946a22a docs(04-rbac-03): finalize RBAC enforcement plan — human-verify checkpoint approved
- Task 3 (human-verify) approved — all 3 tasks complete
- SUMMARY.md updated: tasks 3/3, next phase readiness updated
- STATE.md stopped_at reflects full completion
- ROADMAP.md phase 4 progress confirmed 3/3 summaries complete

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 17:20:14 -06:00
94ada11fbd docs(04-rbac-03): complete RBAC API enforcement plan — guards, test-message endpoint, integration tests
- 17 portal API endpoints guarded with Depends() RBAC guards
- POST /agents/{aid}/test endpoint allows operators to QA agents
- GET /tenants/{tid}/users, GET /admin/users listing endpoints
- POST /admin/impersonate with AuditEvent audit trail
- 56 integration tests covering full RBAC matrix and invite flow
- STATE.md updated, ROADMAP.md phase 4 marked complete
Awaiting human-verify checkpoint (Task 3) before phase is fully done
2026-03-24 17:18:52 -06:00
9515c5374a test(04-rbac-03): add failing integration tests for RBAC enforcement and invite flow
RED phase — tests are written, will pass when connected to live DB.
Tests cover:
- Full RBAC matrix: platform_admin/customer_admin/operator on all endpoints
- Operator can POST /test but not POST /agents (create)
- Missing headers return 422
- Impersonation creates AuditEvent row
- Full invite flow: create -> accept -> login with correct role
- Expired invite rejection
- Resend generates new token and extends expiry
- Double-accept prevention
2026-03-24 17:16:13 -06:00
43b73aa6c5 feat(04-rbac-03): wire RBAC guards to all portal API endpoints + new endpoints
- Add require_platform_admin guard to GET/POST /tenants, PUT/DELETE /tenants/{id}
- Add require_tenant_member to GET /tenants/{id}, GET agents, GET agent/{id}
- Add require_tenant_admin to POST agents, PUT/DELETE agents
- Add require_tenant_admin to billing checkout and portal endpoints
- Add require_tenant_admin to channels slack/install and whatsapp/connect
- Add require_tenant_member to channels /{tid}/test
- Add require_tenant_admin to all llm_keys endpoints
- Add require_tenant_member to all usage GET endpoints
- Add POST /tenants/{tid}/agents/{aid}/test (require_tenant_member for operators)
- Add GET /tenants/{tid}/users with pending invitations (require_tenant_admin)
- Add GET /admin/users with tenant filter/role filter (require_platform_admin)
- Add POST /admin/impersonate with AuditEvent logging (require_platform_admin)
- Add POST /admin/stop-impersonation with AuditEvent logging (require_platform_admin)
2026-03-24 17:13:35 -06:00
e899b14fa7 docs(04-rbac-02): complete portal RBAC integration plan
- 04-02-SUMMARY.md: Auth.js JWT + role nav + tenant switcher + impersonation banner + user pages
- STATE.md: advanced to plan 3, metrics recorded, base-ui decisions added
- ROADMAP.md: phase 4 updated to 2/3 plans complete
- REQUIREMENTS.md: RBAC-05 marked complete
2026-03-24 17:08:50 -06:00
1fa4c3e3ad docs(04-rbac-01): complete RBAC foundation plan — migration, guards, invitations, tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 13:57:17 -06:00
7b0594e7cc test(04-rbac-01): unit tests for RBAC guards, invitation system, portal auth
- test_rbac_guards.py: 11 tests covering platform_admin pass-through,
  customer_admin/operator 403 rejection, tenant membership checks,
  and platform_admin bypass for tenant-scoped guards
- test_invitations.py: 11 tests covering HMAC token roundtrip,
  tamper/expiry rejection, invitation create/accept/resend/list
- test_portal_auth.py: 7 tests covering role field (not is_admin),
  tenant_ids list, active_tenant_id, platform_admin all-tenants,
  customer_admin own-tenants-only
- All 27 tests pass
2026-03-24 13:55:55 -06:00
d59f85cd87 feat(04-rbac-01): RBAC guards + invite token + email + invitation API
- rbac.py: PortalCaller dataclass + get_portal_caller dependency (header-based)
- rbac.py: require_platform_admin (403 for non-platform_admin)
- rbac.py: require_tenant_admin (platform_admin bypasses; customer_admin
  checks UserTenantRole; operator always rejected)
- rbac.py: require_tenant_member (platform_admin bypasses; all roles
  checked against UserTenantRole)
- invite_token.py: generate_invite_token (HMAC-SHA256, base64url, 48h TTL)
- invite_token.py: validate_invite_token (timing-safe compare_digest, TTL check)
- invite_token.py: token_to_hash (SHA-256 for DB storage)
- email.py: send_invite_email (sync smtplib, skips if smtp_host empty)
- invitations.py: POST /api/portal/invitations (create, requires tenant admin)
- invitations.py: POST /api/portal/invitations/accept (accept invitation)
- invitations.py: POST /api/portal/invitations/{id}/resend (regenerate token)
- invitations.py: GET /api/portal/invitations (list pending)
- portal.py: AuthVerifyResponse now returns role+tenant_ids+active_tenant_id
- portal.py: auth/register gated behind require_platform_admin
- tasks.py: send_invite_email_task Celery task (fire-and-forget)
- gateway/main.py: invitations_router mounted
2026-03-24 13:52:45 -06:00
f710c9c5fe feat(04-rbac-01): DB migration 006 + RBAC ORM models + config fields
- Migration 006: adds role TEXT+CHECK column to portal_users, backfills
  is_admin -> platform_admin/customer_admin, drops is_admin
- Migration 006: creates user_tenant_roles table (UNIQUE user_id+tenant_id)
- Migration 006: creates portal_invitations table with token_hash, status, expires_at
- PortalUser: replaced is_admin (bool) with role (str, default customer_admin)
- Added UserRole enum (PLATFORM_ADMIN, CUSTOMER_ADMIN, CUSTOMER_OPERATOR)
- Added UserTenantRole ORM model with FK cascade deletes
- Added PortalInvitation ORM model with token_hash unique constraint
- Settings: added invite_secret, smtp_host, smtp_port, smtp_username,
  smtp_password, smtp_from_email fields
2026-03-24 13:49:16 -06:00
2aecc5c787 fix(04-rbac): revise plans based on checker feedback 2026-03-24 13:46:03 -06:00
bf4adf0b21 docs(04-rbac): create phase plan — 3 plans in 3 waves 2026-03-24 13:37:36 -06:00