openai / gpt-6.1-sol / low / low effort preferred over cursor / composer-2.5 / Composer 2.5 default / unknown 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.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.cursor / composer-2.5 / Composer 2.5 default / unknown effort answer
## Evidence packet
### 1. Conclusion (primary risk)
**Asymmetric empty-list semantics for asset narrowing** in `apply_inspection_filters` can make the visible inspection set **wider than intended** when the client sends “no asset types selected” as an empty array.
| Dimension | When list is present but empty | Effect |
|-----------|--------------------------------|--------|
| `asset_id_in` | Explicit `sa_false()` → **match nothing** | ```144:150:[REDACTED: private project name]/backend/app/services/inspection_filter_pipeline.py``` |
| `asset_type_ids` | `Asset.asset_type_id.in_([])` only — **no empty-list guard** | ```141:142:[REDACTED: private project name]/backend/app/services/inspection_filter_pipeline.py``` |
The pipeline already documents that SQLAlchemy `in_([])` **silently drops** the clause for `asset_id_in` and fixes it with `sa_false()`. The same hazard is **not** handled for `asset_type_ids`. Depending on SQLAlchemy compilation, an empty `IN ()` may become a no-op or an always-false predicate; either way, behavior is **not aligned** with the documented “empty list = match nothing” contract used for `asset_id_in`, and UI that maps “zero selected types” → `asset_type_ids: []` can show **all types** instead of **none**.
**Confidence:** High for **internal pipeline inconsistency** and the documented `in_([])` hazard; medium for **exact SQLAlchemy compile outcome** without `filter_compiler` / router spec parsing in the packet.
**Secondary risk (viewport + nulls):** Step 9 applies bbox only after requiring non-null centroids:
```181:190:[REDACTED: private project name]/backend/app/services/inspection_filter_pipeline.py```
Any inspection whose joined `Asset` has null `centroid_lat`/`centroid_lng` is **excluded** when `viewport_bbox` is set, even if the map/list elsewhere still shows those rows under other filters. That is a **null-sensitive combined filter** (viewport + Asset join), not necessarily a bug, but it is a common FE/BE divergence if the map draws assets without centroids.
**Confidence:** High that the predicate excludes null centroids; medium that the product intends that.
---
### 2. Path trace (what the packet actually supports)
**Backend predicate assembly (complete in packet)**
Single entry: `apply_inspection_filters(stmt, spec, …)` with fixed order:
1. Tenant `scope.inspection_filter()` + `archival_filter(spec.current_only)`
2. `project_id` / `in_project` (mutually exclusive branches: `project_id` wins if set)
3. `asset_type_ids` → `IN` (no empty guard)
4. `asset_id_in` → empty → `FALSE`
5. `compile_filters(saved_filter_ids)`
6. `constrain_parent_by_observation_filters(..., current_only=spec.current_only)`
7. `nl_filter_group` via `compile_transient_condition_group` (strict; no silent widen)
8. `apply_search`
9. `viewport_bbox` + non-null centroid range checks
```112:122:[REDACTED: private project name]/backend/app/services/inspection_filter_pipeline.py```
**“Matching” in packet = import merge, not grid filters**
`inspection_match.py` builds **dedup/merge** predicates for ingest (`find_existing_inspection`, `InspectionKeys.matches_row`), keyed on muni/project/asset/UTC date/direction/soft time/operator — **not** on `InspectionFilterSpec`. It is a **different** “matching” lane from grid filtering; no wire path links `useInspectionData.ts` to this module.
**Frontend request (incomplete in packet)**
`useInspectionData.ts` only loads `/inspections/{id}/review-boot` and `/review-pack/{id}/inspection.json`, gated on `review_pack_path`. It does **not** build or send grid filter specs (`nl_filter_group`, `viewport_bbox`, `asset_type_ids`, etc.). The packet **cannot** establish how the inspections grid serializes filters or which query endpoint is called.
```74:83:[REDACTED: private project name]/frontend/src/hooks/useInspectionData.ts```
**Discarded hypothesis:** Treating `useInspectionData` as the inspections **filter** request path — **not supported** by the file’s API usage.
---
### 3. Minimal correction
Mirror the `asset_id_in` sentinel for asset types:
```python
if spec.asset_type_ids is not None:
if not spec.asset_type_ids:
stmt = stmt.where(sa_false())
else:
stmt = stmt.where(Asset.asset_type_id.in_(spec.asset_type_ids))
```
Optional product clarification (not required for the empty-list bug): document that `viewport_bbox` **implicitly** filters to assets with centroids.
---
### 4. Boundary regression cases
| Case | Expected after fix |
|------|----------------------|
| `asset_type_ids=[]`, other dims default | **Zero rows** (parity with `asset_id_in=[]`) |
| `asset_type_ids=None` | No asset-type narrowing (unchanged) |
| `asset_id_in=[]` | Zero rows (existing behavior) |
| `viewport_bbox` set, asset with `centroid_lat/lng` NULL | Row **excluded** |
| `viewport_bbox` set, centroid on min/max lon/lat | **Included** (`>=` / `<=` inclusive) |
| `project_id=5` and `in_project=false` both sent | Only **project_id** branch runs (`elif` chain) |
| `observation_filter_ids` + `nl_filter_group` both set | Both apply; NL **after** observation parent constrain (order pinned) |
For **import match** (separate suite): UTC date-only vs timed same day, one side midnight UTC; `direction` NULL vs value (`IS NOT DISTINCT FROM` in SQL); `performed_by` NULL/empty vs conflicting non-empty on both sides.
---
### 5. Missing evidence / uncertainty
- **Frontend filter client:** No hook/page building `InspectionFilterSpec` or calling `/inspections/query` / pill-state — cannot prove how empty `asset_type_ids` is encoded or whether map viewport always sends bbox with Asset join assumptions.
- **Dependencies:** `inspection_filter_spec.py` (defaults), `inspections.py` router (spec from query body), `filter_compiler.py`, `observation_parent_filters.py`, `apply_search`, `archival_filter` — behavior of combined saved + observation filters and search null/empty strings unknown here.
- **Consequence:** Strongest **end-to-end** parity claim is pipeline-internal (`asset_type_ids` vs `asset_id_in`); reproducing in UI requires the missing FE/router slice.
---
### 6. Next useful action
Add a backend parity test next to existing SQL parity tests for `/inspections/query`: same base `stmt`, `asset_type_ids=[]` vs `asset_id_in=[]` should both yield empty sets; optionally assert compiled SQL contains a false sentinel for both. Extend packet with the router handler that maps query params → `InspectionFilterSpec` to close the FE gap.
---
**Alternatives / false positives:** If the API never sends `asset_type_ids=[]` (only `null` when unset), the defect may be latent. If SQLAlchemy version always compiles `in_([])` to false, user-visible bug might still be absent, but parity with the explicit `asset_id_in` contract and comments would remain wrong.Primary judge's stated reason
A is more useful for the requested outcome because its reproducible SQL/Python disagreement supports a minimal correction and differential regression cases. This is a clear substantive advantage in defect identification, not a preference based on presentation. Actual downstream duplicate creation remains unverified.
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_a4959fadac9c7f61ba3d0ecb37b8c602f59fa55002bff5fa929bb8015677b10a. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.