classifyTaskType determines the cognitive type of the incoming task. This drives effort allocation, model selection, and confidence calibration.
(task string)
| 55 | // classifyTaskType determines the cognitive type of the incoming task. |
| 56 | // This drives effort allocation, model selection, and confidence calibration. |
| 57 | func classifyTaskType(task string) string { |
| 58 | t := strings.ToLower(task) |
| 59 | |
| 60 | // Multi-step detection (check first) |
| 61 | multiSignals := []string{"and then", "after that", "step by step", "first", "finally"} |
| 62 | multiCount := 0 |
| 63 | for _, sig := range multiSignals { |
| 64 | if strings.Contains(t, sig) { |
| 65 | multiCount++ |
| 66 | } |
| 67 | } |
| 68 | if multiCount >= 2 || strings.Count(t, ",") >= 3 { |
| 69 | return "multi_step" |
| 70 | } |
| 71 | |
| 72 | // Ranking/comparison — check BEFORE coding (needs strong model) |
| 73 | for _, sig := range []string{"top", "best", "most popular", "rank", "compare", "versus", "which is better"} { |
| 74 | if strings.Contains(t, sig) { |
| 75 | return "ranking" |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | // Coding — use word boundary awareness to avoid false positives |
| 80 | codingSignals := []string{"write code", "function", "implement", "debug", "fix the bug", "write a script", "refactor", "algorithm"} |
| 81 | for _, sig := range codingSignals { |
| 82 | if strings.Contains(t, sig) { |
| 83 | return "coding" |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | // Summarization |
| 88 | for _, sig := range []string{"summarize", "summary", "tldr", "overview", "key points", "recap"} { |
| 89 | if strings.Contains(t, sig) { |
| 90 | return "summarization" |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // Reasoning |
| 95 | for _, sig := range []string{"why", "explain", "analyze", "evaluate", "should i", "pros and cons"} { |
| 96 | if strings.Contains(t, sig) { |
| 97 | return "reasoning" |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | // Retrieval |
| 102 | for _, sig := range []string{"find", "search", "list", "get", "show me", "look up", "fetch", "what is"} { |
| 103 | if strings.Contains(t, sig) { |
| 104 | return "retrieval" |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | return "general" |
| 109 | } |
| 110 | |
| 111 | // Governor holds the verifier and registry — the "Teacher" layer. |
| 112 | type Governor struct { |