Repository navigation
feat(core): fall back to the CoDev mirror for ripgrep downloads - #147
Merged
Merged
Conversation
When rg is neither on PATH nor cached, CoDev Code downloads it from GitHub releases on first use — which corporate networks commonly block, leaving file search empty until the user intervenes (PR #146 made that failure visible and retryable; codevhub#230 stages the binary at install time, but only for users who ran codevhub). The download tail now tries GitHub first and falls back to the landing page's mirror of the official executables (codev-landing-page#64), which hosts them raw — no archive, so the mirror path skips extraction and stages the binary through a scoped temp dir before copying into place (the cache check is bare existence, so a partial target must never appear). Each attempt is bounded to 30s so a blackholing proxy can't stall first search for minutes. The fallback engages via catchCause, not catch: a proxy block page returns 200 + HTML, which passes filterStatusOk and dies in extract as a defect, and that case must reach the mirror too. New mocked-HTTP tests cover the fallback order, success caching, and failure non-caching; test/preload.ts now redirects XDG_CACHE_HOME to a temp dir so tests exercising the real binary-resolution path can never touch the developer's ~/.cache/codev. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Same convention as codev-gateway's const.ts: keeps the host out of casual greps, not a secret. The test's plain-text URL assertion now doubles as proof the encoded value decodes to the right mirror. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
rgis neither on PATH nor in~/.cache/codev/bin, CoDev Code downloads it from GitHub releases on first use — which corporate networks commonly block. PR #146 made that failure visible and retryable, and codevhub#230 stages the binary at install time, but users who never rancodevhub(fresh machine, cleared cache) were still stuck. This adds a second source inside the agent itself: GitHub first, then the CoDev landing page's mirror of the official 15.1.0 executables (quickbeard/codev-landing-page#64,rg-<version>-<platform>-<arch>[.exe]).Changes
packages/core/src/ripgrep/binary.tsfromGithub(unchanged archive → extract flow) andfromMirror(raw executable, no extraction — staged in a scoped temp dir, then copied to the target + chmod; the cache check is bare file existence, so a partial target must never appear).Effect.catchCause, notEffect.catch: a corporate proxy block page returns 200 + HTML, which passesfilterStatusOkand then dies insideextractas a defect — that case must reach the mirror too.Effect.timeout) so a blackholing proxy can't hang first-time file search on OS TCP timeouts before the fallback is even tried.Effect.fail) rather than a defect, so they trigger the fallback as well.packages/core/test/ripgrep-binary.test.ts(new) — first coverage of binary resolution at all, using the mocked-HTTP-client pattern frommodels.test.ts(AppNodeBuilder+Layer.fresh): fallback order (GitHub URL then exact mirror URL — pinning the hosted-filename contract), bytes land at the target with the exec bit and no leftover staging dir, success is cached (no further requests), failure is not cached (recovers mid-session), and an empty mirror body never creates the target.packages/core/test/preload.ts— redirectsXDG_CACHE_HOMEto a fresh temp dir for the whole suite, so tests that exercise real binary resolution can never read or clobber the developer's actual~/.cache/codev(the new tests write fake bytes at the rg target path;models.test.ts's cache writes also become hermetic).Cross-repo invariant
VERSIONhere,RG_VERSIONin codevhub, and the landing page's hosted filenames must move together on a ripgrep bump — host new binaries first. Until codev-landing-page#64 deploys, the mirror GET 404s and behavior degrades to exactly today's GitHub-only failure.Test plan
bun typecheckinpackages/coreandpackages/opencodepackages/core: 1083 pass, 0 fail (caught and fixed a leak where the fake test binary outlived the file and broke the live ripgrep suites)test/ripgrep.test.ts+test/filesystem/@search downloads via the mirror (log shows "github ripgrep download failed, trying the CoDev mirror")🤖 Generated with Claude Code