← Model losses

Head-to-head comparison

xai / grok-4.7-efficient / low / low effort preferred over deepseek / deepseek-flash / none / 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

Assess the review-pack boot, retrieval, and adoption boundaries for architectural consistency under retries, changed inspection state, and partial failure. Identify a concrete invariant that is missing or inconsistently enforced, trace its path through the supplied implementation, and propose the smallest cohesive correction plus regression coverage.

xai / grok-4.7-efficient / low / low effort answer

The missing invariant is that a published review-boot sibling is valid only for the currently adopted review-pack version, and must be cleared or replaced in the same locked transaction that changes that version.

**Invariant.** `review_boot_json` / `review_boot_pack_sha256` are either null or a digest of the `inspection.json` bytes of the inspection’s current `review_pack_path` + `review_pack_job_id`. A path or producer-job change must drop the previous sibling before commit. A stamp may publish boot only while holding that row lock and only when path and job still match the artifact. A retry whose pointer is already current must republish boot when the sibling is null or sha-mismatched, without a second invalidation. A failed stamp must not leave the previous version’s boot in place.

**Where it breaks.** `adopt_review_pack` (`review_pack_adoption.py` 120–164) updates the pointer, invalidates acceptance, and audits `AUTO_INVALIDATE_REVIEW_PACK_CHANGE`, but never reads or writes the boot columns. An identical retry (`version_changed` false, 163–164) is a pure no-op, so it cannot repair a boot stamp that failed after the pointer commit. `stamp_review_boot` / `persist_review_boot_from_bytes` (`review_boot.py` 155–208) are best-effort, swallow all errors, use `db.get` without `FOR UPDATE`, and do not compare path or job to the bytes. Consequences under the three stresses:

- Partial failure: pointer commit succeeds, boot stamp logs and returns; GET first-paint still serves the previous pack’s zones, cards, and start.
- Retry: second adopt sees the same path and job, skips invalidation and skips boot, so the stale sibling sticks.
- Changed inspection state / races: an unlocked `persist_review_boot_from_bytes` can commit pack A’s boot after pack B is adopted, or commit boot for bytes whose adopt later rolls back. In-place `inspection.json` writers in the same packet (`save_inspection_start` 2874–2896, `regenerate_heatmap` 3923–3954) also change bytes that boot hashes (`review_boot.py` 126–127, 133–151) without restamping, so `review_boot_pack_sha256` no longer names the adopted object. `serve_review_pack_file` does not consult boot at all.

**Smallest cohesive correction.** In `adopt_review_pack`, on `version_changed`, set `review_boot_json` and `review_boot_pack_sha256` to null in that same locked transaction (before the audit write). Add optional `pack_bytes`. After the pointer assignment, and also on the unchanged retry path, if `pack_bytes` is present and the row’s path/job equal `new_path`/`new_job_id`, call `apply_review_boot`. On retry, apply only when the stored boot sha differs, so a missed stamp is repaired without another `AUTO_INVALIDATE`. Change `stamp_review_boot` and `persist_review_boot_from_bytes` to require `expected_path` and `expected_job_id`, `SELECT … FOR UPDATE`, and no-op on mismatch — do not write boot for a pack that is not yet the adopted pointer. Callers that stamp before adopt should pass bytes into adopt instead. Same rule for `save_inspection_start` and `regenerate_heatmap`: after a successful `inspection.json` put, `apply_review_boot` on the written bytes under the inspection lock already held, or clear the boot columns if stamping fails, so a sha is never left pointing at the pre-write object.

**Regression coverage.** (1) A→B adopt with pre-existing boot and no bytes nulls both boot columns and still invalidates and audits. (2) A→B adopt with bytes leaves `review_boot_pack_sha256 == sha256(bytes)` and `boot["pack_sha256"]` equal to that digest; a rollback of the adopt transaction restores the old boot. (3) Stale-job rejection does not clear boot. (4) Retry with the same path and job and bytes, boot already null, republishes boot and does not emit a second `AUTO_INVALIDATE`. (5) `persist_review_boot_from_bytes` with a mismatched expected path/job does not overwrite boot after a committed adopt. (6) `save_inspection_start` updates boot `inspection_start_s` and boot sha to the written bytes; if the boot flush fails, boot columns are null rather than the pre-write slice.

**Alternatives discarded.** Track-data binding already fails closed on a changed read (`review_pack.py` 4186–4226); inspection.json enrichment fail-open is a different policy and does not explain stale first-paint after pack switch. Certification lock/sidecar recovery is local and already idempotent. Unlocked boot writes are not fixed by logging.

