Merge adapter lifecycle safeguards
This commit is contained in:
commit
15a913003c
11 changed files with 541 additions and 11 deletions
|
|
@ -15,7 +15,7 @@ from .changesets import ChangesetStore
|
|||
from .context import compile_context
|
||||
from .errors import DocForgeError
|
||||
from .index import ProjectIndex
|
||||
from .models import ProjectService
|
||||
from .models import ProjectService, RuntimeValidatedProject
|
||||
from .project import Project, project_root_fingerprint
|
||||
from .rendering import RenderService
|
||||
from .viewer_manager import ViewerManagerClient
|
||||
|
|
@ -80,6 +80,7 @@ EXCLUDED_OPERATIONS = (
|
|||
STALE_ERROR_CODES = frozenset(
|
||||
{
|
||||
"base_conflict",
|
||||
"adapter_restart_required",
|
||||
"content_conflict",
|
||||
"source_changed",
|
||||
"stale_adapter_source",
|
||||
|
|
@ -166,6 +167,8 @@ class DocForgeService:
|
|||
synchronization: dict[str, object] | None = None
|
||||
try:
|
||||
try:
|
||||
if isinstance(self.project, RuntimeValidatedProject):
|
||||
self.project.validate_runtime()
|
||||
result: dict[str, Any] = operation()
|
||||
except DocForgeError as error:
|
||||
if not synchronize or error.code not in RECOVERABLE_INDEX_ERROR_CODES:
|
||||
|
|
@ -229,6 +232,11 @@ class DocForgeService:
|
|||
|
||||
@staticmethod
|
||||
def _remediation(error: DocForgeError) -> dict[str, object] | None:
|
||||
if error.code == "adapter_restart_required":
|
||||
return {
|
||||
"retryable": False,
|
||||
"action": "restart_project_server",
|
||||
}
|
||||
if error.code in {"missing_index", "stale_index", "invalid_index"}:
|
||||
return {
|
||||
"retryable": True,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue