fix: Windows grep outage and test-run telemetry pollution
Issue for this PR
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
Two defects found while reading Azure telemetry for 2026-07-22 → 2026-08-05.
1. grep was broken for 99 Windows machines (#1072).
ripgrep's Windows release is a zip, and we extracted it by shelling out to
powershell.exe -Command Expand-Archive, with a literal "powershell.exe" string as the
fallback when neither powershell.exe nor pwsh.exe resolved. cross-spawn's
parseNonShell() sets needsShell = true whenever resolveCommand() returns undefined and
re-spawns through cmd.exe /d /s /c, so cmd.exe replied '…' is not recognized as an internal or external command. We threw that string verbatim, and since RipgrepBinary.filepath is
Effect.cached, one failed extraction killed grep for the whole session.
This extracts the zip in-process with @zip.js/zip.js, so there is no external shell to
resolve. That is the same approach packages/opencode/src/file/ripgrep.ts already uses — which
is why glob/ls/skill never showed this failure while grep did.
Three things came out of review and are included:
checkSignature: true. zip.js defaults CRC verification off, so a corrupt download
decodes "successfully", gets written to the cache, and is trusted by every later session.- Atomic install.
filepathtrusts the cached binary on existence alone, so an interrupted
write left a truncatedrg.exethat was reused forever. Both paths now stage torg.exe.tmp
and rename. CRC cannot catch this — it is verified before the write. - Attributed failures. Child stderr was reported verbatim, so a shell-level failure looked
like a tool bug. A resolve failure is also memoized, so it is re-reported on every later grep.
Typed FS/HTTP failures are now wrapped asripgrep binary resolve failed: ….
Upstream has the same fragility open as anomalyco/opencode#24291. Their #23457 fix only changed
how paths were passed to PowerShell (the inlined-and-escaped form we already carry); it did not
remove the dependency. upstream/dev still has the original code.
2. Test runs polluted production telemetry (#1073).
1,020 of 3,135 machine ids were test processes (provider_id="test", cli_version="local"),
which regenerate their machine id every run — inflating install and active-machine counts by
about a third. doInit() now refuses the baked-in connection string under NODE_ENV=test,
BUN_TEST, VITEST or JEST_WORKER_ID.
Keyed on test runners and deliberately not on CI: altimate-code-actions wraps this CLI, so
every run of that shipped product sets CI/GITHUB_ACTIONS, and gating on those would blind a
real product surface. bun test sets NODE_ENV=test, which covers CI and developer machines
with one condition. An explicit APPLICATIONINSIGHTS_CONNECTION_STRING is always honoured, so
suites with their own sink are unaffected; ALTIMATE_TELEMETRY_FORCE=true overrides the
default-sink refusal, and the existing opt-outs still win over both.
How did you verify your code works?
- 8 ripgrep tests, including a layer-level test that drives
filepaththrough the Windows
zip path with stubbed HTTP/FS and a spawner that throws if invoked — pinning that the
Windows path spawns nothing and that the install is staged-then-renamed. The CRC test was
confirmed to fail withoutcheckSignature: true. - 15 telemetry tests, including that CI on its own must still report, and one that stubs no
env at all so it relies on the real runner'sNODE_ENV— the assumption the gate rests on. bun turbo typecheckgreen; marker guard green.- Full suites run against a
mainbaseline worktree:packages/core1,038 pass,
packages/opencode11,014 pass, with zero failures unique to this branch (the remaining
MCP/plugin failures reproduce onmain).
Not verified on a real Windows host — I have no Windows runner. The zip decoding, install and
no-spawn behaviour are covered by tests; the end-to-end "grep works on a machine without
PowerShell on PATH" claim is inferred from the call graph, not executed.
Known follow-ups, deliberately not in this PR: bundling rg so there is no runtime download
(upstream wants this too — anomalyco/opencode#31734), unifying the two ripgrep resolvers, and
making filepath cache only successes so a transient failure stops poisoning the session.
Screenshots / recordings
Not a UI change.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Summary by cubic
Fixes Windows grep outages by extracting ripgrep in-process (no PowerShell) and installing it atomically, and stops automated tests from sending production telemetry. Adds a Windows CI E2E that resolves and runs rg.exe with PowerShell removed from PATH (fixes #1072, #1073).
-
Bug Fixes
- Windows grep (#1072): in-process zip decode via
@zip.js/zip.jswith CRC; atomic install (stage → rename); clearer, named HTTP/extract errors; normalized failure messageripgrep failed with code X: …with a “no output” fallback; Windows-only E2E verifies download/extract/install/exec with PowerShell off PATH. - Telemetry (#1073): suppress the default App Insights under test runners (
NODE_ENV=test,BUN_TEST,VITEST,JEST_WORKER_ID); CI alone still reports; explicitAPPLICATIONINSIGHTS_CONNECTION_STRINGhonored;ALTIMATE_TELEMETRY_FORCE=trueopt-in; docs updated.
- Windows grep (#1072): in-process zip decode via
-
Dependencies
- Added
@zip.js/zip.js@2.7.62topackages/core.
- Added
Summary by CodeRabbit
-
Bug Fixes
- Improved ripgrep installation on Windows with in-process extraction, CRC validation, atomic staging/rename, and better contextual errors.
- Enhanced ripgrep process failure reporting to always include normalized stderr and exit codes (or a clear “no output” fallback).
-
Telemetry
- Automated test runs now avoid the baked-in production App Insights sink; CI remains enabled.
- Explicit connection strings and
ALTIMATE_TELEMETRY_FORCE=truestill enable telemetry, with disable overrides taking precedence.
-
Documentation
- Added documentation for telemetry test-run exclusions and override behavior.
-
Tests / CI
- Added Windows ripgrep end-to-end coverage and automated telemetry tests.
- Added a Windows-only CI job for ripgrep resolution E2E.