Add autonomous controller health adapter
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
"""Autonomous Controller health adapter."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from .blocker_task_adapter import BlockerTaskAdapter
|
||||
from .git_permission_watchdog import GitPermissionWatchdog
|
||||
from .system_blocker_memory import SystemBlockerMemory
|
||||
from .system_health_center import SystemHealthCenter
|
||||
|
||||
|
||||
class AutonomousHealthAdapter:
|
||||
def __init__(self):
|
||||
self.git = GitPermissionWatchdog()
|
||||
self.memory = SystemBlockerMemory()
|
||||
self.task_adapter = BlockerTaskAdapter()
|
||||
self.health = SystemHealthCenter()
|
||||
|
||||
def check(self, previous_blockers: list[dict[str, Any]] | None = None) -> dict[str, Any]:
|
||||
git_report = self.git.scan().to_dict()
|
||||
blockers = list(previous_blockers or [])
|
||||
if git_report.get("status") != "healthy":
|
||||
blockers.append({
|
||||
"blocker_id": "git-permission",
|
||||
"category": "git_permission",
|
||||
"title": "Git object permission drift",
|
||||
"severity": "p0",
|
||||
"evidence": [str(git_report)],
|
||||
})
|
||||
return self.health.build(git_report=git_report, blockers=blockers)
|
||||
|
||||
def optimize_task(self, blocker: dict[str, Any]) -> dict[str, Any]:
|
||||
decision = self.memory.decide(blocker)
|
||||
return self.task_adapter.to_task(blocker, decision.to_dict())
|
||||
|
||||
|
||||
__all__ = ["AutonomousHealthAdapter"]
|
||||
Reference in New Issue
Block a user