Skip to content

Implement review.md recommendations: security fixes, correctness hardening, and CI repair#5

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/implement-review-recommendations
Closed

Implement review.md recommendations: security fixes, correctness hardening, and CI repair#5
Copilot wants to merge 2 commits into
mainfrom
copilot/implement-review-recommendations

Conversation

Copilot AI commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Implements all recommendations from review.md and fixes the one pre-existing test failure. Changes are grouped by severity.

Security

  • Command injection (src/embedder.js): generateAndSaveProfile was building a shell string with interpolated device and sampleSize values. Replaced execSync(cmd) with execFileSync(process.execPath, [script, '--device', device, ...]).

Correctness

  • Overly-broad model matching (src/model-management.js): Both deleteModel and isModelDownloaded used String.includes() in their fallback scan, meaning deleteModel('bert') would match roberta. Replaced with a matchesModelName() helper that requires exact equality or a -// separator prefix.
  • Silent pool hang on full degradation (src/worker-pool.js): When the last worker crashed, pending run() promises would never settle. _removeWorker now rejects all queued tasks immediately when the pool empties.
  • Dead else branch (src/embedder.js): Provider default ternary's else arm evaluated to options.provider which the ?? had already consumed — simplified to undefined.
  • In-place splice mutation (src/embedder.js): applyPerfProfile mutated a const array via splice; changed to let + reassignment.

Test fix

  • provider-loader-cuda.test.js was asserting loaded === true but always got false. Root cause: the runner script patched fs.existsSync via import fs from 'fs', but provider-loader.js held a named ESM binding (import { existsSync } from 'fs') which is a frozen snapshot, not a live reference to module.exports. Fixed by:
    1. Changing provider-loader.js to import fs from 'fs' + fs.existsSync(...) (reads module.exports at call time).
    2. Using createRequire in the runner script to patch the CJS module.exports directly, which is the same object fs.existsSync reads through.

Provider loader

  • ldconfig -p was called once per missing library (up to 6 times); output is now cached in a module-level variable.
  • activateCuda and activateDml were declared async but contain no await; removed the unnecessary keyword.

CI

  • Workflow used pnpm but the repo commits package-lock.json (npm). Switched to npm ci to match the lockfile.
  • Node matrix expanded from [18.x] to [18.x, 20.x, 22.x].
  • Artifact name now includes ${{ matrix.node-version }} to avoid upload conflicts across matrix legs.

Package / DX

  • Added "exports" field to package.json for proper ESM subpath resolution.
  • Removed bench/ from "files" — the benchmarking scripts were being shipped to npm consumers.
  • Added semi, eqeqeq, no-var, prefer-const to eslint.config.cjs.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • huggingface.co
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/embedeer/embedeer/bench/grid-search.js --device cpu --sample-size 1 --out /tmp/embedeer-grid-CdZEof/grid-out.json (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/embedeer/embedeer/bench/grid-search.js --device cpu --sample-size 1 --out /tmp/embedeer-grid-gxqcZZ/grid-out.json (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/embedeer/embedeer/bench/grid-search.js --device cpu --sample-size 1 --out /tmp/embedeer-grid-u8kF2J/grid-out.json (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Implement review recommendations and fix CI testing errors Implement review.md recommendations: security fixes, correctness hardening, and CI repair Apr 11, 2026
Copilot AI requested a review from jsilvanus April 11, 2026 08:28
@jsilvanus jsilvanus marked this pull request as ready for review April 11, 2026 10:16
@jsilvanus

Copy link
Copy Markdown
Owner

Was implemented in #6

@jsilvanus jsilvanus closed this Apr 11, 2026
@jsilvanus jsilvanus deleted the copilot/implement-review-recommendations branch April 14, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants