diff --git a/cmd/core-runtime/information_request_test.go b/cmd/core-runtime/information_request_test.go new file mode 100644 index 0000000..94b60db --- /dev/null +++ b/cmd/core-runtime/information_request_test.go @@ -0,0 +1,25 @@ +package main + +import ( + "testing" + + "git.cin.su/m/Assistant/contracts/interaction" +) + +func TestSpecializedInformationReplyIsNotOverwrittenByResearch(t *testing.T) { + for _, kind := range []interaction.InformationRequestKind{ + interaction.InformationRequestMemoryInventory, + interaction.InformationRequestTimeDifference, + interaction.InformationRequestCapabilityInventory, + interaction.InformationRequestCognitiveModelInventory, + interaction.InformationRequestCognitiveChannelStatus, + interaction.InformationRequestCognitiveRecovery, + } { + if shouldRunGeneralResearch(kind) { + t.Fatalf("specialized information request %q must bypass general research", kind) + } + } + if !shouldRunGeneralResearch("") { + t.Fatal("ordinary research requests must still use general research") + } +} diff --git a/cmd/core-runtime/main.go b/cmd/core-runtime/main.go index 6cdc620..5487027 100644 --- a/cmd/core-runtime/main.go +++ b/cmd/core-runtime/main.go @@ -769,7 +769,7 @@ func main() { needsCognition = false } researchBacked := false - if hasChatRoute(routePlan, chatRouteResearch) && semantic.Interpretation.Clarification != interaction.ClarificationRequired { + if hasChatRoute(routePlan, chatRouteResearch) && semantic.Interpretation.Clarification != interaction.ClarificationRequired && shouldRunGeneralResearch(semantic.InformationRequestKind) { if planID, idErr := ids.New(); idErr == nil { parts := interactiondomain.IndependentRequestParts(effectiveTaskMessage) replies := make([]string, 0, len(parts)) @@ -1589,6 +1589,10 @@ func main() { } } +func shouldRunGeneralResearch(kind interaction.InformationRequestKind) bool { + return kind == "" +} + func creatorSessionHandler(bootstrapToken, creatorUsername, creatorPassword string, sessionKey []byte, now func() time.Time) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { authenticated := identitydomain.BootstrapMatches(bootstrapToken, bearerToken(r))