025f81e961
Daemon half of the action-resolution boundary: - Add resolveAction wrapper: delegates to ResolveActionCandidate, records outcome in the decision trace (action-resolve:route/matcher) - Refactor actionAct: remove matcher call, consume candidate, write resolved values back into Slots for downstream branches - Add 8 integration tests pinning all required scenarios: route-sourced, matcher-sourced, matcher miss, destructive confirm, task-status intercept, stage-0, learned-router, alias match All existing tests pass. Execution/risk/confirmation unchanged.
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/kami/maven/internal/decision"
|
|
"github.com/kami/maven/internal/router"
|
|
)
|
|
|
|
// resolveAction produces an ActionCandidate from a routing decision. It is the
|
|
// single boundary between routing and action execution: everything downstream
|
|
// (refusesCommand, task-status, Praxis, Hexis, proposeGap, tool.Executor.Exec)
|
|
// consumes the candidate rather than re-resolving the function.
|
|
//
|
|
// Delegates to router.ResolveActionCandidate for the resolution logic, then
|
|
// records the outcome in the decision trace.
|
|
func (h *reactiveHandler) resolveAction(ctx context.Context, dec router.Decision) router.ActionCandidate {
|
|
candidate := router.ResolveActionCandidate(dec, h.matcher)
|
|
|
|
// Record the resolution outcome in the decision trace.
|
|
if dec.Intent == router.IntentAct {
|
|
if candidate.ActionResolved() {
|
|
noteActionResolution(ctx, string(candidate.Source), candidate.Fn, true)
|
|
} else {
|
|
noteActionResolution(ctx, "matcher", "", false)
|
|
}
|
|
}
|
|
|
|
return candidate
|
|
}
|
|
|
|
// noteActionResolution records the action resolution outcome in the decision
|
|
// trace. A nil recorder is the normal case in tests.
|
|
func noteActionResolution(ctx context.Context, source, fn string, resolved bool) {
|
|
rec := decision.From(ctx)
|
|
if rec == nil {
|
|
return
|
|
}
|
|
outcome := decision.Declined
|
|
reason := "no match"
|
|
if resolved {
|
|
outcome = decision.Won
|
|
reason = "resolved via " + source
|
|
if fn != "" {
|
|
reason += ": " + fn
|
|
}
|
|
}
|
|
rec.Note(decision.Claim{
|
|
Stage: decision.StageAction,
|
|
Claimant: "action-resolve",
|
|
Outcome: outcome,
|
|
Reason: reason,
|
|
})
|
|
}
|