fix: preserve source event IDs across all feedback

This commit is contained in:
2026-10-10 15:02:30 +08:00
parent b41dc76ac4
commit c2ee8a5a4b
26 changed files with 553 additions and 54 deletions
+3 -3
View File
@@ -98,8 +98,8 @@ func TestOneShotResultMustMatchSourceIdentityAndPersistBeforeReceipt(t *testing.
if err != nil {
t.Fatal(err)
}
sourceID := "event-once-1"
resultID := expectedResultEventID(data.dispatcherID, sourceID)
sourceID := "numberID-once-0000123/Case"
resultID := sourceID
result := map[string]any{}
example, err := os.ReadFile("../../../contracts/schema/examples/mq-result-uploaded.json")
if err != nil {
@@ -169,7 +169,7 @@ func TestSaaSMockAwaitsExactResultBeforeStoppingCapture(t *testing.T) {
if err := json.Unmarshal(result, &message); err != nil {
t.Fatal(err)
}
message["event_id"] = expectedResultEventID(data.dispatcherID, eventID)
message["event_id"] = eventID
message["dispatcher_id"] = data.dispatcherID
payload := message["payload"].(map[string]any)
payload["task_id"], payload["callee"], payload["trunk_id"] = "task-full", "15003164745", "trunk-mock"
+1 -6
View File
@@ -24,11 +24,6 @@ type oneShotResult struct {
BodySHA256 string
}
func expectedResultEventID(dispatcherID, sourceID string) string {
identity := sha256.Sum256([]byte("call.execute.result\x00" + dispatcherID + "\x00" + sourceID))
return fmt.Sprintf("result-%x", identity[:])
}
func verifyOneShotReceipt(body []byte, dispatcherID string, tenantID int64, sourceID string) (string, error) {
if err := contract.ValidateCurrent("mq", body); err != nil {
return "", errors.New("call dispatch receipt violates the current MQ contract")
@@ -67,7 +62,7 @@ func summarizeOneShotResult(body []byte, dispatcherID, sourceID, taskID, callee,
} `json:"recording"`
} `json:"payload"`
}
if err := json.Unmarshal(body, &event); err != nil || event.EventType != "call.execute.result" || event.EventID != expectedResultEventID(dispatcherID, sourceID) || event.DispatcherID != dispatcherID || event.Payload.TaskID != taskID || event.Payload.Callee != callee || event.Payload.TrunkID != trunkID {
if err := json.Unmarshal(body, &event); err != nil || event.EventType != "call.execute.result" || event.EventID != sourceID || event.DispatcherID != dispatcherID || event.Payload.TaskID != taskID || event.Payload.Callee != callee || event.Payload.TrunkID != trunkID {
return oneShotResult{}, errors.New("final MQ result does not belong to the selected one-shot call")
}
sha := sha256.Sum256(body)