Add improvements

This commit is contained in:
Urtzi Alfaro
2026-01-12 14:24:14 +01:00
parent 6037faaf8c
commit 230bbe6a19
61 changed files with 1668 additions and 894 deletions

View File

@@ -35,7 +35,6 @@ async def get_recent_actions(
ingredient_id: Optional[str] = Query(None, description="Filter by ingredient"),
product_id: Optional[str] = Query(None, description="Filter by product"),
hours_ago: int = Query(24, description="Look back hours"),
x_internal_service: str = Header(None, description="Internal service authentication")
):
"""
Get recent orchestrator actions for alert context enrichment.
@@ -52,9 +51,6 @@ async def get_recent_actions(
logger = structlog.get_logger()
# Simple internal service authentication
if x_internal_service != "alert-intelligence":
raise HTTPException(status_code=403, detail="Access denied")
try:
settings = get_settings()

View File

@@ -51,13 +51,6 @@ async def ensure_unique_run_number(db: AsyncSession, base_run_number: str) -> st
proposed_run_number = f"{base_run_number[:50-len(random_suffix)-1]}-{random_suffix}"
def verify_internal_api_key(x_internal_api_key: str = Header(...)):
"""Verify internal API key for service-to-service communication"""
if x_internal_api_key != settings.INTERNAL_API_KEY:
raise HTTPException(status_code=403, detail="Invalid internal API key")
return True
async def load_fixture_data_for_tenant(
db: AsyncSession,
tenant_uuid: UUID,
@@ -161,8 +154,7 @@ async def clone_demo_data(
demo_account_type: str,
session_id: Optional[str] = None,
session_created_at: Optional[str] = None,
db: AsyncSession = Depends(get_db),
_: bool = Depends(verify_internal_api_key)
db: AsyncSession = Depends(get_db)
):
"""
Clone orchestration run demo data from base tenant to virtual tenant
@@ -234,8 +226,7 @@ async def clone_demo_data(
@router.delete("/tenant/{virtual_tenant_id}")
async def delete_demo_data(
virtual_tenant_id: str,
db: AsyncSession = Depends(get_db),
_: bool = Depends(verify_internal_api_key)
db: AsyncSession = Depends(get_db)
):
"""Delete all orchestration runs for a virtual demo tenant"""
logger.info("Deleting orchestration runs for virtual tenant", virtual_tenant_id=virtual_tenant_id)
@@ -281,6 +272,6 @@ async def delete_demo_data(
@router.get("/clone/health")
async def health_check(_: bool = Depends(verify_internal_api_key)):
async def health_check():
"""Health check for demo cloning endpoint"""
return {"status": "healthy", "service": "orchestrator"}

View File

@@ -583,17 +583,24 @@ class OrchestrationSaga:
"""
Generate forecasts for tenant.
NOTE: AI insights generated in step 0.5 are already posted to the AI Insights Service
and will be automatically consumed by the forecast service via its dynamic rules engine.
The forecast service queries the AI Insights Service for recent insights when generating
forecasts, so there's no need to explicitly pass them here.
Args:
tenant_id: Tenant ID
context: Execution context
context: Execution context (includes ai_insights_posted count from step 0.5)
Returns:
Forecast result
"""
logger.info(f"Generating forecasts for tenant {tenant_id}")
ai_insights_count = context.get('ai_insights_posted', 0)
logger.info(f"Generating forecasts for tenant {tenant_id} (AI insights available: {ai_insights_count})")
try:
# Call forecast service with circuit breaker protection
# The forecast service will automatically query AI Insights Service for recent insights
if self.forecast_breaker:
result = await self.forecast_breaker.call(
self.forecast_client.generate_forecasts, tenant_id