From 35a272ce23f34a38b01eef5059dc81f0cef5cca5 Mon Sep 17 00:00:00 2001 From: npc0-hue Date: Sat, 29 Aug 2026 10:36:32 +0800 Subject: [PATCH] Accept sessioned autonomous run logs --- platform/service/log_ingest.go | 2 +- platform/service/log_ingest_test.go | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/platform/service/log_ingest.go b/platform/service/log_ingest.go index b703328..1e016fa 100644 --- a/platform/service/log_ingest.go +++ b/platform/service/log_ingest.go @@ -150,7 +150,7 @@ func (svc *CoreService) ensureRunLogStreamForBatch(batch domain.LogBatchIngest, expectedStreamID = runSessionLogStreamID(batch.RunEndpointID, batch.ServerInstanceID, batch.LogSessionID, batch.StreamKey) } if batch.LogStreamID != expectedStreamID { - if batch.LogSessionID != "" || !legacyAutonomousLogStream(batch) { + if !legacyAutonomousLogStream(batch) { return repo.ErrNotFound } } diff --git a/platform/service/log_ingest_test.go b/platform/service/log_ingest_test.go index f2a0e30..8bf1a88 100644 --- a/platform/service/log_ingest_test.go +++ b/platform/service/log_ingest_test.go @@ -441,14 +441,25 @@ func TestCoreServiceAcceptsLegacyAutonomousJobLogStreamWithoutPlatformJob(t *tes } } -func TestCoreServiceRejectsSessionMetadataOnLegacyAutonomousStreamID(t *testing.T) { +func TestCoreServiceAcceptsSessionMetadataOnLegacyAutonomousStreamID(t *testing.T) { svc, sessionToken := newRegisteredLogIngestService(t) batch := validLogBatch(t, sessionToken, 1, 1) batch.LogStreamID = jobLogStreamID("autonomous-bootstrap-start", "stdout") batch.LogSessionID = "session-a" batch.SessionStartedAt = time.Date(2026, 7, 3, 12, 30, 0, 0, time.UTC) - if _, err := svc.IngestLogBatch(batch); err == nil { - t.Fatal("expected session-scoped batch with legacy autonomous stream ID to be rejected") + ack, err := svc.IngestLogBatch(batch) + if err != nil { + t.Fatalf("ingest session-scoped legacy autonomous stream: %v", err) + } + if !ack.Accepted || ack.LogStreamID != batch.LogStreamID || ack.LatestSeq != batch.LastSeq { + t.Fatalf("unexpected legacy autonomous session ack: %+v", ack) + } + stream, err := svc.GetLogStream(batch.LogStreamID) + if err != nil { + t.Fatalf("get session-scoped legacy autonomous stream: %v", err) + } + if stream.LogSessionID != batch.LogSessionID || !stream.SessionStartedAt.Equal(batch.SessionStartedAt) { + t.Fatalf("session metadata was not persisted: %+v", stream) } }