fix(memory): unify Outcome enum and add ABANDONED support

- Add ABANDONED value to core Outcome enum in types.py
- Replace duplicate OutcomeType class in mcp/tools.py with alias to Outcome
- Simplify mcp/service.py to use outcome directly (no more silent mapping)
- Add migration 0006 to extend PostgreSQL episode_outcome enum
- Add missing constraints to migration 0005 (ix_facts_unique_triple_global)

This fixes the semantic issue where ABANDONED outcomes were silently
converted to FAILURE, losing information about task abandonment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-06 01:46:48 +01:00
parent 3edce9cd26
commit 192237e69b
5 changed files with 75 additions and 18 deletions

View File

@@ -1024,15 +1024,8 @@ class MemoryToolService:
context: ToolContext,
) -> dict[str, Any]:
"""Execute the 'record_outcome' tool."""
# Map outcome type to memory Outcome
# Note: ABANDONED maps to FAILURE since core Outcome doesn't have ABANDONED
outcome_map = {
OutcomeType.SUCCESS: Outcome.SUCCESS,
OutcomeType.PARTIAL: Outcome.PARTIAL,
OutcomeType.FAILURE: Outcome.FAILURE,
OutcomeType.ABANDONED: Outcome.FAILURE, # No ABANDONED in core enum
}
outcome = outcome_map.get(args.outcome, Outcome.FAILURE)
# OutcomeType is now an alias for Outcome, use directly
outcome = args.outcome
# Record in episodic memory
episodic = await self._get_episodic()