mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
feat: Add circuit breaker for file sync failures (#364)
Signed-off-by: phernandez <paul@basicmachines.co> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Pydantic schemas for sync report responses."""
|
||||
|
||||
from typing import TYPE_CHECKING, Dict, Set
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING, Dict, List, Set
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
@@ -9,6 +10,17 @@ if TYPE_CHECKING:
|
||||
from basic_memory.sync.sync_service import SyncReport
|
||||
|
||||
|
||||
class SkippedFileResponse(BaseModel):
|
||||
"""Information about a file that was skipped due to repeated failures."""
|
||||
|
||||
path: str = Field(description="File path relative to project root")
|
||||
reason: str = Field(description="Error message from last failure")
|
||||
failure_count: int = Field(description="Number of consecutive failures")
|
||||
first_failed: datetime = Field(description="Timestamp of first failure")
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class SyncReportResponse(BaseModel):
|
||||
"""Report of file changes found compared to database state.
|
||||
|
||||
@@ -24,6 +36,9 @@ class SyncReportResponse(BaseModel):
|
||||
checksums: Dict[str, str] = Field(
|
||||
default_factory=dict, description="Current file checksums (path -> checksum)"
|
||||
)
|
||||
skipped_files: List[SkippedFileResponse] = Field(
|
||||
default_factory=list, description="Files skipped due to repeated failures"
|
||||
)
|
||||
total: int = Field(description="Total number of changes")
|
||||
|
||||
@classmethod
|
||||
@@ -42,6 +57,15 @@ class SyncReportResponse(BaseModel):
|
||||
deleted=report.deleted,
|
||||
moves=report.moves,
|
||||
checksums=report.checksums,
|
||||
skipped_files=[
|
||||
SkippedFileResponse(
|
||||
path=skipped.path,
|
||||
reason=skipped.reason,
|
||||
failure_count=skipped.failure_count,
|
||||
first_failed=skipped.first_failed,
|
||||
)
|
||||
for skipped in report.skipped_files
|
||||
],
|
||||
total=report.total,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user