← Model losses

Head-to-head comparison

xai / grok-4.7-efficient / xhigh / xhigh effort preferred over xai / grok-4.7-efficient / high / high effort · close win.

Primary judge: Sol 6.1, requested Low. Effective provider effort and internal attempts were not verified. A close win is still a scored preference; it does not establish a material defect.

Reviewed public evidence

Task goal

Design a pure utility converting nonnegative integer milliseconds into human-readable durations for a monitoring UI. Requirements: deterministic locale-neutral formatting, round-to-nearest-second ties upward, correct carries, day/hour/minute/second boundaries, maximum safe integer input, explicit invalid input handling, compact and expanded modes, and no calendar/timezone/date interpretation. Provide contracts and boundary examples.

Give one coherent design with explicit requirements, assumptions and alternatives, state/invariant/transaction details appropriate to the stated scope, and measurable pass/fail acceptance checks. Do not invent benchmark measurements, provider costs, source inspection, executed tests or objective passes. Every contributor must independently answer the complete identical question; there are no separate roles, files or tool evidence.

xai / grok-4.7-efficient / xhigh / xhigh effort answer

## 1. Design

Adopt one pure, total function, `formatDuration(value, mode) -> Result`, as the monitoring-UI duration contract. It converts a nonnegative integer millisecond count into a deterministic, locale-neutral day/hour/minute/second string, or a closed error. It does not consult a clock, calendar, timezone, or locale.

**Normative requirements**

- Input is a mathematical integer in `0 .. 9007199254740991` (`2^53−1`). That ceiling is the shared maximum even if the host has wider integers, so ports stay identical.
- Invalid input never yields a duration string and is never clamped, coerced, or replaced with a placeholder.
- Round to nearest second; ties round upward. For valid `ms`: `q = ms div 1000`, `r = ms mod 1000`, `roundedSeconds = q + 1` if `r >= 500`, else `q`. Do not compute `(ms + 500) / 1000` in binary64: `MAX + 500` is not a safe integer.
- Fixed ratios only: `60 s = 1 m`, `60 m = 1 h`, `24 h = 1 d` (`86400` SI seconds). No leap seconds, DST, weeks, months, or years.
- After rounding, decompose with integer `div`/`mod` so hours are `0..23`, minutes `0..59`, seconds `0..59`, and only days may be unbounded within the safe ceiling. Carries are a consequence of decomposition, not a second pass that can emit `60s`.
- Modes are exactly `compact` and `expanded`. No default.
- Locale-neutral ASCII only. No grouping separators, no translated units, no `Intl` duration formatting.
- Zero-valued units are omitted. The only zero forms are `0s` and `0 seconds`.
- Same `(ms, mode)` always returns the same bytes. No mutable configuration.

**Result contract**

```text
formatDuration(value, mode) ->
  { ok: true, text } | { ok: false, error }

error.code:
  invalid-type      // null, bool, object, numeric string, missing
  not-an-integer    // fractional, NaN
  negative          // < 0, including distinguishable -0
  exceeds-maximum   // > 9007199254740991, or non-finite +Infinity
  invalid-mode      // anything other than compact | expanded
```

Success and error are mutually exclusive. The call is atomic: no partial string and no observable intermediate state. There is no transaction because there is no state to commit. Purity implies concurrent calls do not interfere.

**Formatting grammar**

- Numbers: base-10 ASCII digits, no sign, no leading zeros except the zero duration.
- Compact suffixes are glued to the number: `d`, `h`, `m`, `s`. Expanded words are separated from the number by one space and are singular iff the count is exactly 1: `day`/`days`, `hour`/`hours`, `minute`/`minutes`, `second`/`seconds`.
- Present units appear only in descending order, joined by one U+0020. No comma, “and”, trailing space, or padding.
- Recomposition invariant: `86400*d + 3600*h + 60*m + s = roundedSeconds`.

**Boundary examples (specified, not executed)**

