openai / gpt-6.1-sol / high / high effort preferred over xai / grok-4.7-efficient / 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.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 preferred because its backend trace and bounded operator finding support actionable investigation without directing an unnecessary empty-list fix. The advantage is supported and task-relevant, but the shared successful primary diagnosis makes this a weak preference rather than an established material quality gap. Confidence concerns this comparison; an independent review could weigh A's additional conditional observations differently.
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_25e8cc729cd867d9925c66e1fe3b3455754ad1a52c79c948402c2fa346c7d12b. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.