Awesome Reviewers

When implementing algorithmic transformations that clients depend on (especially split/partition functions and any logic that rebuilds/serializes structured strings), treat semantics as a stable API: explicitly define and document the contract (edge cases, limits, nil/empty handling, delimiter rules), and guarantee deterministic output by not relying on non-deterministic table iteration.

Practical rules:

Example (deterministic query rebuild while avoiding pairs ordering issues):

local function rebuild_query_in_order(kv)
  local keys = {}
  for k in pairs(kv) do
    keys[#keys+1] = k
  end
  table.sort(keys)

  local parts = {}
  for i = 1, #keys do
    local k = keys[i]
    local v = kv[k]
    -- If kv[k] can have repeated values, encode accordingly; otherwise keep single.
    parts[#parts+1] = k .. "=" .. v
  end
  return table.concat(parts, "&")
end