| ms | rounded s | compact | expanded |
|---|---|---|---|
| 0, 1, 499 | 0 | `0s` | `0 seconds` |
| 500, 1499 | 1 | `1s` | `1 second` |
| 1500 | 2 | `2s` | `2 seconds` |
| 59499 | 59 | `59s` | `59 seconds` |
| 59500, 59999, 60499 | 60 | `1m` | `1 minute` |
| 60500 | 61 | `1m 1s` | `1 minute 1 second` |
| 90000 | 90 | `1m 30s` | `1 minute 30 seconds` |
| 3599499 | 3599 | `59m 59s` | `59 minutes 59 seconds` |
| 3599500 | 3600 | `1h` | `1 hour` |
| 3661500 | 3662 | `1h 1m 2s` | `1 hour 1 minute 2 seconds` |
| 86399499 | 86399 | `23h 59m 59s` | `23 hours 59 minutes 59 seconds` |
| 86399500, 86399999, 86400000 | 86400 | `1d` | `1 day` |
| 172799499 | 172799 | `1d 23h 59m 59s` | `1 day 23 hours 59 minutes 59 seconds` |
| 172799500 | 172800 | `2d` | `2 days` |
| 9007199254740991 | 9007199254741 | `104249991d 8h 59m 1s` | `104249991 days 8 hours 59 minutes 1 second` |

Ceiling check: `9007199254740991 = 9007199254740*1000 + 991`, so the tie rule adds one second. `104249991*86400 + 32341 = 9007199254741`, and `32341 = 8*3600 + 59*60 + 1`.

Invalid examples: `-1` and `-0` → `negative`; `1.5` and `NaN` → `not-an-integer`; `"500"`, `null`, `true` → `invalid-type`; `9007199254740992` and `+Infinity` → `exceeds-maximum`; mode `short` → `invalid-mode`.

**Assumptions**

- Integer type only. Integral floats such as `500.0` are rejected so telemetry type bugs stay visible.
- JSON numbers above `2^53−1` may already be corrupted before this function runs. Repair is out of scope; large ingest must use a string or arbitrary-precision integer.
- Omitting zero units is the monitoring default. `1m` means 60 rounded seconds, not “about one minute.”
- A `Result` is preferred. A language may throw the same closed codes, but must not return a fallback string.
- No sub-second display mode in v1.

**Invariants**

- I1. Hours, if shown, are `1..23`; minutes and seconds, if shown, are `1..59`; days, if shown, are `>= 1`.
- I2. Equal rounded-second counts produce identical text for the same mode.
- I3. Output is ASCII and contains neither grouping marks nor a zero component unless the whole value rounded to 0.
- I4. Implementation must not read locale, timezone, or current time.

**Pass/fail checks (criteria only; not run)**

- Fail if `499` renders as one second, or `500`/`1500`/`59500`/`3599500`/`86399500` fail to round up and carry.
- Fail if any success string contains `60s`, `60m`, `24h`, a zero unit beside a nonzero unit, a leading/double/trailing space, a comma, or a grouping separator.
- Fail if `3661500` is not exactly `1h 1m 2s` / `1 hour 1 minute 2 seconds`.
- Fail if `9007199254740991` is not exactly the ceiling strings above, or if recomposition does not equal `9007199254741`.
- Fail if any invalid example returns `ok: true`, or if two calls with the same valid input differ.
- Fail if labels are localized or if `1` uses a plural word.

Confidence is high on rounding, carry, and the safe-integer ceiling, and moderate on the omitted-zero presentation choice, which is an explicit assumption rather than a requirement.

## 2. Alternatives discarded

- Ties-to-even, truncation, or displaying `60s` before carry: contradicts the tie and carry requirements.
- `Intl` duration formatters or localized plurals: not locale-neutral or deterministic.
- Calendar units, weeks, or DST-aware days: forbidden date interpretation. A week unit would also be a breaking grammar change.
- Fixed-width `0d 0h 0m 0s`, always-trailing `1m 0s`, or largest-unit-only text: either noisy or lossy for a monitoring UI.
- Clamping overflow to the max string, or coercing numeric strings: hides bad telemetry. `"1e3"` and padded strings are parser-dependent.
- Unspaced compact `1d2h3m4s`: harder to scan; not needed for v1.
- Float `(ms+500)/1000`: incorrect near `2^53−1`.

