Skip to content

fix(security): Migration auf @huggingface/transformers v4 + ner-worker-Build-Fix#3

Closed
Baldri wants to merge 3 commits into
claude/session/fix/redteam-gate-auditfrom
claude/session/feat/transformers-v4-migration
Closed

fix(security): Migration auf @huggingface/transformers v4 + ner-worker-Build-Fix#3
Baldri wants to merge 3 commits into
claude/session/fix/redteam-gate-auditfrom
claude/session/feat/transformers-v4-migration

Conversation

@Baldri

@Baldri Baldri commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Was

Migration von @xenova/transformers 2.17.2 auf @huggingface/transformers 4.2.0 (gepflegter Nachfolger) plus Fix des nie gebauten NER-Workers.

Stacked PR auf claude/session/fix/redteam-gate-audit (#2) — bitte #2 zuerst mergen.

Warum

  • npm audit meldete eine Critical-Kette (11 protobufjs-Advisories inkl. Arbitrary Code Execution GHSA-xq3m-2v4x-88gg) über @xenova → onnxruntime-web → onnx-proto → protobufjs. Der npm-Fix-Pfad wäre ein Downgrade auf 2.0.1 gewesen — keine Option.
  • Nebenbefund der Analyse: dist/main/ner-worker.js wurde von keinem Build-Script erzeugt → NERDetector fiel im gebauten Produkt still auf [] zurück, der 3-Layer-NER-Pfad war im Release-Build tot.

Änderungen

  • Dependency-Swap in package.json; build:main-External angepasst; neues Script build:ner-worker in die Build-Chain eingehängt
  • 4 Files: Import-Name + quantized: falsedtype: 'fp32' (ner-worker.ts, model-manager.ts, direct-ner-detector.ts, privacy-ner-integration.test.ts)
  • env-API, progress_callback, Cache-Layout unverändert — bestehender piiranha-v1-Cache wird ohne Re-Download weiterverwendet (offline verifiziert)

Tests

  • npm run typecheck: grün | CI=1 npm test: Exit 0 | npm run build: grün, dist/main/ner-worker.js (6.3 kB) wird erzeugt
  • npm audit --omit=dev: 0 Vulnerabilities (vorher 4 nach PR fix: Prüf-Session — Commit-Gate entblockt, Deps gepatcht, Modellkatalog aktualisiert #2, 9 vor der Prüf-Session)
  • Regression: RUN_3LAYER=1 npm run test:red-team lädt piiranha über die neue Library aus dem bestehenden Cache (776 ms), 42 Failures vs. 48 in der Baseline 2026-03-17 — alle 7 dokumentierten 'Fixed by NER'-Tests bestehen weiterhin

Review-Punkte

  • Packaging: onnxruntime-node ist neu eine Pflicht-Dependency mit nativen Binaries (~50–100 MB); electron-builder smartUnpack sollte die .node-Files automatisch aus dem asar entpacken — beim nächsten dist:mac prüfen (Prüfpunkt, kein Blocker)
  • Electron 27 (Node 18.17) ist am unteren Rand der engines-Ranges von onnxruntime-node/sharp — künftige transformers.js-Updates könnten Node 20+ verlangen; Electron-Upgrade separat einplanen
  • dtype: 'fp32' entspricht dem bisherigen quantized: false (Node-Default wäre ohnehin fp32)

Dokumentation

  • Migrations-Analyse mit Beweisführung (Scratchpad-Audit-Test, Offline-Modell-Test) liegt im Session-Verlauf; Red-Team-Baseline-Vergleich gegen tests/red-team/results/2026-03-17-3layer-v1-summary.md

🤖 Generated with Claude Code

Baldri and others added 3 commits July 2, 2026 17:25
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Plan was fully implemented on 2026-03-17 (GitHub release v0.7.0,
mingly-website commit 02e6d22, preprocessor fixes shipped) but the
checkboxes were never ticked. Verified against live site, app and
release on 2026-07-02; marked done and committed as historical record.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Replaces @xenova/transformers 2.17.2 with @huggingface/transformers 4.2.0
(the maintained successor). Eliminates the entire protobufjs critical
advisory chain (11 advisories incl. GHSA-xq3m-2v4x-88gg arbitrary code
execution) via @xenova -> onnxruntime-web -> onnx-proto -> protobufjs:
npm audit --omit=dev is now clean (0 vulnerabilities).

API changes: package rename in 4 dynamic imports; quantized:false ->
dtype:'fp32' (option removed in v3+). env.cacheDir/allowRemoteModels,
progress_callback, cache layout and token-classification output are
unchanged - the existing piiranha-v1 model cache is reused without
re-download.

Also fixes a latent build gap: dist/main/ner-worker.js was never built
(no esbuild entry), so NERDetector silently fell back to [] in packaged
builds - the 3-layer NER path was dead in production. New
build:ner-worker script is chained into build.

Verified: typecheck + full test suite green, build produces the worker
bundle, RUN_3LAYER=1 red-team run loads piiranha via the new library
from the existing cache (776ms) with 42 failures vs 48 in the 2026-03-17
baseline - all 7 documented NER-fixed tests still pass, no regressions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Baldri Baldri deleted the branch claude/session/fix/redteam-gate-audit July 2, 2026 16:02
@Baldri Baldri closed this Jul 2, 2026
@Baldri Baldri deleted the claude/session/feat/transformers-v4-migration branch July 2, 2026 16:03
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.

1 participant