LoadScopePriorities loads the scope priorities map from scope_priorities.json. Scores are stored as float strings (e.g. "52.42") and rounded to int.
()
| 176 | // LoadScopePriorities loads the scope priorities map from scope_priorities.json. |
| 177 | // Scores are stored as float strings (e.g. "52.42") and rounded to int. |
| 178 | func LoadScopePriorities() map[string]int { |
| 179 | if cachedScopePriorities != nil { |
| 180 | return cachedScopePriorities |
| 181 | } |
| 182 | |
| 183 | data, err := registryFS.ReadFile("scope_priorities.json") |
| 184 | if err != nil { |
| 185 | cachedScopePriorities = make(map[string]int) |
| 186 | return cachedScopePriorities |
| 187 | } |
| 188 | |
| 189 | var entries []scopePriorityEntry |
| 190 | if err := json.Unmarshal(data, &entries); err != nil { |
| 191 | cachedScopePriorities = make(map[string]int) |
| 192 | return cachedScopePriorities |
| 193 | } |
| 194 | |
| 195 | m := make(map[string]int, len(entries)) |
| 196 | for _, entry := range entries { |
| 197 | f, err := strconv.ParseFloat(entry.FinalScore, 64) |
| 198 | if err != nil { |
| 199 | continue |
| 200 | } |
| 201 | m[entry.ScopeName] = int(math.Round(f)) |
| 202 | } |
| 203 | |
| 204 | // Apply manual overrides from scope_overrides.json |
| 205 | if overrideData, err := registryFS.ReadFile("scope_overrides.json"); err == nil { |
| 206 | var wrapper struct { |
| 207 | PriorityOverrides map[string]int `json:"priority_overrides"` |
| 208 | } |
| 209 | if json.Unmarshal(overrideData, &wrapper) == nil { |
| 210 | for scope, score := range wrapper.PriorityOverrides { |
| 211 | m[scope] = score |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | cachedScopePriorities = m |
| 217 | return cachedScopePriorities |
| 218 | } |
| 219 | |
| 220 | // LoadAutoApproveSet returns the set of auto-approve scope names. |
| 221 | // Sources (merged): recommend=="true" in scope_priorities.json |