xai / grok-4.7-efficient / medium / medium effort preferred over openai / gpt-6-luna / low / low 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 / medium / medium effort answer
The utility should be a total, pure function that validates a nonnegative safe integer millisecond count, rounds once to the nearest second with ties upward, decomposes that second count with fixed 60/60/24 carries, and formats only days, hours, minutes, and seconds.
## Conclusion
Define `formatDurationMs(ms, mode) -> { ok: true, value: string } | { ok: false, code }`. It must not throw, coerce, read the clock, consult locale, or construct a date. `mode` is required and is exactly `compact` or `expanded`. The safe-integer ceiling is `MAX = 2^53 - 1 = 9007199254740991`, even on hosts with wider integers.
Validation order is fixed: `invalid_mode`, `invalid_type`, `non_finite`, `non_integer`, `negative`, then `exceeds_max_safe_integer`. Booleans, strings, null, and objects are `invalid_type`; do not call `valueOf`. `NaN` and infinities are `non_finite`. Fractional values, including negative fractions, are `non_integer`. `-0` is valid zero because it is not `< 0`. Integer-typed values and exact integer floats inside `[0, MAX]` are valid; numeric strings are not.
For a valid `ms`, use truncating division, not `ms + 500`, so the largest input cannot overflow:
- `q = ms // 1000`, `r = ms % 1000`, with `r` in `0..999`
- `totalSeconds = q + 1` when `r >= 500`, otherwise `q`
- `days = totalSeconds // 86400`; remainder decomposes by `3600` and `60`
- Invariant: `days >= 0`, `0 <= hours <= 23`, `0 <= minutes,seconds <= 59`
A day is exactly `86400` elapsed seconds, never a civil or DST day. Rounding happens once before decomposition, so a tie can carry across seconds, minutes, hours, and days together. The maximum valid result is `9007199254741` seconds, which is `104249991` days, `8` hours, `59` minutes, and `1` second. That arithmetic fits exactly inside the safe-integer range.
Both modes omit zero units, use ASCII digits without grouping separators, and separate units with one U+0020 space. Compact uses `d`, `h`, `m`, and `s` with no space before the suffix. Expanded uses fixed English `day/days`, `hour/hours`, `minute/minutes`, and `second/seconds`, singular only when the count is `1`. Zero is `0s` or `0 seconds`. There is no trailing space and no comma. Compact and expanded must encode the same components. The mapping is not reversible to the original milliseconds. Logical length bounds are at most 22 characters compact and 45 expanded. There is no mutable state, I/O, or transaction; validate, round, decompose, and format are one pure computation, and failure yields only an error code.
Hand-derived acceptance checks, not executed tests:
| Input | Required result |
|---|---|
| `0`, `1`, `499`, `-0` | `0s` / `0 seconds` |
| `500`, `999`, `1000`, `1499` | `1s` / `1 second` |
| `1500` | `2s` / `2 seconds` |
| `59499` | `59s` / `59 seconds` |
| `59500` | `1m` / `1 minute` |
| `3599499` | `59m 59s` / `59 minutes 59 seconds` |
| `3599500` | `1h` / `1 hour` |
| `86399499` | `23h 59m 59s` / `23 hours 59 minutes 59 seconds` |
| `86399500`, `86400000` | `1d` / `1 day` |
| `86400500` | `1d 1s` / `1 day 1 second` |
| `90061000` | `1d 1h 1m 1s` / `1 day 1 hour 1 minute 1 second` |
| `120000` | `2m` / `2 minutes` |
| `9007199254740991` | `104249991d 8h 59m 1s` / `104249991 days 8 hours 59 minutes 1 second` |
| `-1` | `negative` |
| `-1.5`, `1.5` | `non_integer` |
| `NaN`, `Infinity` | `non_finite` |
| `"1000"`, `true`, `null` | `invalid_type` |
| `9007199254740992` | `exceeds_max_safe_integer` |
| mode `short` | `invalid_mode` |
Pass means every row matches and every valid pair of modes agrees after label normalization. Any clamping, half-to-even tie break, per-unit rounding, locale separator, week/month/year unit, or date/timezone conversion is a fail.
## Alternatives
Half-to-even would send `500` to `0` and fails the tie rule. Always ceiling would send `1` to `1s` and is not nearest-second rounding. Rounding each unit separately can double-carry and was discarded. Weeks were excluded because the required units stop at days. Always rendering zero units, prose commas, and `Intl` labels were discarded in favor of deterministic ASCII. A throwing API is workable but worse for a UI data path; clamping negatives would hide clock skew and was rejected.
## Missing evidence
No host language, existing helper, or UI copy guide was supplied. The numeric contract is portable, but the concrete type and module placement remain conditional. English expanded words are a fixed contract choice, not evidence of a product decision.
## Next useful action
Pin this contract and the boundary table as the specification, then implement the function and its checks against that table without adding calendar or locale dependencies.openai / gpt-6-luna / low / low effort answer
## Recommended design
Provide a pure function with explicit input validation and two output modes:
```text
formatDuration(milliseconds, mode = "compact") -> string
```
**Contract and assumptions**
- Accept only nonnegative safe integers (`0` through `Number.MAX_SAFE_INTEGER`). Reject other values, including fractions, negatives, `NaN`, infinities, strings, and unsafe integers, with a documented `RangeError` or equivalent.
- Round to the nearest second, with exact half-second ties upward, before decomposing into units. For nonnegative inputs, use `floor((milliseconds + 500) / 1000)`, taking care that the intermediate addition does not exceed the exact integer range. An alternative is quotient/remainder rounding, which avoids that intermediate overflow.
- Decompose total seconds into days, hours, minutes, and seconds using fixed units: 86,400; 3,600; and 60 seconds. Do not use dates, calendars, or timezones.
- Make formatting locale-neutral: fixed unit labels, numeric digits, spacing, and ordering; no locale APIs.
- Compact mode emits nonzero units with short labels, such as `1d 2h 3m 4s`. Expanded mode emits nonzero units with full labels and fixed pluralization, such as `1 day, 2 hours, 3 minutes, 4 seconds`. Specify zero behavior explicitly: recommend `0s` and `0 seconds` when the rounded duration is zero. Omit zero-valued units otherwise.
- Reject unsupported modes explicitly rather than silently selecting one.
The operation is stateless and has no transaction or mutable-state requirements. Its key invariant is that after rounding, the emitted units represent exactly the rounded total seconds, with each subordinate unit below its radix (hours < 24, minutes < 60, seconds < 60). Carrying follows naturally from quotient/remainder decomposition.
## Boundary examples
- `0 ms` → `0s` / `0 seconds`
- `499 ms` → `0s` / `0 seconds`
- `500 ms` → `1s` / `1 second`
- `59,499 ms` → `59s` / `59 seconds`
- `59,500 ms` → `1m` / `1 minute`
- `3,599,500 ms` → `1h` / `1 hour`
- `86,399,500 ms` → `1d` / `1 day`
- `Number.MAX_SAFE_INTEGER` is accepted and formatted by the same fixed-unit decomposition.
## Acceptance checks
Pass if tests establish that: valid safe-integer inputs return deterministic strings in both modes; locale changes do not affect output; all listed rounding ties and unit carries behave as specified; zero and pluralization follow the contract; invalid inputs and invalid modes fail explicitly; and the maximum safe integer is handled without precision loss. Also verify decomposition by parsing or independently recomputing units and confirming they reconstruct the rounded second count. No implementation or test execution is claimed here.
## Alternatives and dependencies
A design could retain zero-valued intermediate units (for example, `1h 0m 2s`) or use different labels, but that should be a deliberate documented contract; omitting them is more compact. The task does not specify exact labels, exception type, or zero-unit policy, so these are design choices rather than established requirements. No source evidence or execution results were supplied; implementation-specific conclusions remain unverified.
Primary judge's stated reason
B is the weak, forced preference because its concrete maximum-input result and explicit validation outcomes can be translated into acceptance checks with fewer unresolved details. The designs are substantially equivalent; this is not a proven material quality gap, and an independent review could reasonably reject the preference.
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_0bdc8976aaa4ca32e88d0ef40e00451659b287bfdca78c359975d229ff2769ba. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.