← Model losses

Head-to-head comparison

cursor / composer-2.5 / Composer 2.5 default / unknown effort preferred over deepseek / deepseek-flash / none / unknown 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

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.

cursor / composer-2.5 / Composer 2.5 default / unknown effort answer

## Evidence packet

### 1. Conclusion (high confidence)

**Missing invariant:** After the canonical review-pack **version** changes (`review_pack_path` or `review_pack_job_id`), any `review_boot_json` / `review_boot_pack_sha256` on `Inspection` must describe **that** adopted artifact (or be explicitly cleared). The code enforces version invalidation for acceptance/signoff in adoption, but **does not tie boot columns to the adopted pointer**, so first-paint boot can disagree with what retrieval serves under the current path.

**Implication:** Under retries, partial boot stamping, or pack replacement, Review can paint zones/cards/duration/start from a **prior** pack SHA while `GET …/review-pack/…/inspection.json` (and progressive fallbacks) read the **current** tree—an architectural seam between boot, retrieval, and adoption.

---

### 2. Trace through supplied implementation

| Layer | Behavior | Source |
|--------|----------|--------|
| **Boot write** | `apply_review_boot` sets `review_boot_json` and `review_boot_pack_sha256` from **hashed pack bytes**; does not commit. | `review_boot.py` 144–152, 106–130 |
| **Boot persist** | `stamp_review_boot` uses a nested savepoint; failures are logged and **non-blocking**. `persist_review_boot_from_bytes` uses a **separate** session/commit. | `review_boot.py` 155–182, 185–208 |
| **Boot purpose** | DB sibling for first-paint before pack bytes; disk `inspection.json` remains enrichment source. | `review_boot.py` 1–6 |
| **Adoption** | On `path_changed` or `job_changed`, updates pointer/job, invalidates acceptance/signoff (unless override), audits `AUTO_INVALIDATE_REVIEW_PACK_CHANGE`. **No boot fields.** | `review_pack_adoption.py` 120–162 |
| **Retrieval** | `serve_review_pack_file` uses `inspection.review_pack_path`, else latest `review_pack` / `embedded_import` job `output_path`; for `inspection.json`, may overlay `user_overrides.inspection_start_s` and enrich from DB. | `review_pack.py` 4068–4097, 4280–4282, 309–336 |
| **In-place pack edits** | `save_inspection_start` / `regenerate_heatmap` rewrite `inspection.json` on the **current** path without any boot update in this packet. | `review_pack.py` 2874–2896, 3952–3954 |

**Reproducible triggers**

1. **Adoption success + boot not refreshed:** `adopt_review_pack` with `version_changed=True` updates path/job and invalidates acceptance; boot columns unchanged → boot still reflects old `pack_sha256` / zones/cards/`inspection_start_s`.
2. **Partial failure:** Ingest commits new `review_pack_path` while `stamp_review_boot` fails inside savepoint (warning only) or `persist_review_boot_from_bytes` races a later adoption → pointer and boot diverge.
3. **Changed inspection state without version bump:** Reviewer `PUT …/inspection-start` or heatmap regen mutates on-disk `inspection.json`; boot still holds pre-edit `inspection_start_s` (and SHA from last boot stamp). Adoption does not run, so acceptance may stay valid while first-paint boot is wrong.
4. **Retrieval vs boot (cross-endpoint):** Router never reads boot; clients combining inspection-detail boot with review-pack GET can see inconsistent start/zones without a single enforced binding.

**Retries (partially consistent elsewhere):** Supporting evidence attach uses `_supporting_evidence_ids` for idempotent retries (`review_pack.py` 3179–3206). That does **not** extend to boot/adoption alignment.

---

### 3. Smallest cohesive correction

In `adopt_review_pack`, when `version_changed` is true (same condition as acceptance invalidation and audit), **clear** boot state on the locked row:

- `inspection.review_boot_json = None`
- `inspection.review_boot_pack_sha256 = None`

Rely on existing ingest paths (`apply_review_boot` / `stamp_review_boot`) to repopulate from new `inspection.json` bytes in the **same** transaction as pointer commit when bytes are available (call site not in packet—must be verified).

Optional narrow follow-up (same invariant family, not required for adoption fix): after authoritative `inspection.json` writes (`save_inspection_start`, `regenerate_heatmap`), either refresh boot from new bytes or document boot as “pack-ingest-only” and stop exposing `inspection_start_s` on boot for post-review edits.

---

### 4. Regression coverage (proposed)

1. **`adopt_review_pack` path change:** Pre-seed boot JSON + SHA; adopt new `new_path` / `new_job_id`; assert boot fields are `None`, acceptance invalidated per existing rules, audit emitted.
2. **Stale job rejection:** `new_job_id < old_job_id`; assert boot **unchanged** and `stale_job=True`.
3. **Boot repopulation:** After adoption clear, call `apply_review_boot(inspection, new_pack_bytes)` in test harness; assert `review_boot_pack_sha256 == sha256(new_pack_bytes)` and slim payload matches `build_review_boot`.
4. **Partial stamp failure (integration):** Simulate `stamp_review_boot` flush failure on ingest; assert either transaction rolls back pointer or adoption clear leaves boot null until successful stamp (documents chosen policy).

---

### 5. Alternatives / discarded hypotheses

- **Certification stage-1 lock/draft:** Strong internal consistency (canonical JSON, SHA sidecar recovery) but scoped to local certification, not boot/adoption—discarded as primary defect for this question.
- **regenerate_heatmap DB failure after R2 write:** Real partial-failure bug, but localized to heatmap/prescan cache, not boot/adoption boundary—secondary.
- **Same path + same `job_id` in-place overwrite:** Adoption intentionally does not `version_changed`; content can change without invalidation or boot refresh—separate invariant (content-addressed pack); not fully provable from packet alone.

---

### 6. Missing evidence / uncertainty

- Call sites that invoke `adopt_review_pack` and whether they always call `stamp_review_boot` / `apply_review_boot` in one transaction.
- `GET /inspections/{id}` shape and whether clients gate on `review_boot_pack_sha256` vs live pack.
- Whether `Inspection` model defaults boot columns to null on path change elsewhere.

**Consequence:** Fix location is certain (`review_pack_adoption.py` on `version_changed`); end-to-end “never null boot after adopt” depends on ingest pairing not shown here.

---

### 7. Next useful action

Implement boot clear on `version_changed` in `adopt_review_pack`, add tests 1–3 above, then grep ingest/finalize paths to ensure boot stamp runs in the same commit as pointer update (or document + test explicit null boot until stamp succeeds).

**Confidence:** **High** for adoption/boot pointer mismatch from supplied sources; **medium** for full production severity without ingest and API client contracts.

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 receives a slight forced preference for grounding changed inspection state in an actual supplied rewrite path while avoiding A's unsupported hash scenario. This is not an established material quality gap; an independent review could reasonably favor A's regression coverage.

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_154fac4a393b1862b40ed4a4c2314ae10013ede2cb34479d32bf1c8f6dad4bf4. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.