← Model losses

Head-to-head comparison

openai / gpt-6-luna / xhigh / xhigh effort preferred over xai / grok-4.7-efficient / high / high effort · clear 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

Trace inspection filtering and matching from frontend request through backend predicate construction. Identify a concrete parity or data-integrity risk (including nulls, ranges, or combined filters) where the visible result set can diverge from intended semantics; show the precise path and propose a minimal correction and boundary regression cases.

openai / gpt-6-luna / xhigh / xhigh effort answer

## Evidence packet

**Conclusion — concrete matching parity defect.** In `inspection_match.py`, the Python mirror treats whitespace-only `performed_by` as missing: `normalize_operator()` calls `.strip()` and returns `None` for an empty result (lines 48–55), and `matches_row()` accepts a row when its normalized operator is `None` (lines 129–134). The SQL predicate does not: it accepts only `NULL`, the exact empty string, a missing candidate operator, or a case-insensitive trimmed equality (lines 243–249). For a stored value of `'   '` and candidate operator `"Alice"`, Python matches but SQL rejects. This contradicts the stated 1:1 parity at lines 99–107.

**Risk and path.** The batch path uses `matches_row()` to filter bulk-probe results and deduplicate incoming records (lines 99–103); the sequential path uses `find_existing_inspection()`’s SQL predicate (lines 167–177, 215–263). Thus the same inspection can match in the batch path but fail to match in the sequential path. If the failed match leads to a new insert, it can create a duplicate inspection and diverge in visible results. That final persistence/display consequence depends on callers not included in the packet.

**Filtering trace.** The supplied frontend hook requests `/inspections/{id}/review-boot` and, when a review pack exists, `/review-pack/{id}/inspection.json` (`useInspectionData.ts`, lines 17–29 and 74–91). It does not show a grid-filter request or construction of an `InspectionFilterSpec`, so the frontend-to-filter-spec mapping cannot be established from this snapshot. The backend pipeline applies tenant/archive predicates, project and asset restrictions, saved and observation filters, transient NL filters, search, and then viewport bounds (`inspection_filter_pipeline.py`, lines 129–190). Viewport filtering requires non-null centroids and uses inclusive min/max bounds. No defect in those bounds is established by the supplied code.

**Minimal correction and regression cases.** Make SQL treat a trimmed-empty stored operator as missing, e.g. add `NULLIF(BTRIM(performed_by), '') IS NULL` to the missing-operator branch. This fixes the demonstrated spaces-only case. PostgreSQL’s default `BTRIM` does not necessarily match Python’s broader `str.strip()` behavior for tabs or Unicode whitespace; either align that normalization contract or test and handle those characters explicitly.

Add a differential regression test comparing SQL and `matches_row()` for candidate `"Alice"` against stored `NULL`, `''`, `'   '`, `'alice'`, and `'[REDACTED: person name]'`; also test a whitespace-only candidate. For the separate time predicate, retain boundary cases where either side is UTC midnight (accepted) versus two different non-midnight times on the same UTC date (rejected).

**Uncertainty / next useful action.** The filter schema, inspection router, filter compiler, frontend client, and `inspection_match` callers are outside the packet; their behavior and the final route from a failed match to a displayed duplicate are unverified. The next useful check is a SQL-vs-Python differential test for operator normalization, followed by checking the caller behavior on a SQL miss.

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

The sequential SQL match and the Python mirror disagree on whitespace-only operators, so the same inspection can merge on one path and insert a duplicate on the other. The supplied frontend hook never builds a filter or match predicate.

**Conclusion.** `find_existing_inspection` and `InspectionKeys.matches_row` are documented as the same strict match, but a stored `performed_by` of only spaces is missing in Python and present in SQL. Confidence is high: both predicates and the intended rule are in `inspection_match.py`.

Intended rule: operator agrees case- and whitespace-insensitively, or is missing on either side. `normalize_operator` (lines 48–55) defines missing as null, `''`, or whitespace-only after `strip()`, and the comment says that definition was extracted so the bulk and sequential paths cannot drift. `matches_row` (lines 129–134) uses it: if the row operator normalizes to `None`, it returns `True`.

The sequential predicate does not:

```244:249:[REDACTED: private project name]/backend/app/services/inspection_match.py
AND (
      performed_by IS NULL
      OR performed_by = ''
      OR CAST(:op AS text) IS NULL
      OR LOWER(TRIM(performed_by)) = LOWER(TRIM(CAST(:op AS text)))
    )
```

