openai / gpt-6.1-sol / low / low effort preferred over xai / grok-4.7-efficient / low / low 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.xai / grok-4.7-efficient / low / low effort answer
The operator-match predicate is not null/whitespace-safe across the two in-packet match implementations, so the same inspection can merge on one path and duplicate on the other. The supplied frontend hook never builds an inspection filter request.
**Primary risk (high confidence).** `InspectionKeys.matches_row` and `find_existing_inspection` disagree on whitespace-only `performed_by`.
Intended semantics, stated in `inspection_match.py` and implemented by `normalize_operator` (lines 48–55, 129–134): an operator is missing when it is null, empty, or whitespace-only; missing on either side accepts; otherwise compare case-insensitively after trim.
- Python path: `normalize_operator(' ')` is `None`, so `matches_row` returns `True` against a real operator such as `'Alice'`.
- SQL path (`find_existing_inspection`, lines 244–249): `performed_by IS NULL OR performed_by = ''` does not treat `' '` as missing. `LOWER(TRIM(performed_by))` becomes `''`, which is not equal to `'alice'`, so the row is rejected when `:op` is non-null.
Incoming operators are normalized before bind (`op_norm` at line 213), so the reverse case (whitespace only on the candidate) already matches in SQL via `CAST(:op AS text) IS NULL`. Only a whitespace-only stored `performed_by` diverges. Chunk dedup and the sequential probe can therefore disagree, and the strict-match invariant (one canonical row) fails. `LIMIT 2` also undercounts that warning; it does not change the chosen id.
Minimal correction — make the SQL missing-check the same as `normalize_operator`:
```sql
AND (
NULLIF(BTRIM(performed_by), '') IS NULL
OR CAST(:op AS text) IS NULL
OR LOWER(BTRIM(performed_by)) = LOWER(BTRIM(CAST(:op AS text)))
)
```
Boundary cases (same muni/project/asset/UTC date/direction; both times non-midnight and equal unless noted):
1. DB `performed_by=' '`, candidate `'Alice'` → both paths match (today: Python matches, SQL does not).
2. DB `'Alice'`, candidate `' '` / `None` / `''` → both match.
3. DB `' Alice '`, candidate `'alice'` → both match.
4. DB `'Alice'`, candidate `'[REDACTED: person name]'` → both reject.
5. DB `NULL` or `''`, candidate `'[REDACTED: person name]'` → both match.
6. Direction `NULL`/`NULL` matches; `NULL`/`'U'` does not.
7. Both times non-midnight and unequal → reject; either side midnight UTC → accept.
**Second filter risk (medium confidence; reachability not in packet).** `asset_id_in` treats `[]` as match-nothing because SQLAlchemy `in_([])` drops the clause (lines 144–150). `asset_type_ids` does not (lines 141–142). If an empty list is accepted by `InspectionFilterSpec`, the grid returns every asset type in scope instead of none. Same sentinel as `asset_id_in` (`sa_false()` when the list is empty). Regress `[]` → empty set, `None` → no predicate, `[id]` → that type only. Schema validation is outside this packet.
**Discarded or weaker.** Viewport bounds are inclusive and drop null centroids; antimeridian behavior is unspecified here. `project_id` wins over `in_project` by `if/elif`; whether both can be set is outside the packet. `useInspectionData.ts` only gates review-boot and `inspection.json`; it does not construct filter predicates, so it is not on this path. Nullable `direction` inside `hard_key` is unsafe for SQL `IN` (`NULL` never matches `NULL`) even though sequential SQL uses `IS NOT DISTINCT FROM`; the bulk `IN` caller is not in this packet. `matches_row` uses `astimezone` on a naive datetime (local zone), while `parse_inspection_datetime` uses `replace(tzinfo=UTC)`; that diverges only if a naive value reaches `matches_row`.
**Missing.** `InspectionFilterSpec`, `compile_filters`, `apply_search`, `archival_filter`, and the bulk probe that consumes `hard_key` are outside the packet. Consequence: empty `asset_type_ids` and null-direction bulk `IN` cannot be confirmed as live callers from this snapshot alone. The operator whitespace split does not depend on those files.
**Next action.** Add a differential test for case 1 above (whitespace-only DB operator vs named candidate) against both `matches_row` and the SQL text, then align the SQL `NULLIF(BTRIM(...))` check. Separately, mirror the `asset_id_in` empty-list sentinel on `asset_type_ids` if the spec allows `[]`.Primary judge's stated reason
B is preferable because it preserves the useful primary diagnosis without recommending a correction for a nonexistent empty-IN widening defect, and it more carefully bounds the normalization fix and downstream duplication claim. This is a supported substantive reliability advantage, rather than a slight forced preference based on presentation.
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_d6f302cdb576592a2efa9e99ee8c527076ea151d0efe8645848d251f1da36b84. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.