From a676e35905b4c93d3131c73abf2090f1573badbc Mon Sep 17 00:00:00 2001 From: toki Date: Sat, 15 Aug 2026 15:21:42 +0900 Subject: [PATCH] =?UTF-8?q?fix(openai):=20cleanup=EC=9D=98=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=20history=20=ED=8C=90=EC=A0=95=EC=9D=84=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/openai/hot_path_cleanup_test.go | 20 +++++++++++++++++++ apps/edge/internal/openai/hot_path_light.go | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/apps/edge/internal/openai/hot_path_cleanup_test.go b/apps/edge/internal/openai/hot_path_cleanup_test.go index 4ffed818..7ae8a253 100644 --- a/apps/edge/internal/openai/hot_path_cleanup_test.go +++ b/apps/edge/internal/openai/hot_path_cleanup_test.go @@ -64,6 +64,26 @@ func TestHotPathCleanupTerminalMatrix(t *testing.T) { } } +func TestHotPathCleanupMatchIgnoresCallerHistoryReserialization(t *testing.T) { + store := newHotPathLightStore(1) + store.records["req_cleanup_history"] = &hotPathLightRecord{ + requestID: "req_cleanup_history", ownerEdgeID: "edge-a", principalRef: "principal-a", protocol: "anthropic", + lineage: logicalRequestLineage{Endpoint: logicalRequestEndpointAnthropic, HistoryDigest: "before", ToolsetDigest: "tools"}, + phase: hotPathPhaseCleanupPending, pendingKind: hotPathPendingCleanup, pendingHash: "issued-cleanup", + pending: map[string]hotPathPendingCall{"call-cleanup": {}}, consumedHashes: map[string]struct{}{}, consumedIDs: map[string]struct{}{}, + } + lineage := logicalRequestContinuationLineage{ + Prefix: logicalRequestLineage{Endpoint: logicalRequestEndpointAnthropic, HistoryDigest: "reserialized", ToolsetDigest: "tools"}, + IssuedCallHash: "issued-cleanup", ResultIDs: []string{"call-cleanup"}, + } + store.mu.Lock() + record, matched, err := store.matchRecordLocked("edge-a", "principal-a", "anthropic", lineage) + store.mu.Unlock() + if err != nil || !matched || record == nil { + t.Fatalf("cleanup match: matched=%t record=%v err=%v", matched, record, err) + } +} + func TestHotPathCleanupPrimaryErrorPrecedence(t *testing.T) { for _, endpoint := range []string{"openai", "anthropic"} { endpoint := endpoint diff --git a/apps/edge/internal/openai/hot_path_light.go b/apps/edge/internal/openai/hot_path_light.go index 5f23b051..18117214 100644 --- a/apps/edge/internal/openai/hot_path_light.go +++ b/apps/edge/internal/openai/hot_path_light.go @@ -823,6 +823,12 @@ func (s *hotPathLightStore) matchRecordLocked(ownerEdgeID, principalRef, protoco if record.protocol != protocol { return nil, true, fmt.Errorf("%w: protocol changed", errLogicalRequestLineage) } + if record.phase == hotPathPhaseCleanupPending && record.pendingKind == hotPathPendingCleanup { + if record.lineage.Endpoint != lineage.Prefix.Endpoint || record.lineage.ToolsetDigest != lineage.Prefix.ToolsetDigest { + return nil, true, describeArtifactPrefixMismatch(record.lineage, lineage.Prefix) + } + return record, true, nil + } if record.lineage != lineage.Prefix { return nil, true, describeArtifactPrefixMismatch(record.lineage, lineage.Prefix) }