← Model losses

Head-to-head comparison

openai / gpt-6.1-sol / high / high effort preferred over openai / gpt-6.1-sol / 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.

openai / gpt-6.1-sol / high / high effort answer

## Finding: whitespace-only operators break matching parity

**High confidence; independently assessed from the supplied snapshot.** The Python matcher accepts an existing inspection whose operator is spaces-only, but the SQL matcher rejects it when the incoming operator is named.

In `[REDACTED: private project name]/backend/app/services/inspection_match.py`:

- `normalize_operator()` strips whitespace and converts an empty result to `None` (lines 48–55).
- `InspectionKeys.matches_row()` accepts a match when either normalized operator is missing (lines 129–134).
- `find_existing_inspection()` normalizes the incoming operator, but its SQL considers the stored operator missing only when it is `NULL` or exactly `''` (lines 213, 244–249).

**Reproducible trigger:** use identical municipality, project, asset, UTC timestamp and direction; stored `performed_by = '   '`; incoming operator `'Alice'`.

| Path | Result |
|---|---|
| Python `matches_row()` | `True`: stored operator normalizes to `None`. |
| SQL `find_existing_inspection()` | No match: spaces are neither `NULL` nor `''`, and `LOWER(TRIM('   ')) != 'alice'`. |

The reverse ordering accepts the match: incoming spaces normalize to `None`, satisfying SQL’s `:op IS NULL` branch. Thus record order and sequential-versus-batched matching can change the matching result. A caller that inserts after a miss could produce duplicate canonical inspections, affecting displayed rows and counts; that insertion/display linkage is **not established by this packet**.

## Request-to-predicate trace—and its limit

`[REDACTED: private project name]/frontend/src/hooks/useInspectionData.ts` does **not** issue an inspection-filter request. It fetches:

1. `/inspections/{id}/review-boot`, enabled only for positive IDs (lines 17–29).
2. `/review-pack/{id}/inspection.json`, gated by a fetched boot payload and nonempty trimmed pack path (lines 74–90).

Consequently, this snapshot cannot establish how frontend filter controls become `InspectionFilterSpec`.

Once a spec reaches `apply_inspection_filters()` in `[REDACTED: private project name]/backend/app/services/inspection_filter_pipeline.py`, predicates are composed in this order:

- Tenant scope and archival filtering (line 130).
- Project filtering: explicit `project_id` takes precedence over `in_project` (lines 133–138).
- Asset types and asset IDs; an empty asset-ID list explicitly matches nothing (lines 141–150).
- Saved filters, observation-parent filters, then transient NL conditions (lines 155–175).
- Search (line 178).
- Viewport: non-null coordinates and inclusive longitude/latitude bounds (lines 181–190).

Successive `.where()` calls intersect these dimensions. The internal semantics of the imported compilers and parent-filter helper remain outside the packet.

## Smallest correction and regression cases

For the demonstrated spaces-only defect, replace SQL’s:

```sql
OR performed_by = ''
```

with:

```sql
OR TRIM(performed_by) = ''
```

Keep the existing `performed_by IS NULL` branch.

Add SQL-versus-Python differential tests, holding all other keys equal:

- Stored operator `NULL`, `''`, and `'   '` against `'Alice'`: all match.
- Reverse each pair: all match.
- `' Alice '` against `'alice'`: match.
- `'Alice'` against `'[REDACTED: person name]'`: no match.
- Repeat the whitespace case with both directions `NULL`, midnight/non-midnight timestamps, and unequal non-midnight timestamps; operator normalization must not bypass direction or time restrictions.

**Remaining boundary:** Python `.strip()` also removes tabs, newlines and other whitespace; PostgreSQL’s default `TRIM()` removes spaces. Test these explicitly. Full whitespace parity requires the SQL and Python paths to use the same normalization definition; the minimal patch above fixes only the demonstrated space case.

## Uncertainty and next action

No frontend-to-filter transport, schema validation, compiler internals, bulk-probe implementation or insert-on-miss caller is supplied. Therefore, antimeridian ranges, combined-filter transport bugs and nullable bulk-key failures are hypotheses—not established defects.

