Skip to content

fix(orchestration): wire plan_with_cache into handle_plan_goal (#2070)#2074

Merged
bug-ops merged 2 commits intomainfrom
issue-2070-plan-cache
Mar 20, 2026
Merged

fix(orchestration): wire plan_with_cache into handle_plan_goal (#2070)#2074
bug-ops merged 2 commits intomainfrom
issue-2070-plan-cache

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 20, 2026

Summary

Wire the incomplete plan_with_cache infrastructure from PR #2068 into the actual planning code path. When orchestration.plan_cache.enabled = true, goals are now embedded, cached plans are found via similarity, and completed plans are stored in the cache.

Changes

  1. Added plan_cache and pending_goal_embedding fields to OrchestrationState
  2. Modified handle_plan_goal() to:
    • Lazy-initialize PlanCache on first call (when enabled + memory available)
    • Embed normalized goal before calling plan_with_cache()
    • Call plan_with_cache() instead of direct planner.plan()
  3. Modified finalize_plan_execution() to store completed plans in cache
  4. Modified handle_plan_cancel() to clear pending embedding
  5. Fixed clippy::large_futures in acp.rs/daemon.rs via Box::pin

Test Results

  • 6264/6264 tests PASS (+23 from plan_cache unit tests)
  • fmt: ✅ PASS
  • clippy: ✅ PASS (0 warnings with --features full)
  • All validators approved:
    • Security: Low risk, no blockers
    • Performance: No blocking issues (embedding cost 20–200ms, inherent to semantic similarity)
    • Testing: APPROVED (6 gaps identified, none blocking)
    • Implementation critique: Ready for review

Validation

  • Architect designed integration with graceful degradation
  • Critic reviewed for type safety, edge cases, invariants — approved
  • Developer implemented per design + 2 important fixes
  • 4 validators (tester, perf, security, impl-critic) approved
  • Reviewer approved, IMP-1 fix applied and re-verified

Follow-ups (file after merge)

  • FOLLOW-1 (medium): test assertion for cancel clearing embedding
  • FOLLOW-2/3/4 (low): additional integration tests + docs clarification

Closes #2070

@github-actions github-actions bot added rust Rust code changes core zeph-core crate bug Something isn't working size/L Large PR (201-500 lines) labels Mar 20, 2026
bug-ops added 2 commits March 20, 2026 23:36
Integrate PlanCache into the planning path so orchestration.plan_cache.enabled
actually takes effect. Previously handle_plan_goal() called LlmPlanner::new().plan()
directly, bypassing plan_with_cache() and leaving the plan_cache table unpopulated.

Changes:
- OrchestrationState: add plan_cache (lazy) and pending_goal_embedding fields
- Agent: extract init_plan_cache_if_needed() and goal_embedding_for_cache() helpers
- handle_plan_goal: lazy-init PlanCache, embed normalized goal, call plan_with_cache()
- finalize_plan_execution: cache completed plan template via cache_plan()
- handle_plan_cancel: clear pending_goal_embedding to prevent state leak (IMP-2)
- normalize goal before embedding for consistent cache hit quality (IMP-1)
- log EmbedUnsupported at DEBUG instead of WARN to reduce noise (SUG-2)
- Box::pin Agent builder futures in acp.rs and daemon.rs to satisfy large_futures lint
…an status

In finalize_plan_execution, Canceled and the catch-all arm now call
pending_goal_embedding.take() so the embedding does not linger when a plan
ends in a non-retryable state.

Also added clarifying comments in the Failed and Paused arms explaining why
the embedding is intentionally retained there: retry/resume goes through
finalize_plan_execution again, reusing the same embedding, and a new /plan
goal cannot be issued while pending_graph is Some.
@bug-ops bug-ops force-pushed the issue-2070-plan-cache branch from c885bea to 572ee74 Compare March 20, 2026 22:36
@bug-ops bug-ops enabled auto-merge (squash) March 20, 2026 22:36
@bug-ops bug-ops merged commit 922cb42 into main Mar 20, 2026
25 checks passed
@bug-ops bug-ops deleted the issue-2070-plan-cache branch March 20, 2026 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(orchestration): wire plan_with_cache into handle_plan_goal (#1856 follow-up)

1 participant