Skip to content

Commit 568e38e

Browse files
committed
fix(termination): emit only 'Document Processing Terminated' for root fatal; drop extra fatal outbox
- Remove recording of "Document Processing Fatal Error" outbox event on root ("/") fatal termination; only mark run terminated and throw. - Preserve `reason` on the terminated lifecycle event. - Update `DocumentProcessorTerminationTest` to expect a single terminated event with cause "fatal" and reason "panic". - Simplifies termination semantics and avoids duplicate/overlapping events.
1 parent 7d0574b commit 568e38e

2 files changed

Lines changed: 6 additions & 19 deletions

File tree

src/main/java/blue/language/processor/TerminationService.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ void terminateScope(ProcessorEngine.Execution execution,
3939
}
4040

4141
if (ScopeRuntimeContext.TerminationKind.FATAL.equals(kind) && "/".equals(normalized)) {
42-
runtime.recordRootEmission(createFatalOutboxEvent(normalized, reason));
4342
runtime.markRunTerminated();
4443
throw new RunTerminationException(true);
4544
}
@@ -68,14 +67,4 @@ private Node createTerminationLifecycleEvent(ScopeRuntimeContext.TerminationKind
6867
}
6968
return event;
7069
}
71-
72-
private Node createFatalOutboxEvent(String scopePath, String reason) {
73-
Node event = new Node().properties("type", new Node().value("Document Processing Fatal Error"));
74-
event.properties("domain", new Node().value(scopePath));
75-
event.properties("code", new Node().value("RuntimeFatal"));
76-
if (reason != null && !reason.isEmpty()) {
77-
event.properties("reason", new Node().value(reason));
78-
}
79-
return event;
80-
}
8170
}

src/test/java/blue/language/processor/DocumentProcessorTerminationTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void rootGracefulTerminationStopsFurtherWork() {
6161
}
6262

6363
@Test
64-
void rootFatalTerminationRecordsFatalOutbox() {
64+
void rootFatalTerminationEmitsTerminationEvent() {
6565
Node document = blue.yamlToNode("name: Root Fatal\n" +
6666
"contracts:\n" +
6767
" testChannel:\n" +
@@ -79,13 +79,11 @@ void rootFatalTerminationRecordsFatalOutbox() {
7979
DocumentProcessingResult result = blue.processDocument(initialized, event);
8080

8181
List<Node> triggeredEvents = result.triggeredEvents();
82-
assertEquals(2, triggeredEvents.size(), "Fatal run should emit terminated and fatal error events");
83-
assertEquals("Document Processing Terminated", stringProperty(triggeredEvents.get(0), "type"));
84-
assertEquals("fatal", stringProperty(triggeredEvents.get(0), "cause"));
85-
assertEquals("Document Processing Fatal Error", stringProperty(triggeredEvents.get(1), "type"));
86-
assertEquals("/", stringProperty(triggeredEvents.get(1), "domain"));
87-
assertEquals("RuntimeFatal", stringProperty(triggeredEvents.get(1), "code"));
88-
assertEquals("panic", stringProperty(triggeredEvents.get(1), "reason"));
82+
assertEquals(1, triggeredEvents.size(), "Fatal run should emit the terminated lifecycle event only");
83+
Node terminatedEvent = triggeredEvents.get(0);
84+
assertEquals("Document Processing Terminated", stringProperty(terminatedEvent, "type"));
85+
assertEquals("fatal", stringProperty(terminatedEvent, "cause"));
86+
assertEquals("panic", stringProperty(terminatedEvent, "reason"));
8987
}
9088

9189
@Test

0 commit comments

Comments
 (0)