Commit Graph

2 Commits

Author SHA1 Message Date
Chiguyong fb86d4e51b refactor(iq): ce-simplify-code fixes — P1 bug + P2 quality
P1 (bug fix):
- store_prompt_reflection: bypass store() and write ORM entry directly
  so task_hash/version/score land in metadata_ JSONB column. Previously
  store() dropped these keys, breaking list_prompt_reflections_by_hash
  filtering (U7 would always return empty).

P2 (quality):
- DangerousToolsConfig: pre-compile regex patterns in __post_init__
  (is_dangerous runs on per-tool hot path in autonomy mode).
- ABTester.compare_prompt_versions: extract _no_data_result helper,
  remove redundant isinstance check after value type guard.
- orchestrator: fix misleading "transient TeamPlan" comment.

Tests updated to match new store_prompt_reflection implementation
(direct ORM write instead of store() delegation). 137 tests pass.
2026-07-06 14:20:42 +08:00
Chiguyong 9653b1d5f7 feat(memory): U5 ReflexionEngine reflection persistence to EpisodicMemory (R11, R15)
Cross-task reflection persistence for prompt self-tuning:
- EpisodicMemory.store_prompt_reflection(): persists reflection via existing
  store() with task_type="prompt_reflection" discriminator. Key format:
  prompt_reflection:{task_hash}:{version}. Non-raising on failure.
- EpisodicMemory.search_prompt_reflections(): semantic search with
  task_type filter. Returns [] on failure.
- EpisodicMemory.cleanup_expired(): TTL cleanup (default 30 days).
- ReflexionEngine.__init__: optional episodic_memory param (None=backward compat)
- ReflexionEngine._reflect: persists reflection+improved_prompt+score after
  generation. Non-blocking — persistence failure doesn't block in-task retry.

Tests: 16 new tests (store/search/cleanup + _reflect persistence paths +
multi-version coexistence). All pass.
2026-07-06 13:50:10 +08:00