← Model losses

Head-to-head comparison

openai / gpt-6-astra / low / low effort preferred over openai / gpt-6.1-sol / 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

Qualify whether a safe, bounded whole-revision cohort batch can replace the per-ancestor cohort SELECT inside readActiveCombinedSeason, or whether the honest result is no source change. Planning qualification only. Do not propose the rejected exact-key/index-page design. Do not claim a production or remote latency win.

## Current reader (src/combined-season-store.js readActiveCombinedSeason)
- One fresh pointer read: SELECT season_id,revision FROM combined_season_active WHERE id=1. Null pointer returns null. No cross-request cache.
- Active version: SELECT * WHERE season_id=? AND revision=?. Missing throws 'Missing active combined version'.
- Active cohorts: SELECT public_id,cohort_id,cohort_sha256,public_json WHERE season_id=? AND revision=? ORDER BY public_id. Validate board.season id/revision, rows.length===cohort_count, board.waves===rows.length, digest({board,battles:parsed public_json in that order})===manifest_sha256. Else 'Invalid active combined snapshot'. Active battles are retained in the return value.
- Ancestry walk from the active version, not from all season rows. seen revision or seen.size>=10000 throws 'Invalid combined history chain'. Missing parent row throws 'Missing combined history ancestor'. For each ancestor revision ≠ active: SELECT public_json WHERE season_id=? AND revision=? ORDER BY public_id; validate season id/revision, length===cohort_count, digest===manifest_sha256; else 'Invalid combined history snapshot'. Historical battles are used only for digest and then dropped. History retains only {revision,sourceRevision,recordedAt,board}. Returned history is reversed (root first).
- Queries for N versions (1 active + N-1 ancestors): 2N+1. Fixture N=25 → 51 reads.
- Staged/abandoned/rollback descendants are excluded because they are not on the parent_revision chain from the fresh pointer. Season scoping is the bound season_id. Tenant isolation is that season_id plus board.season.id check.
- Corrupt JSON.parse throws SyntaxError today (not remapped). Manifest/count mismatch uses the Error strings above. Preserve those fail-closed outcomes. Do not skip proofs.
- Schema (migrations/0008_combined_seasons.sql): cohorts PK (season_id,revision,public_id). No CHECK on cohort_count or public_json length. Triggers block UPDATE/DELETE of versions and cohorts, not INSERT of an additional cohort row. D1 max bound parameters = 100. D1 max row = 2,000,000 bytes. D1 has no published max response-byte limit; query execution and result serialization run inside Workers CPU/memory limits. Workers isolate memory is 128 MB per isolate, shared across concurrent requests, not a per-query budget. events.js already chunks IN lists at 100 bindings and that pattern is not a byte bound.

## Evidence (do not treat fixture sizes as maxima)
- Clean base 2f91cf6997ae45284f7049251f94651f42d34e8f. Fixture SHA256 88e5ebd008f06153f53e57c6b85e811d72778d1d27a1b78fc79296d1e44c7a90. 25 versions, 1017 cohort rows, max public_json 14204 bytes, max revision public_json sum 467929 bytes / 52 rows, sum of all public_json 8392192, sum of board_json 524262.
- Integrity-viable prototype batches ancestor cohorts with revision IN (≤99) plus season_id, ORDER BY revision, public_id, then groups and validates count/digest. It does not use exact public_id keys. Local results: exact fixture output, 28 reads vs 51, max 25 bindings, and 8 integrity cases passed including extra-row-before-batch (error 'Invalid combined history snapshot'). It is distinct from the rejected exact-key proposal (67 reads, slower, and an isolated-copy extra-row insert was omitted so the candidate accepted a snapshot the baseline rejected).
- Prototype defects that must not be copied: fixed 99-revision batch with no byte/row budget; parsed ancestor battles accumulated in a Map until return; no prompt release. Sampled process heapUsed peak was 55690136 prototype vs 23530272 baseline. Those samples are not a platform guarantee.
- Local median 72.88 ms vs 73.47 ms (~0.8%). Not a meaningful latency improvement. Remote D1 round-trip value is unmeasured. Do not claim a speedup. Query-count reduction is the only established mechanism.
- Binding boundaries already shown on empty synthetic cohorts: 0/1/98/99/100/198/199 ancestors split 99+remainder, max 100 bindings. That does not validate response bytes or heap.

