altimate-code icon indicating copy to clipboard operation
altimate-code copied to clipboard

tech-debt: drop process.env mutation from dispatcher test files (parallel-safety)

Open sahrizvi opened this issue 3 months ago • 0 comments

Follow-up from v0.9.6 review — coderabbit MAJOR on PR #1129 discussion r3839417768.

Context

Both dispatcher test files set ALTIMATE_TELEMETRY_DISABLED=true in beforeAll and clear it in afterAll:

  • packages/opencode/test/altimate/dispatcher.test.ts (existing — shipped months ago)
  • packages/opencode/test/skill/release-v0.9.6-adversarial.test.ts (v0.9.6)

Problem

Mutating process.env in a shared bun-test process isn't parallel-safe. bun test runs test files sequentially in one process by default in this repo, so it's not biting anyone today — but the moment someone enables bun test --concurrency N (or bun makes parallel-file execution the default), these files can:

  • Observe each other's env-var mutations mid-run
  • Have their afterAll restore step race an unrelated file's beforeAll set

Flakes, not correctness bugs — but hard to diagnose once they land.

The actual fix (small)

Delete the env-var setup entirely. Both test files exercise Dispatcher.call which wraps every Telemetry.track call in try { ... } catch {} that swallows all errors. The env var was defensive against nothing — telemetry firing during a test cannot fail the test regardless.

Concrete diff, ~5 lines of removal per file:

- beforeAll(() => {
-   process.env.ALTIMATE_TELEMETRY_DISABLED = "true"
- })
- afterAll(() => {
-   delete process.env.ALTIMATE_TELEMETRY_DISABLED
- })

(plus the save/restore additions in the release test file — those were a partial patch that still didn't reach parallel-safety; drop them too.)

Priority

P3 — advisory. Not blocking any current or planned work. Address whenever a contributor is next in the dispatcher test area, or as part of a broader "make tests parallel-safe" pass if the repo ever flips --concurrency on.

References

sahrizvi avatar Aug 23 '26 19:08 sahrizvi