**Missing evidence.** Callers of `adopt_review_pack` and `stamp_review_boot`, and the GET that serves `review_boot_json`, are outside this packet. Severity of first-paint mismatch depends on that reader treating boot as authoritative until pack bytes arrive — the boot module states that, but the reader is not here. `Inspection` column definitions are also outside the packet; the correction assumes those two attributes exist as assigned in `apply_review_boot`.

**Next action.** Implement the clear-or-restamp inside `adopt_review_pack` plus the locked path/job check on the boot writers, with the six regressions above. Do not keep an independent best-effort stamp that can commit a sibling for a non-current pack.

deepseek / deepseek-flash / none / unknown effort answer

I'll analyze the three files for a missing or inconsistently enforced invariant across boot, retrieval, and adoption boundaries.

## Task-relevant conclusion

**The missing invariant: a review-pack pointer change must invalidate the persisted first-paint boot slice (`review_boot_json` / `review_boot_pack_sha256`).** `adopt_review_pack` (`review_pack_adoption.py`) atomically rewrites `review_pack_path`/`review_pack_job_id` and invalidates acceptance + sign-off, but never clears or re-stamps the boot columns that `review_boot.py` writes. Nothing ties a boot payload's `pack_sha256` to the live pointer at read time, so a stale boot slice survives an adoption and is served as if it belonged to the current pack.

This is not merely theoretical: the DB-served boot is documented as the *pre-paint* source ("GET /inspections/{id} serves this DB sibling so Review chrome + location count can paint before the pack bytes arrive" — `review_boot.py:3-5`), while the actual `inspection.json` served by `serve_review_pack_file` can be derived from a **different job's output_path** (`review_pack.py:4084-4097`) than the one used to stamp boot. So boot and pack bytes are not guaranteed to come from the same artifact identity.

## Evidence chain

1. **Boot stamps an identity token deliberately.** `build_review_boot` returns `"pack_sha256": pack_sha256` (`review_boot.py:124`), and `apply_review_boot` writes both `inspection.review_boot_json` and `inspection.review_boot_pack_sha256` (`review_boot.py:150-151`). The SHA is the whole point: it is meant to bind the slice to a specific pack revision.

2. **Adoption changes the artifact, not the boot.** `adopt_review_pack` sets `inspection.review_pack_path` and `review_pack_job_id` (`review_pack_adoption.py:125-126`) and calls `invalidate_acceptance_and_signoff` (`:133`) plus writes `AUTO_INVALIDATE_REVIEW_PACK_CHANGE` (`:141-162`). Neither the mutation block (`:124-162`) nor the dataclass result exposes any boot-field handling. There is no reference to `review_boot_json` anywhere in the supplied adoption path.

3. **The retry/partial-failure case makes it worse.** `adopt_review_pack` treats `path_changed or job_changed` as the trigger (`:122`). Two distinct failure modes are unguarded:
   - **Same-path regeneration with a new job id**: `job_changed=True`, `path_changed=False`. The boot slice's `pack_sha256` now describes old content at the unchanged path — exactly the "in-place same-path regeneration" the docstring at `:72-74` says must not revive proof. It correctly invalidates acceptance but leaves boot attesting the old bytes.
   - **A → B → A cycle**: the docstring promises an audit event per actual change (`:71-74`), but on return to A the boot slice from the first A is once again *byte-plausible* while the SHA may match a regenerated (different) A. Nothing re-stamps.

4. **Best-effort stamping means boot can be absent or lagging, and absence is not distinguished from staleness.** `stamp_review_boot` swallows all exceptions (`review_boot.py:177-182`) and `persist_review_boot_from_bytes` swallows all exceptions (`:203-208`). So after an adoption that races or fails a boot write, a reader has no way to tell "boot is current" from "boot is stale" from "boot never landed" using only the pair `(review_boot_json, review_boot_pack_sha256)`.

5. **The read path that would consume boot is outside the packet.** The `review_boot_pack_sha256` column is written here but no consumer appears in the three supplied files; the boot GET is in the inspection router (`app.models.inspection` / the `/inspections/{id}` route), which is listed as an *outside* dependency and is not supplied. That is the one step I cannot verify from this snapshot.

## Implication

A reviewer can see boot-derived chrome, zone list, and location count (potentially with `inspection_start_s`, `interest_zones`, `review_cards` from `review_boot.py:123-130`) that does not correspond to the pack they then load. Because `inspection_start_s` and `review_cards.physical_zone` are precisely the fields later used as *provenance* by evidence attachment (`_frozen_review_zone_bounds`, `_assert_evidence_and_observation_in_requested_zone` in `review_pack.py:983-1094`), a stale boot slice can mislead the reviewer about frozen zone geometry before any server-side validation corrects them.

## Smallest cohesive correction

Make boot invalidation part of the same atomic contract as adoption, mirroring the acceptance invalidation:

