- Add 10 sharing endpoint tests (share/unshare memory, tag shares, shared-with-me,
my-shares, recall with shared, update permission checks)
- Add hypothesis property-based tests for model validation (roundtrip, bounds,
enum, sort_by, limit)
- Tighten model validation: sort_by Literal, limit ge=1/le=500, tags/keywords max_length
- Fix dashboard shared_with_me stat to include tag-based shares
- Add tag-sharing management UI (share/remove tags, user typeahead)
- Replace alert() with inline error messages
- Fix route ordering bug: share-tag routes before {memory_id} parameterized routes
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
from typing import Any, Literal, Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
MAX_MEMORY_CHARS = 800
|
|
|
|
|
|
class MemoryStore(BaseModel):
|
|
content: str = Field(..., max_length=MAX_MEMORY_CHARS)
|
|
category: str = "facts"
|
|
tags: str = Field(default="", max_length=500)
|
|
expanded_keywords: str = Field(default="", max_length=500)
|
|
importance: float = Field(default=0.5, ge=0.0, le=1.0)
|
|
force_sensitive: bool = False
|
|
|
|
|
|
class MemoryRecall(BaseModel):
|
|
context: str
|
|
expanded_query: str = ""
|
|
category: Optional[str] = None
|
|
sort_by: Literal["importance", "relevance", "recency"] = "importance"
|
|
limit: int = Field(default=10, ge=1, le=500)
|
|
|
|
|
|
class MemoryResponse(BaseModel):
|
|
id: int
|
|
category: str
|
|
importance: float
|
|
|
|
|
|
class SecretResponse(BaseModel):
|
|
id: int
|
|
content: str
|
|
source: str # "vault", "encrypted", "plaintext"
|
|
|
|
|
|
class SyncResponse(BaseModel):
|
|
memories: list[dict[str, Any]]
|
|
server_time: str
|
|
|
|
|
|
class ShareMemory(BaseModel):
|
|
shared_with: str = Field(..., min_length=1, max_length=100)
|
|
permission: Literal["read", "write"] = "read"
|
|
|
|
|
|
class ShareTag(BaseModel):
|
|
tag: str = Field(..., min_length=1, max_length=100)
|
|
shared_with: str = Field(..., min_length=1, max_length=100)
|
|
permission: Literal["read", "write"] = "read"
|
|
|
|
|
|
class UnshareTag(BaseModel):
|
|
tag: str = Field(..., min_length=1, max_length=100)
|
|
shared_with: str = Field(..., min_length=1, max_length=100)
|
|
|
|
|
|
class MemoryUpdate(BaseModel):
|
|
content: Optional[str] = Field(None, max_length=MAX_MEMORY_CHARS)
|
|
tags: Optional[str] = None
|
|
importance: Optional[float] = Field(None, ge=0.0, le=1.0)
|
|
expanded_keywords: Optional[str] = None
|