## Candidate under test (attack this; do not rubber-stamp)
Only batch whole ancestor revisions, never the active revision's retained payload (different columns; battles must remain in the return value). Keep the version walk one row at a time so board_json (up to the 2 MB row cap) is not itself batched. After a window of at most 99 ancestor revisions:
1. Size probe: SELECT revision, COUNT(*) n, COALESCE(SUM(LENGTH(public_json)),0) bytes FROM combined_season_cohorts WHERE season_id=? AND revision IN (...) GROUP BY revision. Absent revision means 0 rows. Response is integers only.
2. Pack whole revisions into payload groups whose sum(bytes) + n*per-row allowance ≤ a raw budget. A revision over budget is fetched alone, same shape as today's one-revision SELECT, and is not failed solely for size (that would change currently successful reads). Never LIMIT/truncate rows. Never look up exact public_ids.
3. Payload: SELECT revision, public_json WHERE season_id=? AND revision IN (group) ORDER BY revision, public_id. Group by revision preserving public_id order. Validate season, count, digest. On mismatch throw the existing error. Then drop that revision's strings and parsed battles before the next revision. Do not retain historical battles.
4. History order remains ancestry order, not SQL revision sort. Only walked revisions are queried, so staged/rollback siblings stay excluded. Pointer is read once per call, not cached.
5. Extra same-revision INSERT between probe and payload must be visible to the payload IN query and fail closed on count/digest. A size/count mismatch between probe and payload also fails closed. Deletes cannot happen (trigger). Other seasons cannot match the bound season_id.

Worst case to bound explicitly: 99 revisions × one ~2 MB public_json already exceeds 128 MB before parse, so a fixed 99 cap is unsafe. Also bound row-object overhead, D1 JSON escaping of the result (quotes in stored JSON), Worker-side JSON.parse + stable()/TextEncoder copies during digest, and the fact that sibling revisions' raw strings stay live until the result array is released.

## Decide
1. Is this strategy integrity-safe if implemented exactly, or is there a remaining omission/order/tenant/staged/rollback/pointer/fail-open hole?
2. Is the windowed SUM(LENGTH()) probe safe on SQLite/D1 (row-at-a-time, blobs not accumulated), or can the probe itself exceed isolate memory? If the probe is unsafe, is any multi-revision batch provably safe? If not, the result is no-change.
3. Give an exact raw-byte budget, per-row allowance, and max revisions (≤99) with arithmetic showing peak D1 serialization and Worker heap stay strictly inside 128 MB with shared-isolate margin, including parse and canonical copies. State what is pre-existing single-revision risk versus new batch risk.
4. Say whether a genuine source candidate is warranted. If yes, list the minimum code/test/doc delta. Tests must exercise 0/1/24/99/100/198+ revisions, binding cap 100, insertion race, public_id order, tenant/season, missing/corrupt/count/hash, cycle/depth, rollback/staged exclusion, pointer refresh, and batch boundaries. If no, state the exact limiting evidence for no-change.
5. Do not recommend cross-request cache, skipped proofs, scoring/UI/ingestion/schema/runtime changes, or production calls.

Return a concise verdict: IMPLEMENT with exact constants and non-negotiable constraints, or NO-CHANGE with the limiting evidence. Flag uncertainty instead of guessing platform behavior.

openai / gpt-6-astra / low / low effort answer

## NO-CHANGE

Independent, read-only assessment of the supplied snapshot. **Integrity is conditionally viable; bounded memory is not established. No source candidate is warranted.**

### 1. Integrity

Whole-revision, season-bound `IN` queries preserve completeness and `public_id` ordering. With every walked revision validated—including absent groups as empty arrays—there is no identified tenant, staged-sibling, rollback-descendant, or pointer-cache hole.

Non-negotiable qualifications:

- Validate in ancestry order, not SQL revision order.
- Preserve existing count/hash errors and unwrapped `SyntaxError`. Walking ahead can encounter a missing parent/cycle before a nearer corrupt snapshot that the baseline would reject first; exact error precedence is therefore not automatically preserved.
- An inserted row **visible to the payload statement** is included and rejected by count/hash validation. Separate statements alone do not establish D1 visibility guarantees.
- A probe/payload mismatch check is an integrity check **after materialization**, not a memory bound.

These conclusions follow from `src/combined-season-store.js:19–28` and the insertion-permitting schema at `migrations/0008_combined_seasons.sql:18–34`.

### 2. The probe does not establish a byte bound

`LENGTH(public_json)` on SQLite TEXT counts Unicode characters, not UTF-8 bytes, and stops at an embedded NUL. Calling its sum `bytes` is incorrect. Corrupt text with a short prefix and large NUL-delimited suffix can substantially defeat that estimate before `JSON.parse` rejects it.

`COUNT`/`SUM` aggregate state does not inherently accumulate payload blobs. The existing primary-key order offers a plausible streaming grouping plan. However, the packet supplies no D1 execution-plan or allocator guarantee proving total query memory is row-bounded; sorting, buffering, and serialization remain uncertain. **This is not evidence that the probe necessarily exhausts memory.**

Also, the response includes TEXT `revision`, not integers only; the schema does not constrain revision length.

### 3. Exact safe constants cannot be justified

No defensible raw-byte budget, per-row allowance, or multi-revision cap can satisfy the requested strict shared-isolate guarantee from this evidence.

- The stated counterexample is approximately `99 × 2,000,000 = 198,000,000` raw bytes, already above even 128 MiB (`134,217,728` bytes).
- Inserts between probe and payload can increase payload size without an established bound. Rejecting afterward cannot prevent allocation failure.
- D1 response escaping and buffering, JS string/row-object allocation, parsed-object expansion, recursive canonical copies, JSON serialization, and `TextEncoder` allocation lack supported peak-memory constants. The copying path is explicit at `src/combined-season-profile.js:13–15`.
- Dropping references does not guarantee immediate collection; sibling strings remain live while the batch result retains them.
- Fetching version rows individually does not prevent a window implementation from retaining many raw `board_json` strings.
- Retained active data, growing history, and concurrent requests have no established shared-isolate headroom.

**Pre-existing risks:** an arbitrarily large single revision, retained history boards, parsing/canonicalization, and concurrent requests.  
**New risks:** simultaneously live sibling payloads, window metadata/raw boards, and reliance on a stale size estimate. Single-revision fallback preserves compatibility but cannot turn these into an absolute memory guarantee.

### 4. Recommendation

Leave source unchanged. The prototype establishes query-count reduction only; its timing and heap samples establish neither latency benefit nor platform safety. Its 28-read result also excludes the newly proposed probes.

Requalification would require trustworthy byte accounting, a bound effective **before payload materialization despite inserts**, and supported allocation/concurrency assumptions. Boundary and integrity tests alone cannot supply those guarantees. No code/test delta is justified under the present scope.

openai / gpt-6.1-sol / low / low effort answer

## NO-CHANGE

Independent assessment of the supplied snapshot only. **Integrity qualification is plausible; the required memory qualification is not established.**

1. **Integrity:** Whole-revision queries avoid the rejected omission flaw. Bound season, walked revisions only, `ORDER BY revision, public_id`, ancestry-ordered validation/history, and unchanged count/digest proofs preserve selection and public output. Extra rows visible to the payload query must fail with `Invalid combined history snapshot`. Preserve `SyntaxError` for corrupt JSON and all existing missing/cycle/depth errors (`src/combined-season-store.js:19–28`).
   
   Validation must follow ancestry order—not SQL revision order—and probe mismatch checks must not replace an otherwise encountered JSON parse error. Walking an entire window before validating its earlier ancestors can also change which error surfaces first.

2. **Probe:** SQLite aggregation need not accumulate all `public_json` values; indexed grouping can plausibly process rows incrementally. **That is not a demonstrated D1 execution-memory guarantee.** Query-plan buffering, storage decoding, and placement/accounting of execution memory are unspecified here. The probe returns revision strings as well as integers, and the schema does not bound revision-string lengths.

   More importantly, SQLite `LENGTH(TEXT)` counts characters, not UTF-8 bytes, and stops at an embedded NUL. Thus the proposed `bytes` expression is not a trustworthy raw-byte measurement for all schema-permitted data. A byte-correct measurement would still not solve the remaining qualification gaps.

3. **No defensible exact constants:** Neither an exact raw budget nor a per-row allowance can prove the requested shared-isolate bound from this evidence.
   - `99 × 2,000,000 = 198,000,000` bytes already exceeds even 128 MiB, before wrappers, serialization, or parsing.
   - Inserts between probe and payload can increase response size **without a bound**. Detecting mismatch after `.all()` materializes the response protects integrity, not memory.
   - D1 escaping/copy behavior, JavaScript row/object overhead, parsed-object expansion, canonical object reconstruction, string encoding, and garbage-collection timing lack established upper bounds. `canonical()` explicitly reconstructs arrays/objects before stringification and encoding (`src/combined-season-profile.js:13–15`).
   - Active payloads and accumulated historical boards already remain live; concurrent requests share the isolate. No bound on that existing live set or concurrency is supplied.

   **Pre-existing risk:** arbitrarily many cohorts in one revision, retained active battles, and growing board history. **New batch risk:** sibling revisions’ raw results coexist with one revision’s parsing/canonicalization, plus window metadata and potential probe-to-payload growth. Fetching oversized revisions alone preserves existing behavior but cannot establish total safety.

4. **Recommendation:** No source candidate is warranted under the requested proof standard; minimum authorized source/test/doc delta is **none**. Missing platform bounds are uncertainty, not proof that every multi-revision batch is unsafe—but they prevent declaring this candidate provably safe.

The prototype establishes query-count reduction only. Its local latency difference does not establish a speedup. The next useful action is to record these qualification blockers, without implementation or production calls.

Primary judge's stated reason

B receives a slight forced preference because its explicit treatment of absent groups helps prevent an omitted validation when translating the qualification into future work. A provides equivalent underlying proof obligations and a useful error-precedence refinement, so this is not an established material quality difference. An independent review could reasonably reject the preference.

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

Battle wave: 83b6dfa9-59af-4543-9e30-bcd15553ccf9. Pair: brp1_19313494fe363f3014c9a992e9c01560554b4f08911fe4b5e93e5f4023ed6182. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.