Commit bc7ec7a
fix: Windows grep outage and test-run telemetry pollution
Two production defects found in Azure telemetry over 2026-07-22 → 2026-08-05.
**Windows `grep` broken for 99 machines**
`core_failure` showed 328 events across 99 distinct Windows machines (of 617
total) carrying `? is not recognized as an internal or external command,
operable program or batch file.` and its German, French, Spanish and Portuguese
translations. Present on released 0.9.2, 0.9.3 and 0.9.4.
Root cause: ripgrep's Windows release is a zip, and `RipgrepBinary` extracted it
via `powershell.exe -Command Expand-Archive`, falling back to the literal string
`"powershell.exe"` when neither `powershell.exe` nor `pwsh.exe` resolved.
`cross-spawn`'s `parseNonShell()` sets `needsShell = true` when `resolveCommand()`
returns undefined and re-spawns through `cmd.exe /d /s /c`, so cmd.exe produced
that message. `throw new Error(result.stderr.trim())` made it the error verbatim,
and since `RipgrepBinary.filepath` is `Effect.cached`, one failed extraction broke
grep for the whole session.
Upstream carries the same fragility: anomalyco/opencode#24291 is open, reporting
`Expand-Archive` unusable when spawned from the Bun-compiled binary, affecting
`grep`, `glob` and `skill`. Their #23457 fix only corrected how paths were passed
to PowerShell (the `$args` → inlined-and-escaped form we already carry); it did
not remove the dependency on PowerShell being resolvable.
Extract the zip in-process with `@zip.js/zip.js`, converging on the approach the
`packages/opencode/src/file/ripgrep.ts` shim already uses in production.
`unzipExecutable` is exported so archive handling is tested directly, and decodes
with `checkSignature: true` — zip.js defaults it off, and a CRC-corrupt download
would otherwise be written to the cache and trusted by every later session.
Install the binary atomically (stage to `rg.exe.tmp`, then rename). `filepath`
trusts the cached binary on existence alone, so an interrupted write previously
left a truncated `rg.exe` that every later session reused — the same permanent
breakage `checkSignature` guards against, which CRC cannot catch because it is
verified before the write. The tar path installs the same way.
Attribute resolution failures. Child stderr was reported verbatim, so a
shell-level failure was indistinguishable from a tool bug; and because a resolve
failure is memoized, it is re-reported on every later grep in the session. The tar
branch now names ripgrep, and any typed filesystem or HTTP failure is wrapped as
`ripgrep binary resolve failed: …`.
Note the blast radius is wider than the `grep` tool: `@opencode-ai/core/ripgrep`
also backs the HTTP-API file handlers and `cli/cmd/debug/ripgrep.ts`.
**Test runs shipped telemetry to the production resource**
1,020 of 3,135 machine ids in the same window emitted `provider_id="test"` /
`cli_version="local"` — test processes that regenerate their machine id every
run, inflating install and active-machine counts by roughly a third. `doInit()`
gated only on `ALTIMATE_TELEMETRY_DISABLED`.
Refuse the baked-in connection string when `NODE_ENV=test`, `BUN_TEST`, `VITEST`
or `JEST_WORKER_ID` is set. Keyed on test runners, 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 alike.
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.
Test plan: 8 ripgrep tests — including a layer-level test that drives `filepath`
through the Windows zip path with a spawner that fails if invoked, asserting the
staged-then-renamed install, and a CRC case that fails without `checkSignature` —
plus 15 telemetry-gate tests covering CI-alone-still-reports and one that relies
on the real runner's `NODE_ENV`. `turbo typecheck` green, marker guard green,
`packages/core` and `packages/opencode` suites show no failures beyond the
pre-existing set on `main`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 03b9459 commit bc7ec7a
8 files changed
Lines changed: 556 additions & 32 deletions
File tree
- docs/docs/reference
- packages
- core
- src
- ripgrep
- test
- opencode
- src/altimate/telemetry
- test/telemetry
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
129 | 147 | | |
130 | 148 | | |
131 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
29 | 74 | | |
30 | 75 | | |
31 | 76 | | |
| |||
48 | 93 | | |
49 | 94 | | |
50 | 95 | | |
51 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
52 | 117 | | |
53 | 118 | | |
54 | 119 | | |
55 | 120 | | |
56 | 121 | | |
57 | 122 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
79 | 130 | | |
80 | 131 | | |
81 | 132 | | |
| |||
84 | 135 | | |
85 | 136 | | |
86 | 137 | | |
87 | | - | |
88 | | - | |
| 138 | + | |
89 | 139 | | |
| 140 | + | |
90 | 141 | | |
91 | 142 | | |
92 | 143 | | |
| |||
103 | 154 | | |
104 | 155 | | |
105 | 156 | | |
106 | | - | |
107 | 157 | | |
108 | 158 | | |
109 | 159 | | |
| |||
114 | 164 | | |
115 | 165 | | |
116 | 166 | | |
117 | | - | |
118 | | - | |
119 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
120 | 179 | | |
121 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
122 | 192 | | |
123 | 193 | | |
124 | 194 | | |
| |||
0 commit comments