## 3. Missing evidence

No language, existing formatter, or UI sample was supplied. Consequence: the math and error taxonomy can be implemented as specified, but space-separated compact text and `Result` versus typed throws may need a later compatibility pass if a host convention already exists. JSON ingest of large durations is an upstream dependency this function cannot correct.

## 4. Next useful action

Lock this grammar and error enum as the implementation spec, then implement `div`/`mod` rounding in the chosen integer type and check each boundary row by recomposition rather than by float division.

xai / grok-4.7-efficient / high / high effort answer

## 1. Design

Pure, total function. No clock, locale, timezone, calendar, or mutable state. A day is exactly 86400 SI seconds. Round once to a whole second, then split. Do not format invalid input.

**Domain.** `ms` must be an exact integer in `0 … 9007199254740991` (`2^53−1`). `mode` must be exactly `compact` or `expanded` (case-sensitive; no locale casefold). `-0` is valid and identical to `0`. No coercion of strings, booleans, `null`, or non-integral numbers. Integers above the max are rejected even if the host can represent them exactly.

**Result (all-or-nothing).** Success is `{ ok: true, text }` with a canonical ASCII string. Failure is `{ ok: false, reason }` and has no renderable duration. Reasons, in this priority: `invalid_mode`, then `negative`, then `above_max_safe_integer`, then `not_integer`. One reason only. No throw on the documented invalid set.

**Rounding (ties upward).** Exact integer division, not float add:

- `q = ms div 1000`, `r = ms mod 1000`
- `totalSeconds = q + 1` if `r >= 500`, else `q`

That is round-half-up for nonnegative values: `…499 →` lower second, `…500 →` next second. Do not use `floor((ms+500)/1000)`: for `ms >= 9007199254740492`, `ms+500` is outside the safe-integer range. Do not use banker’s rounding. Do not round per unit.

**Split (fixed units, carries by construction).**

- `seconds = totalSeconds mod 60`
- `minutes = (totalSeconds div 60) mod 60`
- `hours = (totalSeconds div 3600) mod 24`
- `days = totalSeconds div 86400`

Postcondition: `totalSeconds = days*86400 + hours*3600 + minutes*60 + seconds`, with `seconds, minutes ∈ 0..59`, `hours ∈ 0..23`, `days >= 0`. A displayed field never holds 60 or 24. No weeks, months, years, leap seconds, or DST.

**Format (locale-neutral).** Digits are ungrouped ASCII. Tokens are `d` `h` `m` `s` only, order fixed, single spaces, no sign, no padding, no colon clock form.

- Compact: nonzero units only. All-zero is exactly `0s`. Never empty.
- Expanded: always four units, zeros kept (`0d 0h 0m 0s`).

Same `(days, hours, minutes, seconds)` in both modes. Strings match only when all four units are nonzero; mode is not string identity.

**Invariants.** Referentially transparent; no shared state; concurrent calls cannot interfere. Output ignores process locale and timezone. Sub-second residue affects output only through the one rounding step. Success text length is at least 2. Failure never produces a duration string. Rounded seconds are a non-decreasing step function of `ms`: `0` for `0..499`; for `n >= 1`, `n` for `ms` in `[1000*(n-1)+500, 1000*n+499]`, truncated at the max. Each full bucket has 1000 values; the zero bucket has 500 because negatives are rejected.

**Boundary examples (contract fixtures, not executed results).**