Next action: reproduce the operator mismatch with a database-backed differential test, then apply the narrow SQL correction and define broader whitespace handling.

MATERIAL_EVIDENCE_CONFLICT: `inspection_match.py:99–107` claims Python/SQL predicate equivalence, but `48–55,129–134` treat stored whitespace-only operators as missing while `244–249` do not.

openai / gpt-6.1-sol / low / low effort answer

## Finding: operator normalization differs between matching paths

**Confirmed predicate-parity defect; high confidence.** In `inspection_match.py`, Python accepts an existing whitespace-only operator as missing, but SQL does not.

Reproducible trigger:
- Existing inspection: `performed_by = '   '`.
- Incoming inspection: operator `"Alice"`.
- Municipality, project, asset, UTC date, time, and direction otherwise match; existing row is not deleted.

**Precise path**
- Incoming operator becomes `"Alice"` through `normalize_operator()` (lines 48–55, 213).
- Python `InspectionKeys.matches_row()` normalizes the existing operator to `None`, so accepts it (lines 129–134).
- SQL `find_existing_inspection()` accepts existing operators only when NULL, exactly `''`, or normalized-equal to the incoming operator (lines 244–249). Spaces are neither NULL nor empty, and `LOWER(TRIM('   '))` differs from `"alice"`, so SQL rejects the row.

Consequently, bulk/chunk matching can merge a record that sequential matching rejects. Rejection can lead to duplicate canonical inspections **if the caller inserts after a nonmatch**; that caller is outside this packet. Such duplicates can subsequently appear in filtered result sets.

### Minimal correction and regressions

Replace SQL’s `performed_by = ''` missing-value branch with `NULLIF(TRIM(performed_by), '') IS NULL`. This fixes the demonstrated spaces-only case.

Python `str.strip()` also handles tabs, newlines, and broader whitespace that PostgreSQL’s default `TRIM` does not. For complete parity, explicitly define and implement the same whitespace-normalization contract on both sides.

Differential SQL/Python regression cases:
- Existing operator NULL, `''`, spaces-only, tabs-only, and newline-only against incoming `"Alice"`.
- Reverse those missing-value cases.
- `" Alice "` against `"alice"`; `"Alice"` against `"[REDACTED: person name]"`.
- Hold other keys equal, then vary NULL/non-NULL direction, midnight versus non-midnight time, unequal non-midnight times, and UTC date boundaries to ensure independent predicates still constrain matching.

## Frontend-to-filter trace: evidence limitation

`useInspectionData.ts` requests `/inspections/{id}/review-boot` (lines 17–29), then conditionally requests `/review-pack/{id}/inspection.json` (lines 74–90). **It does not construct a filtering request.** An end-to-end frontend filter serialization trace cannot be established from this snapshot.

Once an `InspectionFilterSpec` reaches `apply_inspection_filters()`, the visible construction is:
tenant/archive → project → asset type → asset IDs → saved filters → observation-parent filters → transient NL → search → viewport (lines 129–190).

Successive `.where()` calls combine these dimensions conjunctively. Explicit empty asset IDs match nothing (lines 146–150); viewport bounds are inclusive and exclude NULL coordinates (lines 181–190). No concrete range or combined-filter defect is established here. Spec validation, router assembly, and delegated compiler semantics remain outside the packet.

**Next useful action:** add the operator differential regression and normalization fix first; independently verify frontend filter serialization against the router/spec contract when that evidence is available.

MATERIAL_EVIDENCE_CONFLICT: `inspection_match.py:99–107` claims Python/SQL predicate parity, but Python treats whitespace-only existing operators as missing at lines 129–134 while SQL rejects them against a named incoming operator at lines 244–249.

Primary judge's stated reason

Forced, slight preference for B: its explicit reverse-order explanation helps a maintainer reproduce and understand the matching asymmetry before applying the correction. The answers are substantively near-equivalent; this is not an established material quality difference, and an independent review could reasonably favor A's additional UTC boundary coverage.

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