Initial curated ITWorx_MCP_Hub source from 368fba691ea8d23403b4d56b53b5ec670d7c5020
This commit is contained in:
commit
cb5be898ea
663 files changed
+82674
No files matched your search
@@ -0,0 +1,66 @@
|
||||
"""Deterministic recovery assertions used by clean-room restore tests."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable, Mapping
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RecoveryReport:
|
||||
checks: Mapping[str, bool]
|
||||
details: Mapping[str, str]
|
||||
|
||||
@property
|
||||
def passed(self) -> bool:
|
||||
return all(self.checks.values())
|
||||
|
||||
|
||||
class RecoveryProbe:
|
||||
"""Prove recovery semantics without requiring a production credential."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
login: Callable[[], bool],
|
||||
discovery: Callable[[], bool],
|
||||
tool_call: Callable[[], bool],
|
||||
negative_auth: Callable[[], bool],
|
||||
audit_continuity: Callable[[], bool],
|
||||
) -> None:
|
||||
self._checks = {
|
||||
"login": login,
|
||||
"discovery": discovery,
|
||||
"toolCall": tool_call,
|
||||
"negativeAuth": negative_auth,
|
||||
"auditContinuity": audit_continuity,
|
||||
}
|
||||
|
||||
def run(self) -> RecoveryReport:
|
||||
results: dict[str, bool] = {}
|
||||
details: dict[str, str] = {}
|
||||
for name, check in self._checks.items():
|
||||
try:
|
||||
result = bool(check())
|
||||
except Exception as exc: # noqa: BLE001
|
||||
result = False
|
||||
details[name] = type(exc).__name__
|
||||
results[name] = result
|
||||
details.setdefault(name, "passed" if result else "failed")
|
||||
return RecoveryReport(results, details)
|
||||
|
||||
|
||||
def connector_isolation_report(statuses: Mapping[str, str]) -> dict[str, Any]:
|
||||
"""A failed connector degrades only itself and never grants access elsewhere."""
|
||||
|
||||
normalized = {str(name): str(status) for name, status in statuses.items()}
|
||||
failed = sorted(
|
||||
name for name, status in normalized.items() if status not in {"healthy", "ready"}
|
||||
)
|
||||
return {
|
||||
"status": "degraded" if failed else "healthy",
|
||||
"failedConnectors": failed,
|
||||
"isolated": True,
|
||||
"redisAuthoritative": False,
|
||||
}
|
||||
Reference in new issue
Block a user