← Model losses

Head-to-head comparison

xai / grok-4.7-efficient / high / high 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

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.

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`.

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

**Conclusion:** The snapshot does not establish a frontend-to-backend filtering or matching parity defect. The supplied frontend hook fetches review-pack enrichment, not an inspection-filter request, so it provides no evidence about how filter parameters are sent. The backend pipeline does show a concrete boundary risk: if `viewport_bbox` permits `min_lon > max_lon` (or `min_lat > max_lat`), its inclusive lower-and-upper-bound predicates cannot match any centroid (pipeline lines 180–189). Whether such bounds are rejected earlier is unknown because the filter-spec schema is outside the packet.

**Recommendation:** Validate bbox ordering when constructing the filter spec, or normalize/explicitly support antimeridian-crossing longitude ranges if those are intended. Add boundary tests for equal bounds, reversed longitude and latitude bounds, and points exactly on each inclusive edge. Also test combined bbox and asset-type filters to confirm both narrow the result set.

**Alternative / uncertainty:** Empty `asset_id_in` is explicitly handled as match-none (lines 144–150), and nullable centroids are explicitly excluded when bbox filtering (lines 184–185); neither alone demonstrates unintended behavior. `inspection_match.py` compares UTC date/time and uses NULL-safe direction matching, but it is import deduplication logic, not the inspection-filter request path. The frontend request construction, bbox validation, and relevant dependencies are not present, so end-to-end parity cannot be confirmed.

**Next useful action:** Inspect the schema/route that parses `viewport_bbox` and the frontend code that builds `/inspections/query` requests; verify reversed-range handling and add request-to-SQL regression coverage.

Primary judge's stated reason

Forced weak preference for A: its independently supported operator mismatch gives a concrete regression target and minimal correction that directly advance the requested data-integrity investigation. This is not an established material quality gap, given A's incorrect secondary finding and unsupported certainty about downstream insertion. An independent review could reasonably prioritize B's restraint instead.

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_c3d9b5d3991edccf565722bc0d4ca2ab547535fb0c8d8b74efd67657db576fb8. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.