Incoming operator is normalized before bind (line 213), so a whitespace-only *request* becomes NULL and both sides accept. The column side is not normalized. `performed_by = '   '` fails `IS NULL` and `= ''`. `TRIM` yields `''`, which is not equal to a real operator, so SQL returns no row. `matches_row` treats that column as missing and accepts.

Trigger: same `municipality_id`, `project_id`, `asset_id`, UTC date, and `camera_direction`; `deleted_at` null; stored `performed_by = '   '`; incoming operator `'Alice'`. Sequential path returns `None` and inserts another canonical row. Chunk filtering and in-chunk dedup via `matches_row` treat them as one inspection. Visible identity of the inspection set then depends on which path ran.

Minimal correction: treat trimmed-empty `performed_by` as missing, matching `normalize_operator` for ordinary spaces (the equality branch already uses `TRIM`):

```sql
AND (
      performed_by IS NULL
      OR TRIM(performed_by) = ''
      OR CAST(:op AS text) IS NULL
      OR LOWER(TRIM(performed_by)) = LOWER(TRIM(CAST(:op AS text)))
    )
```

Boundary cases (both paths must agree):

- `'   '` vs `'Alice'` → match (fails today in SQL only)
- `'   '` vs null → match
- `''` vs `'Alice'` → match
- null vs `'Alice'` → match
- `'Alice'` vs `'  alice  '` → match
- `'Alice'` vs `'[REDACTED: person name]'` → no match
- `'Alice'` vs null → match
- `'\tAlice'` vs `'Alice'` → still diverges after the minimal fix: Python `strip()` removes tabs and other Unicode whitespace; PostgreSQL `TRIM` removes only U+0020 spaces

**Filter path (separate, same packet).** `useInspectionData.ts` only loads review-boot and `inspection.json`. It does not send `InspectionFilterSpec`. Predicate construction is `apply_inspection_filters`. A second result-set footgun is in that function, not on a frontend request: empty `asset_id_in` is forced to `sa_false()` because the same file says `in_([])` silently drops the clause (lines 144–150), but empty `asset_type_ids` is passed straight to `Asset.asset_type_id.in_(...)` (lines 141–142). An empty type list therefore drops the type constraint and returns every inspection allowed by the other predicates, instead of none. Guard it the same way as `asset_id_in`. Viewport bounds are inclusive and reject null centroids; an inverted or antimeridian box (`min_lon > max_lon`) is unsatisfiable. Whether callers can send that box is outside this packet.

**Alternatives discarded.** Direction null-safety in the sequential SQL (`IS NOT DISTINCT FROM`) matches Python `!=` for `None`. The hazard is only if `hard_key` (which includes nullable `direction`) is later used in SQL tuple `IN`, where `NULL = NULL` is unknown. That caller is not in the packet. `inspection_type_id` omitted from the key is documented intent, not drift. Naive `astimezone(timezone.utc)` versus `parse_inspection_datetime`’s `replace(tzinfo=UTC)` can shift the date, but only if a naive value reaches `inspection_candidate_keys` / `matches_row`; those callers are outside the packet. `project_id` winning over `in_project` is explicit `if/elif`, not an accidental widen. Review-pack trim checks in the hook are consistent with each other and are not filter predicates.

**Missing evidence.** `InspectionFilterSpec`, the `/inspections/query` router, the bulk `hard_key` probe, and the SQLAlchemy version are outside the packet. Consequence: empty `asset_type_ids` is a definite clause-drop if `[]` reaches `apply_inspection_filters`, but this snapshot cannot show that the API accepts `[]`. The operator divergence does not depend on those files.

**Next action.** Add one differential case, stored `performed_by = '   '` against incoming `'Alice'`, asserting `find_existing_inspection` and `matches_row` both match; then change the SQL empty check to `TRIM(performed_by) = ''`. Separately, mirror the `asset_id_in` empty-list `sa_false()` guard for `asset_type_ids`.

Primary judge's stated reason

A is preferable because its actionable finding stays within the demonstrated predicate behavior and preserves uncertainty about displayed duplicates. B's unsupported additional defect could direct unnecessary corrective work and encode an incorrect understanding of empty-list filtering. This is a clear evidence-discipline advantage, not merely a forced slight preference; both nevertheless deliver the principal valid finding.

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

Battle wave: 1a629e2d-f9fa-4128-8962-e007165c19b0. Pair: brp1_ce2560d54f4ad7144a2711d516cb09d2a00c6042c1148528ee3bc01ef7126f60. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.