Bugfix/unimplemented workspaces#521
Open
hrshjswniii wants to merge 5 commits into
Open
Conversation
param20h
requested changes
Jun 7, 2026
…resolve schemas conflict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Related Issue
Closes #483
📝 What does this PR do?
This PR includes the following bug fixes, feature implementations, and optimizations:
1. Leaking Soft-Deleted Documents in Global Chat RAG Retrieval (Bug Fix)
Resolves a security/data-isolation bug where soft-deleted documents (where
is_deleted = Truein SQLite) were leaking into global/unscoped chatbot retrieval:retrievefunction in [retriever.py], to check the SQLite database for active document IDs. If no specificdocument_idis supplied, it queries for a whitelist of all non-deleted (is_deleted=False) document IDs belonging to the querying user or their workspaces.CustomVectorRetrieverasdocument_ids, which filters vector store queries viawhere_filter = {"document_id": {"$in": document_ids}}.CustomBM25Retrieverasdocument_idsand updatedquery_bm25in [bm25.py], to skip index.pklfiles that do not match the active list.test_retrieve_excludes_soft_deleted_documentsto [test_retriever.py], to assert that retrieval ignores soft-deleted documents.2. Collaborative Workspaces (New Feature)
Fully implements collaborative workspaces to support shared document spaces, invitations, and access isolation:
WorkspaceandWorkspaceMembershipmodels in [models.py], . Addedworkspace_idand relationships toDocumentandUsermodels._migrate_schemain [database.py], to automatically add theworkspace_idcolumn to thedocumentstable on startup.POST /api/v1/workspaces/invite: Allows users to invite other users to a workspace (creating the workspace and membership on the fly if needed).GET /api/v1/workspaces/invite/verify: Verifies the validity of secure invite tokens.POST /api/v1/workspaces/invite/accept: Decodes the token and adds the authenticated user to the workspace.personal,company, or specific UUID).3. PDF Image Parsing Memory Optimizations (OOM Prevention)
Optimizes raw image processing during PDF ingestion to prevent Out-Of-Memory issues on large files:
finallyblock to release memory immediately for each page rather than waiting for the entire document parsing to finish.🗂️ Type of Change
🧪 How was this tested?
uvicorn app.main:app --reload)npm run devinsidefrontend/)test_retrieve_excludes_soft_deleted_documentsinbackend/tests/test_retriever.pyand 4 workspace verification tests inbackend/tests/test_workspaces.py).venv/Scripts/pytest— all 122 tests passed successfully)documentsschema migration automatically on startup.✅ Self-Review Checklist
dev, notmain