Skip to content

fix: User Isolation Gaps fix - #93

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

fix: User Isolation Gaps fix#93
saharannaveen wants to merge 10 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

@saharannaveen
saharannaveen requested a review from a team as a code owner July 27, 2026 07:17
@saharannaveen saharannaveen changed the title Feature - User Isolation fix: User Isolation Gaps fix Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Enterprise

Run ID: 529b300e-6a60-45c8-8c70-71f2f9a4a850

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

nsaharan added 10 commits July 30, 2026 04:04
- 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

Signed-off-by: Naveen Saharan <nsaharan@redhat.com>
… rejection

Signed-off-by: Naveen Saharan <nsaharan@redhat.com>
- /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)

Signed-off-by: Naveen Saharan <nsaharan@redhat.com>
Signed-off-by: Naveen Saharan <nsaharan@redhat.com>
Signed-off-by: Naveen Saharan <nsaharan@redhat.com>
Signed-off-by: Naveen Saharan <nsaharan@redhat.com>
…ent duplicates

Signed-off-by: Naveen Saharan <nsaharan@redhat.com>
Signed-off-by: Naveen Saharan <nsaharan@redhat.com>
…t, not sub

Signed-off-by: Naveen Saharan <nsaharan@redhat.com>
- Rules: load from backend on mount (listRules), save on add (createRule)
- Memories: preserve backend UUIDs with setMemories action
- localStorage: scope keys per user (dataverse-ai-chats:{sub})
- Personalization: start empty, load from backend (single source of truth)
- Feedback: use authenticatedFetch with USER_DATA.sub as userId
- chatStorage: scope CHATS_STORAGE_KEY per user
- auth-check: only set dummy user when session.user is unset
- test-login: dev-only endpoint for multi-user browser testing

Signed-off-by: Naveen Saharan <nsaharan@redhat.com>
@NP-compete NP-compete added the deep-agent PRs targeting the deep-agent branch label Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deep-agent PRs targeting the deep-agent branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants