fix(incidents): bind durable readback tenant context

This commit is contained in:
ogt
2026-07-11 20:10:17 +08:00
parent 476c6a6315
commit ca5ed596dc
6 changed files with 79 additions and 18 deletions

View File

@@ -730,9 +730,17 @@ class IncidentService:
)
return "updated"
async def get_for_readback(self, incident_id: str) -> Incident | None:
async def get_for_readback(
self,
incident_id: str,
*,
project_id: str | None = None,
) -> Incident | None:
"""Return durable incident truth, with Redis as an availability fallback."""
incident = await self.get_from_episodic_memory(incident_id)
incident = await self.get_from_episodic_memory(
incident_id,
project_id=project_id,
)
if incident is not None:
return incident
@@ -742,7 +750,11 @@ class IncidentService:
)
return await self.get_from_working_memory(incident_id)
async def get_active_incidents(self) -> list[Incident]:
async def get_active_incidents(
self,
*,
project_id: str | None = None,
) -> list[Incident]:
"""
列出所有活躍的 Incidents。
@@ -755,7 +767,9 @@ class IncidentService:
try:
from src.repositories.incident_repository import get_incident_repository
incidents = await get_incident_repository().get_active()
incidents = await get_incident_repository().get_active(
project_id=project_id,
)
logger.info(
"get_active_incidents_from_episodic_memory",
count=len(incidents),