| ms | seconds | compact | expanded |
|---:|---:|---|---|
| 0, 499 | 0 | `0s` | `0d 0h 0m 0s` |
| 500, 999, 1000, 1499 | 1 | `1s` | `0d 0h 0m 1s` |
| 1500 | 2 | `2s` | `0d 0h 0m 2s` |
| 59499 | 59 | `59s` | `0d 0h 0m 59s` |
| 59500, 59999, 60000 | 60 | `1m` | `0d 0h 1m 0s` |
| 3599499 | 3599 | `59m 59s` | `0d 0h 59m 59s` |
| 3599500, 3600000 | 3600 | `1h` | `0d 1h 0m 0s` |
| 86399499 | 86399 | `23h 59m 59s` | `0d 23h 59m 59s` |
| 86399500, 86400000 | 86400 | `1d` | `1d 0h 0m 0s` |
| 172799499 | 172799 | `1d 23h 59m 59s` | `1d 23h 59m 59s` |
| 172799500 | 172800 | `2d` | `2d 0h 0m 0s` |
| 90061000 | 90061 | `1d 1h 1m 1s` | `1d 1h 1m 1s` |
| 9007199254740499 | 9007199254740 | `104249991d 8h 59m` | `104249991d 8h 59m 0s` |
| 9007199254740500 and 9007199254740991 | 9007199254741 | `104249991d 8h 59m 1s` | `104249991d 8h 59m 1s` |

Invalid: `-1` and `-500` → `negative` (no rounding); `1.5`, `NaN`, `Infinity`, `"1000"`, `null`, `true` → `not_integer`; `9007199254740992` → `above_max_safe_integer`; `Compact`, `""` → `invalid_mode`.

**Pass/fail checks (criteria only).** (1) Fixture table matches exactly, both modes. (2) Repeat call is deep-equal. (3) For `k ∈ {0, 59, 3599, 86399, 9007199254740}`, `1000*k+499 → k` and `1000*k+500 → k+1`, then the split bounds hold. (4) Reconstruction identity on every fixture. (5) Compact grammar `0s` or ordered nonzero tokens; expanded always four canonical tokens. (6) Invalid set returns the stated reason and no duration text. (7) Implementation does not read locale, TZ, or `Date`. (8) Top-domain pair above: tie neighbor and max share one string; `…499` differs by one second and shows `0s` only in expanded.

Confidence: high on rounding, carry, and the safe-integer bound; medium on symbolic rather than prose expanded text, because no UI copy spec was supplied.

## 2. Alternatives discarded

- Half-to-even, floor, or always-ceil: violate nearest-with-ties-upward.
- `ms+500` before divide: overflows the required domain.
- Per-unit rounding: can double-carry.
- Weeks/months, `Date`, or locale duration formatters: calendar or locale dependence.
- English plurals (`1 second` / `2 seconds`): deterministic if frozen, but not strictly locale-neutral. Acceptable only as a separate presentation adapter over the same numeric tuple, not as a second algorithm.
- Compact that keeps only the top two units, or `<1s` for sub-second: loses the rounded exact value.
- Clock padding or colons: look like civil time.
- Throw-by-default: can take down a monitoring render. A throwing wrapper may sit outside this contract.
- Jammed tokens (`1d2h`): legal alternate spelling; spaced tokens are the canonical form so parsers have one grammar.

## 3. Missing evidence

No host language, existing module, or UI copy guide was supplied. Consequence: the numeric contract can be implemented as specified; the symbolic expanded form is an assumption. If product chrome requires English words, that adapter must not change rounding or carries. IEEE `div 1000` is the required formula; this packet does not claim an exhaustive float proof or a test run.

## 4. Next useful action

Implement `round → split → render` against the fixture table and the eight checks above in the host language, using exact integer div/mod, and treat any mismatch as a contract failure rather than a display tweak.

Primary judge's stated reason

B weakly reduces ambiguity when implementing one invalid-input case. This is a forced, slight preference, not an established material quality difference; A's stronger precedence specification and boundary coverage are substantial counterweights. An independent review could reasonably reject this weighting.

This reason is the judge's assessment. No independent factual-defect finding is asserted by this record.

Battle wave: 585c0981-9fac-4115-8abf-75261811b5a0. Pair: brp1_60bf267cafb024d14a38066dab1b4e7bdafca02834b5dd886df7c88d914da1de. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.