feat(engine): implement MissionManager execution with meta-prompts

The MissionManager now builds evolving meta-prompts and processes
thread outcomes for continuous learning:

fire_mission() upgraded:
- Loads Project MemoryDocs via RetrievalEngine for context
- Builds meta-prompt from: goal, current_focus, approach_history,
  project knowledge docs, trigger payload, thread count
- Spawns thread with meta-prompt as user message
- Background task waits for completion and processes outcome
- Daily thread budget enforcement (max_threads_per_day)

Meta-prompt structure:
  # Mission: {name}
  Goal: {goal}
  ## Current Focus (evolves between threads)
  ## Previous Approaches (what we've tried)
  ## Knowledge from Prior Threads (lessons, playbooks, issues)
  ## Trigger Payload (webhook/event data if applicable)
  ## Instructions (accomplish step, report next focus, check goal)

Outcome processing:
- Extracts "next focus:" from FINAL() response → updates current_focus
- Detects "goal achieved: yes" → completes mission
- Records accomplishment in approach_history
- Failed threads recorded as "FAILED: {error}"

Cron ticker:
- start_cron_ticker() spawns tokio task, ticks every 60s
- Checks active Cron missions, fires those past next_fire_at

151 tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
2026-03-24 09:24:55 -07:00
co-authored by Claude Opus 4.6
parent 10cf040b43
commit 536fafb096
3 changed files with 209 additions and 13 deletions
+1 -3
View File
@@ -156,9 +156,7 @@ impl EffectExecutor for EffectBridgeAdapter {
.rate_limiter
.check_and_record(&context.user_id, lookup_name, &rl_config)
.await;
if let crate::tools::rate_limiter::RateLimitResult::Limited {
retry_after, ..
} = result
if let crate::tools::rate_limiter::RateLimitResult::Limited { retry_after, .. } = result
{
return Err(EngineError::Effect {
reason: format!(