RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Go: add context, part5 (#19108)
Jin Haic0cf9e9d062e
diff --git a/internal/harness/events/events_test.go b/internal/harness/events/events_test.goindex 70ae19fa09..bc6dd667b3 100644--- a/internal/harness/events/events_test.go+++ b/internal/harness/events/events_test.go@@ -12,7 +12,7 @@ import ()func TestMemoryEventStore_AppendAndStream(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()s := NewMemoryEventStore()ev1 := &Event{ID: "e1", Type: EventGraphStart, Clock: 1, Timestamp: time.Now(), TraceID: "trace-1"}@@ -41,7 +41,7 @@ func TestMemoryEventStore_AppendAndStream(t *testing.T) {}func TestMemoryEventStore_Get(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()s := NewMemoryEventStore()s.Append(ctx, &Event{ID: "find-me", Type: EventNodeStart, Clock: 1, TraceID: "t"})@@ -63,7 +63,7 @@ func TestMemoryEventStore_Get(t *testing.T) {}func TestMemoryEventStore_Range(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()s := NewMemoryEventStore()for i := 1; i <= 10; i++ {s.Append(ctx, &Event{ID: EventID(fmt.Sprintf("e%d", i)), Clock: uint64(i), Type: EventStepStart, Timestamp: time.Now(), TraceID: "t"})@@ -82,7 +82,7 @@ func TestMemoryEventStore_Range(t *testing.T) {}func TestMemoryEventStore_Seek(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()s := NewMemoryEventStore()for i := 1; i <= 5; i++ {s.Append(ctx, &Event{ID: EventID(fmt.Sprintf("e%d", i)), Clock: uint64(i), Type: EventStepStart, TraceID: "t"})@@ -99,7 +99,7 @@ func TestMemoryEventStore_Seek(t *testing.T) {}func TestMemoryEventStore_Length(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()s := NewMemoryEventStore()n, _ := s.Length(ctx)if n != 0 {@@ -149,7 +149,7 @@ func TestMemoryEventStore_Filter(t *testing.T) {func TestLocalFileEventStore_GC_RetainsSurvivingEvents(t *testing.T) {dir := t.TempDir()- ctx := context.Background()+ ctx := t.Context()s, err := NewLocalFileEventStore(dir)if err != nil {@@ -196,7 +196,7 @@ func TestLocalFileEventStore_GC_RetainsSurvivingEvents(t *testing.T) {}func TestMemoryEventStore_GC(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()s := NewMemoryEventStore()old := &Event{ID: "old", Clock: 1, Type: EventGraphStart, Timestamp: time.Now().Add(-2 * time.Hour), TraceID: "t"}s.Append(ctx, old)@@ -216,7 +216,7 @@ func TestMemoryEventStore_GC(t *testing.T) {func TestLocalFileEventStore_AppendAndReopen(t *testing.T) {dir := t.TempDir()- ctx := context.Background()+ ctx := t.Context()s, err := NewLocalFileEventStore(dir)if err != nil {@@ -249,7 +249,7 @@ func TestLocalFileEventStore_AppendAndReopen(t *testing.T) {func TestLocalFileEventStore_SegmentRotation(t *testing.T) {dir := t.TempDir()- ctx := context.Background()+ ctx := t.Context()// Use small maxSize to force rotation.s := &LocalFileEventStore{@@ -338,7 +338,7 @@ func TestEvent_Seal(t *testing.T) {}func TestMemoryEventStore_Snapshot(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()s := NewMemoryEventStore()s.Append(ctx, &Event{ID: "s1", Clock: 1, Type: EventGraphStart, TraceID: "snap-trace", Timestamp: time.Now()})s.Append(ctx, &Event{ID: "s2", Clock: 2, Type: EventGraphEnd, TraceID: "snap-trace", Timestamp: time.Now()})@@ -375,7 +375,7 @@ func TestLogicalClock(t *testing.T) {}func TestEventRecorder_GraphCallback(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := NewMemoryEventStore()r := NewEventRecorder(store, WithTraceID("rec-trace"), WithThreadID("rec-thread"))@@ -407,7 +407,7 @@ func TestEventRecorder_GraphCallback(t *testing.T) {}func TestEventRecorder_ModelAndToolCalls(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := NewMemoryEventStore()r := NewEventRecorder(store, WithTraceID("mt-trace"))@@ -434,7 +434,7 @@ func TestEventRecorder_ModelAndToolCalls(t *testing.T) {}func TestEventRecorder_FineGrained(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := NewMemoryEventStore()r := NewEventRecorder(store, WithTraceID("fine"))@@ -464,7 +464,7 @@ func TestEventRecorder_FineGrained(t *testing.T) {}func TestEventRecorder_ContextHelpers(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := NewMemoryEventStore()r := NewEventRecorder(store, WithTraceID("ctx-test"))@@ -478,14 +478,14 @@ func TestEventRecorder_ContextHelpers(t *testing.T) {}// Context without recorder should return nil.- ctx2 := context.Background()+ ctx2 := t.Context()if RecorderFromContext(ctx2) != nil {t.Fatal("expected nil from context without recorder")}}func TestSubAgentAndSessionEvents(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := NewMemoryEventStore()r := NewEventRecorder(store, WithTraceID("sub-session"))diff --git a/internal/harness/graph/checkpoint/checkpoint_conformance_test.go b/internal/harness/graph/checkpoint/checkpoint_conformance_test.goindex 5d0868e771..6eb5ce3ff2 100644--- a/internal/harness/graph/checkpoint/checkpoint_conformance_test.go+++ b/internal/harness/graph/checkpoint/checkpoint_conformance_test.go@@ -6,7 +6,6 @@package checkpointimport (- "context""fmt""sort""testing"@@ -62,7 +61,7 @@ func threadConfigWithID(tid, cpid string) map[string]interface{} {// TestPutAndGet verifies basic write-then-read.func (suite *ConformanceTestSuite) TestPutAndGet(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()tid := "test-thread-putget"data := map[string]interface{}{"key1": "value1", "key2": 42, "key3": true}@@ -84,7 +83,7 @@ func (suite *ConformanceTestSuite) TestPutAndGet(t *testing.T) {// TestPutAndGetByID verifies getting a specific checkpoint by ID.func (suite *ConformanceTestSuite) TestPutAndGetByID(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()tid := "test-thread-byid"data1 := map[string]interface{}{"version": 1}@@ -138,7 +137,7 @@ func (suite *ConformanceTestSuite) TestPutAndGetByID(t *testing.T) {// TestListEmpty verifies List returns nil/empty for a thread with no checkpoints.func (suite *ConformanceTestSuite) TestListEmpty(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()entries, err := cp.List(ctx, threadConfig("nonexistent-thread"), 10)if err != nil {@@ -152,7 +151,7 @@ func (suite *ConformanceTestSuite) TestListEmpty(t *testing.T) {// TestListOrder verifies List returns checkpoints in reverse chronological order.func (suite *ConformanceTestSuite) TestListOrder(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()tid := "test-thread-order"n := 5@@ -211,7 +210,7 @@ func (suite *ConformanceTestSuite) TestListOrder(t *testing.T) {// TestListWithLimit verifies List respects the limit parameter.func (suite *ConformanceTestSuite) TestListWithLimit(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()tid := "test-thread-limit"for i := 0; i < 10; i++ {@@ -233,7 +232,7 @@ func (suite *ConformanceTestSuite) TestListWithLimit(t *testing.T) {// TestMultipleThreads verifies isolation between threads.func (suite *ConformanceTestSuite) TestMultipleThreads(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()threads := []string{"thread-a", "thread-b", "thread-c"}for _, tid := range threads {@@ -261,7 +260,7 @@ func (suite *ConformanceTestSuite) TestMultipleThreads(t *testing.T) {// TestGetNonExistent verifies Get returns nil for non-existent threads.func (suite *ConformanceTestSuite) TestGetNonExistent(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()got, err := cp.Get(ctx, threadConfig("does-not-exist"))if err != nil {@@ -275,7 +274,7 @@ func (suite *ConformanceTestSuite) TestGetNonExistent(t *testing.T) {// TestOverwriteExisting verifies Put with same thread ID replaces latest.func (suite *ConformanceTestSuite) TestOverwriteExisting(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()tid := "test-thread-overwrite"v1 := map[string]interface{}{"value": "first"}@@ -303,7 +302,7 @@ func (suite *ConformanceTestSuite) TestOverwriteExisting(t *testing.T) {// TestListAcrossThreads verifies List only returns entries for the specified thread.func (suite *ConformanceTestSuite) TestListAcrossThreads(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()for i := 0; i < 3; i++ {tid := fmt.Sprintf("thread-%d", i)@@ -327,7 +326,7 @@ func (suite *ConformanceTestSuite) TestListAcrossThreads(t *testing.T) {// TestPutPreservesData verifies all types of data are preserved.func (suite *ConformanceTestSuite) TestPutPreservesData(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()tid := "test-thread-types"data := map[string]interface{}{@@ -359,7 +358,7 @@ func (suite *ConformanceTestSuite) TestPutPreservesData(t *testing.T) {// TestDeepCopySemantics verifies that Put stores a copy, not a reference.func (suite *ConformanceTestSuite) TestDeepCopySemantics(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()tid := "test-thread-deepcopy"data := map[string]interface{}{@@ -387,7 +386,7 @@ func (suite *ConformanceTestSuite) TestDeepCopySemantics(t *testing.T) {// TestConcurrentAccess verifies thread safety under concurrent Put/Get operations.func (suite *ConformanceTestSuite) TestConcurrentAccess(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()const goroutines = 20const opsPerGoroutine = 50@@ -426,7 +425,7 @@ func (suite *ConformanceTestSuite) TestConcurrentAccess(t *testing.T) {// TestManyCheckpoints verifies performance with many checkpoints.func (suite *ConformanceTestSuite) TestManyCheckpoints(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()const n = 100tid := "test-thread-many"@@ -474,7 +473,7 @@ func (suite *ConformanceTestSuite) TestManyCheckpoints(t *testing.T) {// TestEmptyValues verifies round-trip with empty maps.func (suite *ConformanceTestSuite) TestEmptyValues(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()tid := "test-thread-empty"empty := map[string]interface{}{}@@ -494,7 +493,7 @@ func (suite *ConformanceTestSuite) TestEmptyValues(t *testing.T) {// TestNilConfig verifies Get/Put with missing thread_id returns an error.func (suite *ConformanceTestSuite) TestNilConfig(t *testing.T) {cp := suite.NewCheckpointer()- ctx := context.Background()+ ctx := t.Context()// Put without thread_id should fail.err := cp.Put(ctx, map[string]interface{}{}, map[string]interface{}{"key": "val"})diff --git a/internal/harness/graph/checkpoint/checkpoint_edge_serde_test.go b/internal/harness/graph/checkpoint/checkpoint_edge_serde_test.goindex a7a9f2ac39..a0cc43c674 100644--- a/internal/harness/graph/checkpoint/checkpoint_edge_serde_test.go+++ b/internal/harness/graph/checkpoint/checkpoint_edge_serde_test.go@@ -3,7 +3,6 @@package checkpointimport (- "context""fmt""sync""testing"@@ -19,7 +18,7 @@ import (// TestCheckpointSerde_VariousTypes verifies round-trip of all basic types.func TestCheckpointSerde_VariousTypes(t *testing.T) {ms := NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()tid := "serde-types"cfg := map[string]interface{}{constants.ConfigKeyThreadID: tid}@@ -63,7 +62,7 @@ func TestCheckpointSerde_VariousTypes(t *testing.T) {// TestCheckpointSerde_EmptyMap verifies empty map round-trip.func TestCheckpointSerde_EmptyMap(t *testing.T) {ms := NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()tid := "serde-empty"cfg := map[string]interface{}{constants.ConfigKeyThreadID: tid}@@ -87,7 +86,7 @@ func TestCheckpointSerde_EmptyMap(t *testing.T) {// TestCheckpointSerde_LargeMap verifies large map serialization.func TestCheckpointSerde_LargeMap(t *testing.T) {ms := NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()tid := "serde-large"cfg := map[string]interface{}{constants.ConfigKeyThreadID: tid}@@ -115,7 +114,7 @@ func TestCheckpointSerde_LargeMap(t *testing.T) {// TestCheckpointSerde_NestedArrays verifies deeply nested arrays.func TestCheckpointSerde_NestedArrays(t *testing.T) {ms := NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()tid := "serde-nest-arr"cfg := map[string]interface{}{constants.ConfigKeyThreadID: tid}@@ -148,7 +147,7 @@ func TestCheckpointSerde_NestedArrays(t *testing.T) {// TestCheckpointConcurrent_DifferentThreads runs Put on 100 threads.func TestCheckpointConcurrent_DifferentThreads(t *testing.T) {ms := NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()var wg sync.WaitGroupfor i := 0; i < 100; i++ {wg.Add(1)@@ -171,7 +170,7 @@ func TestCheckpointConcurrent_DifferentThreads(t *testing.T) {// TestCheckpointSerde_ListZeroLimit verifies List returns all when limit=0.func TestCheckpointSerde_ListZeroLimit(t *testing.T) {ms := NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()tid := "list-zero"cfg := map[string]interface{}{constants.ConfigKeyThreadID: tid}@@ -195,7 +194,7 @@ func TestCheckpointSerde_ListZeroLimit(t *testing.T) {// TestCheckpointSerde_LatestAfterManyPuts verifies Get returns latest.func TestCheckpointSerde_LatestAfterManyPuts(t *testing.T) {ms := NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()tid := "latest-after-many"cfg := map[string]interface{}{constants.ConfigKeyThreadID: tid}@@ -228,7 +227,7 @@ func TestCheckpointSerde_LatestAfterManyPuts(t *testing.T) {// TestCheckpointSerde_TimestampOrdering verifies List ordering.func TestCheckpointSerde_TimestampOrdering(t *testing.T) {ms := NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()tid := "ts-ordering"cfg := map[string]interface{}{constants.ConfigKeyThreadID: tid}@@ -262,7 +261,7 @@ func TestCheckpointSerde_TimestampOrdering(t *testing.T) {// TestCheckpointSerde_ParentIDChain verifies parent_id links form a chain.func TestCheckpointSerde_ParentIDChain(t *testing.T) {ms := NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()tid := "parent-chain"cfg := map[string]interface{}{constants.ConfigKeyThreadID: tid}@@ -296,7 +295,7 @@ func TestCheckpointSerde_ParentIDChain(t *testing.T) {// TestCheckpointSerde_RapidPutGet does 1000 Put/Get cycles on same thread.func TestCheckpointSerde_RapidPutGet(t *testing.T) {ms := NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()tid := "rapid-pg"cfg := map[string]interface{}{constants.ConfigKeyThreadID: tid}@@ -319,7 +318,7 @@ func TestCheckpointSerde_RapidPutGet(t *testing.T) {// on multiple threads.func TestCheckpointConcurrent_RapidCycle(t *testing.T) {ms := NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()var wg sync.WaitGroupfor g := 0; g < 20; g++ {wg.Add(1)diff --git a/internal/harness/graph/checkpoint/checkpoint_test.go b/internal/harness/graph/checkpoint/checkpoint_test.goindex 05fb6baebc..51c4901368 100644--- a/internal/harness/graph/checkpoint/checkpoint_test.go+++ b/internal/harness/graph/checkpoint/checkpoint_test.go@@ -1,12 +1,11 @@package checkpointimport (- "context""testing")func TestMemorySaver(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()saver := NewMemorySaver()threadID := "test-thread-1"@@ -49,7 +48,7 @@ func TestMemorySaver(t *testing.T) {}func TestMemorySaverMultipleVersions(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()saver := NewMemorySaver()threadID := "test-thread-2"@@ -94,7 +93,7 @@ func TestMemorySaverMultipleVersions(t *testing.T) {}func TestMemorySaverMultipleThreads(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()saver := NewMemorySaver()// Save checkpoints for different threads@@ -170,7 +169,7 @@ func TestDeepCopySlice(t *testing.T) {}func TestMemorySaverWithMetadata(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()saver := NewMemorySaver()threadID := "test-thread-meta"@@ -208,7 +207,7 @@ func TestMemorySaverWithMetadata(t *testing.T) {}func TestMemorySaverCheckpointID(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()saver := NewMemorySaver()threadID := "test-thread-id"diff --git a/internal/harness/graph/checkpoint/concurrency_test.go b/internal/harness/graph/checkpoint/concurrency_test.goindex 48bc451b0b..6d1a30dc90 100644--- a/internal/harness/graph/checkpoint/concurrency_test.go+++ b/internal/harness/graph/checkpoint/concurrency_test.go@@ -2,7 +2,6 @@package checkpointimport (- "context""testing""time"@@ -87,7 +86,7 @@ func TestVersionConflictError(t *testing.T) {}func TestCheckpointManager_SaveWithVersionConflict(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()manager := NewCheckpointManager(10)// Create initial checkpoint@@ -115,7 +114,7 @@ func TestCheckpointManager_SaveWithVersionConflict(t *testing.T) {}func TestCheckpointManager_PutWrites(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()manager := NewCheckpointManager(10)// Create initial checkpoint@@ -164,7 +163,7 @@ func TestCheckpointManager_PutWrites(t *testing.T) {}func TestCheckpointManager_PutWrites_Conflict(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()manager := NewCheckpointManager(10)// Create initial checkpoint@@ -207,7 +206,7 @@ func TestCheckpointManager_PutWrites_Conflict(t *testing.T) {}func TestCheckpointManager_GetTuple(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()manager := NewCheckpointManager(10)config := types.NewRunnableConfig()@@ -245,7 +244,7 @@ func TestCheckpointManager_GetTuple(t *testing.T) {}func TestCheckpointManager_GetTupleByVersion(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()manager := NewCheckpointManager(10)// Create and save multiple checkpoints@@ -307,7 +306,7 @@ func TestCheckpointManager_GetTupleByVersion(t *testing.T) {}func TestCheckpointManager_GetLineage(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()manager := NewCheckpointManager(10)// Create and save multiple checkpoints in a version chain.@@ -358,7 +357,7 @@ func TestCheckpointManager_GetLineage(t *testing.T) {}func TestCheckpointManager_ConcurrentWrites(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()manager := NewCheckpointManager(10)// Create initial checkpointdiff --git a/internal/harness/graph/graph/graph_checkpoint_migration_test.go b/internal/harness/graph/graph/graph_checkpoint_migration_test.goindex b03a3e80d7..63eddccd8e 100644--- a/internal/harness/graph/graph/graph_checkpoint_migration_test.go+++ b/internal/harness/graph/graph/graph_checkpoint_migration_test.go@@ -37,7 +37,7 @@ func TestCheckpointMigration_ParentChild_Mapping(t *testing.T) {// Migrate back via the subgraph object (mapping stored in subgraph.checkpointMap).sub, _ := csg.GetSubgraph("sub")- parentCPID, err := sub.MigrateCheckpoint(context.Background(), "thread1", subCPID, "")+ parentCPID, err := sub.MigrateCheckpoint(t.Context(), "thread1", subCPID, "")if err != nil {t.Fatalf("MigrateCheckpoint to parent: %v", err)}@@ -63,8 +63,8 @@ func TestCheckpointMigration_MultipleSubgraphs(t *testing.T) {t.Fatalf("AddSubgraph sub_b: %v", err)}- subAID, _ := csg.MigrateCheckpoint(context.Background(), "t1", "parent_a", "sub_a")- subBID, _ := csg.MigrateCheckpoint(context.Background(), "t1", "parent_b", "sub_b")+ subAID, _ := csg.MigrateCheckpoint(t.Context(), "t1", "parent_a", "sub_a")+ subBID, _ := csg.MigrateCheckpoint(t.Context(), "t1", "parent_b", "sub_b")if subAID == subBID {t.Fatal("expected different checkpoint IDs")}@@ -72,11 +72,11 @@ func TestCheckpointMigration_MultipleSubgraphs(t *testing.T) {// Migrate back via subgraph objects (mappings stored in subgraph checkpointMap).subA, _ := csg.GetSubgraph("sub_a")subB, _ := csg.GetSubgraph("sub_b")- backA, _ := subA.MigrateCheckpoint(context.Background(), "t1", subAID, "")+ backA, _ := subA.MigrateCheckpoint(t.Context(), "t1", subAID, "")if backA != "parent_a" {t.Fatalf("expected parent_a, got %s", backA)}- backB, _ := subB.MigrateCheckpoint(context.Background(), "t1", subBID, "")+ backB, _ := subB.MigrateCheckpoint(t.Context(), "t1", subBID, "")if backB != "parent_b" {t.Fatalf("expected parent_b, got %s", backB)}@@ -138,7 +138,7 @@ func TestCheckpointMigration_VersionEvolution(t *testing.T) {constants.ConfigKeyThreadID: tid,},}- _, err = v1Compiled.Invoke(context.Background(), map[string]any{}, cfg)+ _, err = v1Compiled.Invoke(t.Context(), map[string]any{}, cfg)if err != nil {t.Fatalf("V1 Invoke: %v", err)}@@ -147,7 +147,7 @@ func TestCheckpointMigration_VersionEvolution(t *testing.T) {if !ok {t.Fatal("v1Compiled does not implement StateInspector")}- snap, err := inspector.GetState(context.Background(), cfg)+ snap, err := inspector.GetState(t.Context(), cfg)if err != nil {t.Fatalf("V1 GetState: %v", err)}@@ -167,7 +167,7 @@ func TestCheckpointMigration_VersionEvolution(t *testing.T) {if err != nil {t.Fatalf("V2 Compile: %v", err)}- _, err = v2Compiled.Invoke(context.Background(), map[string]any{}, cfg)+ _, err = v2Compiled.Invoke(t.Context(), map[string]any{}, cfg)if err != nil {t.Fatalf("V2 Invoke: %v", err)}@@ -176,7 +176,7 @@ func TestCheckpointMigration_VersionEvolution(t *testing.T) {if !ok2 {t.Fatal("v2Compiled does not implement StateInspector")}- snap2, err := inspector2.GetState(context.Background(), cfg)+ snap2, err := inspector2.GetState(t.Context(), cfg)if err != nil {t.Fatalf("V2 GetState: %v", err)}@@ -213,7 +213,7 @@ func TestSubgraphPersistence_SharedCheckpointer(t *testing.T) {constants.ConfigKeyThreadID: tid,},}- ctx := context.Background()+ ctx := t.Context()_, err = cg.Invoke(ctx, map[string]any{}, cfg)if err != nil {@@ -243,7 +243,7 @@ func TestSubgraphPersistence_MultipleThreads_Isolated(t *testing.T) {t.Fatalf("Compile: %v", err)}- ctx := context.Background()+ ctx := t.Context()for i := 0; i < 3; i++ {tid := fmt.Sprintf("isolated-thread-%d", i)cfg := &types.RunnableConfig{@@ -267,7 +267,7 @@ func TestCheckpointMigration_SubgraphNotFound(t *testing.T) {oc, _ := outer.Compile()csg := NewCompiledStateGraph(oc)- _, err := csg.MigrateCheckpoint(context.Background(), "t1", "cp1", "nonexistent")+ _, err := csg.MigrateCheckpoint(t.Context(), "t1", "cp1", "nonexistent")if err == nil {t.Fatal("expected error for nonexistent subgraph")}@@ -278,7 +278,7 @@ func TestCheckpointMigration_ParentNotFound(t *testing.T) {oc, _ := outer.Compile()csg := NewCompiledStateGraph(oc)- _, err := csg.MigrateCheckpoint(context.Background(), "t1", "cp1", "")+ _, err := csg.MigrateCheckpoint(t.Context(), "t1", "cp1", "")if err == nil {t.Fatal("expected error when no parent exists")}diff --git a/internal/harness/graph/graph/graph_integration_test.go b/internal/harness/graph/graph/graph_integration_test.goindex 96315e474f..53cc426f40 100644--- a/internal/harness/graph/graph/graph_integration_test.go+++ b/internal/harness/graph/graph/graph_integration_test.go@@ -320,7 +320,7 @@ func TestGraphIntegration_RecursionLimit(t *testing.T) {t.Fatalf("Compile: %v", err)}- _, err = cg.Invoke(context.Background(), map[string]interface{}{"step": 0})+ _, err = cg.Invoke(t.Context(), map[string]interface{}{"step": 0})if err == nil {t.Fatal("expected recursion limit error")}@@ -357,7 +357,7 @@ func TestGraphIntegration_ConcurrentInvocations(t *testing.T) {wg.Add(1)go func(id int) {defer wg.Done()- _, err := cg.Invoke(context.Background(), map[string]interface{}{"counter": id})+ _, err := cg.Invoke(t.Context(), map[string]interface{}{"counter": id})errs <- err}(i)}@@ -386,7 +386,7 @@ func TestGraphIntegration_NodeError(t *testing.T) {t.Fatalf("Compile: %v", err)}- _, err = cg.Invoke(context.Background(), map[string]interface{}{})+ _, err = cg.Invoke(t.Context(), map[string]interface{}{})if err == nil {t.Fatal("expected error from failing node")}@@ -407,7 +407,7 @@ func TestGraphIntegration_NoOpNode(t *testing.T) {t.Fatalf("Compile: %v", err)}- result, err := cg.Invoke(context.Background(), map[string]interface{}{"a": 1})+ result, err := cg.Invoke(t.Context(), map[string]interface{}{"a": 1})if err != nil {t.Fatalf("Invoke: %v", err)}@@ -456,7 +456,7 @@ func TestGraphIntegration_BranchFanOut(t *testing.T) {t.Fatalf("Compile: %v", err)}- result, err := cg.Invoke(context.Background(), map[string]interface{}{})+ result, err := cg.Invoke(t.Context(), map[string]interface{}{})if err != nil {t.Fatalf("Invoke: %v", err)}@@ -489,7 +489,7 @@ func TestGraphIntegration_GetState(t *testing.T) {t.Fatalf("Compile: %v", err)}- result, err := cg.Invoke(context.Background(), map[string]interface{}{"value": ""})+ result, err := cg.Invoke(t.Context(), map[string]interface{}{"value": ""})if err != nil {t.Fatalf("Invoke: %v", err)}diff --git a/internal/harness/graph/graph/graph_test.go b/internal/harness/graph/graph/graph_test.goindex ddd79a13e4..1329d76d45 100644--- a/internal/harness/graph/graph/graph_test.go+++ b/internal/harness/graph/graph/graph_test.go@@ -246,7 +246,7 @@ func TestGraphWithMultipleNodes(t *testing.T) {t.Fatalf("Failed to compile graph: %v", err)}- ctx := context.Background()+ ctx := t.Context()initialState := map[string]interface{}{"counter": 0,"step": "",diff --git a/internal/harness/graph/graph/graph_timetravel_send_test.go b/internal/harness/graph/graph/graph_timetravel_send_test.goindex 7d76b87f68..6cc636dc7a 100644--- a/internal/harness/graph/graph/graph_timetravel_send_test.go+++ b/internal/harness/graph/graph/graph_timetravel_send_test.go@@ -39,7 +39,7 @@ func TestTimeTravel_MultiStepInject(t *testing.T) {insp := getInspector(t, cg)tid := "tt-multi-inject"- ctx := context.Background()+ ctx := t.Context()cfg := &types.RunnableConfig{Configurable: map[string]interface{}{constants.ConfigKeyThreadID: tid},}@@ -95,7 +95,7 @@ func TestTimeTravel_ForkFromCheckpoint(t *testing.T) {}insp := getInspector(t, cg)- ctx := context.Background()+ ctx := t.Context()// Run thread A.tidA := "tt-fork-a"@@ -161,7 +161,7 @@ func TestChain_SequentialMapReduce(t *testing.T) {t.Fatalf("Compile: %v", err)}- result, err := cg.Invoke(context.Background(), map[string]any{})+ result, err := cg.Invoke(t.Context(), map[string]any{})if err != nil {t.Fatalf("Invoke: %v", err)}@@ -192,7 +192,7 @@ func TestChain_Collector(t *testing.T) {t.Fatalf("Compile: %v", err)}- result, err := cg.Invoke(context.Background(), map[string]any{})+ result, err := cg.Invoke(t.Context(), map[string]any{})if err != nil {t.Fatalf("Invoke: %v", err)}@@ -250,7 +250,7 @@ func TestConditionalEdge_Fallback(t *testing.T) {t.Fatalf("Compile: %v", err)}- ctx := context.Background()+ ctx := t.Context()result, err := cg.Invoke(ctx, map[string]any{"target": "unknown"})if err != nil {t.Fatalf("Invoke: %v", err)@@ -289,7 +289,7 @@ func TestReducer_AcrossCheckpoint(t *testing.T) {}tid := "reducer-across-cp"- ctx := context.Background()+ ctx := t.Context()cfg := &types.RunnableConfig{Configurable: map[string]interface{}{constants.ConfigKeyThreadID: tid},}@@ -321,7 +321,7 @@ func TestEngine_50Threads_SharedEngine(t *testing.T) {t.Fatalf("Compile: %v", err)}- ctx := context.Background()+ ctx := t.Context()var wg sync.WaitGroupfor i := 0; i < 50; i++ {wg.Add(1)@@ -366,7 +366,7 @@ func TestBinaryOp_IntAccumulator(t *testing.T) {t.Fatalf("Compile: %v", err)}- result, err := cg.Invoke(context.Background(), map[string]any{})+ result, err := cg.Invoke(t.Context(), map[string]any{})if err != nil {t.Fatalf("Invoke: %v", err)}@@ -405,7 +405,7 @@ func TestEngine_StarTopology(t *testing.T) {t.Fatalf("Compile: %v", err)}- _, err = cg.Invoke(context.Background(), map[string]any{})+ _, err = cg.Invoke(t.Context(), map[string]any{})if err != nil {t.Fatalf("Invoke: %v", err)}diff --git a/internal/harness/graph/graph/state_inspector_test.go b/internal/harness/graph/graph/state_inspector_test.goindex 9e7410e374..7ae6276e72 100644--- a/internal/harness/graph/graph/state_inspector_test.go+++ b/internal/harness/graph/graph/state_inspector_test.go@@ -134,7 +134,7 @@ func TestGetStateHistory_WithData(t *testing.T) {t.Fatalf("Invoke: %v", err)}- history, err := insp.GetStateHistory(context.Background(), cfg, 10, nil)+ history, err := insp.GetStateHistory(t.Context(), cfg, 10, nil)if err != nil {t.Fatalf("GetStateHistory: %v", err)}@@ -168,7 +168,7 @@ func TestUpdateState(t *testing.T) {}// Execute once to create a checkpoint.- _, err = cg.Invoke(context.Background(), struct{ Value string }{Value: "initial"}, cfg)+ _, err = cg.Invoke(t.Context(), struct{ Value string }{Value: "initial"}, cfg)if err != nil {t.Fatalf("Invoke: %v", err)}@@ -179,7 +179,7 @@ func TestUpdateState(t *testing.T) {AsNode: "user",ThreadID: "test-update-state",}- newCfg, err := insp.UpdateState(context.Background(), cfg, update)+ newCfg, err := insp.UpdateState(t.Context(), cfg, update)if err != nil {t.Fatalf("UpdateState: %v", err)}@@ -188,7 +188,7 @@ func TestUpdateState(t *testing.T) {}// Verify update was persisted.- snap, err := insp.GetState(context.Background(), newCfg)+ snap, err := insp.GetState(t.Context(), newCfg)if err != nil {t.Fatalf("GetState after update: %v", err)}@@ -218,14 +218,14 @@ func TestCompiledStateGraph_Inspection(t *testing.T) {},}- snap, err := csg.GetState(context.Background(), cfg)+ snap, err := csg.GetState(t.Context(), cfg)if err != nil {t.Fatalf("CompiledStateGraph GetState: %v", err)}// After initial compile with no run, snap may be nil (no checkpoint yet)._ = snap- history, err := csg.GetStateHistory(context.Background(), cfg, 10, nil)+ history, err := csg.GetStateHistory(t.Context(), cfg, 10, nil)if err != nil {t.Fatalf("CompiledStateGraph GetStateHistory: %v", err)}@@ -259,12 +259,12 @@ func TestGetState_WithChannels(t *testing.T) {},}- _, err = cg.Invoke(context.Background(), map[string]any{}, cfg)+ _, err = cg.Invoke(t.Context(), map[string]any{}, cfg)if err != nil {t.Fatalf("Invoke: %v", err)}- snap, err := insp.GetState(context.Background(), cfg)+ snap, err := insp.GetState(t.Context(), cfg)if err != nil {t.Fatalf("GetState: %v", err)}diff --git a/internal/harness/graph/interrupt/interrupt_test.go b/internal/harness/graph/interrupt/interrupt_test.goindex e91cf2177a..6bbcded914 100644--- a/internal/harness/graph/interrupt/interrupt_test.go+++ b/internal/harness/graph/interrupt/interrupt_test.go@@ -142,7 +142,7 @@ func TestIsInterruptContext(t *testing.T) {}// Regular context should not be interrupt context- regularCtx := context.Background()+ regularCtx := t.Context()if IsInterruptContext(regularCtx) {t.Error("Regular context should not be an interrupt context")}diff --git a/internal/harness/graph/pregel/engine_test.go b/internal/harness/graph/pregel/engine_test.goindex ee62919049..a77f1f0f7b 100644--- a/internal/harness/graph/pregel/engine_test.go+++ b/internal/harness/graph/pregel/engine_test.go@@ -89,7 +89,7 @@ func TestEngine_RunSync(t *testing.T) {sg := newSimpleGraph(t)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -123,7 +123,7 @@ func TestEngine_RunSyncWithChannelRead(t *testing.T) {}engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{"name": "world"})+ result, err := engine.RunSync(t.Context(), map[string]any{"name": "world"})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -138,7 +138,7 @@ func TestEngine_RecursionLimit(t *testing.T) {sg.AddEdge("node_a", constants.End)engine := NewEngine(sg, WithRecursionLimit(3))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err != nil {// Engine runs successfully: node_a -> node_b -> node_a loops via self-edget.Logf("got error (expected from recursion limit): %v", err)@@ -170,7 +170,7 @@ func TestEngine_EmptyGraph(t *testing.T) {sg := graph.NewStateGraph(map[string]any{"x": ""})sg.AddChannel("x", channels.NewLastValue(""))engine := NewEngine(sg, WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{"x": "1"})+ _, err := engine.RunSync(t.Context(), map[string]any{"x": "1"})if err == nil {t.Fatal("expected error for graph with no entry point")}diff --git a/internal/harness/graph/pregel/optimized_test.go b/internal/harness/graph/pregel/optimized_test.goindex d04b3a78ce..f9a86fd75e 100644--- a/internal/harness/graph/pregel/optimized_test.go+++ b/internal/harness/graph/pregel/optimized_test.go@@ -2,7 +2,6 @@package pregelimport (- "context""testing""ragflow/internal/harness/graph/channels"@@ -171,7 +170,7 @@ func TestBumpStep(t *testing.T) {optimized := NewPregelOptimizedEngine(baseEngine, nil)t.Run("bump step for dependent tasks", func(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()// Simulate task completionupdatedChannels := map[string]struct{}{@@ -346,7 +345,7 @@ func TestOptimizedApplyWrites(t *testing.T) {optimized := NewPregelOptimizedEngine(baseEngine, nil)t.Run("apply writes with bump_step", func(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()// Create a registry with a channelregistry := channels.NewRegistry()@@ -398,7 +397,7 @@ func TestPrepareNextTasksOptimized(t *testing.T) {optimized := NewPregelOptimizedEngine(baseEngine, nil)t.Run("prepare next tasks with optimization", func(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()tasks, triggers, err := optimized.PrepareNextTasksOptimized(ctx,diff --git a/internal/harness/graph/pregel/pregel_async_stream_edge_test.go b/internal/harness/graph/pregel/pregel_async_stream_edge_test.goindex 360ec29396..7377395dc3 100644--- a/internal/harness/graph/pregel/pregel_async_stream_edge_test.go+++ b/internal/harness/graph/pregel/pregel_async_stream_edge_test.go@@ -23,7 +23,7 @@ import (// TestStream_ChannelStream_Basic verifies ChannelStream emit/consume cycle.func TestStream_ChannelStream_Basic(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()stream := types.NewChannelStream(types.StreamModeValues, 10)defer stream.Close()@@ -46,7 +46,7 @@ func TestStream_ChannelStream_Basic(t *testing.T) {// TestStream_ChannelStream_CloseWhileReading tests close during iteration.func TestStream_ChannelStream_CloseWhileReading(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()stream := types.NewChannelStream(types.StreamModeValues, 10)_ = stream.Emit(ctx, &types.StreamChunk{Data: "a", Step: 1})@@ -93,7 +93,7 @@ func TestConcurrent_MultipleEngines_DifferentGraphs(t *testing.T) {go func(idx int) {defer wg.Done()engine := NewEngine(newSimpleGraph(t), WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "conc"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "conc"})if err != nil {t.Errorf("engine %d: %v", idx, err)}@@ -106,7 +106,7 @@ func TestConcurrent_MultipleEngines_DifferentGraphs(t *testing.T) {// with different inputs sequentially.func TestConcurrent_SharedEngine_DifferentInputs(t *testing.T) {engine := NewEngine(newSimpleGraph(t), WithRecursionLimit(10))- ctx := context.Background()+ ctx := t.Context()for _, input := range []map[string]any{{"value": "a"}, {"value": "b"}, {"value": "c"},@@ -142,11 +142,11 @@ func TestConcurrent_ManyEngines_WithCheckpointer(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "conc"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "conc"})if err != nil {t.Errorf("engine %d: %v", idx, err)}- cp, err := ms.Get(context.Background(), map[string]interface{}{+ cp, err := ms.Get(t.Context(), map[string]interface{}{constants.ConfigKeyThreadID: tid,})if err != nil || cp == nil {@@ -173,7 +173,7 @@ func TestRetry_ZeroMaxAttempts(t *testing.T) {rp.MaxAttempts = 0engine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&rp))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "zero"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "zero"})t.Logf("zero max attempts: err=%v attempts=%d", err, attempts.Load())}@@ -194,7 +194,7 @@ func TestRetry_MaxIntervalCapped(t *testing.T) {}engine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&rp))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "maxint"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "maxint"})if err == nil {t.Fatal("expected error")}@@ -214,7 +214,7 @@ func TestRetry_JitterVariation(t *testing.T) {rp.Jitter = trueengine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&rp))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "jitter"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "jitter"})if err == nil {t.Fatal("expected error")}@@ -245,7 +245,7 @@ func TestEngine_DAG_ModeFanIn(t *testing.T) {_ = sg.AddEdge("join", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -273,7 +273,7 @@ func TestEngine_NodeReturningCommand(t *testing.T) {_ = sg.AddEdge("dest", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -306,7 +306,7 @@ func TestEngine_MixedChannels_TopicPlusLastValue(t *testing.T) {_ = sg.AddEdge("finalizer", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync: %v", err)}diff --git a/internal/harness/graph/pregel/pregel_boundary_engine_test.go b/internal/harness/graph/pregel/pregel_boundary_engine_test.goindex b15816e38e..341afa2b67 100644--- a/internal/harness/graph/pregel/pregel_boundary_engine_test.go+++ b/internal/harness/graph/pregel/pregel_boundary_engine_test.go@@ -24,7 +24,7 @@ func TestBoundary_EmptyStateGraph(t *testing.T) {_ = sg.AddEdge(constants.Start, "nop")_ = sg.AddEdge("nop", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -34,7 +34,7 @@ func TestBoundary_EmptyStateGraph(t *testing.T) {func TestBoundary_NilConfig(t *testing.T) {sg := newSimpleGraph(t)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -49,7 +49,7 @@ func TestBoundary_NoTasksStillCompletes(t *testing.T) {_ = sg.AddEdge(constants.Start, "only")_ = sg.AddEdge("only", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -77,7 +77,7 @@ func TestBoundary_BinOpWithCheckpointer(t *testing.T) {Configurable: map[string]interface{}{constants.ConfigKeyThreadID: tid},}engine := NewEngine(sg, WithRecursionLimit(10), WithCheckpointer(ms), WithConfig(cfg))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -99,7 +99,7 @@ func TestBoundary_ManyIndependentCheckpointers(t *testing.T) {Configurable: map[string]interface{}{constants.ConfigKeyThreadID: tid},}engine := NewEngine(newSimpleGraph(t), WithRecursionLimit(10), WithCheckpointer(ms), WithConfig(cfg))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err != nil {t.Errorf("engine %d: %v", idx, err)}@@ -122,7 +122,7 @@ func TestBoundary_NodeContextDeadline(t *testing.T) {_ = sg.AddEdge(constants.Start, "slow")_ = sg.AddEdge("slow", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- ctx, cancel := context.WithTimeout(context.Background(), 20*time.Millisecond)+ ctx, cancel := context.WithTimeout(t.Context(), 20*time.Millisecond)defer cancel()_, err := engine.RunSync(ctx, map[string]any{"value": "x"})if err == nil {@@ -145,7 +145,7 @@ func TestBoundary_SequentialChannelAccumulator(t *testing.T) {_ = sg.AddEdge("a", "b")_ = sg.AddEdge("b", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -177,7 +177,7 @@ func TestBoundary_RetryInterruptCheckpointer(t *testing.T) {rp := types.DefaultRetryPolicy()rp.MaxAttempts = 5engine := NewEngine(sg, WithRecursionLimit(10), WithCheckpointer(ms), WithConfig(cfg), WithRetryPolicy(&rp), WithInterrupts("*"))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected interrupt")}@@ -186,7 +186,7 @@ func TestBoundary_RetryInterruptCheckpointer(t *testing.T) {func TestBoundary_MaxRecursionLimit(t *testing.T) {engine := NewEngine(newSimpleGraph(t), WithRecursionLimit(1<<31-1))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err != nil {t.Fatalf("RunSync: %v", err)}diff --git a/internal/harness/graph/pregel/pregel_durability_deep_test.go b/internal/harness/graph/pregel/pregel_durability_deep_test.goindex 280607621f..1e55fd66a2 100644--- a/internal/harness/graph/pregel/pregel_durability_deep_test.go+++ b/internal/harness/graph/pregel/pregel_durability_deep_test.go@@ -2,7 +2,6 @@package pregelimport (- "context""fmt""sync""sync/atomic"@@ -32,7 +31,7 @@ func TestDurabilitySync_Basic(t *testing.T) {WithConfig(cfg),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": "sync"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "sync"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -42,7 +41,7 @@ func TestDurabilitySync_Basic(t *testing.T) {}// Checkpoint should exist after Sync run.- cp, _ := ms.Get(context.Background(), map[string]interface{}{+ cp, _ := ms.Get(t.Context(), map[string]interface{}{constants.ConfigKeyThreadID: tid,})if cp == nil {@@ -68,7 +67,7 @@ func TestDurabilitySync_WithInterrupt(t *testing.T) {WithConfig(cfg),WithInterrupts("node_a"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "sync"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "sync"})_ = err}@@ -90,7 +89,7 @@ func TestDurabilityAsync_Basic(t *testing.T) {WithConfig(cfg),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": "async"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "async"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -102,7 +101,7 @@ func TestDurabilityAsync_Basic(t *testing.T) {// Wait briefly for async save.time.Sleep(50 * time.Millisecond)- cp, _ := ms.Get(context.Background(), map[string]interface{}{+ cp, _ := ms.Get(t.Context(), map[string]interface{}{constants.ConfigKeyThreadID: tid,})if cp == nil {@@ -132,7 +131,7 @@ func TestDurability_AllModes_SameOutput(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": d})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": d})if err != nil {t.Fatalf("durability %s: %v", d, err)}@@ -163,7 +162,7 @@ func TestDurability_AllModes_LargeState(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "large"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "large"})if err != nil {t.Fatalf("durability %s: %v", d, err)}@@ -197,7 +196,7 @@ func TestDurability_ConcurrentEngines(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "conc"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "conc"})if err != nil {errCount.Add(1)t.Errorf("engine %d (%s): %v", idx, d, err)@@ -230,7 +229,7 @@ func TestDurability_InterruptEachMode(t *testing.T) {WithConfig(cfg),WithInterrupts("node_a"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "int"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "int"})_ = err})}@@ -255,7 +254,7 @@ func TestDurability_RapidModeSwitch(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "switch"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "switch"})if err != nil {t.Fatalf("run %d (%s): %v", i, d, err)}@@ -275,7 +274,7 @@ func TestDurability_NoCheckpointer(t *testing.T) {WithRecursionLimit(10),WithConfig(cfg),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": "no-cp"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "no-cp"})if err != nil {t.Fatalf("durability %s without CP: %v", d, err)}@@ -306,7 +305,7 @@ func TestDurability_ManySequentialRuns(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "seq"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "seq"})if err != nil {t.Fatalf("run %d: %v", i, err)}@@ -329,7 +328,7 @@ func TestDurability_DefaultConfig(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": "default"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "default"})if err != nil {t.Fatalf("RunSync: %v", err)}diff --git a/internal/harness/graph/pregel/pregel_durability_timetravel_test.go b/internal/harness/graph/pregel/pregel_durability_timetravel_test.goindex 40df8ab635..4b8af279f9 100644--- a/internal/harness/graph/pregel/pregel_durability_timetravel_test.go+++ b/internal/harness/graph/pregel/pregel_durability_timetravel_test.go@@ -31,7 +31,7 @@ func TestDurabilityExit_Basic(t *testing.T) {}engine := NewEngine(sg, WithRecursionLimit(10), WithConfig(cfg))- result, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -46,7 +46,7 @@ func TestDurabilityExit_MultiStep(t *testing.T) {cfg := &types.RunnableConfig{Durability: types.DurabilityExit}engine := NewEngine(newSimpleGraph(t), WithRecursionLimit(10), WithConfig(cfg))- result, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -65,7 +65,7 @@ func TestDurabilityExit_NoCheckpointer(t *testing.T) {}engine := NewEngine(sg, WithRecursionLimit(10), WithConfig(cfg))- ctx := context.Background()+ ctx := t.Context()_, err := engine.RunSync(ctx, map[string]any{"value": "hello"})if err != nil {t.Fatalf("RunSync without checkpointer: %v", err)@@ -88,7 +88,7 @@ func TestTimeTravel_GetState_AfterExecution(t *testing.T) {}engine := NewEngine(sg, WithRecursionLimit(10), WithCheckpointer(ms), WithConfig(cfg))- ctx := context.Background()+ ctx := t.Context()_, err := engine.RunSync(ctx, map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)@@ -141,7 +141,7 @@ func TestTimeTravel_UpdateState_ThenResume(t *testing.T) {t.Fatalf("Compile: %v", err)}- ctx := context.Background()+ ctx := t.Context()cfg := &types.RunnableConfig{Configurable: map[string]interface{}{constants.ConfigKeyThreadID: "tt-update-resume",@@ -201,7 +201,7 @@ func TestTimeTravel_MultipleUpdates(t *testing.T) {t.Fatalf("Compile: %v", err)}- ctx := context.Background()+ ctx := t.Context()tid := "tt-multi-update"// Execute once to create checkpoint.@@ -263,7 +263,7 @@ func TestDurabilityExit_ConcurrentEngines(t *testing.T) {defer wg.Done()cfg := &types.RunnableConfig{Durability: types.DurabilityExit}engine := NewEngine(sg, WithRecursionLimit(10), WithConfig(cfg))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "conc"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "conc"})if err != nil {errCount.Add(1)}@@ -302,7 +302,7 @@ func TestDurabilityExit_InterruptResume(t *testing.T) {WithConfig(cfg),WithInterrupts("process"),)- ctx := context.Background()+ ctx := t.Context()_, err := engine.RunSync(ctx, map[string]any{"value": "start"})if err == nil {t.Fatal("expected interrupt error")@@ -335,7 +335,7 @@ func TestDurabilityExit_LargeState(t *testing.T) {cfg := &types.RunnableConfig{Durability: types.DurabilityExit}engine := NewEngine(sg, WithRecursionLimit(10), WithConfig(cfg))- result, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -361,7 +361,7 @@ func TestFaultInjection_DeferredCheckpointFlushRace(t *testing.T) {defer wg.Done()cfg := &types.RunnableConfig{Durability: types.DurabilityExit}engine := NewEngine(sg, WithRecursionLimit(10), WithConfig(cfg))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "race"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "race"})if err != nil {t.Errorf("engine %d: %v", idx, err)}@@ -395,7 +395,7 @@ func TestFaultInjection_CheckpointGetAfterInterrupt(t *testing.T) {WithInterrupts("unsafe"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err == nil {t.Fatal("expected interrupt")}@@ -416,7 +416,7 @@ func TestFaultInjection_NodePanicWithCheckpointer(t *testing.T) {engine := NewEngine(sg, WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected error from panicking node")}@@ -432,7 +432,7 @@ func TestFaultInjection_EngineReuse_WithDurabilityExit(t *testing.T) {for i := 0; i < runs; i++ {cfg := &types.RunnableConfig{Durability: types.DurabilityExit}engine := NewEngine(sg, WithRecursionLimit(10), WithConfig(cfg))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "reuse"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "reuse"})if err != nil {t.Fatalf("run %d: %v", i, err)}@@ -453,7 +453,7 @@ func TestFaultInjection_ConcurrentCheckpointConflict(t *testing.T) {for g := 0; g < goroutines; g++ {wg.Go(func() {engine := NewEngine(sg, WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "conc"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "conc"})if err != nil {t.Errorf("engine error: %v", err)}@@ -473,7 +473,7 @@ func TestFaultInjection_RapidCancel_Restart(t *testing.T) {engine := NewEngine(sg, WithRecursionLimit(100))for i := 0; i < 10; i++ {- ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)+ ctx, cancel := context.WithTimeout(t.Context(), time.Millisecond)_, err := engine.RunSync(ctx, map[string]any{"value": "cancel"})cancel()if err != nil && !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) {@@ -525,7 +525,7 @@ func TestDurabilityExit_ConfigPropagation(t *testing.T) {for _, d := range []types.Durability{types.DurabilitySync, types.DurabilityExit} {cfg := &types.RunnableConfig{Durability: d}engine := NewEngine(sg, WithRecursionLimit(10), WithConfig(cfg))- result, err := engine.RunSync(context.Background(), map[string]any{"value": "test"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "test"})if err != nil {t.Fatalf("durability %s: %v", d, err)}diff --git a/internal/harness/graph/pregel/pregel_engine_subgraph_edge_test.go b/internal/harness/graph/pregel/pregel_engine_subgraph_edge_test.goindex 04b56ef0c0..f8409b9aee 100644--- a/internal/harness/graph/pregel/pregel_engine_subgraph_edge_test.go+++ b/internal/harness/graph/pregel/pregel_engine_subgraph_edge_test.go@@ -20,7 +20,7 @@ import (func TestEngine_BasicExecution(t *testing.T) {result, err := NewEngine(newSimpleGraph(t), WithRecursionLimit(10)).- RunSync(context.Background(), map[string]any{"value": "start"})+ RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -51,7 +51,7 @@ func TestEngine_BinOpAggregate(t *testing.T) {_ = sg.AddEdge("add10", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -80,7 +80,7 @@ func TestEngine_TopicChannel(t *testing.T) {_ = sg.AddEdge("emit2", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{})+ _, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -101,7 +101,7 @@ func TestEngine_WithCheckpointer(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -137,7 +137,7 @@ func TestEngine_UntrackedValue(t *testing.T) {WithConfig(cfg),)- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -163,7 +163,7 @@ func TestEngine_ReuseDiffConfig(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "reuse"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "reuse"})if err != nil {t.Fatalf("iteration %d: %v", i, err)}@@ -179,7 +179,7 @@ func TestEngine_ManyParallelRuns(t *testing.T) {for i := 0; i < 30; i++ {wg.Go(func() {engine := NewEngine(newSimpleGraph(t), WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "par"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "par"})if err != nil {t.Errorf("RunSync: %v", err)}@@ -208,7 +208,7 @@ func TestEngine_SharedMemorySaver50(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "shared"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "shared"})if err != nil {t.Errorf("engine %d: %v", idx, err)}@@ -226,7 +226,7 @@ func TestEngine_DebugMode(t *testing.T) {WithRecursionLimit(10),WithDebug(true),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": "debug"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "debug"})if err != nil {t.Fatalf("RunSync: %v", err)}diff --git a/internal/harness/graph/pregel/pregel_fault_edge_test.go b/internal/harness/graph/pregel/pregel_fault_edge_test.goindex 4f2ea31fc8..14061be88a 100644--- a/internal/harness/graph/pregel/pregel_fault_edge_test.go+++ b/internal/harness/graph/pregel/pregel_fault_edge_test.go@@ -41,7 +41,7 @@ func TestFault_NodeReturnsEmptyMap(t *testing.T) {_ = sg.AddEdge("reader", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -66,7 +66,7 @@ func TestFault_NodeReturnsNil(t *testing.T) {_ = sg.AddEdge("nil_return", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -93,7 +93,7 @@ func TestFault_RapidEngineCreation(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "rapid"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "rapid"})if err != nil {t.Errorf("engine %d: %v", idx, err)}@@ -134,7 +134,7 @@ func TestFault_DeepErrorChain(t *testing.T) {_ = sg.AddEdge(prev, constants.End)engine := NewEngine(sg, WithRecursionLimit(30))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "deep"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "deep"})if err == nil {t.Fatal("expected error from chain")}@@ -168,7 +168,7 @@ func TestFault_MultipleInterrupts(t *testing.T) {WithInterrupts("b"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err == nil {t.Fatal("expected interrupt")}@@ -182,7 +182,7 @@ func TestFault_MultipleInterrupts(t *testing.T) {// thread doesn't corrupt data.func TestFault_CheckpointerRace_SameThread(t *testing.T) {ms := checkpoint.NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()tid := "race-same-thread"cfg := map[string]interface{}{constants.ConfigKeyThreadID: tid}@@ -222,7 +222,7 @@ func TestFault_ZeroMaxConcurrency(t *testing.T) {WithRecursionLimit(10),WithMaxConcurrency(0),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -238,7 +238,7 @@ func TestFault_HighMaxConcurrency(t *testing.T) {WithRecursionLimit(10),WithMaxConcurrency(100),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -253,7 +253,7 @@ func TestFault_HighMaxConcurrency(t *testing.T) {// the test infrastructure doesn't hang.func TestFault_RepeatedInterrupt(t *testing.T) {engine := NewEngine(newSimpleGraph(t), WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -288,7 +288,7 @@ func TestFault_RapidCreateCancel(t *testing.T) {for i := 0; i < 20; i++ {wg.Go(func() {engine := NewEngine(newSimpleGraph(t), WithRecursionLimit(5))- ctx, cancel := context.WithTimeout(context.Background(), time.Microsecond)+ ctx, cancel := context.WithTimeout(t.Context(), time.Microsecond)defer cancel()_, _ = engine.RunSync(ctx, map[string]any{"value": "x"})})@@ -308,7 +308,7 @@ func TestFault_EngineReuseDifferentConfig(t *testing.T) {WithRecursionLimit(10),WithMaxConcurrency(mc),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "cfg"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "cfg"})if err != nil {t.Fatalf("maxConcurrency=%d: %v", mc, err)}@@ -323,7 +323,7 @@ func TestFault_EngineReuseDifferentConfig(t *testing.T) {// sequentially on the same thread.func TestFault_MultipleCheckpointsSequential(t *testing.T) {ms := checkpoint.NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()tid := "multi-cp-seq"cfg := map[string]interface{}{constants.ConfigKeyThreadID: tid}@@ -362,7 +362,7 @@ func TestFault_MultipleCheckpointsSequential(t *testing.T) {func TestFault_NodeModifiesStateInPlace(t *testing.T) {// Use newSimpleGraph pattern which is known to work with the engine.engine := NewEngine(newSimpleGraph(t), WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -380,7 +380,7 @@ func TestFault_NodeModifiesStateInPlace(t *testing.T) {func TestFault_SimpleRoute(t *testing.T) {// Use newSimpleGraph which is known to work.engine := NewEngine(newSimpleGraph(t), WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -413,7 +413,7 @@ func TestFault_SharedMemorySaver_MultipleEngines(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "shared"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "shared"})if err != nil {t.Errorf("engine %d: %v", idx, err)}@@ -426,7 +426,7 @@ func TestFault_SharedMemorySaver_MultipleEngines(t *testing.T) {func BenchmarkFault_EngineReuseManyTimes(b *testing.B) {sg := newBenchGraph()engine := NewEngine(sg, WithRecursionLimit(10))- ctx := context.Background()+ ctx := b.Context()input := map[string]any{"value": "bench"}b.ResetTimer()diff --git a/internal/harness/graph/pregel/pregel_fault_injection_test.go b/internal/harness/graph/pregel/pregel_fault_injection_test.goindex ca2d9accfc..aa53b673a1 100644--- a/internal/harness/graph/pregel/pregel_fault_injection_test.go+++ b/internal/harness/graph/pregel/pregel_fault_injection_test.go@@ -60,7 +60,7 @@ func TestFaultInjection_NodeError(t *testing.T) {g.AddEdge("fail_node", constants.End)engine := NewEngine(g, WithRecursionLimit(10))- ctx := context.Background()+ ctx := t.Context()_, err := engine.RunSync(ctx, map[string]any{"value": "test"})if err == nil {@@ -80,7 +80,7 @@ func TestFaultInjection_CheckpointCorruption(t *testing.T) {ms := checkpoint.NewMemorySaver()engine := NewEngine(g, WithRecursionLimit(10), WithCheckpointer(ms))- ctx := context.Background()+ ctx := t.Context()// First run creates a clean checkpoint._, err := engine.RunSync(ctx, map[string]any{"value": "first"})@@ -113,7 +113,7 @@ func TestFaultInjection_CheckpointCorruption(t *testing.T) {// goroutines save checkpoints concurrently to the same checkpointer.func TestFaultInjection_CheckpointRace(t *testing.T) {ms := checkpoint.NewMemorySaver()- ctx := context.Background()+ ctx := t.Context()const goroutines = 50const savesPerGoroutine = 20@@ -166,7 +166,7 @@ func TestFaultInjection_NodeTimeout(t *testing.T) {g.AddEdge("slow", constants.End)engine := NewEngine(g, WithRecursionLimit(10))- ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)+ ctx, cancel := context.WithTimeout(t.Context(), 50*time.Millisecond)defer cancel()_, err := engine.RunSync(ctx, map[string]any{"value": "test"})@@ -193,7 +193,7 @@ func TestFaultInjection_RetryExhaustion(t *testing.T) {g.AddEdge("flaky", constants.End)engine := NewEngine(g, WithRecursionLimit(10))- ctx := context.Background()+ ctx := t.Context()_, err := engine.RunSync(ctx, map[string]any{"value": "test"})if err == nil {@@ -243,7 +243,7 @@ func TestFaultInjection_ParallelFanOutWithFailures(t *testing.T) {t.Fatalf("Compile: %v", err)}- ctx := context.Background()+ ctx := t.Context()_, err = cg.Invoke(ctx, State{})if err == nil {t.Log("all workers succeeded (some workers may be skipped)")@@ -286,7 +286,7 @@ func TestFaultInjection_ContextCancel(t *testing.T) {func TestFaultInjection_EngineReuse(t *testing.T) {g := newSimpleGraph(t)engine := NewEngine(g, WithRecursionLimit(10))- ctx := context.Background()+ ctx := t.Context()for i := 0; i < 50; i++ {_, err := engine.RunSync(ctx, map[string]any{"value": fmt.Sprintf("run_%d", i)})diff --git a/internal/harness/graph/pregel/pregel_fault_production_test.go b/internal/harness/graph/pregel/pregel_fault_production_test.goindex f6acdecd48..e15df3db56 100644--- a/internal/harness/graph/pregel/pregel_fault_production_test.go+++ b/internal/harness/graph/pregel/pregel_fault_production_test.go@@ -31,7 +31,7 @@ func TestFault_GoroutineLeakAfterCancel(t *testing.T) {for i := 0; i < 5; i++ {engine := NewEngine(sg, WithRecursionLimit(100))- ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)+ ctx, cancel := context.WithTimeout(t.Context(), time.Millisecond)// Drain but don't wait for channels — cancel should clean up.outputCh, errCh := engine.Run(ctx, map[string]any{"value": "leak"}, types.StreamModeValues)cancel()@@ -60,7 +60,7 @@ func TestFault_GoroutineLeakRapidCreate(t *testing.T) {for i := 0; i < 50; i++ {engine := NewEngine(newSimpleGraph(t), WithRecursionLimit(10))- engine.RunSync(context.Background(), map[string]any{"value": "x"})+ engine.RunSync(t.Context(), map[string]any{"value": "x"})}time.Sleep(10 * time.Millisecond)@@ -86,7 +86,7 @@ func TestFault_NodeBlocksForever(t *testing.T) {_ = sg.AddEdge("stuck", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)+ ctx, cancel := context.WithTimeout(t.Context(), 50*time.Millisecond)defer cancel()_, err := engine.RunSync(ctx, map[string]any{"value": "x"})@@ -118,11 +118,11 @@ func TestFault_CheckpointAfterPanic(t *testing.T) {WithConfig(cfg),)// Force a panic inside RunSync.- _, _ = engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, _ = engine.RunSync(t.Context(), map[string]any{"value": "x"})}()// Checkpointer should still work.- cp, err := ms.Get(context.Background(), map[string]interface{}{+ cp, err := ms.Get(t.Context(), map[string]interface{}{constants.ConfigKeyThreadID: tid,})if err != nil {@@ -143,7 +143,7 @@ func TestFault_CorruptedCheckpoint_EngineStart(t *testing.T) {cfg := map[string]interface{}{constants.ConfigKeyThreadID: tid}// Write an invalid checkpoint that has wrong types for channel data.- ms.Put(context.Background(), cfg, map[string]interface{}{+ ms.Put(t.Context(), cfg, map[string]interface{}{"value": "corrupted","__completed_tasks__": "garbage","__last_state__": "not-json",@@ -157,7 +157,7 @@ func TestFault_CorruptedCheckpoint_EngineStart(t *testing.T) {WithCheckpointer(ms),WithConfig(engineCfg),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err != nil {t.Logf("corrupted checkpoint handled: %v", err)}@@ -188,7 +188,7 @@ func TestFault_TopicChannel_ConcurrentProducers(t *testing.T) {_ = sg.AddEdge(prev, constants.End)engine := NewEngine(sg, WithRecursionLimit(100))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -220,7 +220,7 @@ func TestFault_NodeConcurrentMapWrite(t *testing.T) {_ = sg.AddEdge(prev, constants.End)engine := NewEngine(sg, WithRecursionLimit(30))- result, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -261,7 +261,7 @@ func TestFault_CancelStorm(t *testing.T) {// TestFault_EngineReuseStaleState reuses engine across 100 runs.func TestFault_EngineReuseStaleState(t *testing.T) {engine := NewEngine(newSimpleGraph(t), WithRecursionLimit(10))- ctx := context.Background()+ ctx := t.Context()for i := 0; i < 100; i++ {result, err := engine.RunSync(ctx, map[string]any{"value": "reuse"})@@ -300,7 +300,7 @@ func TestFault_ManyThreadsManyCheckpoints(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err != nil {t.Errorf("thread %d run %d: %v", idx, j, err)}@@ -331,7 +331,7 @@ func TestFault_AllNodesReturnNil(t *testing.T) {_ = sg.AddEdge(prev, constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err != nil {t.Fatalf("RunSync with nil nodes: %v", err)}@@ -367,7 +367,7 @@ func TestFault_LongChainInterruptEarly(t *testing.T) {WithInterrupts("ln_5"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected interrupt after 5 nodes")}diff --git a/internal/harness/graph/pregel/pregel_interrupt_nested_test.go b/internal/harness/graph/pregel/pregel_interrupt_nested_test.goindex eec327a744..bd5a148314 100644--- a/internal/harness/graph/pregel/pregel_interrupt_nested_test.go+++ b/internal/harness/graph/pregel/pregel_interrupt_nested_test.go@@ -4,7 +4,6 @@package pregelimport (- "context""fmt""sync""testing"@@ -24,7 +23,7 @@ func TestInterrupt_NamedNode(t *testing.T) {WithRecursionLimit(10),WithInterrupts("node_a"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err == nil {t.Fatal("expected interrupt at node_a")}@@ -36,7 +35,7 @@ func TestInterrupt_NamedNode_Second(t *testing.T) {WithRecursionLimit(10),WithInterrupts("node_b"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err == nil {t.Fatal("expected interrupt at node_b")}@@ -48,7 +47,7 @@ func TestInterrupt_LastNode(t *testing.T) {WithRecursionLimit(10),WithInterrupts("node_b"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err == nil {t.Fatal("expected interrupt at last node")}@@ -63,7 +62,7 @@ func TestInterrupt_MultipleNamedNodes(t *testing.T) {WithRecursionLimit(10),WithInterrupts("node_a", "node_b"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err == nil {t.Fatal("expected interrupt at multiple nodes")}@@ -78,7 +77,7 @@ func TestInterrupt_Wildcard(t *testing.T) {WithRecursionLimit(10),WithInterrupts("*"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err == nil {t.Fatal("expected interrupt on wildcard")}@@ -93,7 +92,7 @@ func TestInterrupt_AfterNamedNode(t *testing.T) {WithRecursionLimit(10),WithInterruptsAfter("node_a"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err == nil {t.Fatal("expected after-interrupt at node_a")}@@ -104,7 +103,7 @@ func TestInterrupt_WildcardAfter(t *testing.T) {WithRecursionLimit(10),WithInterruptsAfter("*"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err == nil {t.Fatal("expected after-interrupt")}@@ -127,12 +126,12 @@ func TestInterrupt_WithCheckpointer(t *testing.T) {WithInterrupts("node_a"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err == nil {t.Fatal("expected interrupt")}- cp, _ := ms.Get(context.Background(), map[string]interface{}{+ cp, _ := ms.Get(t.Context(), map[string]interface{}{constants.ConfigKeyThreadID: tid,})if cp != nil {@@ -149,7 +148,7 @@ func TestInterrupt_NoCheckpointer(t *testing.T) {WithRecursionLimit(10),WithInterrupts("node_a"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected interrupt without checkpointer")}@@ -167,7 +166,7 @@ func TestInterrupt_Concurrent(t *testing.T) {WithRecursionLimit(10),WithInterrupts("node_a"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "conc"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "conc"})if err == nil {t.Errorf("expected interrupt")}@@ -193,7 +192,7 @@ func TestInterrupt_ConcurrentWithCheckpointer(t *testing.T) {WithConfig(cfg),WithInterrupts("node_a"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Errorf("expected interrupt")}diff --git a/internal/harness/graph/pregel/pregel_perf_benchmark_test.go b/internal/harness/graph/pregel/pregel_perf_benchmark_test.goindex efa3a17891..875ddaefc4 100644--- a/internal/harness/graph/pregel/pregel_perf_benchmark_test.go+++ b/internal/harness/graph/pregel/pregel_perf_benchmark_test.go@@ -44,7 +44,7 @@ func benchmarkSimpleGraph() types.StateGraph {func BenchmarkEngine_SimpleChain(b *testing.B) {g := benchmarkSimpleGraph()engine := NewEngine(g, WithRecursionLimit(10))- ctx := context.Background()+ ctx := b.Context()input := map[string]any{"value": "bench"}b.ResetTimer()@@ -78,7 +78,7 @@ func BenchmarkEngine_LongChain(b *testing.B) {sg.AddEdge(prev, constants.End)engine := NewEngine(sg, WithRecursionLimit(200))- ctx := context.Background()+ ctx := b.Context()input := State{}b.ResetTimer()@@ -100,7 +100,7 @@ func BenchmarkEngine_WithCheckpointer(b *testing.B) {g := benchmarkSimpleGraph()ms := checkpoint.NewMemorySaver()engine := NewEngine(g, WithRecursionLimit(10), WithCheckpointer(ms))- ctx := context.Background()+ ctx := b.Context()input := map[string]any{"value": "bench-cp"}b.ResetTimer()@@ -139,7 +139,7 @@ func BenchmarkEngine_Scaling_Nodes(b *testing.B) {sg.AddEdge(prev, constants.End)engine := NewEngine(sg, WithRecursionLimit(n*2))- ctx := context.Background()+ ctx := b.Context()b.ResetTimer()for i := 0; i < b.N; i++ {@@ -160,7 +160,7 @@ func BenchmarkEngine_Scaling_Nodes(b *testing.B) {func BenchmarkEngine_Allocation(b *testing.B) {g := benchmarkSimpleGraph()engine := NewEngine(g, WithRecursionLimit(10))- ctx := context.Background()+ ctx := b.Context()input := map[string]any{"value": "bench-alloc"}b.ResetTimer()@@ -197,7 +197,7 @@ func BenchmarkEngine_LargeState(b *testing.B) {sg.AddEdge("load", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- ctx := context.Background()+ ctx := b.Context()b.ResetTimer()b.ReportAllocs()@@ -217,7 +217,7 @@ func BenchmarkEngine_LargeState(b *testing.B) {func BenchmarkEngine_ConcurrentCalls(b *testing.B) {g := benchmarkSimpleGraph()engine := NewEngine(g, WithRecursionLimit(10))- ctx := context.Background()+ ctx := b.Context()input := map[string]any{"value": "bench-conc"}b.ResetTimer()@@ -256,7 +256,7 @@ func BenchmarkEngine_Checkpoint_LargeState(b *testing.B) {ms := checkpoint.NewMemorySaver()engine := NewEngine(sg, WithRecursionLimit(10), WithCheckpointer(ms))- ctx := context.Background()+ ctx := b.Context()b.ResetTimer()b.ReportAllocs()diff --git a/internal/harness/graph/pregel/pregel_pressure_test.go b/internal/harness/graph/pregel/pregel_pressure_test.goindex 413443b43e..4fec4d5cb7 100644--- a/internal/harness/graph/pregel/pregel_pressure_test.go+++ b/internal/harness/graph/pregel/pregel_pressure_test.go@@ -83,7 +83,7 @@ func newLoopGraph(t *testing.T, maxIter int) types.StateGraph {func TestEngine_Loop10Iterations(t *testing.T) {sg := newLoopGraph(t, 10)engine := NewEngine(sg, WithRecursionLimit(50))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -106,7 +106,7 @@ func TestEngine_Loop10Iterations(t *testing.T) {func TestEngine_Loop100Iterations(t *testing.T) {sg := newLoopGraph(t, 100)engine := NewEngine(sg, WithRecursionLimit(200))- _, err := engine.RunSync(context.Background(), map[string]any{})+ _, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -140,7 +140,7 @@ func newChainGraph(t *testing.T, n int) types.StateGraph {func TestEngine_Chain50Nodes(t *testing.T) {sg := newChainGraph(t, 50)engine := NewEngine(sg, WithRecursionLimit(100))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -194,7 +194,7 @@ func TestEngine_FanOut10_FanInDAG(t *testing.T) {sg.AddEdge("join", constants.End)engine := NewEngine(sg, WithRecursionLimit(30))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -236,7 +236,7 @@ func TestEngine_Concurrent50SameGraph(t *testing.T) {go func(id int) {defer wg.Done()engine := NewEngine(sg, WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{})+ _, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {errs <- fmt.Errorf("goroutine %d: %w", id, err)}@@ -270,7 +270,7 @@ func TestEngine_MultiTenant50Engines(t *testing.T) {sg.AddEdge(constants.Start, "worker")sg.AddEdge("worker", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{})+ _, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {errs <- fmt.Errorf("engine %d: %w", id, err)}@@ -312,7 +312,7 @@ func TestEngine_BinaryOperatorAggregate(t *testing.T) {sg.AddEdge("join", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -341,7 +341,7 @@ func TestEngine_TimeoutCancel(t *testing.T) {sg.AddEdge(constants.Start, "slow")sg.AddEdge("slow", constants.End)- ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)+ ctx, cancel := context.WithTimeout(t.Context(), 100*time.Millisecond)defer cancel()engine := NewEngine(sg, WithRecursionLimit(10))@@ -359,7 +359,7 @@ func TestEngine_TimeoutCancel(t *testing.T) {func TestEngine_RecursionLimitExceeded(t *testing.T) {sg := newLoopGraph(t, 50)engine := NewEngine(sg, WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{})+ _, err := engine.RunSync(t.Context(), map[string]any{})if err == nil {t.Fatal("expected recursion limit error, got nil")}@@ -390,7 +390,7 @@ func TestEngine_NodePanicRecovery(t *testing.T) {sg.AddEdge("panicker", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{})+ _, err := engine.RunSync(t.Context(), map[string]any{})if err == nil {t.Fatal("expected panic error, got nil")}@@ -421,7 +421,7 @@ func TestEngine_NodeErrorPropagation(t *testing.T) {sg.AddEdge("never_reached", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{})+ _, err := engine.RunSync(t.Context(), map[string]any{})if err == nil {t.Fatal("expected error from failing node, got nil")}@@ -475,7 +475,7 @@ func TestEngine_PartialNodeFailureInFanOut(t *testing.T) {sg.AddEdge("join", constants.End)engine := NewEngine(sg, WithRecursionLimit(30))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})// Error behavior depends on how the engine handles partial failure.// The key thing is that the engine should not hang or crash.if err != nil {@@ -512,7 +512,7 @@ func TestEngine_ContextCancellationMidExecution(t *testing.T) {sg.AddEdge("slow_start", "never_run")sg.AddEdge("never_run", constants.End)- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)+ ctx, cancel := context.WithTimeout(t.Context(), 10*time.Millisecond)defer cancel()engine := NewEngine(sg, WithRecursionLimit(10))@@ -589,7 +589,7 @@ func TestEngine_MixedBSPAndDAG(t *testing.T) {sg.AddEdge("dag_join", constants.End)engine := NewEngine(sg, WithRecursionLimit(20))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -650,7 +650,7 @@ func TestEngine_ConditionalEdgesWithDAG(t *testing.T) {sg.AddEdge("final", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -703,7 +703,7 @@ func TestEngine_LargeFanIn100(t *testing.T) {sg.AddEdge("join", constants.End)engine := NewEngine(sg, WithRecursionLimit(n+10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -759,7 +759,7 @@ func TestEngine_LargeFanOut100(t *testing.T) {sg.AddEdge("collector", constants.End)engine := NewEngine(sg, WithRecursionLimit(n+10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -834,7 +834,7 @@ func TestEngine_InterruptAndLoop(t *testing.T) {engine := NewEngine(sg, WithInterrupts("checkpoint"), WithRecursionLimit(20))// First run: should stop at checkpoint- result1, err1 := engine.RunSync(context.Background(), map[string]any{})+ result1, err1 := engine.RunSync(t.Context(), map[string]any{})if err1 != nil {// GraphInterrupt is expected — that means the engine correctly interruptedt.Logf("first run interrupted as expected: %v", err1)@@ -869,7 +869,7 @@ func TestEngine_EmptyNodeExecution(t *testing.T) {sg.AddEdge("end", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -912,7 +912,7 @@ func TestEngine_NodeReuseConcurrentRun(t *testing.T) {sg.AddEdge("worker", constants.End)engine := NewEngine(sg, WithRecursionLimit(5))- _, err := engine.RunSync(context.Background(), map[string]any{"val": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"val": "start"})if err != nil {errs <- fmt.Errorf("engine %d: %w", id, err)}@@ -963,7 +963,7 @@ func TestEngine_DurabilityModes(t *testing.T) {cfg := types.NewRunnableConfig()cfg.Durability = modeengine := NewEngine(sg, WithRecursionLimit(5), WithConfig(cfg))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("mode=%s failed: %v", mode, err)}@@ -999,7 +999,7 @@ func TestEngine_ChannelWriteConflict(t *testing.T) {sg.AddEdge("a", constants.End)engine := NewEngine(sg, WithRecursionLimit(5))- _, err := engine.RunSync(context.Background(), map[string]any{})+ _, err := engine.RunSync(t.Context(), map[string]any{})// Start→a and Start→b execute in consecutive steps (Pregel mode follows// lastCompletedNode), so no conflict. When they happen in the same step,// LastValue rejects the second write.@@ -1041,7 +1041,7 @@ func TestEngine_ChannelWriteConflict(t *testing.T) {sg.AddEdge("join", constants.End)engine := NewEngine(sg, WithRecursionLimit(20))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -1102,7 +1102,7 @@ func TestEngine_StateConcurrentHighPressure(t *testing.T) {sg.AddEdge("c", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- _, err := engine.RunSync(context.Background(), map[string]any{})+ _, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {errCh <- fmt.Errorf("engine %d: %w", id, err)}@@ -1151,7 +1151,7 @@ func TestEngine_MaxIterationsVsConditionStable(t *testing.T) {)engine := NewEngine(sg, WithRecursionLimit(5))- _, err := engine.RunSync(context.Background(), map[string]any{})+ _, err := engine.RunSync(t.Context(), map[string]any{})if err == nil {t.Skip("engine completed without limit enforcement (timing)")}@@ -1191,7 +1191,7 @@ func TestEngine_MaxIterationsVsConditionStable(t *testing.T) {sg.AddEdge("done", constants.End)engine := NewEngine(sg, WithRecursionLimit(20))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("stable loop should terminate: %v", err)}@@ -1245,7 +1245,7 @@ func TestEngine_ChannelTypeCombinations(t *testing.T) {sg.AddEdge("collect", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -1328,7 +1328,7 @@ func TestEngine_DynamicConditionalRouting(t *testing.T) {sg.AddEdge("final", constants.End)engine := NewEngine(sg, WithRecursionLimit(15))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -1357,7 +1357,7 @@ func TestEngine_CheckpointWithBSPLoop(t *testing.T) {cfg.Configurable = map[string]any{constants.ConfigKeyThreadID: "test-cp-bsp"}engine := NewEngine(sg, WithRecursionLimit(20), WithCheckpointer(cp), WithConfig(cfg))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -1365,7 +1365,7 @@ func TestEngine_CheckpointWithBSPLoop(t *testing.T) {t.Skip("result nil")return}- ctx := context.Background()+ ctx := t.Context()checkpoints, err := cp.List(ctx, map[string]any{constants.ConfigKeyThreadID: "test-cp-bsp",}, 100)@@ -1405,7 +1405,7 @@ func TestEngine_DuplicateNodeID(t *testing.T) {sg.AddEdge("dup", constants.End)engine := NewEngine(sg, WithRecursionLimit(5))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -1446,7 +1446,7 @@ func TestEngine_ExtremeConfigValues(t *testing.T) {)engine := NewEngine(sg, WithRecursionLimit(0))- _, err := engine.RunSync(context.Background(), map[string]any{})+ _, err := engine.RunSync(t.Context(), map[string]any{})if err == nil {t.Skip("engine didn't enforce recursion limit 0 (allowed step 0)")}@@ -1457,7 +1457,7 @@ func TestEngine_ExtremeConfigValues(t *testing.T) {t.Run("recursion_limit_one", func(t *testing.T) {sg := newSimpleGraph(t)engine := NewEngine(sg, WithRecursionLimit(1))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})// With limit=1 and 2 nodes (entry + node_a), may or may not completet.Logf("recursion limit 1 result: %v", err)})@@ -1465,7 +1465,7 @@ func TestEngine_ExtremeConfigValues(t *testing.T) {t.Run("max_concurrency_zero", func(t *testing.T) {sg := newSimpleGraph(t)engine := NewEngine(sg, WithRecursionLimit(10), WithMaxConcurrency(0))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err != nil {t.Fatalf("max concurrency 0 should use default: %v", err)}@@ -1500,7 +1500,7 @@ func TestEngine_MultipleEntryPoints(t *testing.T) {sg.AddEdge("entry_b", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -1558,7 +1558,7 @@ func TestEngine_NodeWithBothEdgeAndConditionalEdge(t *testing.T) {sg.AddEdge("done", constants.End)engine := NewEngine(sg, WithRecursionLimit(20))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -1591,7 +1591,7 @@ func TestEngine_NodeTimeout(t *testing.T) {sg.AddEdge("slow", constants.End)// Use a short context timeout to cut off the slow node- ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)+ ctx, cancel := context.WithTimeout(t.Context(), 50*time.Millisecond)defer cancel()engine := NewEngine(sg, WithRecursionLimit(10))@@ -1667,7 +1667,7 @@ func TestEngine_MultipleFanInNodes(t *testing.T) {sg.AddEdge("final_join", constants.End)engine := NewEngine(sg, WithRecursionLimit(30))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -1707,7 +1707,7 @@ func TestEngine_OverwriteValue(t *testing.T) {sg.AddEdge("writer", constants.End)engine := NewEngine(sg, WithRecursionLimit(5))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -1735,7 +1735,7 @@ func TestEngine_TrivialEmptyGraph(t *testing.T) {sg.AddEdge(constants.Start, constants.End)engine := NewEngine(sg, WithRecursionLimit(5))- result, err := engine.RunSync(context.Background(), map[string]any{"x": "hello"})+ result, err := engine.RunSync(t.Context(), map[string]any{"x": "hello"})if err != nil {t.Fatalf("trivial graph failed: %v", err)}@@ -1765,7 +1765,7 @@ func TestEngine_PregelWithCustomChannels(t *testing.T) {sg.AddEdge("adder", constants.End)engine := NewEngine(sg, WithRecursionLimit(5))- result, err := engine.RunSync(context.Background(), map[string]any{"total": 10, "value": "init"})+ result, err := engine.RunSync(t.Context(), map[string]any{"total": 10, "value": "init"})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -1791,7 +1791,7 @@ func TestEngine_LargeLoopBSP(t *testing.T) {const iterations = 50sg := newLoopGraph(t, iterations)engine := NewEngine(sg, WithRecursionLimit(iterations*2))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync failed: %v", err)}@@ -1834,7 +1834,7 @@ func TestEngine_SingleNodeGraph(t *testing.T) {sg.AddEdge("only", constants.End)engine := NewEngine(sg, WithRecursionLimit(5))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("mode=%s failed: %v", mode, err)}diff --git a/internal/harness/graph/pregel/pregel_retry_comprehensive_test.go b/internal/harness/graph/pregel/pregel_retry_comprehensive_test.goindex f051bb0d7f..a692aff4e9 100644--- a/internal/harness/graph/pregel/pregel_retry_comprehensive_test.go+++ b/internal/harness/graph/pregel/pregel_retry_comprehensive_test.go@@ -41,7 +41,7 @@ func TestRetry_BackoffTiming(t *testing.T) {engine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&rp))start := time.Now()- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})elapsed := time.Since(start)if err == nil {@@ -77,7 +77,7 @@ func TestRetry_NodePolicyOverridesEnginePolicy(t *testing.T) {enginePolicy.MaxAttempts = 3engine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&enginePolicy))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected error")}@@ -107,7 +107,7 @@ func TestRetry_EnginePolicyFallback(t *testing.T) {}engine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&enginePolicy))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected error")}@@ -137,7 +137,7 @@ func TestRetry_JitterRandomized(t *testing.T) {rp.Jitter = trueengine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&rp))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected error")}@@ -184,7 +184,7 @@ func TestRetry_WithCheckpointer_Transient(t *testing.T) {WithRetryPolicy(&rp),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -217,7 +217,7 @@ func TestRetry_ZeroAttempts(t *testing.T) {rp.MaxAttempts = 0engine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&rp))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected error")}@@ -244,7 +244,7 @@ func TestRetry_SingleAttempt(t *testing.T) {rp.MaxAttempts = 1engine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&rp))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected error")}@@ -273,7 +273,7 @@ func TestRetry_NonRetryableError(t *testing.T) {rp.RetryOn = func(err error) bool { return false }engine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&rp))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected error")}@@ -306,7 +306,7 @@ func TestRetry_SelectiveRetry(t *testing.T) {}engine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&rp))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected error")}@@ -339,7 +339,7 @@ func TestRetry_BackoffCapped(t *testing.T) {}engine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&rp))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected error")}@@ -371,7 +371,7 @@ func TestRetry_ZeroMaxInterval(t *testing.T) {}engine := NewEngine(sg, WithRecursionLimit(10), WithRetryPolicy(&rp))- _, err := engine.RunSync(context.Background(), map[string]any{"value": "x"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "x"})if err == nil {t.Fatal("expected error")}diff --git a/internal/harness/graph/pregel/pregel_runtime_callback_test.go b/internal/harness/graph/pregel/pregel_runtime_callback_test.goindex c57f07128c..dba1f8934f 100644--- a/internal/harness/graph/pregel/pregel_runtime_callback_test.go+++ b/internal/harness/graph/pregel/pregel_runtime_callback_test.go@@ -34,7 +34,7 @@ func TestRuntime_ExecutionInfo(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- ctx := context.Background()+ ctx := t.Context()start := time.Now()result, err := engine.RunSync(ctx, map[string]any{"value": "info"})elapsed := time.Since(start)@@ -75,13 +75,13 @@ func TestRuntime_MultipleThreads_IndependentCheckpoints(t *testing.T) {WithCheckpointer(ms),WithConfig(cfg),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": "t"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "t"})if err != nil {t.Errorf("thread %d: %v", idx, err)return}m := result.(map[string]any)- cp, _ := ms.Get(context.Background(), map[string]interface{}{+ cp, _ := ms.Get(t.Context(), map[string]interface{}{constants.ConfigKeyThreadID: tid,})results <- threadResult{@@ -122,7 +122,7 @@ func TestCallback_RunLifecycle(t *testing.T) {)te.SetCallbacks(cb)- outputCh, errCh := te.Run(context.Background(), map[string]any{"value": "cb"}, types.StreamModeValues)+ outputCh, errCh := te.Run(t.Context(), map[string]any{"value": "cb"}, types.StreamModeValues)for range outputCh {}<-errCh@@ -152,7 +152,7 @@ func TestCallback_StepTracking(t *testing.T) {)te.SetCallbacks(cb)- outputCh, errCh := te.Run(context.Background(), map[string]any{"value": "steps"}, types.StreamModeValues)+ outputCh, errCh := te.Run(t.Context(), map[string]any{"value": "steps"}, types.StreamModeValues)for range outputCh {}<-errCh@@ -180,7 +180,7 @@ func TestCallback_MultipleCallbacks(t *testing.T) {)te.SetCallbacks(cb)- outputCh, errCh := te.Run(context.Background(), map[string]any{"value": "multi"}, types.StreamModeValues)+ outputCh, errCh := te.Run(t.Context(), map[string]any{"value": "multi"}, types.StreamModeValues)for range outputCh {}<-errCh@@ -221,7 +221,7 @@ func TestCallback_InterruptCallback(t *testing.T) {)te.SetCallbacks(cb)- outputCh, errCh := te.Run(context.Background(), map[string]any{"value": "int"}, types.StreamModeValues)+ outputCh, errCh := te.Run(t.Context(), map[string]any{"value": "int"}, types.StreamModeValues)for range outputCh {}<-errCh@@ -251,7 +251,7 @@ func TestCallback_CheckpointCallback(t *testing.T) {)te.SetCallbacks(cb)- outputCh, errCh := te.Run(context.Background(), map[string]any{"value": "cp"}, types.StreamModeValues)+ outputCh, errCh := te.Run(t.Context(), map[string]any{"value": "cp"}, types.StreamModeValues)for range outputCh {}<-errCh@@ -280,7 +280,7 @@ func TestCallback_NodeLifecycle(t *testing.T) {)te.SetCallbacks(cb)- outputCh, errCh := te.Run(context.Background(), map[string]any{"value": "node"}, types.StreamModeValues)+ outputCh, errCh := te.Run(t.Context(), map[string]any{"value": "node"}, types.StreamModeValues)for range outputCh {}<-errChdiff --git a/internal/harness/graph/pregel/pregel_stream_retry_integration_test.go b/internal/harness/graph/pregel/pregel_stream_retry_integration_test.goindex 3a21fa7c95..9cbd8485ad 100644--- a/internal/harness/graph/pregel/pregel_stream_retry_integration_test.go+++ b/internal/harness/graph/pregel/pregel_stream_retry_integration_test.go@@ -28,7 +28,7 @@ func TestStream_ValuesMode(t *testing.T) {sg := newSimpleGraph(t)engine := NewEngine(sg, WithRecursionLimit(10))- ctx := context.Background()+ ctx := t.Context()outputCh, errCh := engine.Run(ctx, map[string]any{"value": "start"}, types.StreamModeValues)var events []*StreamEvent@@ -66,7 +66,7 @@ func TestStream_UpdatesMode(t *testing.T) {sg := newSimpleGraph(t)engine := NewEngine(sg, WithRecursionLimit(10))- ctx := context.Background()+ ctx := t.Context()outputCh, errCh := engine.Run(ctx, map[string]any{"value": "start"}, types.StreamModeUpdates)var events []*StreamEvent@@ -92,7 +92,7 @@ func TestStream_TasksMode(t *testing.T) {sg := newSimpleGraph(t)engine := NewEngine(sg, WithRecursionLimit(10))- ctx := context.Background()+ ctx := t.Context()outputCh, errCh := engine.Run(ctx, map[string]any{"value": "start"}, types.StreamModeTasks)var taskStarts []string@@ -116,7 +116,7 @@ func TestStream_TasksMode(t *testing.T) {func TestStream_MultipleModes(t *testing.T) {sg := newSimpleGraph(t)engine := NewEngine(sg, WithRecursionLimit(10))- ctx := context.Background()+ ctx := t.Context()for _, mode := range []types.StreamMode{types.StreamModeValues,@@ -145,7 +145,7 @@ func TestStream_ConcurrentConsumers(t *testing.T) {sg := newSimpleGraph(t)engine := NewEngine(sg, WithRecursionLimit(10))- ctx := context.Background()+ ctx := t.Context()outputCh, errCh := engine.Run(ctx, map[string]any{"value": "conc"}, types.StreamModeValues)var wg sync.WaitGroup@@ -197,7 +197,7 @@ func TestRetry_TransientFailure_Succeeds(t *testing.T) {WithRetryPolicy(&rp),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": "retry"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "retry"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -230,7 +230,7 @@ func TestRetry_TransientFailure_Exhausted(t *testing.T) {WithRetryPolicy(&rp),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "retry"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "retry"})if err == nil {t.Fatal("expected error from exhausted retries")}@@ -267,7 +267,7 @@ func TestRetry_CustomPolicy(t *testing.T) {WithRetryPolicy(&rp),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "retry"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "retry"})if err == nil {t.Fatal("expected permanent failure error")}@@ -305,7 +305,7 @@ func TestRetry_WithCheckpointer(t *testing.T) {WithRetryPolicy(&rp),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -342,7 +342,7 @@ func TestEngine_50NodeChain(t *testing.T) {_ = sg.AddEdge(prev, constants.End)engine := NewEngine(sg, WithRecursionLimit(100))- result, err := engine.RunSync(context.Background(), map[string]any{"value": "fan"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "fan"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -377,7 +377,7 @@ func TestEngine_ChainOf100(t *testing.T) {WithRecursionLimit(150),)- result, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ result, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -410,7 +410,7 @@ func TestEngine_WithMultipleChannels(t *testing.T) {_ = sg.AddEdge("node_b", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- result, err := engine.RunSync(context.Background(), map[string]any{})+ result, err := engine.RunSync(t.Context(), map[string]any{})if err != nil {t.Fatalf("RunSync: %v", err)}@@ -451,7 +451,7 @@ func TestEngine_Interrupt(t *testing.T) {WithInterrupts("target"),)- _, err := engine.RunSync(context.Background(), map[string]any{"value": "start"})+ _, err := engine.RunSync(t.Context(), map[string]any{"value": "start"})if err == nil {t.Fatal("expected interrupt at target")}@@ -477,7 +477,7 @@ func TestEngine_ContextCancellation_Propagation(t *testing.T) {_ = sg.AddEdge("slow", constants.End)engine := NewEngine(sg, WithRecursionLimit(10))- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)+ ctx, cancel := context.WithTimeout(t.Context(), 10*time.Millisecond)defer cancel()_, err := engine.RunSync(ctx, map[string]any{"value": "cancel"})diff --git a/internal/harness/graph/runnable/runnable_test.go b/internal/harness/graph/runnable/runnable_test.goindex 5c6a0bc5af..359c925717 100644--- a/internal/harness/graph/runnable/runnable_test.go+++ b/internal/harness/graph/runnable/runnable_test.go@@ -11,7 +11,7 @@ func TestNewRunnableFunc(t *testing.T) {return "hello " + input, nil}r := NewRunnableFunc(fn)- result, err := r.Invoke(context.Background(), "world")+ result, err := r.Invoke(t.Context(), "world")if err != nil {t.Fatalf("Invoke: %v", err)}@@ -32,7 +32,7 @@ func TestRunnableFunc_WithOptions(t *testing.T) {func TestRunnableFunc_Batch(t *testing.T) {fn := func(ctx context.Context, input int) (int, error) { return input * 2, nil }r := NewRunnableFunc(fn)- outputs, errs := r.Batch(context.Background(), []int{1, 2, 3})+ outputs, errs := r.Batch(t.Context(), []int{1, 2, 3})if len(outputs) != 3 || outputs[0] != 2 || outputs[2] != 6 {t.Errorf("expected [2,4,6], got %v", outputs)}@@ -42,7 +42,7 @@ func TestRunnableFunc_Batch(t *testing.T) {func TestRunnableFunc_Stream(t *testing.T) {fn := func(ctx context.Context, input string) (string, error) { return input, nil }r := NewRunnableFunc(fn)- ch := r.Stream(context.Background(), "test")+ ch := r.Stream(t.Context(), "test")val, ok := <-chif !ok || val != "test" {t.Errorf("expected 'test', got %v (ok=%v)", val, ok)@@ -61,7 +61,7 @@ func TestRunnableFunc_Error(t *testing.T) {r := NewRunnableFunc(func(ctx context.Context, input string) (string, error) {return "", &RunnableError{Message: "failed"}})- _, err := r.Invoke(context.Background(), "x")+ _, err := r.Invoke(t.Context(), "x")if err == nil {t.Fatal("expected error")}@@ -80,7 +80,7 @@ func TestRunnableSeq(t *testing.T) {if err != nil {t.Fatalf("NewRunnableSeq: %v", err)}- result, err := seq.Invoke(context.Background(), "start")+ result, err := seq.Invoke(t.Context(), "start")if err != nil {t.Fatalf("Invoke: %v", err)}@@ -107,7 +107,7 @@ func TestRunnableParallel(t *testing.T) {return n * 20, nil})par := NewRunnableParallel(map[string]Runnable[any, any]{"r1": r1, "r2": r2})- results, err := par.Invoke(context.Background(), 5)+ results, err := par.Invoke(t.Context(), 5)if err != nil {t.Fatalf("Invoke: %v", err)}@@ -125,7 +125,7 @@ func TestRunnableMap(t *testing.T) {func(ctx context.Context, input any) (any, error) { return input, nil },func(ctx context.Context, output any) (any, error) { return output, nil },)- result, _ := mapped.Invoke(context.Background(), "data")+ result, _ := mapped.Invoke(t.Context(), "data")s, _ := result.(string)if s != "proc:data" {t.Errorf("expected 'proc:data', got %s", s)@@ -141,7 +141,7 @@ func TestRunnableMap_Batch(t *testing.T) {func(ctx context.Context, input any) (any, error) { return input, nil },func(ctx context.Context, output any) (any, error) { return output, nil },)- outputs, errs := mapped.Batch(context.Background(), []any{1, 2, 3})+ outputs, errs := mapped.Batch(t.Context(), []any{1, 2, 3})if len(outputs) != 3 {t.Fatalf("expected 3 outputs, got %d", len(outputs))}@@ -153,7 +153,7 @@ func TestRunnableBuilder(t *testing.T) {return "built:" + anyToString(input), nil})r := NewRunnableBuilder(base).Build()- result, _ := r.Invoke(context.Background(), "value")+ result, _ := r.Invoke(t.Context(), "value")s, _ := result.(string)if s != "built:value" {t.Errorf("expected 'built:value', got %s", s)@@ -171,7 +171,7 @@ func TestRunnableBuilder_Then(t *testing.T) {if err != nil {t.Fatalf("Then: %v", err)}- result, _ := b.Build().Invoke(context.Background(), "start")+ result, _ := b.Build().Invoke(t.Context(), "start")s, _ := result.(string)if s != "start_a_b" {t.Errorf("expected 'start_a_b', got %s", s)@@ -186,7 +186,7 @@ func TestRunnableBuilder_Map(t *testing.T) {func(ctx context.Context, input any) (any, error) { return input, nil },func(ctx context.Context, output any) (any, error) { return output, nil },)- result, _ := b.Build().Invoke(context.Background(), "data")+ result, _ := b.Build().Invoke(t.Context(), "data")s, _ := result.(string)if s != "data_inner" {t.Errorf("expected 'data_inner', got %s", s)@@ -202,7 +202,7 @@ func TestRunnableFunc_Concurrent(t *testing.T) {wg.Add(1)go func(val int) {defer wg.Done()- res, _ := r.Invoke(context.Background(), val)+ res, _ := r.Invoke(t.Context(), val)ch <- res}(i)}diff --git a/internal/harness/graph/store/store_test.go b/internal/harness/graph/store/store_test.goindex 2e74806724..bfd54b3c65 100644--- a/internal/harness/graph/store/store_test.go+++ b/internal/harness/graph/store/store_test.go@@ -1,13 +1,12 @@package storeimport (- "context""testing""time")func TestInMemoryStore_BasicOperations(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := NewInMemoryStore()defer store.Close()@@ -47,7 +46,7 @@ func TestInMemoryStore_BasicOperations(t *testing.T) {}func TestInMemoryStore_Search(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := NewInMemoryStore()defer store.Close()@@ -75,7 +74,7 @@ func TestInMemoryStore_Search(t *testing.T) {}func TestInMemoryStore_BatchPut(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := NewInMemoryStore()defer store.Close()@@ -103,7 +102,7 @@ func TestInMemoryStore_BatchPut(t *testing.T) {}func TestInMemoryStore_TTL(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := NewInMemoryStore()defer store.Close()@@ -133,7 +132,7 @@ func TestInMemoryStore_TTL(t *testing.T) {}func TestInMemoryStore_List(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := NewInMemoryStore()defer store.Close()@@ -160,7 +159,7 @@ func TestInMemoryStore_List(t *testing.T) {}func TestInMemoryStore_Clear(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := NewInMemoryStore()namespace := []string{"clear", "test"}@@ -180,7 +179,7 @@ func TestInMemoryStore_Clear(t *testing.T) {}func TestInMemoryStore_Closed(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := NewInMemoryStore()store.Close()diff --git a/internal/harness/graph/task/decorator_test.go b/internal/harness/graph/task/decorator_test.goindex b3b37c9522..820e37f80a 100644--- a/internal/harness/graph/task/decorator_test.go+++ b/internal/harness/graph/task/decorator_test.go@@ -10,7 +10,7 @@ import ()func TestTaskDecorator(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()// Test basic task decoratorfn := func(ctx context.Context, input interface{}) (interface{}, error) {@@ -28,7 +28,7 @@ func TestTaskDecorator(t *testing.T) {}func TestTaskDecoratorWithRetry(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()callCount := 0fn := func(ctx context.Context, input interface{}) (interface{}, error) {@@ -62,7 +62,7 @@ func TestTaskDecoratorWithRetry(t *testing.T) {}func TestTaskDecoratorWithRetryExhausted(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()callCount := 0fn := func(ctx context.Context, input interface{}) (interface{}, error) {@@ -90,7 +90,7 @@ func TestTaskDecoratorWithRetryExhausted(t *testing.T) {}func TestTaskDecoratorWithNonRetryableError(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()callCount := 0fn := func(ctx context.Context, input interface{}) (interface{}, error) {@@ -118,7 +118,7 @@ func TestTaskDecoratorWithNonRetryableError(t *testing.T) {}func TestNamed(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()fn := func(ctx context.Context, input interface{}) (interface{}, error) {return input, nil@@ -135,7 +135,7 @@ func TestNamed(t *testing.T) {}func TestRetryable(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()callCount := 0fn := func(ctx context.Context, input interface{}) (interface{}, error) {@@ -157,7 +157,7 @@ func TestRetryable(t *testing.T) {}func TestWithTimeout(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()fn := func(ctx context.Context, input interface{}) (interface{}, error) {select {@@ -179,7 +179,7 @@ func TestWithTimeout(t *testing.T) {}func TestWithTimeoutSuccess(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()fn := func(ctx context.Context, input interface{}) (interface{}, error) {return "done", nil@@ -196,7 +196,7 @@ func TestWithTimeoutSuccess(t *testing.T) {}func TestCompose(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()fn := func(ctx context.Context, input interface{}) (interface{}, error) {return input.(int) + 1, nil@@ -254,7 +254,7 @@ func TestTaskContext(t *testing.T) {}func TestEntrypoint(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()fn := func(ctx context.Context, input interface{}) (interface{}, error) {return "initialized", nildiff --git a/internal/harness/replay/replay_test.go b/internal/harness/replay/replay_test.goindex aea7688289..649d58aa34 100644--- a/internal/harness/replay/replay_test.go+++ b/internal/harness/replay/replay_test.go@@ -1,7 +1,6 @@package replayimport (- "context""fmt""testing"@@ -9,7 +8,7 @@ import ()func TestReplayEngine_EmptyTrace(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()engine := NewReplayEngine(store)@@ -28,7 +27,7 @@ func TestReplayEngine_EmptyTrace(t *testing.T) {}func TestReplayEngine_ExactReplay(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()// Record a simple trace.@@ -59,7 +58,7 @@ func TestReplayEngine_ExactReplay(t *testing.T) {}func TestReplayEngine_ModelOverride(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("mo"))rec.RecordModelCall(ctx, "gpt-4", "openai", []any{"hi"}, "original", events.TokenUsage{}, 100, 0)@@ -85,7 +84,7 @@ func TestReplayEngine_ModelOverride(t *testing.T) {}func TestReplayEngine_ToolOverride(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("to"))rec.RecordToolCall(ctx, "calc", map[string]any{"expr": "1+1"}, "2", 50, 0, "")@@ -107,7 +106,7 @@ func TestReplayEngine_ToolOverride(t *testing.T) {}func TestReplayEngine_StateOverride(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("so"))rec.RecordStateWrite(ctx, "messages", nil, "initial", "append")@@ -132,7 +131,7 @@ func TestReplayEngine_StateOverride(t *testing.T) {}func TestReplayEngine_OutputStore(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("out"))rec.RecordModelCall(ctx, "gpt-4", "openai", nil, "resp", events.TokenUsage{}, 100, 0)@@ -156,7 +155,7 @@ func TestReplayEngine_OutputStore(t *testing.T) {}func TestReplayEngine_MultipleRuns(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("multi"))for i := 0; i < 5; i++ {@@ -176,7 +175,7 @@ func TestReplayEngine_MultipleRuns(t *testing.T) {}func TestFork_FromEvent(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("fork-test"))rec.RecordModelCall(ctx, "gpt-4", "openai", nil, "resp1", events.TokenUsage{}, 100, 0)@@ -209,7 +208,7 @@ func TestFork_FromEvent(t *testing.T) {}func TestDiff_IdenticalTraces(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("diff-a"))rec.RecordToolCall(ctx, "search", nil, "res", 50, 0, "")@@ -232,7 +231,7 @@ func TestDiff_IdenticalTraces(t *testing.T) {}func TestDiff_DifferentTraces(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("left"))rec.RecordToolCall(ctx, "search", nil, "res1", 50, 0, "")@@ -252,7 +251,7 @@ func TestDiff_DifferentTraces(t *testing.T) {}func TestReplayResult_Metrics(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("metrics"))rec.RecordToolCall(ctx, "t1", nil, "r1", 10, 0, "")@@ -279,7 +278,7 @@ func TestReplayResult_Metrics(t *testing.T) {}func TestEventsContains_FindByType(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("find"))rec.OnNodeStart(ctx, "n1", 0)@@ -348,7 +347,7 @@ func TestReplayExactTools(t *testing.T) {}func TestIntegration_RecordReplayRoundTrip(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("rtt"))@@ -391,7 +390,7 @@ func TestIntegration_RecordReplayRoundTrip(t *testing.T) {}func TestIntegration_ForkThenReplay(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("fork-rtt"))@@ -441,7 +440,7 @@ func TestIntegration_ForkThenReplay(t *testing.T) {// ---- True replay: BuildCheckpoint ----func TestBuildCheckpoint_StateWrite(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("cp-test"))@@ -492,7 +491,7 @@ func TestBuildCheckpoint_EmptyEvents(t *testing.T) {// ---- True replay: Fork with Engine ----func TestFork_WithEngine(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("fork-eng"))@@ -538,7 +537,7 @@ func TestFork_WithEngine(t *testing.T) {}func TestFork_EventNotFound(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()store := events.NewMemoryEventStore()engine := NewReplayEngine(store)@@ -555,7 +554,7 @@ func TestFork_EventNotFound(t *testing.T) {// ---- bench ----func BenchmarkReplay(b *testing.B) {- ctx := context.Background()+ ctx := b.Context()store := events.NewMemoryEventStore()rec := events.NewEventRecorder(store, events.WithTraceID("bench-replay"))diff --git a/internal/ingestion/component/chunker/qa_test.go b/internal/ingestion/component/chunker/qa_test.goindex 478e218a92..b1a3ba854d 100644--- a/internal/ingestion/component/chunker/qa_test.go+++ b/internal/ingestion/component/chunker/qa_test.go@@ -17,7 +17,6 @@package chunkerimport (- "context""strings""testing"@@ -48,7 +47,7 @@ func TestQAChunker_DelimiterTab(t *testing.T) {"output_format": "text","text": "What is Go?\tGo is a programming language.",}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke failed: %v", err)}@@ -73,7 +72,7 @@ func TestQAChunker_DelimiterComma(t *testing.T) {"output_format": "text","text": "What is Rust?,Rust is a systems language.",}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke failed: %v", err)}@@ -98,7 +97,7 @@ func TestQAChunker_Markdown(t *testing.T) {"output_format": "markdown","markdown": "# What is Go?\nGo is a programming language.\n\n# What is Rust?\nRust is a systems language.",}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke failed: %v", err)}@@ -118,7 +117,7 @@ func TestQAChunker_HTMLTable(t *testing.T) {"output_format": "html","html": "<table><tr><td>Q1</td><td>A1</td></tr><tr><td>Q2</td><td>A2</td></tr></table>",}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke failed: %v", err)}@@ -138,7 +137,7 @@ func TestQAChunker_RmQAPrefix(t *testing.T) {"output_format": "text","text": "Question: What is Go?\tAnswer: Go is a language.",}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke failed: %v", err)}@@ -159,7 +158,7 @@ func TestQAChunker_Empty(t *testing.T) {"output_format": "text","text": "",}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke failed: %v", err)}@@ -179,7 +178,7 @@ func TestQAChunker_CaseInsensitivePrefix(t *testing.T) {"output_format": "text","text": "QUESTION: Hello\tANSWER: World",}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke failed: %v", err)}@@ -203,7 +202,7 @@ func TestQAChunker_PrefixSpaceSeparatorStrips(t *testing.T) {"output_format": "text","text": "A language model is useful\tQ How does it work",}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke failed: %v", err)}@@ -229,7 +228,7 @@ func TestQAChunker_HeadingNoTrailingSpace(t *testing.T) {"output_format": "markdown","markdown": "#Hello\nWorld\n",}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke failed: %v", err)}@@ -249,7 +248,7 @@ func TestQAChunker_ChineseLang(t *testing.T) {"output_format": "text","text": "什么是Go?\tGo是一种编程语言。",}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke failed: %v", err)}@@ -273,7 +272,7 @@ func TestQAChunker_MarkdownRendersHTML(t *testing.T) {"output_format": "markdown","markdown": "# Title\nThis is **bold** text.\n",}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke failed: %v", err)}diff --git a/internal/ingestion/component/chunker/table_test.go b/internal/ingestion/component/chunker/table_test.goindex b7b0275efc..2e3ae04b95 100644--- a/internal/ingestion/component/chunker/table_test.go+++ b/internal/ingestion/component/chunker/table_test.go@@ -17,7 +17,6 @@package chunkerimport (- "context""testing")@@ -28,7 +27,7 @@ func tableChunksOf(t *testing.T, inputs map[string]any) []map[string]any {if err != nil {t.Fatalf("NewTableChunker: %v", err)}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("TableChunker.Invoke: %v", err)}diff --git a/internal/ingestion/component/chunker/title_test.go b/internal/ingestion/component/chunker/title_test.goindex 338748fd02..114ab1c5b5 100644--- a/internal/ingestion/component/chunker/title_test.go+++ b/internal/ingestion/component/chunker/title_test.go@@ -17,7 +17,6 @@package chunkerimport (- "context""strings""testing"@@ -92,7 +91,7 @@ func TestTitleChunker_InvokeEmptyInput(t *testing.T) {if err != nil {t.Fatalf("NewTitleChunker: %v", err)}- out, err := c.Invoke(context.Background(), nil, map[string]any{})+ out, err := c.Invoke(t.Context(), nil, map[string]any{})if err != nil {t.Fatalf("Invoke: %v", err)}@@ -127,7 +126,7 @@ func TestTitleChunker_Headings_ASCII(t *testing.T) {}input := "# Top\nFirst body line under Top.\nSecond body.\n## Sub\nBody under Sub heading.\n# TopTwo\nBody under TopTwo."- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"name": "doc.md","text": input,})@@ -159,7 +158,7 @@ func TestTitleChunker_NoHeadings_FallsBack(t *testing.T) {if err != nil {t.Fatalf("NewTitleChunker: %v", err)}- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"name": "doc.txt","text": "alpha line one\nalpha line two",})@@ -186,7 +185,7 @@ func TestTitleChunker_DispatcherHierarchy(t *testing.T) {if _, ok := c.(*TitleChunkerComponent); !ok {t.Fatalf("NewTitleChunker returned %T", c)}- _, err = c.Invoke(context.Background(), nil, map[string]any{+ _, err = c.Invoke(t.Context(), nil, map[string]any{"name": "doc.md","text": "# Top\nFirst body.\n# TopTwo\nBody under TopTwo.",})@@ -215,7 +214,7 @@ func TestTitleChunker_InvokeDeterministic(t *testing.T) {var firstLen intvar firstTexts []stringfor run := 0; run < 10; run++ {- out, err := c.Invoke(context.Background(), nil, inputs)+ out, err := c.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke run %d: %v", run, err)}diff --git a/internal/ingestion/component/chunker/token_children_delim_test.go b/internal/ingestion/component/chunker/token_children_delim_test.goindex bc55046be6..f94b7a02f1 100644--- a/internal/ingestion/component/chunker/token_children_delim_test.go+++ b/internal/ingestion/component/chunker/token_children_delim_test.go@@ -1,7 +1,6 @@package chunkerimport (- "context""strings""testing")@@ -17,7 +16,7 @@ func TestTokenChunker_ChildrenDelimiterDroppedJSON(t *testing.T) {if err != nil {t.Fatalf("NewTokenChunker: %v", err)}- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"name": "doc.json","output_format": "json","json": []map[string]any{@@ -60,7 +59,7 @@ func TestTokenChunker_ChildrenDelimiterBacktickStripped(t *testing.T) {if err != nil {t.Fatalf("NewTokenChunker: %v", err)}- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"name": "doc.txt","output_format": "text","text": "sec one###sec two###sec three",@@ -85,7 +84,7 @@ func TestTokenChunker_ChildrenDelimiterBacktickStripped(t *testing.T) {"delimiters": []string{"\n"},"children_delimiters": []string{"`###`"},})- out2, err := c2.Invoke(context.Background(), nil, map[string]any{+ out2, err := c2.Invoke(t.Context(), nil, map[string]any{"name": "doc.txt","output_format": "text","text": "a `###` b",@@ -110,7 +109,7 @@ func TestTokenChunker_ChildrenDelimiterDroppedText(t *testing.T) {if err != nil {t.Fatalf("NewTokenChunker: %v", err)}- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"name": "doc.txt","output_format": "text","text": "alpha one. alpha two. alpha three.",diff --git a/internal/ingestion/component/chunker/token_delim_contract_test.go b/internal/ingestion/component/chunker/token_delim_contract_test.goindex 859d969608..f282aee30a 100644--- a/internal/ingestion/component/chunker/token_delim_contract_test.go+++ b/internal/ingestion/component/chunker/token_delim_contract_test.go@@ -1,7 +1,6 @@package chunkerimport (- "context""strings""testing")@@ -21,7 +20,7 @@ func TestTokenChunker_BareDelimiterHonored(t *testing.T) {t.Fatalf("NewTokenChunker: %v", err)}const text = "alpha::beta::gamma::delta"- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"name": "doc.txt","output_format": "text","text": text,@@ -65,7 +64,7 @@ func TestTokenChunker_MultiByteBacktickDelimiter(t *testing.T) {if err != nil {t.Fatalf("NewTokenChunker: %v", err)}- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"name": "doc.txt","output_format": "text","text": "第一部分段落第二部分",@@ -93,7 +92,7 @@ func TestTokenChunker_MultiByteBacktickDelimiter(t *testing.T) {if err != nil {t.Fatalf("NewTokenChunker: %v", err)}- out2, err := c2.Invoke(context.Background(), nil, map[string]any{+ out2, err := c2.Invoke(t.Context(), nil, map[string]any{"name": "doc.txt","output_format": "text","text": "A段落B",diff --git a/internal/ingestion/component/parser_test.go b/internal/ingestion/component/parser_test.goindex de1d740e6b..a24721bc5d 100644--- a/internal/ingestion/component/parser_test.go+++ b/internal/ingestion/component/parser_test.go@@ -17,7 +17,6 @@package componentimport (- "context""encoding/json""reflect""strings"@@ -97,7 +96,7 @@ func TestParserComponent_InputsOutputs_NonEmpty(t *testing.T) {// not asserted here.func TestParserComponent_Invoke_TextInput(t *testing.T) {c := &ParserComponent{Param: schema.ParserParam{}.Defaults()}- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"binary": "hello world",})if err != nil {@@ -120,7 +119,7 @@ func TestParserComponent_Invoke_TextInput(t *testing.T) {// pages, in input order, with text intact.func TestParserComponent_Invoke_PageRangeFilter(t *testing.T) {c := &ParserComponent{Param: schema.ParserParam{}.Defaults()}- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"binary": "pageA\fpageB\fpageC",})if err != nil {@@ -159,7 +158,7 @@ func TestParserComponent_Invoke_DeterministicMerge(t *testing.T) {input := "p1\fp2\fp3\fp4\fp5\fp6\fp7\fp8"// First call: produce the canonical bytes.- first, err := c.Invoke(context.Background(), nil, map[string]any{+ first, err := c.Invoke(t.Context(), nil, map[string]any{"binary": input,})if err != nil {@@ -172,7 +171,7 @@ func TestParserComponent_Invoke_DeterministicMerge(t *testing.T) {// Subsequent calls: must produce the same bytes.for i := 0; i < 5; i++ {- got, err := c.Invoke(context.Background(), nil, map[string]any{+ got, err := c.Invoke(t.Context(), nil, map[string]any{"binary": input,})if err != nil {@@ -241,7 +240,7 @@ func TestParserComponent_New_Overrides(t *testing.T) {// doc_id input flows through to the "name" output.func TestParserComponent_Invoke_DocIDCarried(t *testing.T) {c := &ParserComponent{Param: schema.ParserParam{}.Defaults()}- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"binary": "x","doc_id": "doc-123",})@@ -324,7 +323,7 @@ func TestParserComponent_Invoke_ResolvesBinaryFromBucketPath(t *testing.T) {// without decoding it).func TestParserComponent_Invoke_RejectsInvalidUTF8(t *testing.T) {c := &ParserComponent{Param: schema.ParserParam{}.Defaults()}- _, err := c.Invoke(context.Background(), nil, map[string]any{+ _, err := c.Invoke(t.Context(), nil, map[string]any{// 0xFF alone is not valid UTF-8 start byte."binary": string([]byte{0xFF, 0xFE, 0xFD}),})@@ -341,7 +340,7 @@ func TestParserComponent_Invoke_RejectsInvalidUTF8(t *testing.T) {// string.func TestParserComponent_Invoke_AcceptsBytes(t *testing.T) {c := &ParserComponent{Param: schema.ParserParam{}.Defaults()}- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"binary": []byte("alpha\fbeta"),})if err != nil {@@ -364,7 +363,7 @@ func TestParserComponent_Invoke_AcceptsBytes(t *testing.T) {// file families. It only wraps already-prepared page bytes into// schema.Page items.func TestBuildPagesFromBytes_FormatAgnostic(t *testing.T) {- got, err := buildPagesFromBytes(context.Background(), [][]byte{+ got, err := buildPagesFromBytes(t.Context(), [][]byte{[]byte("first page from dispatch"),[]byte("<table>second page from html dispatch</table>"),}, "")diff --git a/internal/ingestion/component/tokenizer_test.go b/internal/ingestion/component/tokenizer_test.goindex 24c6a9968e..ed6902400a 100644--- a/internal/ingestion/component/tokenizer_test.go+++ b/internal/ingestion/component/tokenizer_test.go@@ -61,7 +61,7 @@ func TestTokenizerComponent_Invoke_HappyPath(t *testing.T) {{"text": "bravo chunk text"},{"text": "charlie chunk text"},}- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"tenant_id": "t1","model_id": "embd-1","kb_id": "kb-1",@@ -132,7 +132,7 @@ func TestTokenizerComponent_Invoke_Unicode(t *testing.T) {chunks[i] = map[string]any{"text": txt}}- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"output_format": "chunks","chunks": chunks,})@@ -161,7 +161,7 @@ func TestTokenizerComponent_Invoke_TextPayload(t *testing.T) {c, _ := NewTokenizerComponent(map[string]any{"search_method": []any{"full_text"},})- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"name": "note.txt","output_format": "text","text": "plain payload",@@ -187,7 +187,7 @@ func TestTokenizerComponent_Invoke_JSONPayload(t *testing.T) {c, _ := NewTokenizerComponent(map[string]any{"search_method": []any{"full_text"},})- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"name": "note.pdf","output_format": "json","json": []map[string]any{{"text": "row one"}, {"text": "row two"}},@@ -215,7 +215,7 @@ func TestTokenizerComponent_Invoke_BatchedEmbedding(t *testing.T) {{"text": "two"},{"text": "three"},}- if _, err := c.Invoke(context.Background(), nil, map[string]any{+ if _, err := c.Invoke(t.Context(), nil, map[string]any{"name": "doc.txt","kb_id": "kb-1","output_format": "chunks",@@ -237,7 +237,7 @@ func TestTokenizerComponent_Invoke_FullTextOnly(t *testing.T) {c, _ := NewTokenizerComponent(map[string]any{"search_method": []any{"full_text"},})- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"output_format": "chunks","chunks": []map[string]any{{"text": "alpha bravo"}},})@@ -272,7 +272,7 @@ func TestTokenizerComponent_Invoke_KeywordSplitCommaOnly(t *testing.T) {check := func(keywords string, want []string) {t.Helper()- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"output_format": "chunks","chunks": []map[string]any{{"text": "alpha", "keywords": keywords}},})@@ -313,7 +313,7 @@ func TestTokenizerComponent_Invoke_KeywordSplitCommaOnly(t *testing.T) {func TestTokenizerComponent_Invoke_FullTextAndEmbedding(t *testing.T) {requireTokenizerPool(t)c, _ := withStubEmbedder(t, 4)- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"name": "doc.pdf","kb_id": "kb-1","output_format": "chunks",@@ -344,7 +344,7 @@ func TestTokenizerComponent_Invoke_FullTextAndEmbedding(t *testing.T) {func TestTokenizerComponent_Invoke_EmbedNoResolver(t *testing.T) {requireTokenizerPool(t)c, _ := NewTokenizerComponent(nil)- _, err := c.Invoke(context.Background(), nil, map[string]any{+ _, err := c.Invoke(t.Context(), nil, map[string]any{"kb_id": "kb-1","output_format": "chunks","chunks": []map[string]any{{"text": "alpha"}},@@ -364,7 +364,7 @@ func TestTokenizerComponent_Invoke_EmbedderError(t *testing.T) {c, stub := withStubEmbedder(t, 4)stub.err = errors.New("simulated upstream error")- _, err := c.Invoke(context.Background(), nil, map[string]any{+ _, err := c.Invoke(t.Context(), nil, map[string]any{"kb_id": "kb-1","output_format": "chunks","chunks": []map[string]any{{"text": "alpha"}},@@ -391,7 +391,7 @@ func TestTokenizerComponent_Invoke_EncoderCountMismatch(t *testing.T) {}c := cIntf.(*TokenizerComponent)_ = stub- _, err = c.Invoke(context.Background(), nil, map[string]any{+ _, err = c.Invoke(t.Context(), nil, map[string]any{"kb_id": "kb-1","output_format": "chunks","chunks": []map[string]any{{"text": "a"}, {"text": "b"}, {"text": "c"}},diff --git a/internal/ingestion/component/tokenizer_unit_test.go b/internal/ingestion/component/tokenizer_unit_test.goindex 0372fb977f..c60acb814c 100644--- a/internal/ingestion/component/tokenizer_unit_test.go+++ b/internal/ingestion/component/tokenizer_unit_test.go@@ -152,7 +152,7 @@ func TestTokenizerComponent_Invoke_EmptyChunks(t *testing.T) {c, stub := withStubEmbedder(t, 4)_ = stub- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"kb_id": "kb-1","output_format": "chunks","chunks": []map[string]any{},@@ -181,7 +181,7 @@ func TestTokenizerComponent_Invoke_EmptyChunks(t *testing.T) {func TestTokenizerComponent_Invoke_NilChunks(t *testing.T) {c, stub := withStubEmbedder(t, 4)_ = stub- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"output_format": "chunks",})if err != nil {@@ -202,7 +202,7 @@ func TestTokenizerComponent_Invoke_EmbeddingOnly(t *testing.T) {if err != nil {t.Fatalf("NewTokenizerComponentWithResolver: %v", err)}- out, err := cIntf.(*TokenizerComponent).Invoke(context.Background(), nil, map[string]any{+ out, err := cIntf.(*TokenizerComponent).Invoke(t.Context(), nil, map[string]any{"name": "doc.pdf","kb_id": "kb-1","output_format": "chunks",@@ -230,7 +230,7 @@ func TestTokenizerComponent_Invoke_EmbeddingOnly(t *testing.T) {// empty chunk list, so tokenizeChunks is a no-op and the C++ pool is not needed.func TestTokenizerComponent_Embedding_ZeroChunksStillEmitsConsumptionZero(t *testing.T) {c, stub := withStubEmbedder(t, 2)- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"name": "doc.pdf","kb_id": "kb-1","output_format": "chunks",@@ -473,7 +473,7 @@ func TestChunkOrderInt_EmbeddingOnly(t *testing.T) {{"text": "second chunk", "doc_type_kwd": "text"},},}- out, err := comp.Invoke(context.Background(), nil, inputs)+ out, err := comp.Invoke(t.Context(), nil, inputs)if err != nil {t.Fatalf("Invoke: %v", err)}@@ -519,7 +519,7 @@ func TestChunksFromTokenizerUpstream_FiltersPhantomChunks(t *testing.T) {if err != nil {t.Fatalf("NewTokenizerComponentWithResolver: %v", err)}- out, err := comp.Invoke(context.Background(), nil, map[string]any{+ out, err := comp.Invoke(t.Context(), nil, map[string]any{"name": "doc.pdf","output_format": "json","json": items,@@ -589,7 +589,7 @@ func TestChunkOrderInt_AllPathsUnconditional(t *testing.T) {if err != nil {t.Fatalf("NewTokenizerComponentWithResolver: %v", err)}- out, err := comp.Invoke(context.Background(), nil, tc.inputs)+ out, err := comp.Invoke(t.Context(), nil, tc.inputs)if err != nil {t.Fatalf("Invoke: %v", err)}@@ -638,7 +638,7 @@ func TestChunkOrderInt_A5FilterKeepsSequenceContiguous(t *testing.T) {{"questions": "orphan question"}, // dropped: no retrievable content{"text": "second"},}- out, err := comp.Invoke(context.Background(), nil, map[string]any{+ out, err := comp.Invoke(t.Context(), nil, map[string]any{"name": "doc.pdf","output_format": "chunks","chunks": items,@@ -685,7 +685,7 @@ func TestTokenizerComponent_ImportantKwd_CommaOnly(t *testing.T) {if err != nil {t.Fatalf("NewTokenizerComponent: %v", err)}- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"output_format": "chunks","chunks": []map[string]any{{"text": "doc body", "keywords": "kw1,kw2;kw3,kw4"},@@ -738,7 +738,7 @@ func TestTokenizerComponent_ImportantKwd_PreservesEmptyElements(t *testing.T) {}// Middle empty element must be preserved (["a","","b"]), not dropped.- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"output_format": "chunks","chunks": []map[string]any{{"text": "doc body", "keywords": "a,,b"},@@ -769,7 +769,7 @@ func TestTokenizerComponent_ImportantKwd_PreservesEmptyElements(t *testing.T) {// non-empty keywords field (tokenizer.go:682), so important_kwd is left// unset (nil) rather than materialized as an empty array. Downstream// indexing treats a missing important_kwd as "no keywords", which is safe.- outEmpty, err := c.Invoke(context.Background(), nil, map[string]any{+ outEmpty, err := c.Invoke(t.Context(), nil, map[string]any{"output_format": "chunks","chunks": []map[string]any{{"text": "doc body", "keywords": ""},@@ -853,7 +853,7 @@ func TestTokenizerComponent_ImportantKwd_Bounded(t *testing.T) {}oversized := strings.Repeat("x", 40000)- out, err := c.Invoke(context.Background(), nil, map[string]any{+ out, err := c.Invoke(t.Context(), nil, map[string]any{"output_format": "chunks","chunks": []map[string]any{{"text": "doc body", "keywords": "normal," + oversized + ",中文字"},diff --git a/internal/ingestion/pipeline/pipeline_test.go b/internal/ingestion/pipeline/pipeline_test.goindex 79b1ad4731..4e5d3049be 100644--- a/internal/ingestion/pipeline/pipeline_test.go+++ b/internal/ingestion/pipeline/pipeline_test.go@@ -100,7 +100,7 @@ func TestPipelineRunHappyPath(t *testing.T) {t.Fatalf("NewPipelineFromDSL: %v", err)}- out, err := pipe.Run(context.Background(), map[string]any{"name": "doc-canvas"}, nil)+ out, err := pipe.Run(t.Context(), map[string]any{"name": "doc-canvas"}, nil)if err != nil {t.Fatalf("Run: %v", err)}@@ -121,7 +121,7 @@ func TestPipelineRunHappyPath(t *testing.T) {func TestPipelineRunNilPipeline(t *testing.T) {var p *Pipeline- if _, err := p.Run(context.Background(), nil, nil); err == nil {+ if _, err := p.Run(t.Context(), nil, nil); err == nil {t.Fatal("expected error for nil pipeline")}}@@ -146,7 +146,7 @@ func TestPipelineRunStageErrorBubbles(t *testing.T) {t.Fatalf("NewPipelineFromDSL: %v", err)}- if _, err := pipe.Run(context.Background(), map[string]any{"name": "x"}, nil); err == nil {+ if _, err := pipe.Run(t.Context(), map[string]any{"name": "x"}, nil); err == nil {t.Fatal("expected stage error")}}@@ -252,7 +252,7 @@ func TestPipelineRun_InstanceFactoryOverridesDefaultFactory(t *testing.T) {return &factorySentinelStage{marker: "instance"}, nil})- out, err := pipe.Run(context.Background(), map[string]any{"name": "doc"}, nil)+ out, err := pipe.Run(t.Context(), map[string]any{"name": "doc"}, nil)if err != nil {t.Fatalf("Run: %v", err)}@@ -306,7 +306,7 @@ func TestPipelineRun_TaskScopedFactoriesDoNotLeakAcrossConcurrentPipelines(t *teresults := make(chan result, 2)run := func(pipe *Pipeline) {defer wg.Done()- out, err := pipe.Run(context.Background(), map[string]any{"name": "doc"}, nil)+ out, err := pipe.Run(t.Context(), map[string]any{"name": "doc"}, nil)if err != nil {results <- result{err: err}return@@ -366,7 +366,7 @@ func TestPipelineRunResumableAutoResumes(t *testing.T) {t.Fatalf("NewPipelineFromDSL: %v", err)}- out, err := pipe.Run(context.Background(), map[string]any{"name": "doc-resume"}, nil)+ out, err := pipe.Run(t.Context(), map[string]any{"name": "doc-resume"}, nil)if err != nil {t.Fatalf("Run: %v", err)}@@ -429,7 +429,7 @@ func TestPipelineRunResumableCrossRunResume(t *testing.T) {// Run 1: terminal B errors (oneShotErrStage n=1), simulating a crash.// Non-terminal A's checkpoint + interrupt persist because the error path// does not call ClearInterruptID or store.Delete.- _, err = pipe.Run(context.Background(), map[string]any{"name": "doc-cross-run"}, nil)+ _, err = pipe.Run(t.Context(), map[string]any{"name": "doc-cross-run"}, nil)if err == nil {t.Fatal("Run 1: expected error from simulated crash, got nil")}@@ -443,7 +443,7 @@ func TestPipelineRunResumableCrossRunResume(t *testing.T) {// Run 2: resume from after A via tracker.GetInterruptID. A is skipped;// B's oneShotErrStage (n=2) delegates to its embedded mock successfully.- _, err = pipe.Run(context.Background(), map[string]any{"name": "doc-cross-run"}, nil)+ _, err = pipe.Run(t.Context(), map[string]any{"name": "doc-cross-run"}, nil)if err != nil {t.Fatalf("Run 2: expected recovery success, got error: %v", err)}@@ -502,7 +502,7 @@ func TestPipelineRunResumableDSLChanged(t *testing.T) {if err != nil {t.Fatalf("NewPipelineFromDSL (run 1): %v", err)}- if _, err := pipe1.Run(context.Background(), map[string]any{"name": "doc-dsl-changed"}, nil); err == nil {+ if _, err := pipe1.Run(t.Context(), map[string]any{"name": "doc-dsl-changed"}, nil); err == nil {t.Fatal("Run 1: expected error from simulated crash, got nil")}if mockA.calls != 1 {@@ -527,7 +527,7 @@ func TestPipelineRunResumableDSLChanged(t *testing.T) {if err != nil {t.Fatalf("NewPipelineFromDSL (run 2): %v", err)}- if _, err := pipe2.Run(context.Background(), map[string]any{"name": "doc-dsl-changed"}, nil); err != nil {+ if _, err := pipe2.Run(t.Context(), map[string]any{"name": "doc-dsl-changed"}, nil); err != nil {t.Fatalf("Run 2: expected fresh run to succeed after DSL edit, got error: %v", err)}@@ -608,7 +608,7 @@ func TestGuardDSLChange_CheckpointLookupErrorSkipsOverwrite(t *testing.T) {rawDSL: []byte(`{"dsl":{"components":{"begin":{"obj":{"component_name":"Begin","params":{}}}}}}`),}// tracker is nil-safe (only used on the delete branch, which is skipped).- p.guardDSLChange(context.Background(), store, nil, taskID, map[string]any{"k": "v"})+ p.guardDSLChange(t.Context(), store, nil, taskID, map[string]any{"k": "v"})if store.setCalled {t.Fatal("guardDSLChange must not overwrite fingerprints after a failed checkpoint lookup")}@@ -660,7 +660,7 @@ func TestPipelineRunResumableOverrideChanged(t *testing.T) {if err != nil {t.Fatalf("NewPipelineFromDSL (run 1): %v", err)}- if _, err := pipe1.Run(context.Background(), map[string]any{"name": "doc-ovf-changed"}, map[string]any{"k": "v1"}); err == nil {+ if _, err := pipe1.Run(t.Context(), map[string]any{"name": "doc-ovf-changed"}, map[string]any{"k": "v1"}); err == nil {t.Fatal("Run 1: expected error from simulated crash, got nil")}if mockA.calls != 1 {@@ -674,7 +674,7 @@ func TestPipelineRunResumableOverrideChanged(t *testing.T) {if err != nil {t.Fatalf("NewPipelineFromDSL (run 2): %v", err)}- if _, err := pipe2.Run(context.Background(), map[string]any{"name": "doc-ovf-changed"}, map[string]any{"k": "v2"}); err != nil {+ if _, err := pipe2.Run(t.Context(), map[string]any{"name": "doc-ovf-changed"}, map[string]any{"k": "v2"}); err != nil {t.Fatalf("Run 2: expected fresh run to succeed after override edit, got error: %v", err)}if mockA.calls != 2 {@@ -708,7 +708,7 @@ func TestPipelineRun_RequireResumeRejectsWithoutStore(t *testing.T) {if err != nil {t.Fatalf("NewPipelineFromDSL: %v", err)}- _, err = pipe.Run(context.Background(), map[string]any{"name": "doc"}, nil)+ _, err = pipe.Run(t.Context(), map[string]any{"name": "doc"}, nil)if !errors.Is(err, ErrResumeUnavailable) {t.Fatalf("expected ErrResumeUnavailable, got %v", err)}@@ -769,7 +769,7 @@ func TestPipelineRunForwardsProgressToSink(t *testing.T) {if err != nil {t.Fatalf("NewPipelineFromDSL: %v", err)}- if _, err := pipe.Run(context.Background(), map[string]any{"name": "doc-sink"}, nil); err != nil {+ if _, err := pipe.Run(t.Context(), map[string]any{"name": "doc-sink"}, nil); err != nil {t.Fatalf("Run: %v", err)}@@ -808,34 +808,34 @@ func TestCleanupCheckpoint_DeletesStoreAndClearsTracker(t *testing.T) {t.Cleanup(func() { client.Close() })store := newMemCheckpointStore()- if err := store.Set(context.Background(), "cp-1", []byte("data")); err != nil {+ if err := store.Set(t.Context(), "cp-1", []byte("data")); err != nil {t.Fatalf("store.Set: %v", err)}// Fingerprint keys must share the checkpoint's lifecycle on cleanup.- if err := store.Set(context.Background(), "cp-1"+dslKeySuffix, []byte("dslfp")); err != nil {+ if err := store.Set(t.Context(), "cp-1"+dslKeySuffix, []byte("dslfp")); err != nil {t.Fatalf("store.Set dsl: %v", err)}- if err := store.Set(context.Background(), "cp-1"+ovfKeySuffix, []byte("ovrfp")); err != nil {+ if err := store.Set(t.Context(), "cp-1"+ovfKeySuffix, []byte("ovrfp")); err != nil {t.Fatalf("store.Set ovf: %v", err)}tracker := canvas.NewRunTrackerWithClient(client, time.Hour)- if err := tracker.AttachInterrupt(context.Background(), "cp-1", "interrupt-1"); err != nil {+ if err := tracker.AttachInterrupt(t.Context(), "cp-1", "interrupt-1"); err != nil {t.Fatalf("AttachInterrupt: %v", err)}p := &Pipeline{}- p.cleanupCheckpoint(context.Background(), store, tracker, "cp-1")+ p.cleanupCheckpoint(t.Context(), store, tracker, "cp-1")// checkpoint + dsl fingerprint + ovf fingerprint = 3 deletes.if store.deleteCount() != 3 {t.Fatalf("expected 3 store deletes (checkpoint + 2 fingerprints), got %d", store.deleteCount())}for _, k := range []string{"cp-1", "cp-1" + dslKeySuffix, "cp-1" + ovfKeySuffix} {- if _, found, _ := store.Get(context.Background(), k); found {+ if _, found, _ := store.Get(t.Context(), k); found {t.Fatalf("expected key %q to be deleted", k)}}- id, ok, err := tracker.GetInterruptID(context.Background(), "cp-1")+ id, ok, err := tracker.GetInterruptID(t.Context(), "cp-1")if err != nil {t.Fatalf("GetInterruptID: %v", err)}@@ -874,7 +874,7 @@ func TestRunPlain_WithTracker_Success(t *testing.T) {t.Fatalf("NewPipelineFromDSL: %v", err)}- _, err = pipe.Run(context.Background(), map[string]any{"name": "doc"}, nil)+ _, err = pipe.Run(t.Context(), map[string]any{"name": "doc"}, nil)if err != nil {t.Fatalf("Run: %v", err)}@@ -905,7 +905,7 @@ func TestRunPlain_WithTracker_Error(t *testing.T) {t.Fatalf("NewPipelineFromDSL: %v", err)}- _, err = pipe.Run(context.Background(), map[string]any{"name": "doc"}, nil)+ _, err = pipe.Run(t.Context(), map[string]any{"name": "doc"}, nil)if err == nil {t.Fatal("expected stage error, got nil")}diff --git a/internal/ingestion/pipeline/real_storage_integration_test.go b/internal/ingestion/pipeline/real_storage_integration_test.goindex b33c3b3fb8..d226326acd 100644--- a/internal/ingestion/pipeline/real_storage_integration_test.go+++ b/internal/ingestion/pipeline/real_storage_integration_test.go@@ -93,7 +93,7 @@ func TestPipelineRun_TemplateGeneral_RealMySQLMinIO_OutputShape(t *testing.T) {if err != nil {t.Fatalf("NewPipelineFromDSL: %v", err)}- out, err := pipe.Run(context.Background(), map[string]any{+ out, err := pipe.Run(t.Context(), map[string]any{"doc_id": docID,}, nil)if err != nil {@@ -389,7 +389,7 @@ func mustSeedRealPipelineDocument(}).Error; err != nil {t.Fatalf("create kb: %v", err)}- if err := stg.Put(context.Background(), bucket, objectPath, []byte(content)); err != nil {+ if err := stg.Put(t.Context(), bucket, objectPath, []byte(content)); err != nil {t.Fatalf("put real minio object: %v", err)}if err := db.Create(&entity.File{diff --git a/internal/ingestion/pipeline/template_integration_test.go b/internal/ingestion/pipeline/template_integration_test.goindex 2215b05652..7e87db04f8 100644--- a/internal/ingestion/pipeline/template_integration_test.go+++ b/internal/ingestion/pipeline/template_integration_test.go@@ -88,7 +88,7 @@ func TestPipelineRun_TemplateGeneral_RealComponents(t *testing.T) {t.Fatalf("NewPipelineFromDSL: %v", err)}attachFixedEmbedderFactory(t, pipe)- out, err := pipe.Run(context.Background(), map[string]any{+ out, err := pipe.Run(t.Context(), map[string]any{"doc_id": docID,"kb_id": "test-kb",}, nil)@@ -180,7 +180,7 @@ func TestPipelineRun_TemplateOne_RealComponents(t *testing.T) {t.Fatalf("NewPipelineFromDSL: %v", err)}attachFixedEmbedderFactory(t, pipe)- out, err := pipe.Run(context.Background(), map[string]any{+ out, err := pipe.Run(t.Context(), map[string]any{"doc_id": docID,"kb_id": "test-kb",}, nil)@@ -267,7 +267,7 @@ func TestPipelineRun_TemplateOne_RealComponents_PDFDeepdocChunking(t *testing.T)t.Fatalf("NewPipelineFromDSL: %v", err)}attachFixedEmbedderFactory(t, pipe)- out, err := pipe.Run(context.Background(), map[string]any{+ out, err := pipe.Run(t.Context(), map[string]any{"doc_id": docID,"kb_id": "test-kb",}, nil)@@ -366,7 +366,7 @@ func TestPipelineRun_TemplateManual_RealComponents(t *testing.T) {t.Fatalf("NewPipelineFromDSL: %v", err)}attachFixedEmbedderFactory(t, pipe)- out, err := pipe.Run(context.Background(), map[string]any{+ out, err := pipe.Run(t.Context(), map[string]any{"doc_id": docID,"kb_id": "test-kb",}, nil)@@ -464,7 +464,7 @@ func TestPipelineRun_TemplateLaws_RealComponents(t *testing.T) {t.Fatalf("NewPipelineFromDSL: %v", err)}attachFixedEmbedderFactory(t, pipe)- out, err := pipe.Run(context.Background(), map[string]any{+ out, err := pipe.Run(t.Context(), map[string]any{"doc_id": docID,"kb_id": "test-kb",}, nil)@@ -547,7 +547,7 @@ func TestPipelineRun_TemplatePaper_RealComponents(t *testing.T) {t.Fatalf("NewPipelineFromDSL: %v", err)}attachFixedEmbedderFactory(t, pipe)- out, err := pipe.Run(context.Background(), map[string]any{+ out, err := pipe.Run(t.Context(), map[string]any{"doc_id": docID,"kb_id": "test-kb",}, nil)@@ -628,7 +628,7 @@ func TestPipelineRun_TemplateBook_RealComponents(t *testing.T) {t.Fatalf("NewPipelineFromDSL: %v", err)}attachFixedEmbedderFactory(t, pipe)- out, err := pipe.Run(context.Background(), map[string]any{+ out, err := pipe.Run(t.Context(), map[string]any{"doc_id": docID,"kb_id": "test-kb",}, nil)@@ -732,7 +732,7 @@ func TestPipelineRun_AllIngestionTemplates_RealComponentsSmoke(t *testing.T) {t.Fatalf("NewPipelineFromDSL: %v", err)}attachFixedEmbedderFactory(t, pipe)- out, err := pipe.Run(context.Background(), map[string]any{+ out, err := pipe.Run(t.Context(), map[string]any{"doc_id": docID,}, nil)if err != nil {@@ -810,7 +810,7 @@ func seedTemplateDocument(t *testing.T, stg storage.Storage, name, bucket, path,func seedTemplateDocumentBytes(t *testing.T, stg storage.Storage, name, bucket, path string, content []byte) string {t.Helper()- if err := stg.Put(context.Background(), bucket, path, content); err != nil {+ if err := stg.Put(t.Context(), bucket, path, content); err != nil {t.Fatalf("seed storage: %v", err)}if registerTemplateDocumentRef == nil {diff --git a/internal/ingestion/service/burst_backpressure_test.go b/internal/ingestion/service/burst_backpressure_test.goindex 18266f6cc7..3728e1fd77 100644--- a/internal/ingestion/service/burst_backpressure_test.go+++ b/internal/ingestion/service/burst_backpressure_test.go@@ -189,13 +189,13 @@ func TestFetchBudget_NeverExceedsChannelCapacity(t *testing.T) {}for i := 0; i < cap(ingestor.taskChan)-1; i++ {- ingestor.taskChan <- taskpkg.NewTaskContextForScheduling(context.Background(), &entity.IngestionTask{ID: "filler"})+ ingestor.taskChan <- taskpkg.NewTaskContextForScheduling(t.Context(), &entity.IngestionTask{ID: "filler"})}if got := ingestor.fetchBudget(); got != 1 {t.Fatalf("3/4-full channel: fetchBudget = %d, want 1 (one free slot)", got)}- ingestor.taskChan <- taskpkg.NewTaskContextForScheduling(context.Background(), &entity.IngestionTask{ID: "filler"})+ ingestor.taskChan <- taskpkg.NewTaskContextForScheduling(t.Context(), &entity.IngestionTask{ID: "filler"})if got := ingestor.fetchBudget(); got != 1 {t.Fatalf("full channel: fetchBudget = %d, want 1 (floor: must never fetch 0)", got)}diff --git a/internal/ingestion/service/execute_task_ack_test.go b/internal/ingestion/service/execute_task_ack_test.goindex 9f160e2046..3cd8232f54 100644--- a/internal/ingestion/service/execute_task_ack_test.go+++ b/internal/ingestion/service/execute_task_ack_test.go@@ -60,7 +60,7 @@ func TestExecuteTask_AcksMessageOnCompletion(t *testing.T) {}handle := &fakeTaskHandle{}- ingestor.executeTask(ctx, newAckTaskCtx(context.Background(), taskID, docID, handle))+ ingestor.executeTask(ctx, newAckTaskCtx(t.Context(), taskID, docID, handle))if handle.acks.Load() != 1 || handle.nacks.Load() != 0 {t.Fatalf("expected 1 Ack / 0 Nack on completion, got acks=%d nacks=%d", handle.acks.Load(), handle.nacks.Load())@@ -94,7 +94,7 @@ func TestExecuteTask_AcksMessageOnFailure(t *testing.T) {}handle := &fakeTaskHandle{}- ingestor.executeTask(ctx, newAckTaskCtx(context.Background(), taskID, docID, handle))+ ingestor.executeTask(ctx, newAckTaskCtx(t.Context(), taskID, docID, handle))if handle.acks.Load() != 1 || handle.nacks.Load() != 0 {t.Fatalf("expected 1 Ack / 0 Nack on failure, got acks=%d nacks=%d", handle.acks.Load(), handle.nacks.Load())@@ -170,7 +170,7 @@ func TestExecuteTask_HeartbeatsInProgressDuringLongTask(t *testing.T) {}handle := &fakeTaskHandle{}- go ingestor.executeTask(ctx, newAckTaskCtx(context.Background(), taskID, docID, handle))+ go ingestor.executeTask(ctx, newAckTaskCtx(t.Context(), taskID, docID, handle))<-started@@ -252,7 +252,7 @@ func TestExecuteTask_ReleasesTaskFromCurrentTasks(t *testing.T) {ctx := t.Context()handle := &fakeTaskHandle{}- ingestor.executeTask(ctx, newAckTaskCtx(context.Background(), taskID, docID, handle))+ ingestor.executeTask(ctx, newAckTaskCtx(t.Context(), taskID, docID, handle))if _, stillActive := ingestor.currentTasks[taskID]; stillActive {t.Fatal("expected task released from currentTasks after executeTask finished")@@ -268,7 +268,7 @@ func TestSettleMessage_AckOnTerminal(t *testing.T) {ingestor := newUnitIngestor("test", 1, []string{"pdf"})handle := &fakeTaskHandle{}ctx := t.Context()- taskCtx := newAckTaskCtx(context.Background(), "task-1", "doc-1", handle)+ taskCtx := newAckTaskCtx(t.Context(), "task-1", "doc-1", handle)ingestor.settleMessage(ctx, taskCtx, func(ctx context.Context) bool { return true })@@ -282,7 +282,7 @@ func TestSettleMessage_NackOnNonTerminal(t *testing.T) {ingestor := newUnitIngestor("test", 1, []string{"pdf"})handle := &fakeTaskHandle{}ctx := t.Context()- taskCtx := newAckTaskCtx(context.Background(), "task-1", "doc-1", handle)+ taskCtx := newAckTaskCtx(t.Context(), "task-1", "doc-1", handle)ingestor.settleMessage(ctx, taskCtx, func(ctx context.Context) bool { return false })@@ -308,7 +308,7 @@ func TestSettleMessage_RecoversPanicAndAcksWhenTaskTerminal(t *testing.T) {ingestor := newUnitIngestor("test", 1, []string{"pdf"})handle := &fakeTaskHandle{}ctx := t.Context()- taskCtx := newAckTaskCtx(context.Background(), taskID, docID, handle)+ taskCtx := newAckTaskCtx(t.Context(), taskID, docID, handle)panicked := falsefunc() {@@ -342,7 +342,7 @@ func TestSettleMessage_RecoversPanicAndAcksWhenTaskTerminal(t *testing.T) {func TestAckOrNack_AckOnTerminal(t *testing.T) {ingestor := newUnitIngestor("test", 1, []string{"pdf"})handle := &fakeTaskHandle{}- taskCtx := newAckTaskCtx(context.Background(), "task-1", "doc-1", handle)+ taskCtx := newAckTaskCtx(t.Context(), "task-1", "doc-1", handle)ingestor.ackOrNack(taskCtx, true)@@ -355,7 +355,7 @@ func TestAckOrNack_AckOnTerminal(t *testing.T) {func TestAckOrNack_NackOnNonTerminal(t *testing.T) {ingestor := newUnitIngestor("test", 1, []string{"pdf"})handle := &fakeTaskHandle{}- taskCtx := newAckTaskCtx(context.Background(), "task-1", "doc-1", handle)+ taskCtx := newAckTaskCtx(t.Context(), "task-1", "doc-1", handle)ingestor.ackOrNack(taskCtx, false)@@ -368,7 +368,7 @@ func TestAckOrNack_NackOnNonTerminal(t *testing.T) {func TestAckOrNack_NoOpWhenNoHandle(t *testing.T) {ingestor := newUnitIngestor("test", 1, []string{"pdf"})taskCtx := taskpkg.NewTaskContextForScheduling(- context.Background(),+ t.Context(),&entity.IngestionTask{ID: "task-1", DocumentID: "doc-1", DatasetID: "kb-1", Status: common.RUNNING},)// taskCtx.Handle is nil@@ -394,7 +394,7 @@ func TestSettleMessage_DBTruthOverridesBodyReturn(t *testing.T) {ingestor := newUnitIngestor("test", 1, []string{"pdf"})handle := &fakeTaskHandle{}- taskCtx := newAckTaskCtx(context.Background(), taskID, docID, handle)+ taskCtx := newAckTaskCtx(t.Context(), taskID, docID, handle)// body returns false AND marks the task FAILED — simulating a panic// recovery where markFailed succeeded: the task is terminal (FAILED)diff --git a/internal/ingestion/service/execute_task_test.go b/internal/ingestion/service/execute_task_test.goindex 7b22b2bf01..b283a02e76 100644--- a/internal/ingestion/service/execute_task_test.go+++ b/internal/ingestion/service/execute_task_test.go@@ -46,7 +46,7 @@ func TestExecuteTask_CheckpointParseFailureDoesNotKillProcess(t *testing.T) {}taskCtx := taskpkg.NewTaskContextForScheduling(- context.Background(),+ t.Context(),&entity.IngestionTask{ID: taskID, DocumentID: docID, DatasetID: "kb-1", Status: common.RUNNING},)diff --git a/internal/ingestion/service/heartbeat_test.go b/internal/ingestion/service/heartbeat_test.goindex fe7a82b98a..5b19b7381d 100644--- a/internal/ingestion/service/heartbeat_test.go+++ b/internal/ingestion/service/heartbeat_test.go@@ -1,7 +1,6 @@package serviceimport (- "context""sync""testing""time"@@ -29,7 +28,7 @@ func TestStartHeartbeat_TicksInProgressUntilStop(t *testing.T) {ingestor.heartbeatInterval = 2 * time.Millisecondhandle := &fakeTaskHandle{}- taskCtx := newAckTaskCtx(context.Background(), "task-1", "doc-1", handle)+ taskCtx := newAckTaskCtx(t.Context(), "task-1", "doc-1", handle)stop := ingestor.startHeartbeat(taskCtx)time.Sleep(15 * time.Millisecond)@@ -59,7 +58,7 @@ func TestStartHeartbeat_StopWaitsForInFlightInProgress(t *testing.T) {},}taskCtx := taskpkg.NewTaskContextForScheduling(- context.Background(),+ t.Context(),&entity.IngestionTask{ID: "task-1", DocumentID: "doc-1", DatasetID: "kb-1", Status: common.RUNNING},)taskCtx.Handle = h@@ -93,7 +92,7 @@ func TestStartHeartbeat_NoOpWhenNoHandle(t *testing.T) {ingestor.heartbeatInterval = time.MillisecondtaskCtx := taskpkg.NewTaskContextForScheduling(- context.Background(),+ t.Context(),&entity.IngestionTask{ID: "task-1"},)// taskCtx.Handle is nildiff --git a/internal/ingestion/service/run_task_test.go b/internal/ingestion/service/run_task_test.goindex 9ff3dbdd7e..2e6ab2dfac 100644--- a/internal/ingestion/service/run_task_test.go+++ b/internal/ingestion/service/run_task_test.go@@ -86,7 +86,7 @@ func TestRunTask_CorruptedRunCountSkipped(t *testing.T) {return nil}- terminal := ingestor.runTask(context.Background(), &entity.IngestionTask{+ terminal := ingestor.runTask(t.Context(), &entity.IngestionTask{ID: taskID, DocumentID: docID, DatasetID: "kb-1", Status: common.RUNNING,})@@ -120,7 +120,7 @@ func TestRunTask_RunDocumentTaskFailureMarksFailed(t *testing.T) {return errors.New("boom")}- terminal := ingestor.runTask(context.Background(), &entity.IngestionTask{+ terminal := ingestor.runTask(t.Context(), &entity.IngestionTask{ID: taskID, DocumentID: docID, DatasetID: "kb-1", Status: common.RUNNING,})@@ -158,7 +158,7 @@ func TestRunTask_PipelineCancelledMarksStopped(t *testing.T) {return context.Canceled}- terminal := ingestor.runTask(context.Background(), &entity.IngestionTask{+ terminal := ingestor.runTask(t.Context(), &entity.IngestionTask{ID: taskID, DocumentID: docID, DatasetID: "kb-1", Status: common.STOPPING,})@@ -191,7 +191,7 @@ func TestRunTask_ComponentTimeoutMarksFailed(t *testing.T) {return context.DeadlineExceeded}- terminal := ingestor.runTask(context.Background(), &entity.IngestionTask{+ terminal := ingestor.runTask(t.Context(), &entity.IngestionTask{ID: taskID, DocumentID: docID, DatasetID: "kb-1", Status: common.RUNNING,})@@ -232,7 +232,7 @@ func TestRunTask_AlreadyCompletedAcksNotRedelivers(t *testing.T) {return nil}- terminal := ingestor.runTask(context.Background(), &entity.IngestionTask{+ terminal := ingestor.runTask(t.Context(), &entity.IngestionTask{ID: taskID, DocumentID: docID, DatasetID: "kb-1", Status: common.RUNNING,})@@ -272,7 +272,7 @@ func TestRunTask_PipelineSucceedsConcurrentStopSettlesStopped(t *testing.T) {return nil // pipeline still finishes successfully}- terminal := ingestor.runTask(context.Background(), &entity.IngestionTask{+ terminal := ingestor.runTask(t.Context(), &entity.IngestionTask{ID: taskID, DocumentID: docID, DatasetID: "kb-1", Status: common.RUNNING,})@@ -303,7 +303,7 @@ func TestRunTask_SuccessfulCompletion(t *testing.T) {return nil}- terminal := ingestor.runTask(context.Background(), &entity.IngestionTask{+ terminal := ingestor.runTask(t.Context(), &entity.IngestionTask{ID: taskID, DocumentID: docID, DatasetID: "kb-1", Status: common.RUNNING,})diff --git a/internal/ingestion/task/chunk_index_writer_test.go b/internal/ingestion/task/chunk_index_writer_test.goindex 0d335d7ac4..a4f5ce41b7 100644--- a/internal/ingestion/task/chunk_index_writer_test.go+++ b/internal/ingestion/task/chunk_index_writer_test.go@@ -35,7 +35,7 @@ func TestChunkIndexWriter_EmptyChunks(t *testing.T) {"kb-1",10,)- if err := w.Write(context.Background(), nil); err != nil {+ if err := w.Write(t.Context(), nil); err != nil {t.Fatalf("unexpected error: %v", err)}if !called {@@ -61,7 +61,7 @@ func TestChunkIndexWriter_SingleBatch(t *testing.T) {10,)chunks := make([]map[string]any, 5)- if err := w.Write(context.Background(), chunks); err != nil {+ if err := w.Write(t.Context(), chunks); err != nil {t.Fatalf("unexpected error: %v", err)}if len(batchSizes) != 1 {@@ -84,7 +84,7 @@ func TestChunkIndexWriter_MultipleBatches(t *testing.T) {3,)chunks := make([]map[string]any, 7)- if err := w.Write(context.Background(), chunks); err != nil {+ if err := w.Write(t.Context(), chunks); err != nil {t.Fatalf("unexpected error: %v", err)}if len(batchSizes) != 3 {@@ -107,7 +107,7 @@ func TestChunkIndexWriter_BulkSizeZero(t *testing.T) {0, // bulkSize=0 → should use len(chunks))chunks := make([]map[string]any, 20)- if err := w.Write(context.Background(), chunks); err != nil {+ if err := w.Write(t.Context(), chunks); err != nil {t.Fatalf("unexpected error: %v", err)}if lastBatchSize != 20 {diff --git a/internal/service/agent_run_e2e_test.go b/internal/service/agent_run_e2e_test.goindex b0b95b2ecc..7cf7ba3b63 100644--- a/internal/service/agent_run_e2e_test.go+++ b/internal/service/agent_run_e2e_test.go@@ -199,7 +199,7 @@ func TestRunAgent_RealCanvas_BeginMessage(t *testing.T) {cp := canvas.NewRedisCheckPointStoreWithClient(cpClient, 30*24*time.Hour)svc := NewAgentServiceWithOptions(cp, nil, tracker)events, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-hello","session-hello",@@ -292,7 +292,7 @@ func TestRunAgent_SessionHistoryFeedsSysHistoryAndPersists(t *testing.T) {svc := NewAgentService()run := func(input string) canvas.MessageEvent {t.Helper()- events, err := svc.RunAgent(context.Background(), "user-1", "canvas-history", "session-history", "", input, nil)+ events, err := svc.RunAgent(t.Context(), "user-1", "canvas-history", "session-history", "", input, nil)if err != nil {t.Fatalf("RunAgent(%q): %v", input, err)}@@ -394,7 +394,7 @@ func TestRunAgent_NewSessionPersistsHistoryForNextTurn(t *testing.T) {makeCanvasWithDSL(t, "canvas-new-session", "user-1", "tenant-1", "v-new-session", dsl)svc := NewAgentService()- events, err := svc.RunAgent(context.Background(), "user-1", "canvas-new-session", "", "", "1", nil)+ events, err := svc.RunAgent(t.Context(), "user-1", "canvas-new-session", "", "", "1", nil)if err != nil {t.Fatalf("first RunAgent: %v", err)}@@ -424,7 +424,7 @@ func TestRunAgent_NewSessionPersistsHistoryForNextTurn(t *testing.T) {t.Fatalf("new session lost reusable env state: %#v", globals["env.topic"])}- events, err = svc.RunAgent(context.Background(), "user-1", "canvas-new-session", session.ID, "", "1", nil)+ events, err = svc.RunAgent(t.Context(), "user-1", "canvas-new-session", session.ID, "", "1", nil)if err != nil {t.Fatalf("second RunAgent: %v", err)}@@ -481,7 +481,7 @@ func TestRunAgent_RejectsSessionOwnedByAnotherUser(t *testing.T) {}events, err := NewAgentService().RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-session-owner","session-foreign",@@ -607,7 +607,7 @@ func TestRunAgent_RealCanvas_WaitForUserResume(t *testing.T) {// Run 1: should emit a waiting_for_user event.events1, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-fillup","session-fillup",@@ -644,7 +644,7 @@ func TestRunAgent_RealCanvas_WaitForUserResume(t *testing.T) {// — the actual cause was the test running without the// production environment's checkpoint store.events2, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-fillup","session-fillup", // SAME sessionID as run 1@@ -725,7 +725,7 @@ func TestRunAgent_InterruptPersistsPartialAssistantHistory(t *testing.T) {}events, err := NewAgentService().RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-partial","session-partial",@@ -814,7 +814,7 @@ func TestRunAgent_RealCanvas_WaitForUserResume_EventSemantics(t *testing.T) {svc := NewAgentServiceWithOptions(cp, nil, tracker)events1, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-fillup-events","session-fillup-events",@@ -837,7 +837,7 @@ func TestRunAgent_RealCanvas_WaitForUserResume_EventSemantics(t *testing.T) {}events2, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-fillup-events","session-fillup-events",@@ -955,7 +955,7 @@ func TestRunAgent_RealCanvas_GroupedParallelOuterFollower(t *testing.T) {svc := NewAgentService()events, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-parallel","session-parallel",@@ -1025,7 +1025,7 @@ func TestRunAgent_AllFixture_LoopInterruptResume(t *testing.T) {svc := NewAgentServiceWithOptions(cp, nil, tracker)events1, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-all","session-all-loop",@@ -1065,7 +1065,7 @@ func TestRunAgent_AllFixture_LoopInterruptResume(t *testing.T) {}events2, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-all","session-all-loop",@@ -1092,7 +1092,7 @@ func TestRunAgent_AllFixture_LoopInterruptResume(t *testing.T) {}events3, err := svc.RunAgent(- context.Background(), "user-1", "canvas-all", "session-all-loop", "", "1", nil,+ t.Context(), "user-1", "canvas-all", "session-all-loop", "", "1", nil,)if err != nil {t.Fatalf("RunAgent run 3: %v", err)@@ -1151,7 +1151,7 @@ func TestRunAgent_AllFixture_LoopInterruptResume_MultiTurn(t *testing.T) {for i, input := range inputs {events, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-all-multi",sessionID,@@ -1244,7 +1244,7 @@ func TestRunAgent_AllFixture_IterationFormatsItems(t *testing.T) {sessionID := "session-all-iteration"events1, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-all-iteration",sessionID,@@ -1273,7 +1273,7 @@ func TestRunAgent_AllFixture_IterationFormatsItems(t *testing.T) {}events2, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-all-iteration",sessionID,@@ -1300,7 +1300,7 @@ func TestRunAgent_AllFixture_IterationFormatsItems(t *testing.T) {}events3, err := svc.RunAgent(- context.Background(), "user-1", "canvas-all-iteration", sessionID, "", "a,b,c,d,e", nil,+ t.Context(), "user-1", "canvas-all-iteration", sessionID, "", "a,b,c,d,e", nil,)if err != nil {t.Fatalf("RunAgent run 3: %v", err)@@ -1354,7 +1354,7 @@ func TestRunAgent_AllFixture_VarAssigner(t *testing.T) {cp := canvas.NewRedisCheckPointStoreWithClient(cpClient, 30*24*time.Hour)svc := NewAgentServiceWithOptions(cp, nil, tracker)events, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-all-var-assigner","session-all-var-assigner",@@ -1377,7 +1377,7 @@ func TestRunAgent_AllFixture_VarAssigner(t *testing.T) {t.Fatalf("expected no message before menu resume, got %d", len(messages))}events, err = svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-all-var-assigner","session-all-var-assigner",@@ -1438,7 +1438,7 @@ func TestRunAgent_AllFixture_DataOps(t *testing.T) {cp := canvas.NewRedisCheckPointStoreWithClient(cpClient, 30*24*time.Hour)svc := NewAgentServiceWithOptions(cp, nil, tracker)events, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-all-data-ops","session-all-data-ops",@@ -1461,7 +1461,7 @@ func TestRunAgent_AllFixture_DataOps(t *testing.T) {t.Fatalf("expected no message before menu resume, got %d", len(messages))}events, err = svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-all-data-ops","session-all-data-ops",@@ -1540,7 +1540,7 @@ func TestRunAgent_RealCanvas_CompileFails(t *testing.T) {svc := NewAgentService()events, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-bogus","session-bogus",@@ -1612,7 +1612,7 @@ func TestRunAgent_AllFixture_CategorizeResume(t *testing.T) {cp := canvas.NewRedisCheckPointStoreWithClient(cpClient, 30*24*time.Hour)svc := NewAgentServiceWithOptions(cp, nil, tracker)events1, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-all-categorize","session-all-categorize",@@ -1640,7 +1640,7 @@ func TestRunAgent_AllFixture_CategorizeResume(t *testing.T) {}events2, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-all-categorize","session-all-categorize",@@ -1674,7 +1674,7 @@ func TestRunAgent_AllFixture_CategorizeResume(t *testing.T) {}events3, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-all-categorize","session-all-categorize",@@ -1770,7 +1770,7 @@ func TestRunAgent_RealCanvas_InvokeFails(t *testing.T) {svc := NewAgentService()events, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-invoke-fail","session-invoke-fail",@@ -1877,7 +1877,7 @@ func TestRunAgent_RunTracker_AttachCheckpoint_CallSequence(t *testing.T) {svc := NewAgentServiceWithOptions(cp, canvas.CanvasStateSerializer{}, tracker)events, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-cp","session-cp",@@ -1900,7 +1900,7 @@ func TestRunAgent_RunTracker_AttachCheckpoint_CallSequence(t *testing.T) {// The run id is canvasID-sessionID per runIDFor; this is also// the checkpoint id per the Goal 7 contract.runID := "canvas-cp-session-cp"- got, err := tracker.Get(context.Background(), runID)+ got, err := tracker.Get(t.Context(), runID)if err != nil {t.Fatalf("RunTracker.Get: %v", err)}@@ -2119,7 +2119,7 @@ func TestRunAgent_MissingUploadEmitsError(t *testing.T) {makeCanvasWithDSL(t, "canvas-missing-upload", "user-1", "tenant-1", "v-missing-upload", dsl)events, err := NewAgentService().RunAgent(- context.Background(),+ t.Context(),"user-1","canvas-missing-upload","session-missing-upload",@@ -2197,7 +2197,7 @@ func TestRunAgent_NoFilesRunsNormally(t *testing.T) {svc := NewAgentService()events, err := svc.RunAgent(- context.Background(),+ t.Context(),"user-1",canvasID,sessionID,diff --git a/internal/service/ask_service_test.go b/internal/service/ask_service_test.goindex 8caa783454..d9f63b278b 100644--- a/internal/service/ask_service_test.go+++ b/internal/service/ask_service_test.go@@ -98,7 +98,7 @@ func TestAskService_RetrievalError(t *testing.T) {ret := &fakeRetriever{err: fmt.Errorf("engine down")}llm := &fakeStreamLLM{chunks: []string{"answer"}}svc := NewAskService(ret, nil, 0, 0)- deltas := collect(svc.Stream(context.Background(), llm, "user1", "test", []string{"kb1"}))+ deltas := collect(svc.Stream(t.Context(), llm, "user1", "test", []string{"kb1"}))if len(deltas) < 1 || deltas[0].Kind != AskDeltaError {t.Fatalf("expected error delta, got %+v", deltas)}@@ -108,7 +108,7 @@ func TestAskService_EmptyResult(t *testing.T) {ret := &fakeRetriever{result: &RetrievalTestResponse{Chunks: []map[string]interface{}{}}}llm := &fakeStreamLLM{chunks: []string{"answer"}}svc := NewAskService(ret, nil, 0, 0)- deltas := collect(svc.Stream(context.Background(), llm, "user1", "test", []string{"kb1"}))+ deltas := collect(svc.Stream(t.Context(), llm, "user1", "test", []string{"kb1"}))if len(deltas) < 1 || !strings.Contains(deltas[0].Value, "no relevant information") {t.Fatalf("expected 'no relevant information', got %+v", deltas)}@@ -123,7 +123,7 @@ func TestAskService_StreamingFlow(t *testing.T) {}}llm := &fakeStreamLLM{chunks: []string{"Hello", " world"}}svc := NewAskService(ret, nil, 0, 0)- deltas := collect(svc.Stream(context.Background(), llm, "user1", "test", []string{"kb1"}))+ deltas := collect(svc.Stream(t.Context(), llm, "user1", "test", []string{"kb1"}))var hasAnswer, hasFinal boolfor _, d := range deltas {@@ -150,7 +150,7 @@ func TestAskService_EmptyLLMStreamReturnsError(t *testing.T) {}}llm := &fakeStreamLLM{}svc := NewAskService(ret, nil, 0, 0)- deltas := collect(svc.Stream(context.Background(), llm, "user1", "test", []string{"kb1"}))+ deltas := collect(svc.Stream(t.Context(), llm, "user1", "test", []string{"kb1"}))if len(deltas) != 1 || deltas[0].Kind != AskDeltaError || !strings.Contains(deltas[0].Value, "LLM call failed") {t.Fatalf("expected LLM error delta, got %+v", deltas)@@ -166,7 +166,7 @@ func TestAskService_ThinkTags(t *testing.T) {}}llm := &fakeStreamLLM{chunks: []string{"<think>", "reasoning...", "</think>", "visible answer"}}svc := NewAskService(ret, nil, 0, 0)- deltas := collect(svc.Stream(context.Background(), llm, "user1", "test", []string{"kb1"}))+ deltas := collect(svc.Stream(t.Context(), llm, "user1", "test", []string{"kb1"}))var hasMarker boolfor _, d := range deltas {@@ -187,7 +187,7 @@ func TestAskService_LLMError(t *testing.T) {}}llm := &fakeStreamLLM{err: fmt.Errorf("model offline")}svc := NewAskService(ret, nil, 0, 0)- deltas := collect(svc.Stream(context.Background(), llm, "user1", "test", []string{"kb1"}))+ deltas := collect(svc.Stream(t.Context(), llm, "user1", "test", []string{"kb1"}))if len(deltas) < 1 || deltas[0].Kind != AskDeltaError {t.Fatalf("expected error delta, got %+v", deltas)}@@ -209,7 +209,7 @@ func TestAskService_TemperatureFromLLMSetting(t *testing.T) {"temperature_enabled": true,},})- deltas := collect(svc.StreamWithOptions(context.Background(), llm, "user1", "test", []string{"kb1"}, opts))+ deltas := collect(svc.StreamWithOptions(t.Context(), llm, "user1", "test", []string{"kb1"}, opts))var hasFinal boolfor _, d := range deltas {@@ -241,7 +241,7 @@ func TestAskService_TemperatureDisabledUsesDefault(t *testing.T) {"temperature_enabled": false,},})- deltas := collect(svc.StreamWithOptions(context.Background(), llm, "user1", "test", []string{"kb1"}, opts))+ deltas := collect(svc.StreamWithOptions(t.Context(), llm, "user1", "test", []string{"kb1"}, opts))var hasFinal boolfor _, d := range deltas {@@ -274,7 +274,7 @@ func TestAskService_TemperatureMissingUsesLLMSettingDefaults(t *testing.T) {"temperature_enabled": true,},})- collect(svc.StreamWithOptions(context.Background(), llm, "user1", "test", []string{"kb1"}, opts))+ collect(svc.StreamWithOptions(t.Context(), llm, "user1", "test", []string{"kb1"}, opts))if llm.gotConfig == nil || llm.gotConfig.Temperature == nil || *llm.gotConfig.Temperature != DefaultAskTemperature {t.Errorf("expected LLM_SETTING_DEFAULTS temperature %v, got %+v", DefaultAskTemperature, llm.gotConfig)@@ -376,7 +376,7 @@ func TestAskService_AsyncLLMErrorSurfaces(t *testing.T) {}}llm := &asyncErrStreamLLM{fakeStreamLLM: fakeStreamLLM{chunks: []string{"partial"}}}svc := NewAskService(ret, nil, 0, 0)- deltas := collect(svc.Stream(context.Background(), llm, "user1", "test", []string{"kb1"}))+ deltas := collect(svc.Stream(t.Context(), llm, "user1", "test", []string{"kb1"}))var errDelta *AskDeltafor i := range deltas {@@ -401,7 +401,7 @@ func TestAskService_LLMErrorValueIsRealError(t *testing.T) {}}llm := &fakeStreamLLM{err: fmt.Errorf("provider name missing in model name: gpt-4o")}svc := NewAskService(ret, nil, 0, 0)- deltas := collect(svc.Stream(context.Background(), llm, "user1", "test", []string{"kb1"}))+ deltas := collect(svc.Stream(t.Context(), llm, "user1", "test", []string{"kb1"}))if len(deltas) < 1 || deltas[0].Kind != AskDeltaError {t.Fatalf("expected error delta, got %+v", deltas)}diff --git a/internal/service/bot_completion_history_test.go b/internal/service/bot_completion_history_test.goindex b0e8c41cbf..53db4b5d13 100644--- a/internal/service/bot_completion_history_test.go+++ b/internal/service/bot_completion_history_test.go@@ -26,7 +26,6 @@ package serviceimport ("bytes"- "context""encoding/json""errors""fmt"@@ -175,7 +174,7 @@ func TestBotService_AgentbotInputs_CrossTenantDenied(t *testing.T) {svc := NewBotService(nil, nil)// Attacker (tenant-B) asks for victim (tenant-A's canvas).- title, _, _, _, _, code, err := svc.AgentbotInputs(context.Background(),+ title, _, _, _, _, code, err := svc.AgentbotInputs(t.Context(),"tenant-B", "agent-victim")if !errors.Is(err, dao.ErrUserCanvasNotFound) {t.Errorf("cross-tenant: want ErrUserCanvasNotFound, got %v", err)@@ -239,7 +238,7 @@ func TestBotService_AgentbotInputsReadsBeginParams(t *testing.T) {svc := NewBotService(nil, nil)gotTitle, gotAvatar, prologue, mode, inputs, code, err := svc.AgentbotInputs(- context.Background(), "owner-1", "agent-1")+ t.Context(), "owner-1", "agent-1")if err != nil {t.Fatalf("AgentbotInputs: %v", err)}@@ -409,7 +408,7 @@ func TestBotService_ChatbotCompletion_NewSessionSkipsLLM(t *testing.T) {// llmService is nil — any attempt to reach the LLM path would// fail loudly, so a successful run proves the LLM was skipped.svc := NewBotService(nil, nil)- frames, code, err := svc.ChatbotCompletion(context.Background(),+ frames, code, err := svc.ChatbotCompletion(t.Context(),"tenant-1", "dlg-1", ChatbotCompletionRequest{Question: ""})if err != nil {t.Fatalf("ChatbotCompletion: %v", err)diff --git a/internal/service/chat_pipeline_test.go b/internal/service/chat_pipeline_test.goindex c02f197c10..4999e1f49b 100644--- a/internal/service/chat_pipeline_test.go+++ b/internal/service/chat_pipeline_test.go@@ -81,7 +81,7 @@ func TestAsyncChat_RejectsNonUserLastMessage(t *testing.T) {{"role": "user", "content": "first"},{"role": "assistant", "content": "last message must not be assistant"},}- _, err := s.AsyncChat(context.Background(), "user-1", dialForTest(""), messages, false, nil)+ _, err := s.AsyncChat(t.Context(), "user-1", dialForTest(""), messages, false, nil)if err == nil {t.Fatal("expected error for non-user last message, got nil")}@@ -94,7 +94,7 @@ func TestAsyncChat_RejectsNonUserLastMessage(t *testing.T) {// service should return an error before spawning the goroutine.func TestAsyncChat_EmptyMessages(t *testing.T) {s := &ChatPipelineService{}- _, err := s.AsyncChat(context.Background(), "user-1", dialForTest(""), nil, false, nil)+ _, err := s.AsyncChat(t.Context(), "user-1", dialForTest(""), nil, false, nil)if err == nil {t.Fatal("expected error for empty messages, got nil")}@@ -108,7 +108,7 @@ func TestDecorateAnswer_TimerFormatAlwaysEmitted(t *testing.T) {s := &ChatPipelineService{}timer, _ := newTimerAndPrompt()result := s.decorateAnswer(- context.Background(),+ t.Context(),"hello world",map[string]interface{}{"chunks": []interface{}{}, "doc_aggs": []interface{}{}},"system prompt",@@ -146,7 +146,7 @@ func TestDecorateAnswer_ThinkMarkersPreserved(t *testing.T) {s := &ChatPipelineService{}timer, _ := newTimerAndPrompt()result := s.decorateAnswer(- context.Background(),+ t.Context(),"<think>reasoning</think>visible answer",map[string]interface{}{"chunks": []interface{}{}, "doc_aggs": []interface{}{}},"system prompt",@@ -176,7 +176,7 @@ func TestDecorateAnswer_InvalidKeySuffix(t *testing.T) {s := &ChatPipelineService{}timer, _ := newTimerAndPrompt()result := s.decorateAnswer(- context.Background(),+ t.Context(),"oops: invalid api key",map[string]interface{}{"chunks": []interface{}{}, "doc_aggs": []interface{}{}},"system prompt",@@ -203,7 +203,7 @@ func TestDecorateAnswer_LeavesCanonicalMarkers(t *testing.T) {s := &ChatPipelineService{}timer, _ := newTimerAndPrompt()result := s.decorateAnswer(- context.Background(),+ t.Context(),"see [ID:12] for details",map[string]interface{}{"chunks": []interface{}{}, "doc_aggs": []interface{}{}},"system prompt",@@ -230,7 +230,7 @@ func TestDecorateAnswer_RepairNotRunWhenNoQuote(t *testing.T) {s := &ChatPipelineService{}timer, _ := newTimerAndPrompt()result := s.decorateAnswer(- context.Background(),+ t.Context(),"see (ID: 12) for details",map[string]interface{}{"chunks": []interface{}{}, "doc_aggs": []interface{}{}},"system prompt",@@ -270,7 +270,7 @@ func TestDecorateAnswer_RepairRunsWhenQuote(t *testing.T) {"doc_aggs": []interface{}{},}result := s.decorateAnswer(- context.Background(),+ t.Context(),"see (ID: 12) for details",kb,"system prompt",@@ -299,7 +299,7 @@ func TestDecorateAnswer_PreCheckSkipsInsertCitations(t *testing.T) {timer, _ := newTimerAndPrompt()in := "answer has [ID:3] already in it"result := s.decorateAnswer(- context.Background(),+ t.Context(),in,map[string]interface{}{// No chunks → insertCitations path is gated off anyway,@@ -447,7 +447,7 @@ func TestFallbackToLatestUser(t *testing.T) {// TestHydrateChunkVectors_NoChunksNoop pins the no-op behavior of// the hydration helper on empty input.func TestHydrateChunkVectors_NoChunksNoop(t *testing.T) {- hits, err := HydrateChunkVectors(context.Background(),+ hits, err := HydrateChunkVectors(t.Context(),map[string]interface{}{"chunks": []interface{}{}},nil, nil, nil,)@@ -462,7 +462,7 @@ func TestHydrateChunkVectors_NoChunksNoop(t *testing.T) {// TestHydrateChunkVectors_NilKbinfosNoop pins the no-op behavior of// the hydration helper on nil kbinfos.func TestHydrateChunkVectors_NilKbinfosNoop(t *testing.T) {- hits, err := HydrateChunkVectors(context.Background(), nil, nil, nil, nil)+ hits, err := HydrateChunkVectors(t.Context(), nil, nil, nil, nil)if err != nil {t.Errorf("unexpected error: %v", err)}@@ -525,7 +525,7 @@ func TestNormalizeSQL_StripsThinkBlocks(t *testing.T) {func TestBuildSQLReference_Scalar(t *testing.T) {s := &ChatPipelineService{}ans, ref := s.buildSQLReference(- context.Background(), nil, "", "",+ t.Context(), nil, "", "",[]map[string]interface{}{{"count": 42.0}},"", "", nil, nil,)@@ -552,7 +552,7 @@ func TestBuildSQLReference_MultiRowTable(t *testing.T) {}s := &ChatPipelineService{}ans, ref := s.buildSQLReference(- context.Background(), nil, "", "select id, name from t",+ t.Context(), nil, "", "select id, name from t",rows,"sys", "elasticsearch", nil, nil,)@@ -645,7 +645,7 @@ func TestDecorateAnswer_VectorStrippedFromReference(t *testing.T) {"doc_aggs": []interface{}{},}result := s.decorateAnswer(- context.Background(),+ t.Context(),"x",kb,"system prompt",@@ -1193,7 +1193,7 @@ func TestFetchAggregateChunks_SkipsInfinityMultiKB(t *testing.T) {sqlEngine := &sqlFakeEngine{engineType: "infinity"}s := &ChatPipelineService{}chunks, docAggs := s.fetchAggregateChunks(- context.Background(), sqlEngine, "t",+ t.Context(), sqlEngine, "t","select count(*) from t where x = 1","docnm", []string{"kb_a", "kb_b"},)@@ -1218,7 +1218,7 @@ func TestFetchAggregateChunks_SingleKBSuccess(t *testing.T) {}s := &ChatPipelineService{}chunks, docAggs := s.fetchAggregateChunks(- context.Background(), sqlEngine, "t",+ t.Context(), sqlEngine, "t","select count(*) from t where x = 1","docnm_kwd", []string{"kb_a"},)@@ -1250,7 +1250,7 @@ func TestFetchAggregateChunks_NoWhereClause(t *testing.T) {sqlEngine := &sqlFakeEngine{engineType: "elasticsearch"}s := &ChatPipelineService{}chunks, docAggs := s.fetchAggregateChunks(- context.Background(), sqlEngine, "t",+ t.Context(), sqlEngine, "t","select count(*) from t","docnm_kwd", []string{"kb_a"},)@@ -1269,7 +1269,7 @@ func TestFetchAggregateChunks_RunSQLError(t *testing.T) {}s := &ChatPipelineService{}chunks, docAggs := s.fetchAggregateChunks(- context.Background(), sqlEngine, "t",+ t.Context(), sqlEngine, "t","select count(*) from t where x = 1","docnm_kwd", []string{"kb_a"},)@@ -1282,7 +1282,7 @@ func TestFetchAggregateChunks_RunSQLError(t *testing.T) {func TestBuildSQLReference_EmptyRows(t *testing.T) {s := &ChatPipelineService{}ans, ref := s.buildSQLReference(- context.Background(), nil, "", "", nil,+ t.Context(), nil, "", "", nil,"", "", nil, nil,)if ans != "No results." {@@ -1304,7 +1304,7 @@ func TestBuildSQLReference_NonAggregateWithSourceColumns(t *testing.T) {kbs := []*entity.Knowledgebase{{ID: "kb_a"}}s := &ChatPipelineService{}ans, ref := s.buildSQLReference(- context.Background(), nil, "t", "select doc_id, docnm_kwd, title from t",+ t.Context(), nil, "t", "select doc_id, docnm_kwd, title from t",rows, "", "elasticsearch", kbs, nil,)if !strings.Contains(ans, "Source|") {@@ -1351,7 +1351,7 @@ func TestBuildSQLReference_AggregateMissingSourceColumnsSecondaryFetch(t *testinkbs := []*entity.Knowledgebase{{ID: "kb_a"}}s := &ChatPipelineService{}ans, ref := s.buildSQLReference(- context.Background(), sqlEngine, "t",+ t.Context(), sqlEngine, "t","select count(*) from t where x = 1",rows, "", "elasticsearch", kbs, nil,)@@ -1375,7 +1375,7 @@ func TestBuildSQLReference_NonAggregateMissingSourceEmptyRefs(t *testing.T) {}s := &ChatPipelineService{}ans, ref := s.buildSQLReference(- context.Background(), nil, "t", "select title from t",+ t.Context(), nil, "t", "select title from t",rows, "", "elasticsearch", nil, nil,)if !strings.Contains(ans, "T1") || !strings.Contains(ans, "T2") {@@ -1403,7 +1403,7 @@ func TestBuildSQLReference_DisplayNameTranslation(t *testing.T) {fieldMap := map[string]interface{}{"title": "My Title"}s := &ChatPipelineService{}ans, _ := s.buildSQLReference(- context.Background(), nil, "t", "select doc_id, docnm_kwd, title from t",+ t.Context(), nil, "t", "select doc_id, docnm_kwd, title from t",rows, "", "elasticsearch", nil, fieldMap,)if !strings.Contains(ans, "|My Title|") {@@ -1422,7 +1422,7 @@ func TestBuildSQLReference_ISOTimestampStripped(t *testing.T) {}s := &ChatPipelineService{}ans, _ := s.buildSQLReference(- context.Background(), nil, "t", "select doc_id, docnm_kwd, created_at from t",+ t.Context(), nil, "t", "select doc_id, docnm_kwd, created_at from t",rows, "", "elasticsearch", nil, nil,)if strings.Contains(ans, "T13:24:55") {diff --git a/internal/service/chat_session_test.go b/internal/service/chat_session_test.goindex a58ece3699..5e2ce26b73 100644--- a/internal/service/chat_session_test.go+++ b/internal/service/chat_session_test.go@@ -615,7 +615,7 @@ func TestUpdateMessageFeedback_AppliesChunkFeedbackWithResolvedTenantAndContext(pipeline: &fakePipeline{},docEngine: docEngine,}- ctx := context.WithValue(context.Background(), feedbackContextKey{}, "request-context")+ ctx := context.WithValue(t.Context(), feedbackContextKey{}, "request-context")resp, code, err := svc.UpdateMessageFeedback(ctx, "user-1", "chat-1", "session-1", "msg-1", map[string]interface{}{"thumbup": true,@@ -674,7 +674,7 @@ func TestUpdateMessageFeedback_ToggleUsesResolvedTenantForUndoAndApply(t *testindocEngine: docEngine,}- resp, code, err := svc.UpdateMessageFeedback(context.Background(), "user-1", "chat-1", "session-1", "msg-1", map[string]interface{}{+ resp, code, err := svc.UpdateMessageFeedback(t.Context(), "user-1", "chat-1", "session-1", "msg-1", map[string]interface{}{"thumbup": false,"feedback": "not useful",})@@ -703,7 +703,7 @@ func TestApplyChunkFeedback_DisabledDoesNotTouchEngine(t *testing.T) {docEngine := &fakeFeedbackDocEngine{}svc := &ChatSessionService{docEngine: docEngine}- result, err := svc.applyChunkFeedback(context.Background(), "tenant-1", map[string]interface{}{+ result, err := svc.applyChunkFeedback(t.Context(), "tenant-1", map[string]interface{}{"chunks": []interface{}{map[string]interface{}{"id": "chunk-1", "kb_id": "kb-1"}},}, true)if err != nil {@@ -724,7 +724,7 @@ func TestApplyChunkFeedback_UniformSplitsOneVoteAcrossChunks(t *testing.T) {docEngine := &fakeFeedbackDocEngine{}svc := &ChatSessionService{docEngine: docEngine}- result, err := svc.applyChunkFeedback(context.Background(), "tenant-1", map[string]interface{}{+ result, err := svc.applyChunkFeedback(t.Context(), "tenant-1", map[string]interface{}{"chunks": []interface{}{map[string]interface{}{"id": "chunk-1", "kb_id": "kb-1"},map[string]interface{}{"id": "chunk-2", "kb_id": "kb-1"},@@ -751,7 +751,7 @@ func TestApplyChunkFeedback_RelevanceDistributesOneVoteBySignals(t *testing.T) {docEngine := &fakeFeedbackDocEngine{}svc := &ChatSessionService{docEngine: docEngine}- result, err := svc.applyChunkFeedback(context.Background(), "tenant-1", map[string]interface{}{+ result, err := svc.applyChunkFeedback(t.Context(), "tenant-1", map[string]interface{}{"chunks": []interface{}{map[string]interface{}{"id": "chunk-1", "kb_id": "kb-1", "similarity": 2.0},map[string]interface{}{"id": "chunk-2", "kb_id": "kb-1", "vector_similarity": 1.0},@@ -777,7 +777,7 @@ func TestUpdateChunkWeight_InfinityUsesAtomicAdjuster(t *testing.T) {docEngine := &fakeInfinityFeedbackDocEngine{}svc := &ChatSessionService{docEngine: docEngine}- if ok := svc.updateChunkWeight(context.Background(), "tenant-1", "chunk-1", "kb-1", 0.25); !ok {+ if ok := svc.updateChunkWeight(t.Context(), "tenant-1", "chunk-1", "kb-1", 0.25); !ok {t.Fatal("expected updateChunkWeight to succeed")}if docEngine.getChunkCalled {@@ -804,7 +804,7 @@ func TestApplyChunkFeedback_FallbackClampsAndRemovesPagerank(t *testing.T) {}svc := &ChatSessionService{docEngine: docEngine}- result, err := svc.applyChunkFeedback(context.Background(), "tenant-1", map[string]interface{}{+ result, err := svc.applyChunkFeedback(t.Context(), "tenant-1", map[string]interface{}{"chunks": []interface{}{map[string]interface{}{"id": "chunk-1", "kb_id": "kb-1"}},}, false)if err != nil {@@ -919,7 +919,7 @@ func TestChatCompletionsPassesRequestUserIDToPipeline(t *testing.T) {}_, err := svc.ChatCompletions(- context.Background(),+ t.Context(),"user-1","dialog-1","session-1",@@ -1000,7 +1000,7 @@ func TestChatCompletionsStreamFinalCarriesDecoratedReference(t *testing.T) {streamChan := make(chan string, 8)_, err := svc.ChatCompletions(- context.Background(),+ t.Context(),"user-1","dialog-1","session-1",@@ -1097,7 +1097,7 @@ func TestChatCompletionsModelIDOverrideUsesModelResolver(t *testing.T) {}_, err := svc.ChatCompletions(- context.Background(),+ t.Context(),"user-1","dialog-1","session-1",@@ -1154,7 +1154,7 @@ func TestChatCompletionsStoreHistoryFalseDoesNotPersistSession(t *testing.T) {}result, err := svc.ChatCompletions(- context.Background(),+ t.Context(),"user-1","dialog-1","",@@ -1331,7 +1331,7 @@ func TestCompletionStream_Success(t *testing.T) {}streamChan := make(chan string, 10)- err := svc.CompletionStream(context.Background(), "user-1", "session-1", []map[string]interface{}{+ err := svc.CompletionStream(t.Context(), "user-1", "session-1", []map[string]interface{}{{"role": "user", "content": "hi"},}, "", nil, "msg-1", streamChan)if err != nil {diff --git a/internal/service/chunk/chunk_test.go b/internal/service/chunk/chunk_test.goindex 27ddf47e7a..8dad50c3cc 100644--- a/internal/service/chunk/chunk_test.go+++ b/internal/service/chunk/chunk_test.go@@ -46,7 +46,7 @@ func TestHydrateChunkVectors_AllNonZero(t *testing.T) {{"id": "c2", "vector": []float64{4, 5, 6}},}// No zero vectors → nothing to hydrate.- hydrateChunkVectors(context.Background(), nil, chunks, nil, nil)+ hydrateChunkVectors(t.Context(), nil, chunks, nil, nil)if !reflect.DeepEqual(chunks[0]["vector"], []float64{1, 2, 3}) {t.Error("non-zero vector should not be changed")}@@ -57,15 +57,15 @@ func TestHydrateChunkVectors_AllNonZero(t *testing.T) {func TestHydrateChunkVectors_EmptyChunks(t *testing.T) {// Should not panic on empty or nil.- hydrateChunkVectors(context.Background(), nil, nil, nil, nil)- hydrateChunkVectors(context.Background(), nil, []map[string]interface{}{}, nil, nil)+ hydrateChunkVectors(t.Context(), nil, nil, nil, nil)+ hydrateChunkVectors(t.Context(), nil, []map[string]interface{}{}, nil, nil)}func TestHydrateChunkVectors_MissingIDs(t *testing.T) {chunks := []map[string]interface{}{{"vector": []float64{1.0}}, // no id — skipped}- hydrateChunkVectors(context.Background(), nil, chunks, nil, nil)+ hydrateChunkVectors(t.Context(), nil, chunks, nil, nil)// Should not change anything when engine is nil (FetchChunkVectors returns zero vectors).// The function doesn't panic — it just can't hydrate because dim is 0.// With nil engine, FetchChunkVectors returns zero vectors, so the zero stays zero.@@ -75,7 +75,7 @@ func TestHydrateChunkVectors_NoDim(t *testing.T) {chunks := []map[string]interface{}{{"id": "c1", "vector": []float64{}},}- hydrateChunkVectors(context.Background(), nil, chunks, []string{"kb1"}, []string{"t1"})+ hydrateChunkVectors(t.Context(), nil, chunks, []string{"kb1"}, []string{"t1"})// Empty vectors have dim=0 → early return. No crash.}diff --git a/internal/service/connector_syncer_test.go b/internal/service/connector_syncer_test.goindex 2f70859500..ba1057d29a 100644--- a/internal/service/connector_syncer_test.go+++ b/internal/service/connector_syncer_test.go@@ -89,7 +89,7 @@ func TestUpdateConnectorSchedulePublishesSyncerTask(t *testing.T) {}t.Cleanup(func() { getSyncerTaskPublisher = previousPublisher })- _, code, err := NewConnectorService().UpdateConnector(context.Background(), "conn-1", "user-1", &UpdateConnectorRequest{+ _, code, err := NewConnectorService().UpdateConnector(t.Context(), "conn-1", "user-1", &UpdateConnectorRequest{Status: string(entity.TaskStatusSchedule),})if err != nil {@@ -165,7 +165,7 @@ func TestResumeFailedSyncSchedulesOriginalTaskFromCheckpoint(t *testing.T) {getSyncCheckpointLoader = previousLoader})- ok, code, err := NewConnectorService().ResumeFailedSync(context.Background(), "conn-1", "user-1", &ResumeFailedSyncRequest{KbID: "kb-1", TaskID: "task-1"})+ ok, code, err := NewConnectorService().ResumeFailedSync(t.Context(), "conn-1", "user-1", &ResumeFailedSyncRequest{KbID: "kb-1", TaskID: "task-1"})if err != nil {t.Fatalf("ResumeFailedSync error: %v", err)}@@ -249,7 +249,7 @@ func TestRebuildConnectorDeletesOldSyncCheckpointsBeforePublishing(t *testing.T)getSyncCheckpointDeleter = previousDeleter})- ok, code, err := NewConnectorService().RebuildConnector(context.Background(), "conn-1", "user-1", "kb-1")+ ok, code, err := NewConnectorService().RebuildConnector(t.Context(), "conn-1", "user-1", "kb-1")if err != nil {t.Fatalf("RebuildConnector error: %v", err)}@@ -327,7 +327,7 @@ func TestUpdateConnectorScheduleDoesNotDuplicateRunningTask(t *testing.T) {}t.Cleanup(func() { getSyncerTaskPublisher = previousPublisher })- _, code, err := NewConnectorService().UpdateConnector(context.Background(), "conn-1", "user-1", &UpdateConnectorRequest{+ _, code, err := NewConnectorService().UpdateConnector(t.Context(), "conn-1", "user-1", &UpdateConnectorRequest{Status: string(entity.TaskStatusSchedule),})if err != nil {diff --git a/internal/service/connector_test_connection_test.go b/internal/service/connector_test_connection_test.goindex 5af31753fc..1a341fc4d0 100644--- a/internal/service/connector_test_connection_test.go+++ b/internal/service/connector_test_connection_test.go@@ -42,7 +42,7 @@ func TestConnectorServiceTestConnectorUsesRequestConfig(t *testing.T) {"source": "mock","config": entity.JSONMap{"from": "request"},}- if err := svc.TestConnector(context.Background(), "conn-1", "tenant-1", request); err != nil {+ if err := svc.TestConnector(t.Context(), "conn-1", "tenant-1", request); err != nil {t.Fatalf("TestConnector failed: %v", err)}if capturedConfig["from"] != "request" {@@ -64,7 +64,7 @@ func TestConnectorServiceTestConnectorAllowsUnsavedConnectorWithSource(t *testinsvc := NewConnectorService()svc.connectorRegistry = registry- err := svc.TestConnector(context.Background(), "missing", "tenant-1", entity.JSONMap{+ err := svc.TestConnector(t.Context(), "missing", "tenant-1", entity.JSONMap{"source": "mock","config": entity.JSONMap{"ok": true},})@@ -87,7 +87,7 @@ func TestConnectorServiceTestConnectorSurfacesRawValidationError(t *testing.T) {svc := NewConnectorService()svc.connectorRegistry = registry- err := svc.TestConnector(context.Background(), "missing", "tenant-1", entity.JSONMap{+ err := svc.TestConnector(t.Context(), "missing", "tenant-1", entity.JSONMap{"source": "mock","config": entity.JSONMap{"ok": true},})@@ -104,7 +104,7 @@ func TestConnectorServiceTestConnectorRejectsMissingConfigForMissingConnector(tt.Fatalf("migrate connector tables: %v", err)}- err := NewConnectorService().TestConnector(context.Background(), "missing", "tenant-1", nil)+ err := NewConnectorService().TestConnector(t.Context(), "missing", "tenant-1", nil)if !errors.Is(err, ErrConnectorNotFound) {t.Fatalf("error = %v, want ErrConnectorNotFound", err)}@@ -128,7 +128,7 @@ func TestConnectorServiceTestConnectorRejectsUnauthorizedConnector(t *testing.T)t.Fatalf("insert connector: %v", err)}- err := NewConnectorService().TestConnector(context.Background(), "conn-1", "user-2", entity.JSONMap{+ err := NewConnectorService().TestConnector(t.Context(), "conn-1", "user-2", entity.JSONMap{"source": "mock","config": entity.JSONMap{"ok": true},})@@ -144,7 +144,7 @@ func TestConnectorServiceTestConnectorRejectsUnsupportedSource(t *testing.T) {t.Fatalf("migrate connector tables: %v", err)}- err := NewConnectorService().TestConnector(context.Background(), "missing", "tenant-1", entity.JSONMap{+ err := NewConnectorService().TestConnector(t.Context(), "missing", "tenant-1", entity.JSONMap{"source": "unknown","config": entity.JSONMap{"ok": true},})@@ -167,7 +167,7 @@ func TestConnectorServiceTestConnectorRejectsConnectorWithoutValidator(t *testinsvc := NewConnectorService()svc.connectorRegistry = registry- err := svc.TestConnector(context.Background(), "missing", "tenant-1", entity.JSONMap{+ err := svc.TestConnector(t.Context(), "missing", "tenant-1", entity.JSONMap{"source": "plain","config": entity.JSONMap{"ok": true},})diff --git a/internal/service/dataset/compilation_status_test.go b/internal/service/dataset/compilation_status_test.goindex 8753061e48..535391e81e 100644--- a/internal/service/dataset/compilation_status_test.go+++ b/internal/service/dataset/compilation_status_test.go@@ -16,7 +16,6 @@package datasetimport (- "context""testing""time"@@ -193,7 +192,7 @@ func TestGetDatasetCompilationStatus_Unauthorized(t *testing.T) {func TestGetDatasetCompilationStatus_EmptyID(t *testing.T) {setupCompilationStatusTestDB(t)_, code, err := testCompilationStatusService().GetDatasetCompilationStatus(- context.Background(), "user-1", "")+ t.Context(), "user-1", "")if err == nil {t.Fatal("expected error for empty dataset_id")}diff --git a/internal/service/dataset_artifact_nav_test.go b/internal/service/dataset_artifact_nav_test.goindex 88c1746f41..02bcfed2b6 100644--- a/internal/service/dataset_artifact_nav_test.go+++ b/internal/service/dataset_artifact_nav_test.go@@ -48,7 +48,7 @@ func TestDeleteNav_RemovesOnlyDirectDocChildren(t *testing.T) {defer func() { nav.SetNavService(prev) }()svc := NewDatasetArtifactService()- n, err := svc.DeleteNav(context.Background(), "t1", "kb1")+ n, err := svc.DeleteNav(t.Context(), "t1", "kb1")if err != nil {t.Fatalf("DeleteNav: %v", err)}@@ -79,7 +79,7 @@ func TestDeleteNavNode_RemovesDirectChildren(t *testing.T) {defer func() { nav.SetNavService(prev) }()svc := NewDatasetArtifactService()- n, err := svc.DeleteNavNode(context.Background(), "t1", "kb1", "C1")+ n, err := svc.DeleteNavNode(t.Context(), "t1", "kb1", "C1")if err != nil {t.Fatalf("DeleteNavNode: %v", err)}diff --git a/internal/service/document/apply_doc_counts_test.go b/internal/service/document/apply_doc_counts_test.goindex 66e4dc1a18..2d122a6f58 100644--- a/internal/service/document/apply_doc_counts_test.go+++ b/internal/service/document/apply_doc_counts_test.go@@ -17,7 +17,6 @@package documentimport (- "context""testing""ragflow/internal/entity"@@ -36,7 +35,7 @@ func TestApplyDocCounts_ReparseCarriesDelta(t *testing.T) {t.Fatalf("create doc: %v", err)}svc := testDocumentService(t)- ctx := context.Background()+ ctx := t.Context()// First parse produces 5 chunks / 100 tokens; a re-parse produces 7 / 140.if err := svc.ApplyDocCounts(ctx, "doc-1", "kb-1", 5, 100, 1); err != nil {@@ -81,7 +80,7 @@ func TestApplyDocCounts_KBAggregateClampsAtZero(t *testing.T) {// A run that clears the document (0 chunks) drives the aggregate delta to -5;// 2 - 5 is negative and must clamp to 0 rather than underflow.- if err := svc.ApplyDocCounts(context.Background(), "doc-1", "kb-1", 0, 0, 1); err != nil {+ if err := svc.ApplyDocCounts(t.Context(), "doc-1", "kb-1", 0, 0, 1); err != nil {t.Fatalf("apply: %v", err)}var kb entity.Knowledgebase@@ -106,7 +105,7 @@ func TestApplyDocCounts_ProcessDurationIsAbsolute(t *testing.T) {t.Fatalf("create doc: %v", err)}svc := testDocumentService(t)- ctx := context.Background()+ ctx := t.Context()// A run sets process_duration to its own value; a later run replaces it rather// than accumulating, so the stored value is the last run's, not the 3.5+1.25 sum.diff --git a/internal/service/document/document_test.go b/internal/service/document/document_test.goindex d97a7dd1b6..127d3921e8 100644--- a/internal/service/document/document_test.go+++ b/internal/service/document/document_test.go@@ -787,7 +787,7 @@ func TestContentHashHex_MatchesPythonXXH128(t *testing.T) {}func TestSyncDocumentUpsertRemovesStagedBlobWhenInsertFails(t *testing.T) {- ctx := context.Background()+ ctx := t.Context()db := setupServiceTestDB(t)pushServiceDB(t, db)@@ -840,7 +840,7 @@ func TestSyncDocumentUpsertRemovesStagedBlobWhenUpdateFails(t *testing.T) {t.Cleanup(func() { factory.SetStorage(origStorage) })activeLocation := "sync/github/doc-sync-update.txt"- if err := mockStorage.Put(context.Background(), "kb-sync", activeLocation, []byte("old content")); err != nil {+ if err := mockStorage.Put(t.Context(), "kb-sync", activeLocation, []byte("old content")); err != nil {t.Fatalf("seed active object: %v", err)}oldName := "old.txt"@@ -887,7 +887,7 @@ func TestSyncDocumentUpsertRemovesStagedBlobWhenUpdateFails(t *testing.T) {if err == nil {t.Fatalf("expected update failure")}- got, err := mockStorage.Get(context.Background(), "kb-sync", activeLocation)+ got, err := mockStorage.Get(t.Context(), "kb-sync", activeLocation)if err != nil {t.Fatalf("active object was removed: %v", err)}diff --git a/internal/service/file/file_commit_page_test.go b/internal/service/file/file_commit_page_test.goindex 5f63e66c6d..ac68062463 100644--- a/internal/service/file/file_commit_page_test.go+++ b/internal/service/file/file_commit_page_test.go@@ -1,7 +1,6 @@package fileimport (- "context""strconv""strings""sync"@@ -39,7 +38,7 @@ func newPageCommitTestDB(t *testing.T) *gorm.DB {func TestRecordPageEdit_CreatesCommitAndItem(t *testing.T) {newPageCommitTestDB(t)svc := NewFileCommitService()- ctx := context.Background()+ ctx := t.Context()in := PageEditCommitInput{DatasetID: "kb1",@@ -102,7 +101,7 @@ func TestRecordPageEdit_CreatesCommitAndItem(t *testing.T) {func TestRecordPageEdit_SecondEditLinksParent(t *testing.T) {newPageCommitTestDB(t)svc := NewFileCommitService()- ctx := context.Background()+ ctx := t.Context()base := PageEditCommitInput{DatasetID: "kb1",@@ -139,7 +138,7 @@ func TestRecordPageEdit_SecondEditLinksParent(t *testing.T) {func TestRecordPageEdit_IsolatesDatasets(t *testing.T) {newPageCommitTestDB(t)svc := NewFileCommitService()- ctx := context.Background()+ ctx := t.Context()mk := func(datasetID string) PageEditCommitInput {return PageEditCommitInput{@@ -191,7 +190,7 @@ func TestRecordPageEdit_IsolatesDatasets(t *testing.T) {func TestRecordPageEdit_ConcurrentEditsFormLinearChain(t *testing.T) {newPageCommitTestDB(t)svc := NewFileCommitService()- ctx := context.Background()+ ctx := t.Context()const edits = 8var wg sync.WaitGroupdiff --git a/internal/service/graph/retrieval_test.go b/internal/service/graph/retrieval_test.goindex 22bd9d8a8c..eac67d141c 100644--- a/internal/service/graph/retrieval_test.go+++ b/internal/service/graph/retrieval_test.go@@ -134,7 +134,7 @@ func TestSearchTypeSamples_Success(t *testing.T) {}},},}- result, err := searchTypeSamples(context.Background(), mock, []string{"ragflow_tenant1"}, []string{"kb1"})+ result, err := searchTypeSamples(t.Context(), mock, []string{"ragflow_tenant1"}, []string{"kb1"})if err != nil {t.Fatalf("unexpected error: %v", err)}@@ -145,7 +145,7 @@ func TestSearchTypeSamples_Success(t *testing.T) {func TestSearchTypeSamples_Empty(t *testing.T) {mock := &mockRetrievalEngine{}- result, err := searchTypeSamples(context.Background(), mock, []string{"ragflow_tenant1"}, []string{"kb1"})+ result, err := searchTypeSamples(t.Context(), mock, []string{"ragflow_tenant1"}, []string{"kb1"})if err != nil {t.Fatalf("unexpected error: %v", err)}@@ -173,7 +173,7 @@ func TestRetrieval_Basic(t *testing.T) {}},},}- result, err := Retrieval(context.Background(), mock, nil, nil, []string{"kb1"}, []string{"tenant1"}, "Elon Musk")+ result, err := Retrieval(t.Context(), mock, nil, nil, []string{"kb1"}, []string{"tenant1"}, "Elon Musk")if err != nil {t.Fatalf("Retrieval failed: %v", err)}@@ -197,7 +197,7 @@ func TestRetrieval_Basic(t *testing.T) {func TestRetrieval_NoEntities(t *testing.T) {mock := &mockRetrievalEngine{}- result, err := Retrieval(context.Background(), mock, nil, nil, []string{"kb1"}, []string{"tenant1"}, "test")+ result, err := Retrieval(t.Context(), mock, nil, nil, []string{"kb1"}, []string{"tenant1"}, "test")if err != nil {t.Fatalf("Retrieval failed: %v", err)}@@ -226,7 +226,7 @@ func TestRetrieval_WithChatModel(t *testing.T) {// chatModel with nil ModelName so queryRewrite falls back to raw question,// but the ty2entsJSON construction path is still exercised.chatModel := &modelModule.ChatModel{ModelName: nil, APIConfig: nil}- result, err := Retrieval(context.Background(), mock, chatModel, nil, []string{"kb1"}, []string{"tenant1"}, "Elon Musk")+ result, err := Retrieval(t.Context(), mock, chatModel, nil, []string{"kb1"}, []string{"tenant1"}, "Elon Musk")if err != nil {t.Fatalf("Retrieval failed: %v", err)}@@ -272,7 +272,7 @@ func TestEntitySearch_MultiEntities(t *testing.T) {},},}- mock.Search(context.Background(), entsReq)+ mock.Search(t.Context(), entsReq)if !strings.Contains(capturedText, "Elon Musk") || !strings.Contains(capturedText, "SpaceX") {t.Errorf("expected both entities in query, got %q", capturedText)}@@ -515,7 +515,7 @@ func TestIndexName_Empty(t *testing.T) {func TestSearchKGCommunityContent_EmptyEntities(t *testing.T) {mock := &mockRetrievalEngine{}- result := searchCommunityContent(context.Background(), mock, []string{"ragflow_t1"}, []string{"kb1"}, nil, 1, intPtr(100))+ result := searchCommunityContent(t.Context(), mock, []string{"ragflow_t1"}, []string{"kb1"}, nil, 1, intPtr(100))if result != "" {t.Errorf("expected empty, got %q", result)}@@ -532,7 +532,7 @@ func TestSearchKGCommunityContent_WithContent(t *testing.T) {}},},}- result := searchCommunityContent(context.Background(), mock, []string{"ragflow_t1"}, []string{"kb1"}, []ScoredEntity{{Entity: "E1"}}, 1, intPtr(500))+ result := searchCommunityContent(t.Context(), mock, []string{"ragflow_t1"}, []string{"kb1"}, []ScoredEntity{{Entity: "E1"}}, 1, intPtr(500))if result == "" {t.Fatal("expected non-empty result")}@@ -552,7 +552,7 @@ func TestSearchKGCommunityContent_WithContent(t *testing.T) {func TestSearchKGCommunityContent_NilMaxToken(t *testing.T) {mock := &mockRetrievalEngine{}- result := searchCommunityContent(context.Background(), mock, []string{"ragflow_t1"}, []string{"kb1"}, []ScoredEntity{{Entity: "E1"}}, 1, nil)+ result := searchCommunityContent(t.Context(), mock, []string{"ragflow_t1"}, []string{"kb1"}, []ScoredEntity{{Entity: "E1"}}, 1, nil)if result != "" {t.Errorf("expected empty when maxToken is nil, got %q", result)}@@ -560,7 +560,7 @@ func TestSearchKGCommunityContent_NilMaxToken(t *testing.T) {func TestSearchKGCommunityContent_ZeroMaxToken(t *testing.T) {mock := &mockRetrievalEngine{}- result := searchCommunityContent(context.Background(), mock, []string{"ragflow_t1"}, []string{"kb1"}, []ScoredEntity{{Entity: "E1"}}, 1, intPtr(0))+ result := searchCommunityContent(t.Context(), mock, []string{"ragflow_t1"}, []string{"kb1"}, []ScoredEntity{{Entity: "E1"}}, 1, intPtr(0))if result != "" {t.Errorf("expected empty when maxToken=0, got %q", result)}diff --git a/internal/service/graph/search_test.go b/internal/service/graph/search_test.goindex 57d91724cd..93a47504cc 100644--- a/internal/service/graph/search_test.go+++ b/internal/service/graph/search_test.go@@ -404,7 +404,7 @@ func TestSearchEntities_WithMock(t *testing.T) {}, nil},}- entities, err := SearchEntities(context.Background(), mock, []string{"kb1"}, "Elon", nil, 10)+ entities, err := SearchEntities(t.Context(), mock, []string{"kb1"}, "Elon", nil, 10)if err != nil {t.Fatalf("SearchEntities failed: %v", err)}@@ -423,7 +423,7 @@ func TestSearchEntitiesByTypes_WithMock(t *testing.T) {}, nil},}- entities, err := SearchEntitiesByTypes(context.Background(), mock, []string{"kb1"}, []string{"ORGANIZATION"}, 10)+ entities, err := SearchEntitiesByTypes(t.Context(), mock, []string{"kb1"}, []string{"ORGANIZATION"}, 10)if err != nil {t.Fatalf("SearchEntitiesByTypes failed: %v", err)}@@ -434,7 +434,7 @@ func TestSearchEntitiesByTypes_WithMock(t *testing.T) {func TestSearchTypeSamples_WithMock(t *testing.T) {mock := &mockKGEngine{}- samples, err := SearchTypeSamples(context.Background(), mock, []string{"kb1"})+ samples, err := SearchTypeSamples(t.Context(), mock, []string{"kb1"})if err != nil {t.Fatalf("SearchTypeSamples failed: %v", err)}diff --git a/internal/service/memory_message_service_test.go b/internal/service/memory_message_service_test.goindex 646d35d8f1..66bad6d966 100644--- a/internal/service/memory_message_service_test.go+++ b/internal/service/memory_message_service_test.go@@ -22,7 +22,6 @@package serviceimport (- "context""strings""testing""time"@@ -32,7 +31,7 @@ import (// a clear error rather than panicking.func TestQueueSaveToMemoryTask_NilService(t *testing.T) {var s *MemoryMessageService- _, err := s.QueueSaveToMemoryTask(context.Background(), []string{"m1"}, MemoryMessage{AgentID: "a1"})+ _, err := s.QueueSaveToMemoryTask(t.Context(), []string{"m1"}, MemoryMessage{AgentID: "a1"})if err == nil {t.Fatal("expected error from nil service")}@@ -45,7 +44,7 @@ func TestQueueSaveToMemoryTask_NilService(t *testing.T) {// short-circuits to an empty result with no error.func TestQueueSaveToMemoryTask_EmptyMemoryList(t *testing.T) {s := &MemoryMessageService{memories: nil} // no lookups happen- res, err := s.QueueSaveToMemoryTask(context.Background(), nil, MemoryMessage{AgentID: "a1"})+ res, err := s.QueueSaveToMemoryTask(t.Context(), nil, MemoryMessage{AgentID: "a1"})if err != nil {t.Fatalf("QueueSaveToMemoryTask: %v", err)}@@ -59,7 +58,7 @@ func TestQueueSaveToMemoryTask_EmptyMemoryList(t *testing.T) {// up front.func TestQueueSaveToMemoryTask_MissingAgentID(t *testing.T) {s := &MemoryMessageService{}- _, err := s.QueueSaveToMemoryTask(context.Background(), []string{"m1"}, MemoryMessage{})+ _, err := s.QueueSaveToMemoryTask(t.Context(), []string{"m1"}, MemoryMessage{})if err == nil {t.Fatal("expected error for missing AgentID")}diff --git a/internal/service/memory_message_test.go b/internal/service/memory_message_test.goindex 29ac48f49e..c268e2fcda 100644--- a/internal/service/memory_message_test.go+++ b/internal/service/memory_message_test.go@@ -223,7 +223,7 @@ func TestForgetMessageKeepsCompanionFieldForNonOceanBaseEngines(t *testing.T) {service := NewMemoryService()service.docEngine = docEngine- if err := service.ForgetMessage(context.Background(), "user-1", "memory-1", 42); err != nil {+ if err := service.ForgetMessage(t.Context(), "user-1", "memory-1", 42); err != nil {t.Fatalf("ForgetMessage() error = %v", err)}if docEngine.updateCond["id"] != "memory-1_42" {@@ -280,7 +280,7 @@ func TestUpdateMemoryTeamMemberCannotChangePermissions(t *testing.T) {svc := NewMemoryService()samePermission := " TEAM "- if _, err := svc.UpdateMemory(context.Background(), "member-1", "mem-team", &UpdateMemoryRequest{+ if _, err := svc.UpdateMemory(t.Context(), "member-1", "mem-team", &UpdateMemoryRequest{Description: sptr("member edit"),Permissions: &samePermission,}); err != nil {@@ -288,7 +288,7 @@ func TestUpdateMemoryTeamMemberCannotChangePermissions(t *testing.T) {}nextPermission := "me"- if _, err := svc.UpdateMemory(context.Background(), "member-1", "mem-team", &UpdateMemoryRequest{+ if _, err := svc.UpdateMemory(t.Context(), "member-1", "mem-team", &UpdateMemoryRequest{Permissions: &nextPermission,}); err == nil {t.Fatal("UpdateMemory permission change error = nil, want error")@@ -361,13 +361,13 @@ func TestUpdateMemoryTeamMemberResolvesModelsAgainstOwnerTenant(t *testing.T) {}llmID := "gpt-4o@default@OpenAI"- if _, err := NewMemoryService().UpdateMemory(context.Background(), "member-1", "mem-model", &UpdateMemoryRequest{+ if _, err := NewMemoryService().UpdateMemory(t.Context(), "member-1", "mem-model", &UpdateMemoryRequest{LLMID: &llmID,}); err != nil {t.Fatalf("UpdateMemory model error = %v", err)}- updated, err := dao.NewMemoryDAO().GetByID(context.Background(), dao.DB, "mem-model")+ updated, err := dao.NewMemoryDAO().GetByID(t.Context(), dao.DB, "mem-model")if err != nil {t.Fatalf("get updated memory: %v", err)}@@ -549,7 +549,7 @@ func TestSaveAgentMessageBypassesRequestAccessFilter(t *testing.T) {AgentResponse: "hello",}- ok, detail, err := svc.AddMessage(context.Background(), "", []string{"mem-owned"}, msg)+ ok, detail, err := svc.AddMessage(t.Context(), "", []string{"mem-owned"}, msg)if err != nil {t.Fatalf("AddMessage: %v", err)}@@ -557,7 +557,7 @@ func TestSaveAgentMessageBypassesRequestAccessFilter(t *testing.T) {t.Fatalf("AddMessage with empty current user = (%v, %q), want permission-filtered not found", ok, detail)}- ok, detail, err = svc.saveAgentMessage(context.Background(), []string{"mem-owned"}, msg)+ ok, detail, err = svc.saveAgentMessage(t.Context(), []string{"mem-owned"}, msg)if err != nil {t.Fatalf("saveAgentMessage: %v", err)}@@ -597,7 +597,7 @@ func TestGetMessagesFiltersAccessibleMemoryAndBuildsRecentSearch(t *testing.T) {}svc := &MemoryService{memoryDAO: dao.NewMemoryDAO(), docEngine: docEngine}- got, code, err := svc.GetMessages(context.Background(), []string{"mem-owned", "mem-other"}, "user-1", "agent-1", "session-1", 3)+ got, code, err := svc.GetMessages(t.Context(), []string{"mem-owned", "mem-other"}, "user-1", "agent-1", "session-1", 3)if err != nil {t.Fatalf("GetMessages error: %v", err)}@@ -671,7 +671,7 @@ func TestSearchMessageFiltersAccessibleMemoryAndDefaultsStatus(t *testing.T) {"top_n": 5,}- got, code, err := svc.SearchMessage(context.Background(), "user-1", filter, params)+ got, code, err := svc.SearchMessage(t.Context(), "user-1", filter, params)if err != nil {t.Fatalf("SearchMessage error: %v", err)}@@ -710,7 +710,7 @@ func TestUpdateMessageUpdatesStatusByMessageDocID(t *testing.T) {docEngine := &memoryMessageDocEngine{}svc := &MemoryService{memoryDAO: dao.NewMemoryDAO(), docEngine: docEngine}- ok, err := svc.UpdateMessage(context.Background(), "user-1", "mem-owned", 42, true)+ ok, err := svc.UpdateMessage(t.Context(), "user-1", "mem-owned", 42, true)if err != nil {t.Fatalf("UpdateMessage error: %v", err)}diff --git a/internal/service/model_chat_test.go b/internal/service/model_chat_test.goindex fe9326e4ae..9a61fcd5cd 100644--- a/internal/service/model_chat_test.go+++ b/internal/service/model_chat_test.go@@ -53,7 +53,7 @@ func TestChatStreamWithContextStripsDoneSentinel(t *testing.T) {APIConfig: &modelModule.APIConfig{},}- ch, _ := chatStreamWithContext(context.Background(), chatModel, nil, &modelModule.ChatConfig{})+ ch, _ := chatStreamWithContext(t.Context(), chatModel, nil, &modelModule.ChatConfig{})var sb strings.Builderfor delta := range ch {sb.WriteString(delta)diff --git a/internal/service/model_service_test.go b/internal/service/model_service_test.goindex efbb3e25e5..33d04cdb7e 100644--- a/internal/service/model_service_test.go+++ b/internal/service/model_service_test.go@@ -222,7 +222,7 @@ func TestVerifyProviderModelValidatesRemoteEmbeddingMetadata(t *testing.T) {}},}- result, err := verifyProviderModel(context.Background(), driver, nil, &modelModule.APIConfig{}, nil)+ result, err := verifyProviderModel(t.Context(), driver, nil, &modelModule.APIConfig{}, nil)if err == nil {t.Fatal("verifyProviderModel() error = nil, want validation error")}@@ -672,7 +672,7 @@ func TestReconcileNvidiaInstanceModelsAddsUpdatesAndDeletes(t *testing.T) {{Name: "nvidia/new-embed", MaxOutput: ptrService(8192), MaxDimension: &maxDimension, Dimensions: []int{1024, 2048}, ModelTypes: []string{"embedding"}},}- err := NewModelProviderService().reconcileNvidiaInstanceModels(context.Background(), db, provider, instance, remote)+ err := NewModelProviderService().reconcileNvidiaInstanceModels(t.Context(), db, provider, instance, remote)if err != nil {t.Fatalf("reconcileNvidiaInstanceModels() error = %v", err)}@@ -717,7 +717,7 @@ func TestReconcileNvidiaInstanceModelsRejectsEmptyDiscoveryWithoutMutation(t *te}}- err := NewModelProviderService().reconcileNvidiaInstanceModels(context.Background(), db, provider, instance, nil)+ err := NewModelProviderService().reconcileNvidiaInstanceModels(t.Context(), db, provider, instance, nil)if err == nil {t.Fatal("reconcileNvidiaInstanceModels() error = nil, want empty discovery error")}@@ -753,7 +753,7 @@ func TestReconcileNvidiaInstanceModelsRollsBackPartialRefresh(t *testing.T) {{Name: "nvidia/new", ModelTypes: []string{"chat"}},{Name: "nvidia/keep", ModelTypes: []string{"chat"}},}- err := NewModelProviderService().reconcileNvidiaInstanceModels(context.Background(), db, provider, instance, remote)+ err := NewModelProviderService().reconcileNvidiaInstanceModels(t.Context(), db, provider, instance, remote)if err == nil {t.Fatal("reconcileNvidiaInstanceModels() error = nil, want metadata error")}diff --git a/internal/service/nlp/datasetnav_integration_test.go b/internal/service/nlp/datasetnav_integration_test.goindex a8f4784271..c297b835fc 100644--- a/internal/service/nlp/datasetnav_integration_test.go+++ b/internal/service/nlp/datasetnav_integration_test.go@@ -52,7 +52,7 @@ func findNavRow(t *testing.T, tenantID, kbID, docID string) map[string]interfaceSelectFields: []string{"available_int", "compile_kwd", "type_kwd"},Limit: 10,}- res, err := de.Search(context.Background(), req)+ res, err := de.Search(t.Context(), req)if err != nil {t.Fatalf("search nav row: %v", err)}@@ -90,7 +90,7 @@ func TestDatasetNav_AvailableIntZero_Isolation(t *testing.T) {docID := "navint_doc1"ns := NewNavService(stubNavEmbedder{})- if err := ns.UpsertDoc(context.Background(), nav.UpsertDocInput{+ if err := ns.UpsertDoc(t.Context(), nav.UpsertDocInput{TenantID: tenantID, KbID: kbID, DocID: docID, Summary: "rocket propulsion integration evidence",}); err != nil {t.Fatalf("upsert nav doc: %v", err)@@ -98,7 +98,7 @@ func TestDatasetNav_AvailableIntZero_Isolation(t *testing.T) {t.Cleanup(func() { _ = ns.RemoveDoc(context.Background(), tenantID, kbID, docID) })// NavService.Search must find the nav row (reads nav rows directly).- hits, err := ns.Search(context.Background(), tenantID, kbID, "rocket propulsion", nil, 5)+ hits, err := ns.Search(t.Context(), tenantID, kbID, "rocket propulsion", nil, 5)if err != nil {t.Fatalf("nav search: %v", err)}diff --git a/internal/service/nlp/datasetnav_test.go b/internal/service/nlp/datasetnav_test.goindex 19523e9733..008f084029 100644--- a/internal/service/nlp/datasetnav_test.go+++ b/internal/service/nlp/datasetnav_test.go@@ -262,7 +262,7 @@ func newTestNav(eng *memNavEngine) *NavService {func TestNavService_UpsertDoc_WritesNavRow(t *testing.T) {eng := newMemNavEngine()ns := newTestNav(eng)- if err := ns.UpsertDoc(context.Background(), navUpsertInput("t1", "kb1", "d1", "alpha")); err != nil {+ if err := ns.UpsertDoc(t.Context(), navUpsertInput("t1", "kb1", "d1", "alpha")); err != nil {t.Fatalf("UpsertDoc: %v", err)}if len(eng.rows) == 0 {@@ -287,10 +287,10 @@ func TestNavService_UpsertDoc_WritesNavRow(t *testing.T) {func TestNavService_ListClusters_FiltersRoot(t *testing.T) {eng := newMemNavEngine()ns := newTestNav(eng)- if err := ns.UpsertDoc(context.Background(), navUpsertInput("t1", "kb1", "d1", "aaa")); err != nil {+ if err := ns.UpsertDoc(t.Context(), navUpsertInput("t1", "kb1", "d1", "aaa")); err != nil {t.Fatal(err)}- clusters, total, err := ns.ListClusters(context.Background(), "t1", "kb1", 0, 10)+ clusters, total, err := ns.ListClusters(t.Context(), "t1", "kb1", 0, 10)if err != nil {t.Fatal(err)}@@ -404,10 +404,10 @@ func TestNodeFromRow_ReadableName(t *testing.T) {func TestNavService_Search_ReturnsHit(t *testing.T) {eng := newMemNavEngine()ns := newTestNav(eng)- if err := ns.UpsertDoc(context.Background(), navUpsertInput("t1", "kb1", "d1", "aaa")); err != nil {+ if err := ns.UpsertDoc(t.Context(), navUpsertInput("t1", "kb1", "d1", "aaa")); err != nil {t.Fatal(err)}- hits, err := ns.Search(context.Background(), "t1", "kb1", "aaa", nil, 5)+ hits, err := ns.Search(t.Context(), "t1", "kb1", "aaa", nil, 5)if err != nil {t.Fatal(err)}@@ -429,13 +429,13 @@ func TestNavService_Acceptance4_ListChildren(t *testing.T) {ns := newTestNav(eng)// Two docs that merge into one root cluster (same first char -> identical// stub vectors -> sim=1.0 >= merge threshold).- if err := ns.UpsertDoc(context.Background(), navUpsertInput("t1", "kb1", "d1", "aaa one")); err != nil {+ if err := ns.UpsertDoc(t.Context(), navUpsertInput("t1", "kb1", "d1", "aaa one")); err != nil {t.Fatal(err)}- if err := ns.UpsertDoc(context.Background(), navUpsertInput("t1", "kb1", "d2", "aaa two")); err != nil {+ if err := ns.UpsertDoc(t.Context(), navUpsertInput("t1", "kb1", "d2", "aaa two")); err != nil {t.Fatal(err)}- clusters, _, err := ns.ListClusters(context.Background(), "t1", "kb1", 0, 10)+ clusters, _, err := ns.ListClusters(t.Context(), "t1", "kb1", 0, 10)if err != nil {t.Fatal(err)}@@ -446,7 +446,7 @@ func TestNavService_Acceptance4_ListChildren(t *testing.T) {t.Fatalf("cluster doc_count = %d, want 2 (both docs merged into the cluster)", clusters[0].DocCount)}name := clusters[0].Name- children, total, err := ns.ListChildren(context.Background(), "t1", "kb1", name, 0, 10)+ children, total, err := ns.ListChildren(t.Context(), "t1", "kb1", name, 0, 10)if err != nil {t.Fatal(err)}@@ -473,10 +473,10 @@ func TestNavService_Acceptance4_ListChildren(t *testing.T) {func TestNavService_NavDocDepth(t *testing.T) {eng := newMemNavEngine()ns := newTestNav(eng)- if err := ns.UpsertDoc(context.Background(), navUpsertInput("t1", "kb1", "d1", "aaa one")); err != nil {+ if err := ns.UpsertDoc(t.Context(), navUpsertInput("t1", "kb1", "d1", "aaa one")); err != nil {t.Fatal(err)}- if err := ns.UpsertDoc(context.Background(), navUpsertInput("t1", "kb1", "d2", "aaa two")); err != nil {+ if err := ns.UpsertDoc(t.Context(), navUpsertInput("t1", "kb1", "d2", "aaa two")); err != nil {t.Fatal(err)}// The nav_doc for d2 sits under the root cluster; its depth_int must be 1.@@ -496,10 +496,10 @@ func TestNavService_RemoveDoc_CascadesToEmptyCluster(t *testing.T) {eng := newMemNavEngine()ns := newTestNav(eng)// d1 creates a root cluster (name derived from its summary hash).- if err := ns.UpsertDoc(context.Background(), navUpsertInput("t1", "kb1", "d1", "alpha")); err != nil {+ if err := ns.UpsertDoc(t.Context(), navUpsertInput("t1", "kb1", "d1", "alpha")); err != nil {t.Fatal(err)}- if err := ns.RemoveDoc(context.Background(), "t1", "kb1", "d1"); err != nil {+ if err := ns.RemoveDoc(t.Context(), "t1", "kb1", "d1"); err != nil {t.Fatal(err)}// The nav_doc is gone, and the root cluster (now empty) is pruned.@@ -550,10 +550,10 @@ func TestNavService_MaybeSplitCluster_SplitsOverfull(t *testing.T) {"doc_count_int": 1,})}- if _, err := eng.InsertChunks(context.Background(), rows, idx, "kb1"); err != nil {+ if _, err := eng.InsertChunks(t.Context(), rows, idx, "kb1"); err != nil {t.Fatal(err)}- if err := ns.maybeSplitCluster(context.Background(), "t1", "kb1", clusterName, ""); err != nil {+ if err := ns.maybeSplitCluster(t.Context(), "t1", "kb1", clusterName, ""); err != nil {t.Fatal(err)}splitA := clusterName + ":A"@@ -609,7 +609,7 @@ func TestNavService_MaybeSplitCluster_SplitsOverfull(t *testing.T) {}// A production nav_doc has doc_id but no doc_ids_kwd. Removing one after a// split must update the replacement cluster that inherited its membership.- if err := ns.RemoveDoc(context.Background(), "t1", "kb1", "d00"); err != nil {+ if err := ns.RemoveDoc(t.Context(), "t1", "kb1", "d00"); err != nil {t.Fatalf("RemoveDoc after split: %v", err)}var remainingCount, remainingIDs intdiff --git a/internal/service/nlp/retrieval_test.go b/internal/service/nlp/retrieval_test.goindex 07e0bbb930..505a0eb1e6 100644--- a/internal/service/nlp/retrieval_test.go+++ b/internal/service/nlp/retrieval_test.go@@ -36,7 +36,7 @@ func TestRetrievalUsesRerankCandidatesCountAsCandidateSet(t *testing.T) {aggs := falsererankCandidatesCount := 70- result, err := service.Retrieval(context.Background(), &RetrievalRequest{+ result, err := service.Retrieval(t.Context(), &RetrievalRequest{Question: "alpha",TenantIDs: []string{"tenant-1"},Page: 1,@@ -266,7 +266,7 @@ func TestSearchPassesVectorSimilarityWeightToFusionExpr(t *testing.T) {vectorWeight := 0.8docEngine := &captureSearchDocEngine{engineType: string(engine.EngineInfinity)}service := NewRetrievalService(docEngine, nil)- _, err := service.Search(context.Background(), &RetrievalSearchRequest{+ _, err := service.Search(t.Context(), &RetrievalSearchRequest{Question: "test question", TenantIDs: []string{"tenant-1"}, KbIDs: []string{"kb-1"}, Page: 1, PageSize: 10, KNNTopK: 10,RankFeature: map[string]float64{}, EmbeddingModel: &modelModule.EmbeddingModel{ModelDriver: &captureEmbeddingDriver{}}, VectorSimilarityWeight: &vectorWeight,})@@ -287,7 +287,7 @@ func TestRetrievalPassesVectorSimilarityWeightToSearch(t *testing.T) {result: &types.SearchResult{Chunks: []map[string]interface{}{}, Total: 0},}service := NewRetrievalService(docEngine, &dao.DocumentDAO{})- _, err := service.Retrieval(context.Background(), &RetrievalRequest{+ _, err := service.Retrieval(t.Context(), &RetrievalRequest{Question: "test question", TenantIDs: []string{"tenant-1"}, KbIDs: []string{"kb-1"}, Page: 1, PageSize: 10, KNNTopK: &top,RankFeature: &map[string]float64{}, EmbeddingModel: &modelModule.EmbeddingModel{ModelDriver: &captureEmbeddingDriver{}}, VectorSimilarityWeight: &vectorWeight,})@@ -328,7 +328,7 @@ func TestSearchKeepsLegacyFusionWeightForElasticsearch(t *testing.T) {docEngine := &captureSearchDocEngine{engineType: string(engine.EngineElasticsearch)}service := NewRetrievalService(docEngine, nil)- _, err := service.Search(context.Background(), &RetrievalSearchRequest{+ _, err := service.Search(t.Context(), &RetrievalSearchRequest{Question: "test question",TenantIDs: []string{"tenant-1"},KbIDs: []string{"kb-1"},diff --git a/internal/syncer/connector/discord_test.go b/internal/syncer/connector/discord_test.goindex 58efff7a9f..b1ddeb7906 100644--- a/internal/syncer/connector/discord_test.go+++ b/internal/syncer/connector/discord_test.go@@ -286,7 +286,7 @@ func TestDiscordConnectorValidateConnectorSetting(t *testing.T) {"channels": []any{"general"},})connector.baseURL = server.URL- if err := connector.ValidateConnectorSetting(context.Background(), nil); err != nil {+ if err := connector.ValidateConnectorSetting(t.Context(), nil); err != nil {t.Fatalf("ValidateConnectorSetting: %v", err)}if fixture.requests.Load() == 0 {@@ -300,7 +300,7 @@ func TestDiscordConnectorValidateConnectorSetting(t *testing.T) {})empty.baseURL = server.URLvar valErr *ConnectorValidationError- if err := empty.ValidateConnectorSetting(context.Background(), nil); !errors.As(err, &valErr) {+ if err := empty.ValidateConnectorSetting(t.Context(), nil); !errors.As(err, &valErr) {t.Fatalf("ValidateConnectorSetting empty err = %v, want ConnectorValidationError", err)}}@@ -323,7 +323,7 @@ func TestDiscordOpenSyncMergesBatches(t *testing.T) {})connector.baseURL = server.URL- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -388,7 +388,7 @@ func TestDiscordOpenSyncWindowFilter(t *testing.T) {start := base.Add(-2 * time.Minute)end := base- session, err := connector.OpenSync(context.Background(), SyncRequest{+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: false,WindowStart: &start,WindowEnd: end,@@ -432,7 +432,7 @@ func TestDiscordOpenSyncChannelsAndThreads(t *testing.T) {})connector.baseURL = server.URL- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -479,10 +479,10 @@ func TestDiscordThreadListErrorsPropagate(t *testing.T) {})connector.baseURL = server.URL- if _, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true}); err == nil {+ if _, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true}); err == nil {t.Fatalf("OpenSync: want error, got nil")}- if _, err := connector.OpenPrune(context.Background(), PruneRequest{}); err == nil {+ if _, err := connector.OpenPrune(t.Context(), PruneRequest{}); err == nil {t.Fatalf("OpenPrune: want error, got nil")}})@@ -510,7 +510,7 @@ func TestDiscordResumeSameTarget(t *testing.T) {return connector}- session, err := newConnector().OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := newConnector().OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -530,7 +530,7 @@ func TestDiscordResumeSameTarget(t *testing.T) {t.Fatalf("cursor = %+v, want target ch-1 message m2", cursor)}- resumed, err := newConnector().OpenSync(context.Background(), SyncRequest{+ resumed, err := newConnector().OpenSync(t.Context(), SyncRequest{FromBeginning: true,Resume: batch.Checkpoint,})@@ -578,7 +578,7 @@ func TestDiscordResumeAcrossTargets(t *testing.T) {return connector}- session, err := newConnector().OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := newConnector().OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -591,7 +591,7 @@ func TestDiscordResumeAcrossTargets(t *testing.T) {t.Fatalf("batch checkpoint is nil")}- resumed, err := newConnector().OpenSync(context.Background(), SyncRequest{+ resumed, err := newConnector().OpenSync(t.Context(), SyncRequest{FromBeginning: true,Resume: batch.Checkpoint,})@@ -637,7 +637,7 @@ func TestDiscordResumeFingerprintMismatch(t *testing.T) {"batch_size": 2,})firstConnector.baseURL = server.URL- session, err := firstConnector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := firstConnector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -656,7 +656,7 @@ func TestDiscordResumeFingerprintMismatch(t *testing.T) {"batch_size": 2,})secondConnector.baseURL = server.URL- resumed, err := secondConnector.OpenSync(context.Background(), SyncRequest{+ resumed, err := secondConnector.OpenSync(t.Context(), SyncRequest{FromBeginning: true,Resume: batch.Checkpoint,})@@ -678,7 +678,7 @@ func TestDiscordResumeInvalidCursor(t *testing.T) {})connector.baseURL = server.URL- session, err := connector.OpenSync(context.Background(), SyncRequest{+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true,Resume: &SyncCheckpoint{Cursor: "not-json"},})@@ -709,7 +709,7 @@ func TestDiscordMessagePagination(t *testing.T) {})connector.baseURL = server.URL- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -747,7 +747,7 @@ func TestDiscord429Retry(t *testing.T) {})connector.baseURL = server.URL- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -781,7 +781,7 @@ func TestDiscordPruneSlimDocuments(t *testing.T) {})connector.baseURL = server.URL- session, err := connector.OpenPrune(context.Background(), PruneRequest{})+ session, err := connector.OpenPrune(t.Context(), PruneRequest{})if err != nil {t.Fatalf("OpenPrune: %v", err)}@@ -830,7 +830,7 @@ func TestDiscordPruneGroupBreaksOnTargetSwitch(t *testing.T) {})connector.baseURL = server.URL- session, err := connector.OpenPrune(context.Background(), PruneRequest{})+ session, err := connector.OpenPrune(t.Context(), PruneRequest{})if err != nil {t.Fatalf("OpenPrune: %v", err)}diff --git a/internal/syncer/connector/github_test.go b/internal/syncer/connector/github_test.goindex 411b12049f..94362ddc65 100644--- a/internal/syncer/connector/github_test.go+++ b/internal/syncer/connector/github_test.go@@ -30,7 +30,7 @@ func TestGitHubConnectorOpenSyncUsesWindowAndFingerprint(t *testing.T) {start := mustTime(t, "2026-01-02T12:00:00Z")end := mustTime(t, "2026-01-04T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{WindowStart: &start, WindowEnd: end})+ session, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start, WindowEnd: end})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -109,7 +109,7 @@ func TestGitHubConnectorOpenPrune(t *testing.T) {connector.baseURL = "https://api.github.test"connector.doJSON = githubFixtureDoJSON(t)- session, err := connector.OpenPrune(context.Background(), PruneRequest{})+ session, err := connector.OpenPrune(t.Context(), PruneRequest{})if err != nil {t.Fatalf("OpenPrune failed: %v", err)}@@ -152,7 +152,7 @@ func TestGitHubConnectorOpenSyncResumesAfterCheckpoint(t *testing.T) {connector.doJSON = githubFixtureDoJSON(t)end := mustTime(t, "2026-01-04T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: end})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: end})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -167,7 +167,7 @@ func TestGitHubConnectorOpenSyncResumesAfterCheckpoint(t *testing.T) {t.Fatalf("first checkpoint = %+v, want PR 7", first.Checkpoint)}- resumed, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: end, Resume: first.Checkpoint})+ resumed, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: end, Resume: first.Checkpoint})if err != nil {t.Fatalf("resume OpenSync failed: %v", err)}@@ -203,7 +203,7 @@ func TestGitHubConnectorOpenSyncResumeRejectsMissingSourceAnchor(t *testing.T) {connector.doJSON = githubFixtureDoJSON(t)end := mustTime(t, "2026-01-04T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: end})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: end})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -219,7 +219,7 @@ func TestGitHubConnectorOpenSyncResumeRejectsMissingSourceAnchor(t *testing.T) {}resumeCheckpoint := cloneGitHubCheckpointWithMissingSourceID(t, first.Checkpoint)- resumed, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: end, Resume: resumeCheckpoint})+ resumed, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: end, Resume: resumeCheckpoint})if resumed != nil || err == nil || !errors.Is(err, ErrSyncResumeInvalid) {t.Fatalf("resume OpenSync = session %v, err %v, want ErrSyncResumeInvalid", resumed, err)}@@ -336,7 +336,7 @@ func TestGitHubValidateConnectorSettingSingleRepoSkipsRepoAccess(t *testing.T) {},nil,)- if err := connector.ValidateConnectorSetting(context.Background(), nil); err != nil {+ if err := connector.ValidateConnectorSetting(t.Context(), nil); err != nil {t.Fatalf("ValidateConnectorSetting: %v", err)}}@@ -360,7 +360,7 @@ func TestGitHubValidateConnectorSettingMultipleReposSkipsRepoAccess(t *testing.T},nil,)- if err := connector.ValidateConnectorSetting(context.Background(), nil); err != nil {+ if err := connector.ValidateConnectorSetting(t.Context(), nil); err != nil {t.Fatalf("ValidateConnectorSetting: %v", err)}}@@ -382,7 +382,7 @@ func TestGitHubValidateConnectorSettingUnauthorized(t *testing.T) {"/orgs/openai": {Status: http.StatusUnauthorized, Message: `{"message":"Bad credentials"}`},},)- err = connector.ValidateConnectorSetting(context.Background(), nil)+ err = connector.ValidateConnectorSetting(t.Context(), nil)var credErr *ConnectorMissingCredentialErrorif !errors.As(err, &credErr) {t.Fatalf("err = %v, want ConnectorMissingCredentialError", err)@@ -406,7 +406,7 @@ func TestGitHubValidateConnectorSettingOwnerOrg(t *testing.T) {},nil,)- if err := connector.ValidateConnectorSetting(context.Background(), nil); err != nil {+ if err := connector.ValidateConnectorSetting(t.Context(), nil); err != nil {t.Fatalf("ValidateConnectorSetting: %v", err)}}@@ -430,7 +430,7 @@ func TestGitHubValidateConnectorSettingOwnerUserFallback(t *testing.T) {"/orgs/openai": {Status: http.StatusNotFound, Message: `{"message":"Not Found"}`},},)- if err := connector.ValidateConnectorSetting(context.Background(), nil); err != nil {+ if err := connector.ValidateConnectorSetting(t.Context(), nil); err != nil {t.Fatalf("ValidateConnectorSetting: %v", err)}}@@ -452,7 +452,7 @@ func TestGitHubValidateConnectorSettingOwnerNotFound(t *testing.T) {"/users/ghost": {Status: http.StatusNotFound, Message: `{"message":"Not Found"}`},},)- err = connector.ValidateConnectorSetting(context.Background(), nil)+ err = connector.ValidateConnectorSetting(t.Context(), nil)var valErr *ConnectorValidationErrorif !errors.As(err, &valErr) {t.Fatalf("err = %v, want ConnectorValidationError", err)@@ -478,7 +478,7 @@ func TestGitHubValidateConnectorSettingMissingSSO(t *testing.T) {"/orgs/ssoorg": {Status: http.StatusForbidden, Message: `{"message":"Resource protected by organization SAML enforcement. You must grant your Personal Access token access to this organization."}`},},)- err = connector.ValidateConnectorSetting(context.Background(), nil)+ err = connector.ValidateConnectorSetting(t.Context(), nil)var valErr *ConnectorValidationErrorif !errors.As(err, &valErr) {t.Fatalf("err = %v, want ConnectorValidationError", err)@@ -499,7 +499,7 @@ func TestGitHubValidateConnectorSettingMissingInputs(t *testing.T) {if err != nil {t.Fatalf("NewGitHubConnector failed: %v", err)}- err = connector.ValidateConnectorSetting(context.Background(), nil)+ err = connector.ValidateConnectorSetting(t.Context(), nil)var credErr *ConnectorMissingCredentialErrorif !errors.As(err, &credErr) {t.Fatalf("err = %v, want ConnectorMissingCredentialError", err)@@ -513,7 +513,7 @@ func TestGitHubValidateConnectorSettingMissingInputs(t *testing.T) {if err != nil {t.Fatalf("NewGitHubConnector failed: %v", err)}- err = connector.ValidateConnectorSetting(context.Background(), nil)+ err = connector.ValidateConnectorSetting(t.Context(), nil)var valErr *ConnectorValidationErrorif !errors.As(err, &valErr) {t.Fatalf("err = %v, want ConnectorValidationError", err)diff --git a/internal/syncer/connector/gmail_test.go b/internal/syncer/connector/gmail_test.goindex ee5293809e..eb521592ee 100644--- a/internal/syncer/connector/gmail_test.go+++ b/internal/syncer/connector/gmail_test.go@@ -17,7 +17,7 @@ func TestGmailConnectorOpenSync(t *testing.T) {start := mustTime(t, "2026-01-02T00:00:00Z")end := mustTime(t, "2026-01-03T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{WindowStart: &start, WindowEnd: end})+ session, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start, WindowEnd: end})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -72,7 +72,7 @@ func TestGmailConnectorOpenSyncResumesWithinPage(t *testing.T) {return gmailTestThread(threadID, "Fri, 02 Jan 2026 03:04:05 +0000")}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -87,7 +87,7 @@ func TestGmailConnectorOpenSyncResumesWithinPage(t *testing.T) {t.Fatalf("first checkpoint = %+v, want thread-2", first.Checkpoint)}- resumed, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: first.Checkpoint})+ resumed, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: first.Checkpoint})if err != nil {t.Fatalf("resume OpenSync failed: %v", err)}@@ -106,7 +106,7 @@ func TestGmailConnectorOpenSyncResumesWithinPage(t *testing.T) {func TestGmailConnectorOpenSyncResumeRejectsMissingCheckpoint(t *testing.T) {connector := newFixtureGmailConnector()- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: &SyncCheckpoint{}})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: &SyncCheckpoint{}})if session != nil || err == nil || !errors.Is(err, ErrSyncResumeInvalid) {t.Fatalf("resume OpenSync = session %v, err %v, want ErrSyncResumeInvalid", session, err)}@@ -124,7 +124,7 @@ func TestGmailConnectorResumeRejectsMissingRemoteAnchor(t *testing.T) {connector.GmailConnector.getThread = func(ctx context.Context, userEmail, threadID string) (gmailThread, error) {return gmailTestThreadWithSubject(threadID, threadID, "Fri, 02 Jan 2026 03:04:05 +0000")}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -146,7 +146,7 @@ func TestGmailConnectorResumeRejectsMissingRemoteAnchor(t *testing.T) {ID string `json:"id"`}{{ID: "thread-1"}, {ID: "thread-3"}}}, nil}- resumed, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: first.Checkpoint})+ resumed, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: first.Checkpoint})if err != nil {t.Fatalf("resume OpenSync failed: %v", err)}@@ -225,7 +225,7 @@ func TestGmailOwnersMetadataSorted(t *testing.T) {// TestGmailConnectorOpenPrune verifies Gmail prune emits thread IDs only.func TestGmailConnectorOpenPrune(t *testing.T) {connector := newFixtureGmailConnector()- session, err := connector.OpenPrune(context.Background(), PruneRequest{})+ session, err := connector.OpenPrune(t.Context(), PruneRequest{})if err != nil {t.Fatalf("OpenPrune failed: %v", err)}@@ -247,15 +247,15 @@ func TestGmailConnectorClientForUserCachesByMailbox(t *testing.T) {return &http.Client{}, nil}- first, err := connector.clientForUser(context.Background(), "[email protected]")+ first, err := connector.clientForUser(t.Context(), "[email protected]")if err != nil {t.Fatalf("first client: %v", err)}- second, err := connector.clientForUser(context.Background(), "[email protected]")+ second, err := connector.clientForUser(t.Context(), "[email protected]")if err != nil {t.Fatalf("second client: %v", err)}- other, err := connector.clientForUser(context.Background(), "[email protected]")+ other, err := connector.clientForUser(t.Context(), "[email protected]")if err != nil {t.Fatalf("other client: %v", err)}diff --git a/internal/syncer/connector/google_cloud_storage_test.go b/internal/syncer/connector/google_cloud_storage_test.goindex e6e406768a..bad2343c05 100644--- a/internal/syncer/connector/google_cloud_storage_test.go+++ b/internal/syncer/connector/google_cloud_storage_test.go@@ -17,7 +17,7 @@ func TestGoogleCloudStorageConnectorOpenSyncUsesFingerprintAndFetch(t *testing.T})start := mustTime(t, "2026-01-02T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{+ session, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start,WindowEnd: mustTime(t, "2026-01-04T00:00:00Z"),Fingerprints: map[string]string{@@ -55,7 +55,7 @@ func TestGoogleCloudStorageConnectorOpenSyncUsesFingerprintAndFetch(t *testing.Tif !ok {t.Fatalf("session does not implement Fetcher")}- blob, err := fetcher.Fetch(context.Background(), *doc.FetchRef)+ blob, err := fetcher.Fetch(t.Context(), *doc.FetchRef)if err != nil {t.Fatalf("Fetch: %v", err)}@@ -78,7 +78,7 @@ func TestGoogleCloudStorageConnectorOpenSyncDefersListingUntilNextBatch(t *testireturn baseListObjects(ctx, startAfter, maxKeys)}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -99,7 +99,7 @@ func TestGoogleCloudStorageConnectorOpenSyncFiltersImagesUnlessAllowed(t *testin{Key: "docs/b.txt", LastModified: mustTime(t, "2026-01-02T00:00:00Z"), Size: 1, ETag: "b"},}connector := newTestGoogleCloudStorageConnector(t, objects)- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -113,7 +113,7 @@ func TestGoogleCloudStorageConnectorOpenSyncFiltersImagesUnlessAllowed(t *testinallowed := newTestGoogleCloudStorageConnector(t, objects)allowed.allowImages = true- session, err = allowed.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err = allowed.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("allow images OpenSync: %v", err)}@@ -133,7 +133,7 @@ func TestGoogleCloudStorageConnectorOpenSyncResumesFromCheckpoint(t *testing.T){Key: "docs/c.txt", LastModified: mustTime(t, "2026-01-03T00:00:00Z"), Size: 1, ETag: "c"},})- session, err := connector.OpenSync(context.Background(), SyncRequest{+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true,Resume: &SyncCheckpoint{Cursor: googleCloudStorageSourceID("bucket", "docs/b.txt"),@@ -157,7 +157,7 @@ func TestGoogleCloudStorageConnectorOpenSyncResumeRejectsMissingAnchor(t *testin{Key: "docs/a.txt", LastModified: mustTime(t, "2026-01-01T00:00:00Z"), Size: 1, ETag: "a"},{Key: "docs/c.txt", LastModified: mustTime(t, "2026-01-03T00:00:00Z"), Size: 1, ETag: "c"},})- session, err := connector.OpenSync(context.Background(), SyncRequest{+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true,Resume: &SyncCheckpoint{Cursor: googleCloudStorageSourceID("bucket", "docs/b.txt"),@@ -173,7 +173,7 @@ func TestGoogleCloudStorageConnectorOpenSyncResumeRejectsForeignCheckpoint(t *teconnector := newTestGoogleCloudStorageConnector(t, []googleCloudStorageObject{{Key: "docs/a.txt", LastModified: mustTime(t, "2026-01-01T00:00:00Z"), Size: 1, ETag: "a"},})- session, err := connector.OpenSync(context.Background(), SyncRequest{+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true,Resume: &SyncCheckpoint{Cursor: "other:bucket:docs/a.txt",@@ -190,7 +190,7 @@ func TestGoogleCloudStorageConnectorOpenPruneReturnsSlimSnapshot(t *testing.T) {{Key: "docs/b.txt", LastModified: mustTime(t, "2026-01-02T00:00:00Z"), Size: 1, ETag: "b"},{Key: "docs/folder/", LastModified: mustTime(t, "2026-01-02T00:00:00Z"), Size: 0, ETag: "folder"},})- session, err := connector.OpenPrune(context.Background(), PruneRequest{})+ session, err := connector.OpenPrune(t.Context(), PruneRequest{})if err != nil {t.Fatalf("OpenPrune: %v", err)}@@ -210,7 +210,7 @@ func TestGoogleCloudStorageConnectorOpenSyncIncludesMissingFingerprint(t *testinconnector := newTestGoogleCloudStorageConnector(t, []googleCloudStorageObject{{Key: "docs/no-etag.txt", LastModified: mustTime(t, "2026-01-01T00:00:00Z"), Size: 1},})- session, err := connector.OpenSync(context.Background(), SyncRequest{+ session, err := connector.OpenSync(t.Context(), SyncRequest{Fingerprints: map[string]string{"other": "fingerprint"},})if err != nil {diff --git a/internal/syncer/connector/google_drive_test.go b/internal/syncer/connector/google_drive_test.goindex 1b04faf761..c4365cb9bb 100644--- a/internal/syncer/connector/google_drive_test.go+++ b/internal/syncer/connector/google_drive_test.go@@ -49,7 +49,7 @@ func TestGoogleDriveConnectorOpenSyncUsesWindowFingerprintAndFetch(t *testing.T)start := mustTime(t, "2026-01-02T00:00:00Z")end := mustTime(t, "2026-01-04T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{WindowStart: &start, WindowEnd: end})+ session, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start, WindowEnd: end})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -80,7 +80,7 @@ func TestGoogleDriveConnectorOpenSyncUsesWindowFingerprintAndFetch(t *testing.T)if !ok {t.Fatalf("session does not implement Fetcher")}- blob, err := fetcher.Fetch(context.Background(), *doc.FetchRef)+ blob, err := fetcher.Fetch(t.Context(), *doc.FetchRef)if err != nil {t.Fatalf("Fetch failed: %v", err)}@@ -116,7 +116,7 @@ func TestGoogleDriveConnectorOpenSyncResumesWithinPage(t *testing.T) {return googleDriveFilePage{Files: files}, nil}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -131,7 +131,7 @@ func TestGoogleDriveConnectorOpenSyncResumesWithinPage(t *testing.T) {t.Fatalf("first checkpoint = %+v, want file-2", first.Checkpoint)}- resumed, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: first.Checkpoint})+ resumed, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: first.Checkpoint})if err != nil {t.Fatalf("resume OpenSync failed: %v", err)}@@ -171,7 +171,7 @@ func TestGoogleDriveConnectorResumeRejectsMissingRemoteAnchor(t *testing.T) {connector.listFiles = func(ctx context.Context, userEmail string, request googleDriveListRequest) (googleDriveFilePage, error) {return googleDriveFilePage{Files: files}, nil}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -195,7 +195,7 @@ func TestGoogleDriveConnectorResumeRejectsMissingRemoteAnchor(t *testing.T) {}return googleDriveFilePage{Files: files}, nil}- resumed, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: first.Checkpoint})+ resumed, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: first.Checkpoint})if err != nil {t.Fatalf("resume OpenSync failed: %v", err)}@@ -221,7 +221,7 @@ func TestGoogleDriveConnectorOpenSyncResumeRejectsMissingCheckpoint(t *testing.Tt.Fatalf("NewGoogleDriveConnector failed: %v", err)}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: &SyncCheckpoint{}})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: &SyncCheckpoint{}})if session != nil || err == nil || !errors.Is(err, ErrSyncResumeInvalid) {t.Fatalf("resume OpenSync = session %v, err %v, want ErrSyncResumeInvalid", session, err)}@@ -264,7 +264,7 @@ func TestGoogleDriveSharedFolderScopesRecurse(t *testing.T) {return nil, nil}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -308,7 +308,7 @@ func TestGoogleDriveRateLimitRetries(t *testing.T) {}}}, nil}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}diff --git a/internal/syncer/connector/mysql_test.go b/internal/syncer/connector/mysql_test.goindex 7cfd4d5ff3..42b1619b59 100644--- a/internal/syncer/connector/mysql_test.go+++ b/internal/syncer/connector/mysql_test.go@@ -91,7 +91,7 @@ func TestMySQLConnectorOpenSyncCustomQuery(t *testing.T) {)})- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -155,7 +155,7 @@ func TestMySQLConnectorOpenSyncIncrementalWindow(t *testing.T) {start := mustTime(t, "2026-01-01T00:00:00Z")end := mustTime(t, "2026-01-02T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{WindowStart: &start, WindowEnd: end})+ session, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start, WindowEnd: end})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -191,7 +191,7 @@ func TestMySQLConnectorOpenSyncAllTables(t *testing.T) {)})- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -233,7 +233,7 @@ func TestMySQLConnectorOpenPrune(t *testing.T) {)})- session, err := connector.OpenPrune(context.Background(), PruneRequest{})+ session, err := connector.OpenPrune(t.Context(), PruneRequest{})if err != nil {t.Fatalf("OpenPrune failed: %v", err)}@@ -269,7 +269,7 @@ func TestMySQLConnectorMD5FallbackID(t *testing.T) {)})- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}diff --git a/internal/syncer/connector/notion_test.go b/internal/syncer/connector/notion_test.goindex e35e18ea70..cd802c8904 100644--- a/internal/syncer/connector/notion_test.go+++ b/internal/syncer/connector/notion_test.go@@ -41,7 +41,7 @@ func TestNotionConnectorOpenSyncReadsRootPageChildrenAndAttachment(t *testing.T)return []byte("pdf-body"), nil}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -80,7 +80,7 @@ func TestNotionConnectorOpenSyncDefersTraversalUntilNextBatch(t *testing.T) {return []byte("pdf-body"), nil}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -107,7 +107,7 @@ func TestNotionConnectorOpenSyncUsesIncrementalWindowAndResume(t *testing.T) {return notionBlockPage{Results: []notionBlock{notionTestTextBlock(blockID+"-block", "paragraph", blockID+" body")}}, nil}start := mustTime(t, "2026-01-02T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{+ session, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start,WindowEnd: mustTime(t, "2026-01-04T00:00:00Z"),})@@ -122,7 +122,7 @@ func TestNotionConnectorOpenSyncUsesIncrementalWindowAndResume(t *testing.T) {t.Fatalf("documents = %+v", batch.Documents)}- resumed, err := connector.OpenSync(context.Background(), SyncRequest{+ resumed, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start,WindowEnd: mustTime(t, "2026-01-04T00:00:00Z"),Resume: batch.Checkpoint,@@ -144,7 +144,7 @@ func TestNotionConnectorResumeMissingCheckpointFails(t *testing.T) {return notionBlockPage{Results: []notionBlock{notionTestTextBlock(blockID+"-block", "paragraph", blockID+" body")}}, nil}start := mustTime(t, "2026-01-02T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{+ session, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start,WindowEnd: mustTime(t, "2026-01-04T00:00:00Z"),Resume: &SyncCheckpoint{SourceID: "missing"},@@ -180,7 +180,7 @@ func TestNotionConnectorIncrementalSearchContinuesPastTooNewPages(t *testing.T)return notionBlockPage{Results: []notionBlock{notionTestTextBlock(blockID+"-block", "paragraph", blockID+" body")}}, nil}start := mustTime(t, "2026-01-02T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{+ session, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start,WindowEnd: mustTime(t, "2026-01-04T00:00:00Z"),})@@ -204,7 +204,7 @@ func TestNotionConnectorFileRejectsOversizedBody(t *testing.T) {connector := newTestNotionConnector(t)connector.fileMaxBytes = 4- _, err := connector.file(context.Background(), server.URL)+ _, err := connector.file(t.Context(), server.URL)if err == nil || !strings.Contains(err.Error(), "exceeds maximum size") {t.Fatalf("file err = %v, want maximum size error", err)}@@ -222,7 +222,7 @@ func TestNotionConnectorOpenPruneReturnsPageAndAttachmentIDs(t *testing.T) {}return notionBlockPage{}, nil}- session, err := connector.OpenPrune(context.Background(), PruneRequest{})+ session, err := connector.OpenPrune(t.Context(), PruneRequest{})if err != nil {t.Fatalf("OpenPrune: %v", err)}diff --git a/internal/syncer/connector/outlook_test.go b/internal/syncer/connector/outlook_test.goindex 64fc68eeb3..c31543b190 100644--- a/internal/syncer/connector/outlook_test.go+++ b/internal/syncer/connector/outlook_test.go@@ -16,7 +16,7 @@ func TestOutlookConnectorOpenSync(t *testing.T) {start := mustTime(t, "2026-01-02T00:00:00Z")end := mustTime(t, "2026-01-04T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{WindowStart: &start, WindowEnd: end})+ session, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start, WindowEnd: end})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -76,7 +76,7 @@ func TestOutlookConnectorOpenSyncResumesWithinPage(t *testing.T) {}, nil}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -91,7 +91,7 @@ func TestOutlookConnectorOpenSyncResumesWithinPage(t *testing.T) {t.Fatalf("first checkpoint = %+v, want msg-2", first.Checkpoint)}- resumed, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: first.Checkpoint})+ resumed, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: first.Checkpoint})if err != nil {t.Fatalf("resume OpenSync failed: %v", err)}@@ -107,7 +107,7 @@ func TestOutlookConnectorOpenSyncResumesWithinPage(t *testing.T) {func TestOutlookConnectorOpenSyncResumeRejectsMissingCheckpoint(t *testing.T) {connector := newFixtureOutlookConnector()- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: &SyncCheckpoint{}})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: &SyncCheckpoint{}})if session != nil || err == nil || !errors.Is(err, ErrSyncResumeInvalid) {t.Fatalf("resume OpenSync = session %v, err %v, want ErrSyncResumeInvalid", session, err)}@@ -127,7 +127,7 @@ func TestOutlookConnectorOpenSyncResumeRejectsMissingRemoteAnchor(t *testing.T)}, nil}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -149,7 +149,7 @@ func TestOutlookConnectorOpenSyncResumeRejectsMissingRemoteAnchor(t *testing.T)}, nil}- resumed, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: first.Checkpoint})+ resumed, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: first.Checkpoint})if err != nil {t.Fatalf("resume OpenSync failed: %v", err)}@@ -160,7 +160,7 @@ func TestOutlookConnectorOpenSyncResumeRejectsMissingRemoteAnchor(t *testing.T)func TestOutlookConnectorOpenPrune(t *testing.T) {connector := newFixtureOutlookConnector()- session, err := connector.OpenPrune(context.Background(), PruneRequest{})+ session, err := connector.OpenPrune(t.Context(), PruneRequest{})if err != nil {t.Fatalf("OpenPrune failed: %v", err)}@@ -190,7 +190,7 @@ func TestOutlookGetJSONRetriesTransientStatus(t *testing.T) {acquireAccessToken: func(ctx context.Context) (string, error) { return "token", nil },}var page outlookDeltaPage- if err := connector.getJSON(context.Background(), "https://graph.example.test/messages", &page); err != nil {+ if err := connector.getJSON(t.Context(), "https://graph.example.test/messages", &page); err != nil {t.Fatalf("getJSON failed: %v", err)}if calls != 2 {@@ -221,7 +221,7 @@ func TestOutlookGetJSONReadsBodyBeforeCancel(t *testing.T) {},}var page outlookDeltaPage- if err := connector.getJSON(context.Background(), server.URL+"/messages", &page); err != nil {+ if err := connector.getJSON(t.Context(), server.URL+"/messages", &page); err != nil {t.Fatalf("getJSON failed: %v", err)}}@@ -299,7 +299,7 @@ func TestOutlookGetJSONRefreshesTokenAfterUnauthorized(t *testing.T) {}var page outlookDeltaPage- if err := connector.getJSON(context.Background(), "https://graph.example.test/messages", &page); err != nil {+ if err := connector.getJSON(t.Context(), "https://graph.example.test/messages", &page); err != nil {t.Fatalf("getJSON failed: %v", err)}if tokenCalls != 2 {@@ -334,7 +334,7 @@ func TestOutlookConnectorValidateConnectorSetting(t *testing.T) {}, nil})}- if err := connector.ValidateConnectorSetting(context.Background(), nil); err != nil {+ if err := connector.ValidateConnectorSetting(t.Context(), nil); err != nil {t.Fatalf("ValidateConnectorSetting: %v", err)}if !probed {diff --git a/internal/syncer/connector/postgresql_test.go b/internal/syncer/connector/postgresql_test.goindex 764aa0d8cf..4bb3be5dc9 100644--- a/internal/syncer/connector/postgresql_test.go+++ b/internal/syncer/connector/postgresql_test.go@@ -91,7 +91,7 @@ func TestPostgreSQLConnectorOpenSyncCustomQuery(t *testing.T) {)})- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -149,7 +149,7 @@ func TestPostgreSQLConnectorOpenSyncIncrementalWindow(t *testing.T) {start := mustTime(t, "2026-01-01T00:00:00Z")end := mustTime(t, "2026-01-02T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{WindowStart: &start, WindowEnd: end})+ session, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start, WindowEnd: end})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -185,7 +185,7 @@ func TestPostgreSQLConnectorOpenSyncAllTables(t *testing.T) {)})- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -227,7 +227,7 @@ func TestPostgreSQLConnectorOpenPrune(t *testing.T) {)})- session, err := connector.OpenPrune(context.Background(), PruneRequest{})+ session, err := connector.OpenPrune(t.Context(), PruneRequest{})if err != nil {t.Fatalf("OpenPrune failed: %v", err)}@@ -303,7 +303,7 @@ func TestPostgreSQLConnectorOpenSyncMixedCaseTable(t *testing.T) {)})- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync failed: %v", err)}diff --git a/internal/syncer/connector/rest_api_test.go b/internal/syncer/connector/rest_api_test.goindex 73308a4a11..d978823256 100644--- a/internal/syncer/connector/rest_api_test.go+++ b/internal/syncer/connector/rest_api_test.go@@ -436,7 +436,7 @@ func TestRestAPIFetchPageIntegration(t *testing.T) {"auth_type": "bearer","credentials": map[string]any{"token": "tok"},})- if _, err := c.fetchPage(context.Background(), map[string]any{"page": 1}); err != nil {+ if _, err := c.fetchPage(t.Context(), map[string]any{"page": 1}); err != nil {t.Fatalf("fetchPage: %v", err)}mu.Lock()@@ -478,7 +478,7 @@ func TestRestAPIFetchPagePOST(t *testing.T) {"content_fields": "title","request_body": map[string]any{"q": "x"},})- if _, err := c.fetchPage(context.Background(), nil); err != nil {+ if _, err := c.fetchPage(t.Context(), nil); err != nil {t.Fatalf("fetchPage: %v", err)}mu.Lock()@@ -519,7 +519,7 @@ func TestRestAPIFetchPageErrorMapping(t *testing.T) {"url": server.URL,"content_fields": "title",})- _, err := c.fetchPage(context.Background(), nil)+ _, err := c.fetchPage(t.Context(), nil)if err == nil || !strings.Contains(err.Error(), tt.wantSubstr) {t.Fatalf("err=%v want contains %q", err, tt.wantSubstr)}@@ -557,7 +557,7 @@ func TestRestAPIFetchPageRetries(t *testing.T) {"url": server.URL,"content_fields": "title",})- if _, err := c.fetchPage(context.Background(), nil); err != nil {+ if _, err := c.fetchPage(t.Context(), nil); err != nil {t.Fatalf("fetchPage: %v", err)}if attempts.Load() != 3 {@@ -583,7 +583,7 @@ func TestRestAPIFetchPage429RetryAfter(t *testing.T) {"url": server.URL,"content_fields": "title",})- if _, err := c.fetchPage(context.Background(), nil); err != nil {+ if _, err := c.fetchPage(t.Context(), nil); err != nil {t.Fatalf("fetchPage: %v", err)}if attempts.Load() != 2 {@@ -616,7 +616,7 @@ func TestRestAPIFetchPageRedirectStripsAuth(t *testing.T) {"auth_type": "bearer","credentials": map[string]any{"token": "tok"},})- if _, err := c.fetchPage(context.Background(), nil); err != nil {+ if _, err := c.fetchPage(t.Context(), nil); err != nil {t.Fatalf("fetchPage: %v", err)}mu.Lock()@@ -665,7 +665,7 @@ func TestRestAPISyncSessionPagination(t *testing.T) {"batch_size": 2,"request_delay": 0,})- session, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -714,7 +714,7 @@ func TestRestAPISyncSessionWindowFilter(t *testing.T) {})start := time.Date(2026, 8, 14, 11, 0, 0, 0, time.UTC)end := time.Date(2026, 8, 14, 13, 0, 0, 0, time.UTC)- session, err := c.OpenSync(context.Background(), SyncRequest{WindowStart: &start, WindowEnd: end})+ session, err := c.OpenSync(t.Context(), SyncRequest{WindowStart: &start, WindowEnd: end})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -765,7 +765,7 @@ func TestRestAPIValidateConnectorSetting(t *testing.T) {"url": server.URL,"content_fields": "title",})- if err := c.ValidateConnectorSetting(context.Background(), nil); err != nil {+ if err := c.ValidateConnectorSetting(t.Context(), nil); err != nil {t.Fatalf("ValidateConnectorSetting: %v", err)}if requests.Load() != 1 {@@ -794,7 +794,7 @@ func TestRestAPIMaxPages(t *testing.T) {"max_pages": 1,"request_delay": 0,})- session, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -820,7 +820,7 @@ func TestRestAPIOpenPruneUnsupported(t *testing.T) {"url": "https://example.com","content_fields": "title",})- _, err := c.OpenPrune(context.Background(), PruneRequest{})+ _, err := c.OpenPrune(t.Context(), PruneRequest{})if !errors.Is(err, ErrPruneUnsupported) {t.Fatalf("err=%v want ErrPruneUnsupported", err)}@@ -851,7 +851,7 @@ func TestRestAPIFetchPageServerErrorIsTransient(t *testing.T) {"url": server.URL,"content_fields": "title",})- _, err := c.fetchPage(context.Background(), nil)+ _, err := c.fetchPage(t.Context(), nil)if err == nil || !strings.Contains(err.Error(), "http 500") {t.Fatalf("err=%v want message containing http 500", err)}@@ -873,7 +873,7 @@ func TestRestAPIFetchPage429ExhaustionIsTransient(t *testing.T) {"url": server.URL,"content_fields": "title",})- _, err := c.fetchPage(context.Background(), nil)+ _, err := c.fetchPage(t.Context(), nil)if err == nil || !strings.Contains(err.Error(), "too many requests") {t.Fatalf("err=%v want message containing too many requests", err)}@@ -904,7 +904,7 @@ func TestRestAPISyncSessionNoneNoCheckpoint(t *testing.T) {"id_field": "id","batch_size": 2,})- session, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -962,7 +962,7 @@ func TestRestAPISyncSessionPageResume(t *testing.T) {"batch_size": 2,"request_delay": 0,})- session, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -981,7 +981,7 @@ func TestRestAPISyncSessionPageResume(t *testing.T) {t.Fatalf("cursor=%+v want page 1 source id 2", cursor)}- resumed, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: batch.Checkpoint})+ resumed, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: batch.Checkpoint})if err != nil {t.Fatalf("resume OpenSync: %v", err)}@@ -1049,7 +1049,7 @@ func TestRestAPISyncSessionOffsetResume(t *testing.T) {"batch_size": 2,"request_delay": 0,})- session, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -1068,7 +1068,7 @@ func TestRestAPISyncSessionOffsetResume(t *testing.T) {t.Fatalf("cursor=%+v want offset 0 source id 2", cursor)}- resumed, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: batch.Checkpoint})+ resumed, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: batch.Checkpoint})if err != nil {t.Fatalf("resume OpenSync: %v", err)}@@ -1138,7 +1138,7 @@ func TestRestAPISyncSessionCursorResume(t *testing.T) {"batch_size": 2,"request_delay": 0,})- session, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -1157,7 +1157,7 @@ func TestRestAPISyncSessionCursorResume(t *testing.T) {t.Fatalf("cursor=%+v want empty cursor source id 2", cursor)}- resumed, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: batch.Checkpoint})+ resumed, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: batch.Checkpoint})if err != nil {t.Fatalf("resume OpenSync: %v", err)}@@ -1222,7 +1222,7 @@ func TestRestAPISyncSessionCheckpointResumesInsidePage(t *testing.T) {"batch_size": 2,"request_delay": 0,})- session, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ session, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync: %v", err)}@@ -1250,7 +1250,7 @@ func TestRestAPISyncSessionCheckpointResumesInsidePage(t *testing.T) {t.Fatalf("cursor=%+v want page 1 source id 4", cursor)}- resumed, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: second.Checkpoint})+ resumed, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: second.Checkpoint})if err != nil {t.Fatalf("resume OpenSync: %v", err)}@@ -1302,7 +1302,7 @@ func TestRestAPISyncSessionResumeRejectsInvalidCheckpoint(t *testing.T) {}for _, tc := range cases {t.Run(tc.name, func(t *testing.T) {- session, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: tc.checkpoint})+ session, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: tc.checkpoint})if session != nil || err == nil || !errors.Is(err, ErrSyncResumeInvalid) {t.Fatalf("OpenSync = session %v, err %v, want ErrSyncResumeInvalid", session, err)}@@ -1347,7 +1347,7 @@ func TestRestAPISyncSessionResumeRejectsMissingAnchor(t *testing.T) {"request_delay": 0,})raw, _ := json.Marshal(restAPISyncCursor{Page: 1, SourceID: restAPIHash128("rest_api:2")})- session, err := c.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: &SyncCheckpoint{Cursor: string(raw)}})+ session, err := c.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: &SyncCheckpoint{Cursor: string(raw)}})if err != nil {t.Fatalf("resume OpenSync: %v", err)}diff --git a/internal/syncer/connector/rss_test.go b/internal/syncer/connector/rss_test.goindex a590febcd0..07ef6b757a 100644--- a/internal/syncer/connector/rss_test.go+++ b/internal/syncer/connector/rss_test.go@@ -18,7 +18,7 @@ func TestRSSConnectorOpenSyncFullAndIncremental(t *testing.T) {}connector.fetchFeed = staticRSSFeed- fullSession, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-05T00:00:00Z")})+ fullSession, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-05T00:00:00Z")})if err != nil {t.Fatalf("OpenSync full failed: %v", err)}@@ -41,7 +41,7 @@ func TestRSSConnectorOpenSyncFullAndIncremental(t *testing.T) {}start := mustTime(t, "2026-01-02T00:00:00Z")- incrementalSession, err := connector.OpenSync(context.Background(), SyncRequest{WindowStart: &start, WindowEnd: mustTime(t, "2026-01-04T00:00:00Z")})+ incrementalSession, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start, WindowEnd: mustTime(t, "2026-01-04T00:00:00Z")})if err != nil {t.Fatalf("OpenSync incremental failed: %v", err)}@@ -77,7 +77,7 @@ func TestRSSConnectorOpenPrune(t *testing.T) {t.Fatalf("NewRSSConnector failed: %v", err)}connector.fetchFeed = staticRSSFeed- session, err := connector.OpenPrune(context.Background(), PruneRequest{})+ session, err := connector.OpenPrune(t.Context(), PruneRequest{})if err != nil {t.Fatalf("OpenPrune failed: %v", err)}@@ -103,7 +103,7 @@ func TestRSSConnectorOpenSyncResumesAfterCheckpoint(t *testing.T) {}connector.fetchFeed = staticRSSFeed- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z")})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z")})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -118,7 +118,7 @@ func TestRSSConnectorOpenSyncResumesAfterCheckpoint(t *testing.T) {t.Fatalf("first checkpoint = %+v, want entry-new", first.Checkpoint)}- resumed, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z"), Resume: first.Checkpoint})+ resumed, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z"), Resume: first.Checkpoint})if err != nil {t.Fatalf("resume OpenSync failed: %v", err)}@@ -144,7 +144,7 @@ func TestRSSConnectorOpenSyncResumeRejectsMissingCheckpoint(t *testing.T) {}connector.fetchFeed = staticRSSFeed- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: &SyncCheckpoint{}})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: &SyncCheckpoint{}})if session != nil || err == nil || !errors.Is(err, ErrSyncResumeInvalid) {t.Fatalf("resume OpenSync = session %v, err %v, want ErrSyncResumeInvalid", session, err)}@@ -156,7 +156,7 @@ func TestRSSConnectorValidateConnectorSetting(t *testing.T) {t.Fatalf("NewRSSConnector failed: %v", err)}connector.fetchFeed = staticRSSFeed- if err := connector.ValidateConnectorSetting(context.Background(), nil); err != nil {+ if err := connector.ValidateConnectorSetting(t.Context(), nil); err != nil {t.Fatalf("ValidateConnectorSetting failed: %v", err)}}diff --git a/internal/syncer/connector/webdav_test.go b/internal/syncer/connector/webdav_test.goindex dcf5a8ec38..392b252afa 100644--- a/internal/syncer/connector/webdav_test.go+++ b/internal/syncer/connector/webdav_test.go@@ -202,7 +202,7 @@ func TestNewWebDAVConnectorUsesCustomCACertificate(t *testing.T) {if err != nil {t.Fatalf("NewWebDAVConnector failed: %v", err)}- ctx, cancel := context.WithTimeout(context.Background(), webdavRequestTimeout)+ ctx, cancel := context.WithTimeout(t.Context(), webdavRequestTimeout)defer cancel()req, err := http.NewRequestWithContext(ctx, http.MethodGet, server.URL, nil)if err != nil {@@ -302,7 +302,7 @@ func TestWebDAVConnectorValidateConnectorSetting(t *testing.T) {server, _, _ := newWebDAVTestServer(t, webDAVTestTree())connector := webDAVTestConnector(t, server.URL, false, 2)- if err := connector.ValidateConnectorSetting(context.Background(), nil); err != nil {+ if err := connector.ValidateConnectorSetting(t.Context(), nil); err != nil {t.Fatalf("ValidateConnectorSetting failed: %v", err)}@@ -313,7 +313,7 @@ func TestWebDAVConnectorValidateConnectorSetting(t *testing.T) {if err != nil {t.Fatalf("NewWebDAVConnector failed: %v", err)}- err = missingCredentials.ValidateConnectorSetting(context.Background(), nil)+ err = missingCredentials.ValidateConnectorSetting(t.Context(), nil)if err == nil || !strings.Contains(err.Error(), "username and password") {t.Fatalf("missing credentials error = %v", err)}@@ -324,7 +324,7 @@ func TestWebDAVConnectorOpenSyncFull(t *testing.T) {server, authHeaders, _ := newWebDAVTestServer(t, webDAVTestTree())connector := webDAVTestConnector(t, server.URL, false, 2)- session, err := connector.OpenSync(context.Background(), SyncRequest{+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true,WindowEnd: mustTime(t, "2026-01-07T00:00:00Z"),})@@ -397,7 +397,7 @@ func TestWebDAVConnectorOpenSyncIncremental(t *testing.T) {connector := webDAVTestConnector(t, server.URL, false, 2)start := mustTime(t, "2026-01-02T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{+ session, err := connector.OpenSync(t.Context(), SyncRequest{WindowStart: &start,WindowEnd: mustTime(t, "2026-01-04T00:00:00Z"),})@@ -435,7 +435,7 @@ func TestWebDAVConnectorMountedUnderNonRootPath(t *testing.T) {t.Fatalf("Validate failed: %v", err)}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z")})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z")})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -483,7 +483,7 @@ func TestWebDAVConnectorOpenSyncIncludesSizedFileWithoutLastModified(t *testing.connector := webDAVTestConnector(t, server.URL, false, 10)windowEnd := mustTime(t, "2026-01-02T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: windowEnd})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: windowEnd})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -499,7 +499,7 @@ func TestWebDAVConnectorOpenSyncIncludesSizedFileWithoutLastModified(t *testing.t.Fatalf("updated at = %v, want %v", batch.Documents[0].UpdatedAt, windowEnd)}- unsetSession, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true})+ unsetSession, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true})if err != nil {t.Fatalf("OpenSync with unset WindowEnd failed: %v", err)}@@ -532,7 +532,7 @@ func TestWebDAVConnectorOpenSyncRejectsOversizedResponse(t *testing.T) {})connector := webDAVTestConnector(t, server.URL, false, 10)- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z")})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z")})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -551,7 +551,7 @@ func TestWebDAVConnectorOpenSyncResumesAfterCheckpoint(t *testing.T) {connector := webDAVTestConnector(t, server.URL, false, 2)windowEnd := mustTime(t, "2026-01-07T00:00:00Z")- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: windowEnd})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: windowEnd})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -564,7 +564,7 @@ func TestWebDAVConnectorOpenSyncResumesAfterCheckpoint(t *testing.T) {}session.Close()- resumed, err := connector.OpenSync(context.Background(), SyncRequest{+ resumed, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true,WindowEnd: windowEnd,Resume: first.Checkpoint,@@ -593,7 +593,7 @@ func TestWebDAVConnectorOpenSyncResumeRejectsMissingCheckpoint(t *testing.T) {server, _, _ := newWebDAVTestServer(t, webDAVTestTree())connector := webDAVTestConnector(t, server.URL, false, 2)- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, Resume: &SyncCheckpoint{}})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, Resume: &SyncCheckpoint{}})if session != nil || err == nil || !errors.Is(err, ErrSyncResumeInvalid) {t.Fatalf("resume OpenSync = session %v, err %v, want ErrSyncResumeInvalid", session, err)}@@ -604,7 +604,7 @@ func TestWebDAVConnectorOpenPrune(t *testing.T) {server, _, getRequests := newWebDAVTestServer(t, webDAVTestTree())connector := webDAVTestConnector(t, server.URL, false, 10)- session, err := connector.OpenPrune(context.Background(), PruneRequest{})+ session, err := connector.OpenPrune(t.Context(), PruneRequest{})if err != nil {t.Fatalf("OpenPrune failed: %v", err)}@@ -633,7 +633,7 @@ func TestWebDAVConnectorFiltersAndImages(t *testing.T) {server, _, _ := newWebDAVTestServer(t, webDAVTestTree())withoutImages := webDAVTestConnector(t, server.URL, false, 10)- session, err := withoutImages.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z")})+ session, err := withoutImages.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z")})if err != nil {t.Fatalf("OpenSync failed: %v", err)}@@ -650,7 +650,7 @@ func TestWebDAVConnectorFiltersAndImages(t *testing.T) {}withImages := webDAVTestConnector(t, server.URL, true, 10)- imageSession, err := withImages.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z")})+ imageSession, err := withImages.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z")})if err != nil {t.Fatalf("OpenSync with images failed: %v", err)}@@ -710,7 +710,7 @@ func TestWebDAVConnectorOpenSyncRejectsExternalHref(t *testing.T) {t.Fatalf("NewWebDAVConnector failed: %v", err)}- session, err := connector.OpenSync(context.Background(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z")})+ session, err := connector.OpenSync(t.Context(), SyncRequest{FromBeginning: true, WindowEnd: mustTime(t, "2026-01-07T00:00:00Z")})if err != nil {t.Fatalf("OpenSync failed: %v", err)}diff --git a/internal/utility/file.go b/internal/utility/file.goindex 6106092541..c0c79fa10d 100644--- a/internal/utility/file.go+++ b/internal/utility/file.go@@ -452,8 +452,13 @@ func SetPreviewFileResponseHeaders(h http.Header, contentType, ext, filename str} else {h.Set("Content-Disposition", "attachment")}- } else if filename != "" {+ return+ }++ if filename != "" {h.Set("Content-Disposition", FormatContentDisposition("inline", filename))+ } else {+ h.Set("Content-Disposition", "inline")}}diff --git a/internal/utility/mcp_call_test.go b/internal/utility/mcp_call_test.goindex 47816a7f4f..2b7c9f9a0a 100644--- a/internal/utility/mcp_call_test.go+++ b/internal/utility/mcp_call_test.go@@ -17,7 +17,6 @@package utilityimport (- "context""encoding/json""io""net/http"@@ -136,7 +135,7 @@ func TestCallTool_StreamableHTTP(t *testing.T) {}))defer srv.Close()- res, err := CallTool(context.Background(), CallOptions{+ res, err := CallTool(t.Context(), CallOptions{URL: srv.URL,ServerType: TransportStreamableHTTP,ToolName: "echo",@@ -177,7 +176,7 @@ func TestCallTool_ServerError(t *testing.T) {}))defer srv.Close()- _, err := CallTool(context.Background(), CallOptions{+ _, err := CallTool(t.Context(), CallOptions{URL: srv.URL,ServerType: TransportStreamableHTTP,ToolName: "missing",@@ -196,7 +195,7 @@ func TestCallTool_ServerError(t *testing.T) {// TestCallTool_MissingURL: an empty URL is rejected up front// before any network I/O.func TestCallTool_MissingURL(t *testing.T) {- _, err := CallTool(context.Background(), CallOptions{ToolName: "x"})+ _, err := CallTool(t.Context(), CallOptions{ToolName: "x"})if err == nil {t.Fatalf("expected error for empty URL")}@@ -208,7 +207,7 @@ func TestCallTool_MissingURL(t *testing.T) {// TestCallTool_MissingToolName: an empty tool name is rejected// up front.func TestCallTool_MissingToolName(t *testing.T) {- _, err := CallTool(context.Background(), CallOptions{URL: "http://localhost:0"})+ _, err := CallTool(t.Context(), CallOptions{URL: "http://localhost:0"})if err == nil {t.Fatalf("expected error for empty tool name")}@@ -226,7 +225,7 @@ func TestCallTool_InvalidArgumentsJSON(t *testing.T) {_, _ = w.Write([]byte(`{"jsonrpc":"2.0","id":0,"result":{}}`))}))defer srv.Close()- _, err := CallTool(context.Background(), CallOptions{+ _, err := CallTool(t.Context(), CallOptions{URL: srv.URL,ServerType: TransportStreamableHTTP,ToolName: "x",diff --git a/internal/utility/mcp_client_test.go b/internal/utility/mcp_client_test.goindex 5929ed974d..d41ce471aa 100644--- a/internal/utility/mcp_client_test.go+++ b/internal/utility/mcp_client_test.go@@ -17,7 +17,6 @@package utilityimport (- "context""encoding/json""fmt""io"@@ -81,7 +80,7 @@ func TestFetchToolsStreamableHTTPJSON(t *testing.T) {}))defer srv.Close()- tools, err := FetchTools(context.Background(), FetchOptions{+ tools, err := FetchTools(t.Context(), FetchOptions{URL: srv.URL,ServerType: TransportStreamableHTTP,HTTPClient: srv.Client(),@@ -120,7 +119,7 @@ func TestFetchToolsStreamableHTTPErrorResponse(t *testing.T) {}))defer srv.Close()- _, err := FetchTools(context.Background(), FetchOptions{+ _, err := FetchTools(t.Context(), FetchOptions{URL: srv.URL,ServerType: TransportStreamableHTTP,HTTPClient: srv.Client(),@@ -187,7 +186,7 @@ func TestFetchToolsSSE(t *testing.T) {srv := httptest.NewServer(mux)defer srv.Close()- tools, err := FetchTools(context.Background(), FetchOptions{+ tools, err := FetchTools(t.Context(), FetchOptions{URL: srv.URL + "/sse",ServerType: TransportSSE,HTTPClient: srv.Client(),@@ -203,7 +202,7 @@ func TestFetchToolsSSE(t *testing.T) {func TestFetchToolsUnsupportedType(t *testing.T) {defer allowLoopbackForTests(t)()- _, err := FetchTools(context.Background(), FetchOptions{+ _, err := FetchTools(t.Context(), FetchOptions{URL: "https://example.com",ServerType: "stdio",Timeout: time.Second,@@ -214,7 +213,7 @@ func TestFetchToolsUnsupportedType(t *testing.T) {}func TestFetchToolsEmptyURL(t *testing.T) {- _, err := FetchTools(context.Background(), FetchOptions{URL: "", ServerType: TransportSSE})+ _, err := FetchTools(t.Context(), FetchOptions{URL: "", ServerType: TransportSSE})if err == nil || !strings.Contains(err.Error(), "Invalid url") {t.Fatalf("expected Invalid url error, got %v", err)}diff --git a/internal/utility/workerpool_test.go b/internal/utility/workerpool_test.goindex feeb9e533d..41f9c463e7 100644--- a/internal/utility/workerpool_test.go+++ b/internal/utility/workerpool_test.go@@ -14,11 +14,11 @@ func TestWorkerPoolSubmitAndStats(t *testing.T) {})defer pool.StopWait()- f1, err := pool.Submit(context.Background(), 2)+ f1, err := pool.Submit(t.Context(), 2)if err != nil {t.Fatalf("Submit(2): %v", err)}- f2, err := pool.Submit(context.Background(), 3)+ f2, err := pool.Submit(t.Context(), 3)if err != nil {t.Fatalf("Submit(3): %v", err)}@@ -64,7 +64,7 @@ func TestWorkerPoolSubmitToCanceledTaskReturnsContextError(t *testing.T) {defer pool.StopWait()firstCh := make(chan WorkerPoolResult[int, int], 1)- if err := pool.SubmitTo(context.Background(), 1, firstCh); err != nil {+ if err := pool.SubmitTo(t.Context(), 1, firstCh); err != nil {t.Fatalf("SubmitTo(first): %v", err)}<-started@@ -133,7 +133,7 @@ func TestStopWaitConcurrentSubmitDoesNotPanic(t *testing.T) {returndefault:}- if _, err := pool.Submit(context.Background(), seed+i); err != nil {+ if _, err := pool.Submit(t.Context(), seed+i); err != nil {if err != ErrWorkerPoolStopped {t.Errorf("unexpected submit error: %v", err)}@@ -175,7 +175,7 @@ func TestStopWaitWaitsForInFlightTask(t *testing.T) {closeRelease := func() { closeReleaseOnce.Do(func() { close(release) }) }defer closeRelease()- f, err := pool.Submit(context.Background(), 42)+ f, err := pool.Submit(t.Context(), 42)if err != nil {t.Fatalf("Submit: %v", err)}@@ -211,7 +211,7 @@ func TestSubmitAfterStopWaitReturnsStopped(t *testing.T) {return in, nil})pool.StopWait()- if _, err := pool.Submit(context.Background(), 1); err != ErrWorkerPoolStopped {+ if _, err := pool.Submit(t.Context(), 1); err != ErrWorkerPoolStopped {t.Fatalf("Submit after StopWait = %v, want ErrWorkerPoolStopped", err)}}@@ -258,7 +258,7 @@ func TestStopWaitWithBlockedSubmitNoDeadlock(t *testing.T) {return in, nil})- ctx := context.Background()+ ctx := t.Context()if _, err := pool.Submit(ctx, 1); err != nil {t.Fatalf("first Submit: %v", err)}