Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions backend/app/graph/nodes/technique_categories/finalize.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import logging
from datetime import datetime, timezone
from typing import Any, Dict, List, Optional
from langchain_core.runnables import RunnableConfig
from app.graph.state import EvaluationState
from app.criteria.bmad_items import list_items, get_category, get_category_max
from app.constants import get_quality_gate
from app.models.graph import ItemScore
from app.services.event_channel import create_sommelier_event, get_event_channel

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

To correctly emit the quality_gate_complete event with a custom payload, it's necessary to use the SSEEvent model, which supports a flexible data field. The current import is missing SSEEvent and EventType, which are required for the fix. Please add them to the import statement.

Suggested change
from app.services.event_channel import create_sommelier_event, get_event_channel
from app.services.event_channel import SSEEvent, EventType, create_sommelier_event, get_event_channel


logger = logging.getLogger(__name__)


async def finalize(
Expand Down Expand Up @@ -52,6 +56,35 @@ async def finalize(

quality_gate = get_quality_gate(normalized, coverage)

evaluation_id = state.get("evaluation_id", "")
if evaluation_id:
try:
event_channel = get_event_channel()
event_channel.emit_sync(
evaluation_id,
create_sommelier_event(
evaluation_id=evaluation_id,
sommelier="finalize",
event_type="quality_gate_complete",
progress_percent=95,
message=f"Quality gate: {quality_gate}, score: {round(normalized, 2)}",
),
)
event_channel.emit_sync(
evaluation_id,
create_sommelier_event(
evaluation_id=evaluation_id,
sommelier="system",
event_type="evaluation_complete",
progress_percent=100,
message="Evaluation complete!",
),
)
except Exception:
logger.warning(
"Failed to emit finalize events for %s", evaluation_id, exc_info=True
)

return {
"trace_metadata": {
"finalize": {
Expand Down