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

Function replayExact

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

Source from the content-addressed store, hash-verified

78}
79
80func replayExact(ctx context.Context, cfg *config.Config, req types.AIRequest, row requests.RequestRow, deps Dependencies) (types.AIResponse, error) {
81 var snap types.PolicySnapshot
82 if len(row.PolicySnapshot) > 0 {
83 _ = json.Unmarshal(row.PolicySnapshot, &snap)
84 }
85 backend := strings.TrimSpace(snap.PrimaryBackend)
86 if backend == "" {
87 backend = strings.TrimSpace(row.SelectedBackend)
88 }
89 if backend == "" {
90 return types.AIResponse{}, errors.New("exact replay: missing primary backend in ledger snapshot")
91 }
92
93 if req.RequestType == types.RequestTypeRAG {
94 if err := runRAGRetrieve(ctx, cfg, &req, deps.Retrieval, deps.Rerank); err != nil {
95 return types.AIResponse{}, err
96 }
97 }
98
99 primary := types.RouteDecision{
100 BackendName: backend,
101 Reason: "replay_exact",
102 EstimatedCost: snap.EstimatedCost,
103 }
104 execRes, err := deps.Reliability.ExecuteWithFallbackOpts(ctx, req, primary, nil, types.ReliabilityExecuteOptions{
105 ForcePrimaryBackend: backend,
106 NoFallback: true,
107 })
108 if err != nil {
109 return types.AIResponse{}, err
110 }
111 return buildResponse(cfg, req, "replay_exact", primary, execRes, row.RequestID, row.TraceID), nil
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)

Callers 1

ReplayFunction · 0.85

Calls 3

runRAGRetrieveFunction · 0.85
buildResponseFunction · 0.85

Tested by

no test coverage detected