- In `adopt_review_pack`, inside the `if version_changed:` block (`review_pack_adoption.py:124`), clear the derived boot fields when the version changes, e.g. set `inspection.review_boot_json = None` and `inspection.review_boot_pack_sha256 = None` before `db.add(inspection)`. Record the transition in the existing audit `changes` dict alongside `acceptance_status`.
- Alternatively (less invasive, no read-path change needed): re-stamp boot from the *new* pack bytes within the same transaction. This requires the bytes, which adoption does not currently receive, so clearing is the smaller, safer option; the next successful `stamp_review_boot` repopulates it.

I prefer **clear-on-change** because it fails closed: a `None` boot forces the reader to fall back to the real pack bytes rather than painting a slice with an unverifiable identity. If the boot consumer requires non-null, guard on the SHA match instead (see below), but clearing is the minimal single-point fix.

## Regression coverage

1. **Same-path regeneration**: adopt with `new_path == old_path`, `new_job_id > old_job_id`. Assert `review_boot_json`/`review_boot_pack_sha256` are cleared (or re-stamped to the new SHA) and an `AUTO_INVALIDATE_REVIEW_PACK_CHANGE` row exists.
2. **A → B → A cycle**: adopt A→B→A with increasing job ids; assert boot is cleared/re-stamped at each change and never attests the original A bytes.
3. **Stale-job rejection**: `new_job_id < old_job_id` returns `stale_job=True` with `applied=False` (`:107-118`); assert boot is **unchanged** here — this is the one path that legitimately must not invalidate.
4. **Best-effort failure**: simulate a boot write that raises after adoption; assert the reader (or a confirming assertion on the pair) can distinguish stale/absent boot rather than serving it blindly.

## Alternatives / discarded hypotheses

- **"Boot SHA is checked at read time."** Plausible and would make this a non-issue — but no such check exists in the supplied files, and the boot GET is outside the packet. If the consumer *does* compare `review_boot_pack_sha256` against the live pack SHA and falls back on mismatch, the severity drops to "stale-but-not-served." This is the key uncertainty; I state it rather than assume the defect is realized.
- **"Retrieval path self-heals."** `serve_review_pack_file` will happily serve `inspection.json` from a completed job's `output_path` (`review_pack.py:4084-4097`), so retrieval can deliberately serve a non-pointer artifact. That *increases* the boot/pack divergence risk rather than resolving it.
- **"Certification two-file publish is the intended invariant."** The `lock` path (`review_pack.py:2274-2296`) uses `_put_exclusive_local` + deterministic sidecar recovery (`:1497-1504`) — a genuine partial-failure invariant, but a different subsystem, not the boot/adoption boundary.

## Missing evidence and consequence

- **`app/routers/inspections.py` (boot GET)**, the consumer of `review_boot_json`/`review_boot_pack_sha256`, is an unlisted/outside dependency. Without it, whether the stale slice is actually *served* or *rejected on SHA mismatch* is unverifiable, so the defect's realized severity is uncertain. Confidence in the *missing invalidation* itself is high (the adoption code has no boot handling and the SHA exists expressly to bind identity); confidence that it *reaches a user* is medium pending that file.
- **`app.models.inspection`** definition (column nullability/defaults) is outside the packet; the clear-vs-None approach assumes the columns are nullable.
- **`invalidate_acceptance_and_signoff`** (`app.services.reviewer_signoff`) behavior is outside the packet; I assume it does not itself touch boot fields, but an equivalent clear could already be hidden there.

## Next useful action

Read the boot consumer at `/inspections/{id}` and check for an explicit `review_boot_pack_sha256`-vs-live-pack-SHA gate. If none exists, apply the clear-on-`version_changed` fix in `adopt_review_pack` and add regression tests 1–3 above. If a SHA gate exists, reclassify as defense-in-depth hardening rather than a live defect.

MATERIAL_EVIDENCE_CONFLICT: `review_pack_adoption.py:71-74` asserts every actual version change is invalidated to prevent regen from reviving proof, while `review_pack.py:4126-4165`+`review_boot.py:144-152` allow a boot slice bound to a prior `pack_sha256` to persist across that same change with no invalidation in the supplied adoption path.

Primary judge's stated reason

B provides a more cohesive actionable correction and regression plan for changed inspection state, retries, and independent boot publication. The preference is clear on correction coverage, not a claim of demonstrated production failure; its implementation still requires caller and consumer verification.

This reason is the judge's assessment. No independent factual-defect finding is asserted by this record.

Battle wave: b60a358e-7993-4567-b86d-c5b92705bbea. Pair: brp1_3a50f0dfc60092f1de900eff10e3a2ee16320fb8aa0abb4416d55d558bbc95f8. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.