fix: forward driver onLog output as method_output events#900
Conversation
Out-of-process execution drivers emit log lines via callbacks.onLog,
but these were only sent to the logger — not through the onEvent
stream. This meant WebSocket clients (swamp serve) never received
method_output events from drivers like Tensorlake.
Now onLog also emits MethodExecutionEvent { type: "output" } so
the output appears in the event stream alongside in-process output.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
Blocking Issues
None.
Suggestions
- Test coverage for onEvent in driver path: The test file
method_execution_service_test.tshas no coverage foronEventcallbacks (pre-existing gap, not introduced by this PR). A test verifying thatonLogcallbacks forward events viacontext.onEventwould be valuable as a follow-up — e.g., a mock driver that callsonLogand asserts the event appears on theonEventcallback.
Notes
- Event shape
{ type: "output", stream: "stdout", line }correctly matches theMethodExecutionEventdiscriminated union inmethod_events.ts - Safe optional chaining (
context.onEvent?.()) is consistent with other call sites (data_writer.ts,shell_model.ts) - Hardcoding
stream: "stdout"is appropriate since theonLogcallback doesn't carry stream information - No libswamp import boundary violations — this is internal domain code
- DDD: proper use of domain events within a domain service; no concerns
There was a problem hiding this comment.
Adversarial Review
Critical / High
None.
Medium
-
src/domain/models/method_execution_service.ts:657— hardcodedstream: "stdout"is incorrect for Docker driver outputThe Docker driver (
docker_execution_driver.ts:157-159,328-330) callsonLogexclusively from its stderr stream processing. However, the new code hardcodesstream: "stdout"for allonLogoutput events. This means WebSocket clients will see Docker driver log lines labeled asstdoutwhen they actually originate fromstderr.The root cause is that the
ExecutionCallbacks.onLoginterface (execution_driver.ts:60) is stream-agnostic — it only passes(line: string)with no stream indicator. So the method_execution_service layer has no way to know which stream the line came from.Impact: Consumers relying on
streamto distinguish stdout vs stderr output will misclassify Docker driver logs. This is medium becauseonLogis used for informational logging (e.g., "starting container", "loading model") rather than model output, so the misclassification is unlikely to cause functional breakage — but it is semantically wrong.Suggested fix (not blocking): Either extend
ExecutionCallbacks.onLogto(line: string, stream: "stdout" | "stderr") => voidand pass the stream through, or use a neutral label like"stderr"since the Docker driver (the only current caller) only emits from stderr. Alternatively, document thatstreamon driver-forwarded events is best-effort.
Low
None.
Verdict
PASS — The change correctly addresses the missing event forwarding gap. The event shape matches the MethodExecutionEvent type contract exactly. The use of optional chaining (context.onEvent?.()) is safe. The only concern is the hardcoded stream label, which is a semantic inaccuracy rather than a functional bug.
Summary
Out-of-process execution drivers (Tensorlake, Docker, etc.) emit log lines via
callbacks.onLog, but these were only forwarded to the logger — not through theonEventstream. This meant WebSocket clients usingswamp servenever receivedmethod_outputevents from these drivers.Now
onLogalso emitsMethodExecutionEvent { type: "output" }so the output appears in the event stream alongside in-process output.Test plan
🤖 Generated with Claude Code