Skip to content

fix(bench): only set CODEGRAPH_ENGINE for actual engine-comparison forks - #2341

Merged
carlos-alm merged 2 commits into
mainfrom
fix/issue-2140-embedding-benchmark-engine-warning
Aug 8, 2026
Merged

carlos-alm merged 2 commits into
mainfrom
fix/issue-2140-embedding-benchmark-engine-warning

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

Closes #2140

forkWorker() (scripts/lib/fork-engine.ts) unconditionally set CODEGRAPH_ENGINE to whatever workerName it was given. That's correct for forkEngines()'s own two calls (workerName is 'wasm'/'native', a valid engine value), but embedding-benchmark.ts reuses forkWorker() directly with workerName set to a model name ('minilm', 'jina-small', ...) — an invalid CODEGRAPH_ENGINE value that tripped a "not a valid engine value" warning on every embed call inside that worker. Purely cosmetic noise (it already fell back to "auto" correctly), but a real fix rather than living with it.

Fix

forkWorker() now only sets CODEGRAPH_ENGINE when the caller's envKey is the same WORKER_ENV_KEY forkEngines() itself uses internally — true for an actual engine-comparison fork, never true for a caller using its own distinct env key (like embedding-benchmark.ts's MODEL_WORKER_KEY). No call-site changes needed anywhere, including embedding-benchmark.ts itself.

Test plan

  • New tests/unit/fork-engine-codegraph-engine-env.test.ts: forks a tiny throwaway child script and confirms CODEGRAPH_ENGINE is set when envKey is the real WORKER_ENV_KEY, and unset for a different envKey.
  • Full npm test suite passes (4606 tests, 287 files).
  • npx tsc --noEmit and npm run lint clean.

…rks (#2140)

forkWorker() unconditionally set CODEGRAPH_ENGINE to workerName —
correct when workerName is 'wasm'/'native' (forkEngines()'s own two
calls), but embedding-benchmark.ts reuses forkWorker() directly with
workerName set to a model name ('minilm', 'jina-small', ...), an
invalid engine value that tripped a warning on every embed call
inside that worker.

Gate on envKey === WORKER_ENV_KEY instead, since that's true only for
an actual engine-comparison fork and never true for a caller using its
own distinct env key — no call-site changes needed anywhere.

docs check acknowledged.

Impact: 1 functions changed, 5 affected
@greptile-apps

greptile-apps Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR prevents model benchmark workers from overwriting CODEGRAPH_ENGINE while preserving engine selection for actual engine-comparison forks.

  • Exports the engine worker environment key and gates CODEGRAPH_ENGINE assignment on that exact key.
  • Adds regression coverage for engine workers, model workers, and inherited ambient CODEGRAPH_ENGINE values.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
scripts/lib/fork-engine.ts Gates the child-process engine override to actual engine-comparison workers while retaining inherited environment values for other worker types.
tests/unit/fork-engine-codegraph-engine-env.test.ts Verifies both environment paths and now correctly accounts for an ambient parent CODEGRAPH_ENGINE, resolving the previous environment-dependent assertion.

Reviews (3): Last reviewed commit: "fix(test): make #2140 regression test ro..." | Re-trigger Greptile

fs.writeFileSync(scriptPath, CHILD_SCRIPT);

const result = await forkWorker(scriptPath, '__BENCH_MODEL__', 'minilm', []);
expect(result).toEqual({ codegraphEngine: null });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Ambient engine breaks regression test

If the test process has CODEGRAPH_ENGINE set, forkWorker() passes that inherited value to the child, but this assertion expects null, causing an environment-dependent test failure even though the worker name was correctly not assigned.

Suggested change
expect(result).toEqual({ codegraphEngine: null });
expect(result).toEqual({ codegraphEngine: process.env.CODEGRAPH_ENGINE ?? null });

Fix in Claude Code

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Codegraph Impact Analysis

1 functions changed → 5 callers affected across 5 files

  • forkWorker in scripts/lib/fork-engine.ts:70 (5 transitive callers)

…ENGINE (review)

The "different envKey" assertion hardcoded null, which fails in any
shell/CI environment that already has CODEGRAPH_ENGINE set — forkWorker()
still inherits the parent env in that branch, it just doesn't override it.
Compare against the test process's own value instead.

docs check acknowledged.
@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

@carlos-alm
carlos-alm merged commit 2033ced into main Aug 8, 2026
24 checks passed
@carlos-alm
carlos-alm deleted the fix/issue-2140-embedding-benchmark-engine-warning branch August 8, 2026 04:41
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(bench): embedding-benchmark.ts forked workers print a spurious CODEGRAPH_ENGINE warning

1 participant