From a00212ca4d17c49b4deaf6e73c8dcd45ce469867 Mon Sep 17 00:00:00 2001 From: ajaysi Date: Sat, 7 Mar 2026 12:00:04 +0530 Subject: [PATCH] refactor: Unify canonical task outcome statuses (completed, skipped) across workflow and memory services (Closes #384) --- backend/api/today_workflow.py | 6 +++--- backend/services/task_memory_service.py | 4 ++-- backend/services/today_workflow_service.py | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/api/today_workflow.py b/backend/api/today_workflow.py index 928840b3..ed89e7aa 100644 --- a/backend/api/today_workflow.py +++ b/backend/api/today_workflow.py @@ -191,7 +191,7 @@ async def set_task_status( memory = TaskMemoryService(user_id, db) await memory.record_task_outcome( task, - feedback_score=1 if status == "completed" else -1 if status == "dismissed" else 0, + feedback_score=1 if status == "completed" else -1 if status in ("dismissed", "skipped") else 0, feedback_text=completion_notes ) except Exception as e: @@ -210,7 +210,7 @@ async def set_task_status( "pillarId": task.pillar_id, "title": task.title, "description": task.description, - "status": "skipped" if task.status == "dismissed" else task.status, + "status": "skipped" if task.status in ("dismissed", "skipped") else task.status, } asyncio.create_task(_index_tasks_to_sif(user_id, plan_date, [task_payload], label="today")) @@ -220,7 +220,7 @@ async def set_task_status( "task": { "id": str(task.id), "pillarId": task.pillar_id, - "status": "skipped" if task.status == "dismissed" else task.status, + "status": "skipped" if task.status in ("dismissed", "skipped") else task.status, "decided_at": task.decided_at.isoformat() if task.decided_at else None, } }, diff --git a/backend/services/task_memory_service.py b/backend/services/task_memory_service.py index 94cab477..6c5eea90 100644 --- a/backend/services/task_memory_service.py +++ b/backend/services/task_memory_service.py @@ -15,7 +15,7 @@ from services.intelligence.txtai_service import TxtaiIntelligenceService EXACT_DUPLICATE_LOOKBACK_DAYS = 7 SEMANTIC_SUPPRESSION_SCORE_THRESHOLD = 0.85 -SUPPRESSED_STATUSES = {"dismissed", "rejected"} +SUPPRESSED_STATUSES = {"dismissed", "rejected", "skipped"} class TaskMemoryService: """ @@ -72,7 +72,7 @@ class TaskMemoryService: self.db.commit() # 2. Index into txtai (if status is meaningful) - if task.status in ["completed", "dismissed", "rejected"]: + if task.status in ["completed", "dismissed", "rejected", "skipped"]: # We index the task text with metadata about its outcome # This allows us to search: "Has the user rejected similar tasks?" doc = { diff --git a/backend/services/today_workflow_service.py b/backend/services/today_workflow_service.py index 08eeee69..62ab39c3 100644 --- a/backend/services/today_workflow_service.py +++ b/backend/services/today_workflow_service.py @@ -25,6 +25,7 @@ def _coerce_priority(value: Any) -> str: def _coerce_status(value: Any) -> str: v = str(value or "pending").lower().strip() if v in {"pending", "in_progress", "completed", "skipped", "dismissed"}: + # Canonicalize 'dismissed' to 'skipped' for consistency return "skipped" if v == "dismissed" else v return "pending"