Parent Epic
Part of #692 (Operational Skill Store)
Summary
When learn query finds a matching CapturedProcedure with confidence > 0.8, offer to replay it instead of re-planning from scratch. This is the core token-saving mechanism -- proven workflows skip LLM reasoning entirely.
What Changes
New replay subcommand in terraphim_agent
terraphim-agent learn replay "deploy terraphim-llm-proxy config"
Behaviour:
- Match query against stored procedures (Aho-Corasick + tag matching)
- Display matched procedure with steps, confidence, and replay count
- Dry-run by default -- show steps, require confirmation
- Execute step-by-step with validation:
- Check exit code against
expected_exit_code
- Optionally match output against
expected_output_pattern
- Respect per-step
timeout_secs
- On divergence (unexpected exit code or output), halt and report
- Update procedure's
success_count or failure_count after completion
- Recalculate
confidence score
Integration point for ADF agents
Expose replay as a library function so terraphim_orchestrator agents can call it programmatically:
pub async fn replay_procedure(
procedure_id: &str,
dry_run: bool,
on_step: impl Fn(&ProcedureStep, StepResult) -> ReplayDecision,
) -> Result<ReplayOutcome, ReplayError>;
Affected Crates
terraphim_agent (new replay subcommand + library API)
Dependencies
Acceptance Criteria
Parent Epic
Part of #692 (Operational Skill Store)
Summary
When
learn queryfinds a matchingCapturedProcedurewith confidence > 0.8, offer to replay it instead of re-planning from scratch. This is the core token-saving mechanism -- proven workflows skip LLM reasoning entirely.What Changes
New
replaysubcommand interraphim_agentterraphim-agent learn replay "deploy terraphim-llm-proxy config"Behaviour:
expected_exit_codeexpected_output_patterntimeout_secssuccess_countorfailure_countafter completionconfidencescoreIntegration point for ADF agents
Expose replay as a library function so
terraphim_orchestratoragents can call it programmatically:Affected Crates
terraphim_agent(new replay subcommand + library API)Dependencies
Acceptance Criteria
learn replaymatches and displays procedures