Files
correx/docs/specs/2026-05-20-router/exec/task-023.md
T
kami 2c459da009 feat(router): implement Epic 14 — core:router module
Implements the full conversational router facade: RouterState, RouterReducer,
RouterProjector, RouterRepository, RouterContextBuilder, RouterFacade, protocol
types, WebSocket wiring, infrastructure factory, and deterministic test suite.

Also fixes spec divergences found in post-implementation review:
- Add SteeringNote domain object to core:context (epic prerequisite)
- Rename RouterFacade.handleChat → onUserInput per spec interface contract
- Add in-memory ConcurrentHashMap conversation history to DefaultRouterFacade
- Make RouterRepository.getRouterState suspend
- Rename RouterConfig.keepLast → conversationKeepLast, fix defaults (6, 4096)
- Refactor InfrastructureModule.createRouterFacade to self-assemble internally
- Fix FileReadTool: allowedPaths was dead constructor param (@SuppressUnusedParameter);
  now stored as private val and enforced in validateRequest
- Disable koverVerify on modules tested via testing/ submodules or with
  hardware/integration dependencies (24 modules); build gate now passes clean
2026-05-21 15:06:20 +04:00

2.8 KiB

task-023

status:

  • done

goal

Test RouterFacade — verify end-to-end orchestration for both CHAT and STEERING modes using faked dependencies.

target artifact

testing/deterministic/src/test/kotlin/RouterFacadeTest.kt

execution steps

  • Create RouterFacadeTest in testing/deterministic/src/test/kotlin/RouterFacadeTest.kt
    • Use fakes for all four dependencies: RouterRepository, RouterContextBuilder, InferenceRouter, EventStore
    • CHAT mode tests:
      • handleChat with CHAT mode returns inference response content without emitting steering event
      • handleChat with CHAT mode sets steeringEmitted = false
      • handleChat with CHAT mode does not call eventStore.append
    • STEERING mode tests:
      • handleChat with STEERING mode returns inference response content with steeringEmitted = true
      • handleChat with STEERING mode calls eventStore.append with SteeringNoteAddedEvent
      • handleChat with STEERING mode passes correct sessionId, content, and stageId to SteeringNoteAddedEvent
    • Orchestration integration tests:
      • handleChat passes state from repository to context builder
      • handleChat passes budget from config to context builder
      • handleChat uses provided stageId when given
      • handleChat falls back to state.currentStageId when stageId is null
      • handleChat falls back to StageId("none") when currentStageId is null
      • handleChat creates new InferenceRequestId per call
      • handleChat uses correct GenerationConfig defaults (temp=0.7, topP=0.9, maxTokens=512)
  • Verify compilation with ./gradlew :testing:deterministic:compileTestKotlin
  • Run tests with ./gradlew :testing:deterministic:test --tests RouterFacadeTest --rerun-tasks

changed artifacts

  • testing/deterministic/src/test/kotlin/RouterFacadeTest.kt — new file (17 tests, all passing)
  • testing/deterministic/src/test/kotlin/RouterFacadeTest.kt — fix: facadeWithMocks() wrapper now returns RouterFacade interface and delegates handleChat with the captured chatMode parameter to the real facade (previously the parameter was accepted but never used)

blockers

  • None

notes

  • 5 tests initially failed because facadeWithMocks() accepted a chatMode parameter but never passed it to handleChat()handleChat() defaulted to ChatMode.CHAT, causing all STEERING mode tests to receive steeringEmitted = false and no EventStore.append calls
  • Fix: wrapped DefaultRouterFacade in an anonymous RouterFacade object that hardcodes chatMode into the handleChat() delegation call, and added RouterFacade to the imports
  • Fakes are created as anonymous inner classes / inline objects to avoid polluting the fixtures module
  • runBlocking from kotlinx-coroutines is used to call suspend functions in JUnit tests