2.3 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | |
|---|---|---|---|---|---|---|---|---|
| review-worker-adapter | Review Worker adapter implementation | completed |
|
narrow | low | phase | review |
Description
Review checkpoint after Worker adapter implementation. Verify:
- Build, type-check, and full test suite pass
- Worker adapter matches architecture spec
- Test strategy for Workers is sound (actual workers or reliable mocks)
- Package exports, tsup config, and barrel re-exports are correct and consistent
Acceptance Criteria
npm run buildpasses cleanlynpm run lintpassesnpm testpasses with all tests (core + Redis + WebSocket + Worker)- Worker adapter API matches architecture spec
- Sub-path exports are correctly configured
References
- docs/architecture/event-targets/worker.md
Notes
Review Report
Build / Lint / Tests: All pass. 242 tests across 8 files. Build produces correct d.ts for all 5 entry points (index, redis, ws-client, ws-server, worker).
Worker Adapter API: Matches architecture spec.
createWorkerHostEventTarget(worker: Worker)— host side, usesworker.postMessage/worker.onmessagecreateWorkerThreadEventTarget()— thread side, usesglobalThis.postMessage/globalThis.onmessage- Both follow the same
Map<string, Set<EventListener>>pattern as other adapters __-prefixed event types are silently ignored (consistent with WS adapters)
Exports: Correct.
tsup.config.tshasevent-target-worker.tsentrypackage.jsonhas./event-target-workersub-path exportsrc/index.tsre-exports both factory functions
Test Strategy: Mock-based (not actual Worker threads). Uses mock Worker and globalThis objects. 42 tests covering host send/receive, thread send/receive, topic scoping, envelope round-trip, bidirectional communication, error handling.
Observation: The thread side sets globalThis.onmessage directly, which overwrites any existing handler. This is noted in the architecture doc and acceptable — the adapter takes ownership of the message channel.
Verdict: PASS
Summary
Worker adapter review passed. 242 tests, build, lint all clean. API matches architecture spec. Web Worker only per R&D decision. Mock-based test strategy is sound (42 tests).