xai / grok-4.7-efficient / high / high effort preferred over cursor / composer-2.5 / Composer 2.5 default / 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.
xai / grok-4.7-efficient / high / high effort answer
The missing invariant is that a review boot is valid only for the currently adopted pack generation. `review_boot_json` / `review_boot_pack_sha256` may be published or left in place only while the locked inspection’s `review_pack_path` and `review_pack_job_id` still identify the bytes that were hashed. Adoption, boot publish, and pack retrieval/mutation do not enforce that together, so retries, in-place edits, and partial failure can paint one generation while serving another.
**Evidence.** `adopt_review_pack` treats a path or producer-job change as a new certification generation and invalidates acceptance in that same locked transaction (`review_pack_adoption.py` 69–78, 120–162). It never clears `review_boot_json` or `review_boot_pack_sha256`. A stale older job returns with no mutation (101–118), which is correct, but nothing stops a late boot write from that same older attempt.
`stamp_review_boot` loads with `db.get` and flushes boot columns inside a savepoint, with no row lock, no `populate_existing`, and no path/job compare (`review_boot.py` 155–182). Failures are swallowed. `persist_review_boot_from_bytes` commits on a separate session with the same unconditional write (185–208). `apply_review_boot` returns false on malformed bytes and leaves the previous boot (144–152). Reproducible trigger: job 11 adopts path P11 and commits; job 10’s `persist_review_boot_from_bytes` (or an identity-map `stamp_review_boot`) then writes boot columns only. The pointer stays P11; first-paint boot is job 10’s slice, including a different `inspection_start_s` (`review_boot.py` 123–130). Same-path regeneration is the same hole: adoption changes only `review_pack_job_id` (docstring 72–74) while the old boot remains.
Retrieval does not close the gap. The router never reads or updates boot. `save_inspection_start` and `regenerate_heatmap` already hold `for_update`, then rewrite `inspection.json` (and therefore its SHA) without restamping or clearing boot (`review_pack.py` 2841–2896, 3788–3983). Heatmap regen puts storage before the DB commit; on cache/audit failure it rolls the DB back and leaves the new object in place (3954–3982), so boot still names the pre-regen bytes. `serve_review_pack_file` snapshots `review_pack_path`, closes the session, and serves those bytes (4068–4118, 4260–4347). It binds pack path and a hash only for `track_data.json` (402–419, 4174–4236), not for `inspection.json`. GET also overlays `user_overrides.inspection_start_s` (4280–4282) while boot copies only the pack field. After a successful start save those can be reconciled on the next GET only if override sync actually put; if `inspection.json` is written and `sync_override_inspection_start` then raises (2874–2881), the pack has the new start, the override still has the old one, and the next GET paints the override. Boot matches neither.
**Smallest correction.** Fail closed to “no boot” rather than a foreign boot.
1. In `adopt_review_pack`, on `version_changed` only, set both boot columns to `None` on the already-locked row before the audit, and record that clear in the audit changes. Do not clear on `stale_job`.
2. Extend `stamp_review_boot`, `persist_review_boot_from_bytes`, and `persist_review_boot_from_path` with `expected_path` and `expected_job_id`. Re-load with `with_for_update()` and `populate_existing=True`. Write boot only if `review_pack_path == expected_path` and `review_pack_job_id == expected_job_id`. Otherwise return without writing. Callers must adopt, then stamp, so a stamp-before-adopt no-ops and the adopt clear stands. Keep the savepoint swallow only after that compare, so a failed restamp cannot restore the previous generation.
3. In `save_inspection_start`, sync the override before treating the pack put as committed: on sync failure, put the original `inspection_bytes` back and raise before `db.commit()`. On success, `apply_review_boot` on the locked row from the bytes just written, then commit. In `regenerate_heatmap`, clear boot on the locked row in the transaction that commits the prescan cache; in the existing rollback handler, best-effort clear boot again so a storage-ahead-of-DB failure cannot keep the old slice. Do not publish boot from the router’s in-progress fallback path.
**Regression coverage.** (1) Path change, same-path job change, and path→None clear both boot columns; `stale_job` does not. (2) After job 11 is adopted, persist/stamp of job 10 bytes no-ops; a matching job 11 retry may stamp. (3) Malformed bytes after adopt leave boot null, not the previous payload. (4) `save_inspection_start` leaves `review_boot_pack_sha256` equal to SHA-256 of the written object and `inspection_start_s` equal to the saved value; a forced sync failure leaves the previous object bytes. (5) Heatmap regen DB rollback does not leave boot SHA equal to the pre-regen bytes once the new object has been put.
**Discarded.** Certification lock sidecar recovery already fails closed and replays. Supporting-evidence attach skips ids already stored. Override size checks in `load_override_inspection_start` and `sync_override_inspection_start` agree on skip. Those are not this seam. Omitting `inspection_start_s` from boot would hide the symptom and break the documented first-paint contract; generation binding fixes it if stamp happens after the bytes that retrieval will serve.
**Uncertainty.** Callers of adopt/stamp, the `Inspection` column definitions, and `GET /inspections/{id}` (the documented boot consumer) are outside this packet. If that GET does not compare `review_boot_pack_sha256` to the adopted object, writer-side CAS is necessary but not a complete read-side backstop. `get_inspection_json_bytes` behavior is also outside the packet.
**Next action.** Implement the adopt-clear plus path/job compare-and-set first, then the two router mutation sites, then the five regressions above.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.Primary judge's stated reason
Weak preference for A: its compare-before-publish correction and delayed-writer regression make the recommendation more useful for the explicitly requested retry boundary. This is a slight forced preference, not an established material quality difference; an independent review could reasonably favor B's narrower scope.
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_dc42762b0f265a5a097942d0c646ef621e57b95d92934956ac312184b381ee03. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.