Enhance Delivery Result Structure and Update Test Cases

- Modified the DeliveryResult structure across multiple executors to include RequestID and Content fields, providing detailed summaries and bodies for dry-run, sandbox, and standard deliveries.
- Updated related test cases to reflect changes in the DeliveryResult structure, ensuring accurate validation of delivery types and content handling.
- Revised input formatting to display delivery summaries instead of types, improving clarity in execution summaries.
This commit is contained in:
Max 2026-01-18 17:21:21 +08:00
parent ad7e0dbf85
commit 6c45cc41be
8 changed files with 36 additions and 11 deletions

View file

@ -168,7 +168,11 @@ func (e *Executor) mockPhaseOutput(exec *robottypes.Execution, phase robottypes.
}
case robottypes.PhaseDelivery:
exec.Delivery = &robottypes.DeliveryResult{
Type: robottypes.DeliveryNotify,
RequestID: "dryrun-" + exec.ID,
Content: &robottypes.DeliveryContent{
Summary: "Dry-run delivery completed",
Body: "# Dry-run Delivery\n\nThis is a simulated delivery result.",
},
Success: true,
}
case robottypes.PhaseLearning:

View file

@ -201,7 +201,11 @@ func (e *Executor) mockPhaseOutput(exec *robottypes.Execution, phase robottypes.
}
case robottypes.PhaseDelivery:
exec.Delivery = &robottypes.DeliveryResult{
Type: robottypes.DeliveryNotify,
RequestID: "sandbox-" + exec.ID,
Content: &robottypes.DeliveryContent{
Summary: "Sandbox delivery completed",
Body: "# Sandbox Delivery\n\nThis is a simulated sandbox delivery result.",
},
Success: true,
}
case robottypes.PhaseLearning:

View file

@ -25,7 +25,11 @@ func (e *Executor) RunDelivery(ctx *robottypes.Context, exec *robottypes.Executi
e.simulateStreamDelay()
exec.Delivery = &robottypes.DeliveryResult{
Type: robottypes.DeliveryNotify,
RequestID: "delivery-" + exec.ID,
Content: &robottypes.DeliveryContent{
Summary: "Delivery completed (placeholder)",
Body: "# Delivery\n\nTODO: Implement real delivery logic.",
},
Success: true,
}
return nil

View file

@ -170,7 +170,7 @@ func ParseDelivery(data map[string]interface{}) *robottypes.DeliveryTarget {
func IsValidDeliveryType(t robottypes.DeliveryType) bool {
switch t {
case robottypes.DeliveryEmail, robottypes.DeliveryWebhook,
robottypes.DeliveryFile, robottypes.DeliveryNotify:
robottypes.DeliveryProcess, robottypes.DeliveryNotify:
return true
default:
return false

View file

@ -334,7 +334,7 @@ func TestParseDeliveryFromGoalsResponse(t *testing.T) {
if exec.Goals.Delivery.Type != "" {
validTypes := []types.DeliveryType{
types.DeliveryEmail, types.DeliveryWebhook,
types.DeliveryFile, types.DeliveryNotify,
types.DeliveryProcess, types.DeliveryNotify,
}
found := false
for _, vt := range validTypes {
@ -355,7 +355,7 @@ func TestDeliveryTypeValidation(t *testing.T) {
validTypes := []types.DeliveryType{
types.DeliveryEmail,
types.DeliveryWebhook,
types.DeliveryFile,
types.DeliveryProcess,
types.DeliveryNotify,
}
@ -462,7 +462,7 @@ func TestParseDelivery(t *testing.T) {
})
t.Run("parses all valid delivery types", func(t *testing.T) {
validTypes := []string{"email", "webhook", "file", "notify"}
validTypes := []string{"email", "webhook", "process", "notify"}
for _, dt := range validTypes {
data := map[string]interface{}{

View file

@ -511,12 +511,17 @@ func (f *InputFormatter) FormatExecutionSummary(exec *robottypes.Execution) stri
// Delivery (P4)
if exec.Delivery != nil {
sb.WriteString("## Delivery (P4)\n\n")
sb.WriteString(fmt.Sprintf("- **Type**: %s\n", exec.Delivery.Type))
if exec.Delivery.Content != nil {
sb.WriteString(fmt.Sprintf("- **Summary**: %s\n", exec.Delivery.Content.Summary))
}
if exec.Delivery.Success {
sb.WriteString("- **Status**: ✓ Success\n")
} else {
sb.WriteString(fmt.Sprintf("- **Status**: ✗ Failed (%s)\n", exec.Delivery.Error))
}
if len(exec.Delivery.Results) > 0 {
sb.WriteString(fmt.Sprintf("- **Channels**: %d\n", len(exec.Delivery.Results)))
}
sb.WriteString("\n")
}

View file

@ -455,7 +455,11 @@ func TestInputFormatterFormatExecutionSummary(t *testing.T) {
{TaskID: "t2", Success: true, Duration: 200},
},
Delivery: &types.DeliveryResult{
Type: types.DeliveryEmail,
RequestID: "test-delivery-001",
Content: &types.DeliveryContent{
Summary: "Test delivery completed",
Body: "# Test Delivery\n\nTest delivery body.",
},
Success: true,
},
}
@ -476,7 +480,7 @@ func TestInputFormatterFormatExecutionSummary(t *testing.T) {
assert.Contains(t, result, "## Results (P3)")
assert.Contains(t, result, "✓ t1")
assert.Contains(t, result, "## Delivery (P4)")
assert.Contains(t, result, "email")
assert.Contains(t, result, "Test delivery completed")
})
t.Run("formats execution with error", func(t *testing.T) {

View file

@ -278,8 +278,12 @@ func TestCompleteExecution(t *testing.T) {
// Simulate execution progress
exec.Delivery = &types.DeliveryResult{
RequestID: "test-delivery-001",
Content: &types.DeliveryContent{
Summary: "Test delivery completed",
Body: "# Test Delivery\n\nThis is a test delivery result.",
},
Success: true,
Type: types.DeliveryEmail,
}
err = job.CompleteExecution(ctx, exec)