openai / gpt-6.1-sol / high / high effort preferred over xai / grok-4.7-efficient / high / high 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 / 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.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`.Primary judge's stated reason
A is the more reliable actionable assessment: it traces the backend composition, identifies the actual matching mismatch, and explicitly makes duplicate insertion conditional on an unseen caller. B instead states that the sequential path inserts another row, although that caller is outside the evidence. Together with its unsupported empty-type widening claim, this establishes a material grounding advantage for A rather than merely a forced slight preference.
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_052694826925342243ce4997d8afe24884e005af6a61fda87555b3126c03d0d0. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.