Files
Dragan Spiridonov dd22dbddda test(workers): generalize #491 Bug 1 protection to all 11 workers
The issue #491 fix wired the daemon WorkerManager to the kernel and
shipped one targeted integration test for the learning worker. The
same StubWorkerDomainAccess failure mode applies to every other
worker that declares targetDomains — test-health, flaky-detector,
coverage-tracker, defect-predictor, etc. — and the worker-level
unit tests all explicitly punt on this with comments along the
lines of "complex dependencies require integration tests for full
coverage. Unit tests focus on instantiation." That punt is what
let Bug 1 ship in the first place.

This test iterates EVERY registered production worker (enumerated
dynamically from `daemon.getWorkerManager().list()`), builds the
exact WorkerContext the scheduler hands to doExecute, and asserts
that each of the worker's declared targetDomains resolves to a real
domain API. If the kernel→worker wiring ever breaks again — for
any of the 11 workers, not just learning-consolidation — this test
fails before the daemon ticks for users.

Three assertions:
  1. Every registered worker declares ≥1 targetDomain (catches the
     "shipped a worker with no domains" misconfig).
  2. For every (worker, targetDomain) pair, `getDomainAPI(domain)`
     returns a defined value (the structural Bug 1 contract).
     Failure list is formatted as a multi-line message so the
     maintainer sees exactly which seam broke.
  3. The worker manager's `context.memory` exposes `vectorSearch`
     (only HybridMemoryBackend has it, InMemoryWorkerMemory does
     not) — a cheap structural check for the Bug 4b memory swap.

Verified red→green: with the setKernel/setMemory wiring removed
from handleFleetInit, assertions 2 and 3 fail, listing every
(worker, domain) pair that lost its API. With the wiring restored,
3/3 pass in ~170ms.

The test deliberately does NOT call `daemon.runWorker(id)` to
exercise each worker's full body. Most workers raise legitimate
"no data yet" errors on fresh installs (test-health, flaky-detector
etc.) and asserting completion would couple this test to each
worker's empty-state behaviour. The contract is structural — the
seam to the kernel is alive — not behavioural.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 09:02:13 +00:00
..