When implementing or choosing an algorithm (scoring, aggregation, throttling, parsing), ensure it matches the domain semantics and behaves predictably under edge cases.

Guidelines:

Example (semantic routing aggregation):

-- Scores are for alternative examples of the same intent.
-- Semantics: “any example matches => route succeeds”, so aggregate by max.
local function semantic_pick(scores, threshold)
    local best = -math.huge
    for _, s in ipairs(scores) do
        if s > best then best = s end
    end
    if best >= threshold then
        return true
    end
    return false
end

Apply this standard whenever you change scoring/routing/throttling/parsing logic, especially for user-visible behavior where “almost right” algorithms cause silent misroutes or inconsistent rate-limit outcomes.