mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-15 19:10:47 +02:00
Set up document management for Stirling Engine (#6476)
# Description of Changes Change Stirling Engine to support deleting documents automatically. This happens both on user logout and after an amount of time specified by the Java when ingesting a document (allowing for personal documents to have short lifetimes but org documents to be left in the db with no expiry date). Also sets up an [ACL policy](https://en.wikipedia.org/wiki/Access-control_list) for the documents so the database knows which users have access to which documents. This is not fully implemented in the Java, so currently all docs are treated as having a single owner, the uploader, but theoretically when we need to support org storage, we shouldn't need to change the db schema.
This commit is contained in:
@@ -9,6 +9,7 @@ detector when invoked.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterator
|
||||
from dataclasses import replace
|
||||
|
||||
import pytest
|
||||
@@ -22,10 +23,24 @@ from stirling.contracts import (
|
||||
)
|
||||
from stirling.contracts.contradiction import Claim
|
||||
from stirling.documents import DocumentService, SqliteVecStore
|
||||
from stirling.models import FileId
|
||||
from stirling.models import FileId, OwnerId, PrincipalId, UserId
|
||||
from stirling.services import current_user_id
|
||||
from stirling.services.runtime import AppRuntime
|
||||
from tests.test_pdf_question_agent import StubEmbedder
|
||||
|
||||
USER = UserId("test-user")
|
||||
OWNER = OwnerId("test-user")
|
||||
OWNER_PRINCIPALS = [PrincipalId("test-user")]
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _set_user_context() -> Iterator[None]:
|
||||
token = current_user_id.set(USER)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
current_user_id.reset(token)
|
||||
|
||||
|
||||
def _file(file_id: str, name: str) -> AiFile:
|
||||
return AiFile(id=FileId(file_id), name=name)
|
||||
@@ -69,6 +84,9 @@ async def test_run_answer_agent_builds_agent_with_three_toolsets(
|
||||
file.id,
|
||||
[PageText(page_number=1, text="content")],
|
||||
source=file.name,
|
||||
owner_id=OWNER,
|
||||
read_principals=OWNER_PRINCIPALS,
|
||||
expires_at=None,
|
||||
)
|
||||
|
||||
agent = PdfQuestionAgent(runtime_with_stub_docs)
|
||||
|
||||
Reference in New Issue
Block a user