fix(web): propagate log levels to inference workers
Description
Fixes #1245. Logging changes currently stop at the main JS context, leaving the LlamaCPP and ONNX inference workers at their default level. Send the current level on every worker initialization and forward later changes to existing workers. Each backend retains updates during asynchronous loading and applies them to its JavaScript and native loggers after rac_init.
Idle workers are not started by logging changes; recreated workers inherit the current setting. The synchronous public API is unchanged, with worker updates delivered asynchronously. Older WASM artifacts remain loadable; native live updates require the existing rac_logger_set_min_level export in current-source builds.
Type of Change
- Bug fix
- Documentation update
Testing
- Web typecheck, TypeScript package build, and NodeNext entrypoint validation
- Web lint
- All 350 existing Web tests pass
- Extended existing worker tests cover initial/pending-init/live updates, both registered hosts, disposal, and crash recovery. The two regression cases fail against the original production source.
- Chromium browser smoke with checksum-verified v0.20.37 assets: 3 passed; the existing provider-backed transcription case skips without credentials
- Current-source LlamaCPP and ONNX CPU WASM builds with Emscripten 6.0.2, including canonical ONNX Runtime/Sherpa dependencies and native artifact audits
- Real-worker browser logging suite: 2 passed (29.3s)
- Reads native and JavaScript levels from both worker heaps before/after updates, during initialization, and after recreation.
- Runs real SmolLM2 inference in the production CPU worker, changes DEBUG → ERROR during the response stream, and verifies native INFO suppression on the next successful request without resetting the level.
- All three package verification commands; repeated for both rebuilt backend artifacts
- Pre-commit hooks, including secret scanning
- GitHub CI: all four workflows for
e1af490require maintainer approval before execution (PR build matrix). No CI pass is claimed.
Reproduce the native browser gate from bindings/web after building current CPU artifacts:
RA_RUN_WORKER_LOGGING_E2E=1 npx playwright test tests/browser/worker-logging.spec.ts
The v0.20.37 release artifacts lack the native logger setter/getter exports and cannot satisfy this gate. The inference assertion reproduces unsuppressed INFO output with those older assets and passes with the current-source artifacts. Verification covers CPU workers; no GPU-specific or release certification is claimed.
Checklist
- Code follows project style guidelines
- Self-review completed
- Worker architecture and verification documented in
bindings/web/docs/DEVELOPMENT.md
Readiness: local verification is complete; this PR stays draft until the required GitHub checks run and pass. No release or deployment is included.
Developed with assistance from Codex.
Summary by CodeRabbit
- New Features
- Web applications can now apply logging-level changes to active workers immediately. The selected level is also honored during initialization and carried over when workers are recreated.
- Documentation
- Added developer guidance on worker logging behavior, native logging requirements, and how to run the optional browser tests.