ConvertBudgetToLevel converts a budget value to the nearest thinking level. This is a semantic conversion that maps numeric budgets to discrete levels. Uses threshold-based mapping for range conversion. Budget → Level thresholds: - -1 → auto - 0 → none - 1-512 → minimal - 513-10
(budget int)
| 75 | // - level: The converted thinking level string |
| 76 | // - ok: true if budget is valid, false for invalid negatives (< -1) |
| 77 | func ConvertBudgetToLevel(budget int) (string, bool) { |
| 78 | switch { |
| 79 | case budget < -1: |
| 80 | // Invalid negative values |
| 81 | return "", false |
| 82 | case budget == -1: |
| 83 | return string(LevelAuto), true |
| 84 | case budget == 0: |
| 85 | return string(LevelNone), true |
| 86 | case budget <= ThresholdMinimal: |
| 87 | return string(LevelMinimal), true |
| 88 | case budget <= ThresholdLow: |
| 89 | return string(LevelLow), true |
| 90 | case budget <= ThresholdMedium: |
| 91 | return string(LevelMedium), true |
| 92 | case budget <= ThresholdHigh: |
| 93 | return string(LevelHigh), true |
| 94 | default: |
| 95 | return string(LevelXHigh), true |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | // HasLevel reports whether the given target level exists in the levels slice. |
| 100 | // Matching is case-insensitive with leading/trailing whitespace trimmed. |
no outgoing calls
no test coverage detected