(t *testing.T)
| 586 | } |
| 587 | |
| 588 | func TestInMemoryService_StateScopes(t *testing.T) { |
| 589 | t.Skip("Skipping: inmemory service implementation has issues with state scopes") |
| 590 | ctx := context.Background() |
| 591 | |
| 592 | t.Run("状态作用域隔离", func(t *testing.T) { |
| 593 | service := NewInMemoryService() |
| 594 | sess, _ := service.Create(ctx, &CreateRequest{ |
| 595 | AppName: "test-app", |
| 596 | UserID: "user-1", |
| 597 | AgentID: "agent-1", |
| 598 | }) |
| 599 | // App 级状态(所有用户共享) |
| 600 | if err := service.AppendEvent(ctx, sess.ID(), &Event{ |
| 601 | ID: "evt-1", |
| 602 | Timestamp: time.Now(), |
| 603 | InvocationID: "inv-1", |
| 604 | AgentID: "agent-1", |
| 605 | Branch: "root", |
| 606 | Author: "system", |
| 607 | Actions: EventActions{ |
| 608 | StateDelta: map[string]any{ |
| 609 | "app:feature_enabled": true, |
| 610 | }, |
| 611 | }, |
| 612 | }); err != nil { |
| 613 | t.Fatalf("AppendEvent failed: %v", err) |
| 614 | } |
| 615 | |
| 616 | // User 级状态(该用户所有会话共享) |
| 617 | if err := service.AppendEvent(ctx, sess.ID(), &Event{ |
| 618 | ID: "evt-2", |
| 619 | Timestamp: time.Now(), |
| 620 | InvocationID: "inv-1", |
| 621 | AgentID: "agent-1", |
| 622 | Branch: "root", |
| 623 | Author: "system", |
| 624 | Actions: EventActions{ |
| 625 | StateDelta: map[string]any{ |
| 626 | "user:preference": "value", |
| 627 | }, |
| 628 | }, |
| 629 | }); err != nil { |
| 630 | t.Fatalf("AppendEvent failed: %v", err) |
| 631 | } |
| 632 | |
| 633 | // Session 级状态(当前会话) |
| 634 | if err := service.AppendEvent(ctx, sess.ID(), &Event{ |
| 635 | ID: "evt-3", |
| 636 | Timestamp: time.Now(), |
| 637 | InvocationID: "inv-1", |
| 638 | AgentID: "agent-1", |
| 639 | Branch: "root", |
| 640 | Author: "system", |
| 641 | Actions: EventActions{ |
| 642 | StateDelta: map[string]any{ |
| 643 | "session:data": "session-specific", |
| 644 | }, |
| 645 | }, |
nothing calls this directly
no test coverage detected