Bootstrap SillyHome Future v2 core

This commit is contained in:
2026-06-18 12:16:54 +02:00
commit 549f87523a
15 changed files with 729 additions and 0 deletions

32
app/core/handoff.py Normal file
View File

@@ -0,0 +1,32 @@
from __future__ import annotations
from app.core.models import ControlProfile, HandoffMode
class HandoffMatrix:
def classify(self, profile: ControlProfile) -> HandoffMode:
active_related = set(profile.related_automation_ids) - set(profile.paused_automation_ids)
if profile.handoff_mode is HandoffMode.CONTROLLED and active_related:
return HandoffMode.CONFLICT
if profile.paused_automation_ids:
return HandoffMode.CONTROLLED
if profile.related_automation_ids:
return HandoffMode.CANDIDATE
return profile.handoff_mode
def assume_control(self, profile: ControlProfile) -> ControlProfile:
return profile.model_copy(
update={
"handoff_mode": HandoffMode.CONTROLLED,
"paused_automation_ids": list(profile.related_automation_ids),
}
)
def rollback(self, profile: ControlProfile) -> ControlProfile:
return profile.model_copy(
update={
"handoff_mode": HandoffMode.ROLLBACK,
"paused_automation_ids": [],
}
)