MCPcopy Create free account
hub / github.com/InferCore/InferCore / replayCurrent

Function replayCurrent

internal/replay/replay.go:114–149  ·  view source on GitHub ↗
(ctx context.Context, cfg *config.Config, req types.AIRequest, deps Dependencies)

Source from the content-addressed store, hash-verified

112}
113
114func replayCurrent(ctx context.Context, cfg *config.Config, req types.AIRequest, deps Dependencies) (types.AIResponse, error) {
115 pol, err := deps.Policy.Evaluate(ctx, req)
116 if err != nil {
117 return types.AIResponse{}, err
118 }
119 if !pol.Allowed {
120 return types.AIResponse{}, fmt.Errorf("policy rejected: %s", pol.Reason)
121 }
122 req = pol.Normalized
123 if req.RequestType == types.RequestTypeAgent {
124 return types.AIResponse{}, errors.New("agent execution not implemented")
125 }
126
127 health := allHealthy(cfg)
128 primary, err := deps.Router.SelectRoute(ctx, req, types.RuntimeState{
129 QueueDepth: 0,
130 BackendHealth: health,
131 OverloadDegrade: false,
132 })
133 if err != nil {
134 return types.AIResponse{}, err
135 }
136
137 if req.RequestType == types.RequestTypeRAG {
138 if err := runRAGRetrieve(ctx, cfg, &req, deps.Retrieval, deps.Rerank); err != nil {
139 return types.AIResponse{}, err
140 }
141 }
142
143 fallback := buildFallbackList(cfg, primary.BackendName, health)
144 execRes, err := deps.Reliability.ExecuteWithFallback(ctx, req, primary, fallback)
145 if err != nil {
146 return types.AIResponse{}, err
147 }
148 return buildResponse(cfg, req, pol.Reason, primary, execRes, req.RequestID, ""), nil
149}
150
151func allHealthy(cfg *config.Config) map[string]bool {
152 out := make(map[string]bool, len(cfg.Backends))

Callers 1

ReplayFunction · 0.85

Calls 7

allHealthyFunction · 0.85
runRAGRetrieveFunction · 0.85
buildFallbackListFunction · 0.85
buildResponseFunction · 0.85
EvaluateMethod · 0.65
SelectRouteMethod · 0.65
ExecuteWithFallbackMethod · 0.65

Tested by

no test coverage detected