Skip to content

Feature - User Isolation - #93

Open
saharannaveen wants to merge 9 commits into
redhat-data-and-ai:deep-agentfrom
saharannaveen:feat/user-isolation
Open

Feature - User Isolation#93
saharannaveen wants to merge 9 commits into
redhat-data-and-ai:deep-agentfrom
saharannaveen:feat/user-isolation

Conversation

@saharannaveen

Copy link
Copy Markdown

Summary

Enforce per-user data isolation across all API surfaces — threads, checkpoints, feedback, token usage,
personalization (memories/rules), and memory consolidation
Add thread deletion endpoint that purges all associated data (checkpoints, feedback, token usage), not
just the thread row
Prevent user_id spoofing by always extracting identity from JWT, never from query params
Add Locust load test suite to validate isolation under concurrent multi-user load
What changed

Core isolation enforcement

Personalization REST API (GET/POST/DELETE /memories, /rules) scoped by JWT sub claim
Decay scoring, consolidation, and clustering SQL queries scoped with AND user_id
Feedback endpoint overrides user_id from JWT (prevents spoofing via query param)
Token-usage endpoint now requires authentication
Cache invalidation on memory/rule deletion (was missing; Redis failure no longer causes 500)
Thread deletion cleanup

Custom DELETE /threads/{id} purges checkpoints, feedback, and token usage records
Previously only thread metadata and runs were deleted by Aegra's default handler
Integration tests

12 live integration tests against real Postgres validating cross-user isolation for threads, runs,
checkpoints, feedback, and token usage
Unit tests

27 user isolation tests with in-memory fake DB
5 thread cleanup tests
Load tests

Self-signed JWT provider with JWKS server for Locust virtual users
IsolatedUser scenario with 6 tasks: create thread, chat, list threads, cross-user visibility, feedback
isolation, delete thread
Configurable load profiles (smoke, load, stress, soak)
Test plan

27 unit tests for isolation enforcement (in-memory fake DB)
5 unit tests for thread cleanup
12 integration tests against real Postgres
Locust smoke test against staging (locust -f tests/load/isolation_locustfile.py --tags smoke)
Manual: create thread as user A, verify user B cannot see it via GET /threads
Manual: delete thread, verify checkpoints and feedback are also purged

nsaharan added 9 commits July 7, 2026 16:09
- Add deleteMemory, deleteAllMemories, deleteRule, deleteAllRules API functions
- MemoryList.tsx and RulesEditor.tsx now call backend API on delete
- Use JWT sub claim for user identification instead of preferred_username
- /memory command: typing "/memory <text>" in chat saves to backend DB
- createMemory() API function added to agent-rest.ts
- MemoryList.tsx: add-memory now syncs to backend API
- Fix: cancel active stream when navigating between chats
- Fix: reload thread state from backend when returning to a chat
  that only has human messages (stream was cancelled mid-flight)
@saharannaveen
saharannaveen requested a review from a team as a code owner July 27, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants