Skip to content

fix(browser): share corrupt-model reloads and keep writes made during eviction - #36

Merged
leoisadev1 merged 2 commits into
mainfrom
bg0/review-followups-2
Sep 29, 2026
Merged

leoisadev1 merged 2 commits into
mainfrom
bg0/review-followups-2

Conversation

@leoisadev1

@leoisadev1 leoisadev1 commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Devin left three late findings on #32 after it merged. This PR fixes the two real ones and clarifies the third.

Two callers that shared one corrupt model load got different answers. The first to catch the error queued the one reload, and the second saw the engine as already reloaded and marked it failed, which skipped the first caller's retry too. Each walk now tracks its own reload, so both callers retry the fresh download once, and a download that is corrupt again still stops there. The eviction is keyed to the failed load's rejection, which every sharing caller receives, so a caller that handles it late reuses the first eviction instead of deleting the retry's fresh download. A failed cache delete no longer aborts the retry.

The safe cache deletes an evicted key a second time once earlier writes settle. A new download that started writing during that wait could land first and then be deleted. A write that starts during an eviction now waits for the delete to finish.

The model load limits are idle limits: any download progress restarts them. The code comment and ARCHITECTURE.md now say so instead of describing a total deadline.

Root bun run lint, typecheck, test and build pass. The tests for concurrent callers sharing a corrupt load and for a write during eviction fail on main and pass here. The late-caller ordering is covered by unit tests of the eviction helper; the end-to-end test cannot force that timing. No real browser or device was exercised.

Created with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

… eviction

Callers that shared a corrupt load now each retry once behind the same
eviction instead of one marking the engine failed. A cache write that
starts while an eviction waits is held until the delete finishes. The
load limits are documented as idle limits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bg0-web Ready Ready Preview Sep 29, 2026 4:32pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
bg0-docs Skipped Skipped Sep 29, 2026 4:32pm UTC

Request Review

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 2 potential issues.

Devin Review

Comment thread packages/browser/src/cache.ts
Comment thread packages/browser/src/index.test.ts
…le it

A caller that handled a shared corrupt load after the first eviction
finished started a second one, which could delete the retry's fresh
download. The eviction is now keyed to the failed load's rejection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

Comment thread packages/browser/src/eviction.ts
@leoisadev1
leoisadev1 merged commit ece1208 into main Sep 29, 2026
6 checks passed
@leoisadev1
leoisadev1 deleted the bg0/review-followups-2 branch September 29, 2026 16:34
@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Changes how the browser cache handles corrupt model files.

The cache and test concerns are non-blocking, but the repository’s real-browser verification requirement must be satisfied before merging.

Fix All in Claude CodeFindings

  1. P2 Overlapping evictions remove fresh writes ▶
  2. P2 Shared-load tests miss sharing ▶
  3. P2 Verify the browser flow ▶

Summary

The PR improves recovery from corrupt model loads and coordinates cache writes with eviction. Overlapping evictions can still remove a fresh cache entry, and the shared-load tests can pass without exercising a shared load. The required real-browser remover flow must be verified before merging.

Reviews (1) · Last reviewed commit: "fix(browser): evict a corrupt load once ..."

Comment thread packages/browser/src/cache.ts
Comment thread packages/browser/src/index.test.ts
Comment thread packages/browser/src/index.test.ts
@greptile-apps

greptile-apps Bot commented Sep 29, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P2 Overlapping evictions delete a fresh put ▶

    • Bug
      • A fresh put started during the first eviction completes, but a second eviction subsequently deletes it. The final cache lookup misses instead of returning the fresh value.
    • Cause
      • In packages/browser/src/cache.ts:271-275, the put waits only for the eviction promise present when it starts. A second eviction can schedule its own late delete while that put is pending; that delete runs after the fresh write. The overlapping eviction scheduling is at lines 232-242.
    • Fix
      • Coordinate evictions per key so a late delete cannot run after a put that was admitted to wait for an earlier eviction.
  • P2 Shared-load tests pass without both callers sharing the load ▶

    • Bug
      • The assertions pass when the second caller joins only after the first caller has completed its retry.
    • Cause
      • A fixed 50 ms wait is not synchronization with both callers reaching the shared load.
    • Fix
      • Gate release of the first load on an explicit signal that both callers have joined it.

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – bg0-web — 9ce12479 Deployed Sep 29, 2026 by vercel[bot]
Preview – bg0-docs — 9ce12479 Deployed Sep 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant