Skip to content

[dotnet-code] Add ScopeID equality preservation test #760

Description

@github-actions

Summary

Added a narrow preservation test for workflow.ScopeID.Equal so the Go workflow state-scope semantics are easier to compare with the .NET ScopeId behavior during future ports. The test locks the existing private-scope, shared-scope, and private-vs-shared equality rules without changing production code.

.NET Reference

  • dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/StateKeyObjectTests.cs - verifies ScopeId equality semantics for private executor scopes and shared named scopes.

Public API and Behavior

No public Go API changed. No intentional behavior change was made.

Tests

  • Added TestScopeID_Equal in workflow/json_test.go.
  • Ran gofmt -w workflow/json_test.go.
  • Ran go test ./workflow.

Notes

Rejected candidates from the random .NET sample:

  • dotnet/src/Microsoft.Agents.AI/Harness/Todo/TodoItemInput.cs - the Go todo harness already has the corresponding input shape and recent parity-aligned locking/internals, so no safer tiny improvement was identified.
  • dotnet/src/Microsoft.Agents.AI.Abstractions/ChatHistoryProvider.cs - initially promising for naming default filter helpers, but an open HistoryProvider PR search returned a filtered result, so this candidate was rejected to avoid overlap.
  • dotnet/src/Microsoft.Agents.AI.Workflows/MagenticProgressLedger.cs - no current Go magentic progress ledger counterpart was found, and adding one would be feature work.
  • dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/PolymorphicOutputTests.cs - rejected because open PR searches returned filtered polymorphic-output results, so overlap could not be ruled out.

Generated by .NET-to-Go Code Portability Refactoring Agent · 527.8 AIC · ⌖ 41.6 AIC · ⊞ 20.8K ·


Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch dotnet-code-scopeid-test-4c117468d64e23bf.

Click here to create the pull request

To fix the permissions issue, go to SettingsActionsGeneral and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ

Show patch (50 lines)
From 267af76e85d0996a444b220476e5d8877978d3e7 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Mon, 27 Jul 2026 22:43:30 +0000
Subject: [PATCH] Add ScopeID equality preservation test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 workflow/json_test.go | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/workflow/json_test.go b/workflow/json_test.go
index 8765d0d7c..1c2d6157d 100644
--- a/workflow/json_test.go
+++ b/workflow/json_test.go
@@ -272,6 +272,31 @@ func TestScopeID_JsonRoundtrip(t *testing.T) {
 	}
 }
 
+func TestScopeID_Equal(t *testing.T) {
+	privateScope1 := workflow.ScopeID{ExecutorID: "executor1"}
+	privateScope2 := workflow.ScopeID{ExecutorID: "executor2"}
+
+	if privateScope1.Equal(privateScope2) {
+		t.Fatal("private scopes from different executors should not be equal")
+	}
+	if !privateScope1.Equal(workflow.ScopeID{ExecutorID: "executor1"}) {
+		t.Fatal("private scopes from the same executor should be equal")
+	}
+
+	sharedScope1 := workflow.ScopeID{ExecutorID: "executor1", ScopeName: "sharedScope"}
+	sharedScope2 := workflow.ScopeID{ExecutorID: "executor2", ScopeName: "sharedScope"}
+
+	if !sharedScope1.Equal(sharedScope2) {
+		t.Fatal("shared scopes with the same scope name should be equal")
+	}
+	if sharedScope1.Equal(workflow.ScopeID{ExecutorID: "executor1", ScopeName: "differentScope"}) {
+		t.Fatal("shared scopes with different scope names should not be equal")
+	}
+	if sharedScope1.Equal(privateScope1) {
+		t.Fatal("shared and private scopes should not be equal")
+	}
+}
+
 func TestScopeKey_JsonRoundtrip(t *testing.T) {
 	cases := []struct {
 		name string
-- 
2.54.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions