openai / gpt-6-luna / 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-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.
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 preferable because its actionable range-validation recommendation preserves the distinction between a demonstrated predicate boundary and an unverified upstream defect. B offers better tracing coverage, but its primary proposed fix is justified by an unsupported semantic mismatch. The preference rests on diagnostic correctness, not answer length or formatting.
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_5e7634bd0e2bfbeff8af67cd30f31106ce0b4bd618c0712f412cd08c2837d614. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.